home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / LordLucifer / win32asm / files / win32asm.exe / Win32ASM / Win32DLL / Win32DLLTest.asm < prev   
Encoding:
Assembly Source File  |  1997-11-10  |  4.0 KB  |  126 lines

  1.    Page 60,190
  2.    TITLE MAPI32TS - Console test prog for Win32 DLL demo.
  3.  
  4.  
  5. ; CREATED:       26 Apr 97 by Philippe Auphelle
  6.  
  7. ; MODIFIED:      dd mmm yy by Philippe Auphelle
  8.  
  9.  
  10. ; ============================================================================
  11. ; Yes, it can be done:
  12. ; Test program using the Sample Win32 DLL.
  13. ; ============================================================================
  14.  
  15.  
  16.                 .386
  17.                 .MODEL FLAT,STDCALL
  18.  
  19.                 .SALL
  20.                 .NOLIST
  21.  
  22.  
  23. UniCode         = 0                     ;No Unicode, just plain ASCII.
  24.  
  25.                 INCLUDE INSTR32.MAC
  26.                 INCLUDE WIN32INC.EQU
  27.                 INCLUDE KERNEL32.EQU
  28.  
  29.                 INCLUDE Win32DLL.inc
  30.  
  31.                 .LIST
  32.  
  33. DoDisplay       PROTO Message:DWORD,       ;Because INVOKE doesn't handle
  34.                       MessageLength:DWORD  ;forward references (boo).
  35.  
  36.                 SUBTITLE Macros & Data
  37.                 PAGE
  38.                 .DATA
  39.  
  40. Display         MACRO String
  41.                 INVOKE DoDisplay,
  42.                          OFFSET String,
  43.                          SIZEOF String
  44.                 ENDM
  45.  
  46. MsgSignon       BYTE 'Shell DLL test program.',CR,LF
  47.  
  48. MsgCommandLine  BYTE 'Command line was: '
  49. MsgCRLF         BYTE CR,LF
  50.  
  51.                 ALIGN DWORD
  52.  
  53. hStdOut         DWORD 0                 ;Standard output handle.
  54.  
  55.     SUBTITLE Main Entry Point code.
  56.     PAGE
  57.     .CODE
  58.  
  59. ; This is a console application.
  60. ; It's not a great example of what assembly might achieve against HLL, since
  61. ; it hardly does anything but using a few syscall.
  62. ; It's only purpose is to demonstrate DLL construction and use using assembly
  63. ; language.
  64.  
  65. Start PROC PUBLIC
  66.     INVOKE GetStdHandle,
  67.         STD_OUTPUT_HANDLE               ;Get handle for screen,
  68.                                         ;(might want to test retcode here...)
  69.     MOV hStdOut,EAX                     ;remember it.
  70.  
  71.     Display MsgSignon                   ;Display signon message.
  72.     Display MsgCommandLine              ;'Command line was:'
  73.  
  74.     INVOKE GetCommandLine               ;Get command line pointer in EAX.
  75.     XOR ECX,ECX                         ;Init byte count,
  76.     MOV EBX,EAX                         ;save command line pointer in EBX.
  77.       .WHILE BYTE PTR [EAX] != 0        ;Count command line size.
  78.       INC ECX                           ;Bump byte count,
  79.       INC EAX                           ;bump string pointer,
  80.       .ENDW                             ;till ending Z found.
  81.  
  82.       .IF ECX != 0                      ;If anything to display,
  83.       INVOKE DoDisplay,                 ;Display message
  84.                EBX,                     ;at [EBX],
  85.                ECX                      ;size in ECX.
  86.       CALL RollUp                       ;rollup one line.
  87.       .ENDIF
  88.  
  89.     CALL Foo                            ;Call the great Foo DLL function,
  90.     CALL Bar                            ;then the remakable Bar function.
  91.  
  92.     INVOKE ExitProcess,                 ;We're done:
  93.         0                               ;Null return code.
  94.  
  95.     RET
  96. Start ENDP
  97.  
  98.  
  99. ; Roll up one line (display CRLF).
  100.  
  101. RollUp PROC
  102.     Display MsgCRLF
  103.     RET
  104. RollUp ENDP
  105.  
  106. ; Display a console message.
  107. ; Note that in the following, we must use ADDR rather than OFFSET:
  108. ; MASM doesn't take OFFSET to LOCALs.
  109.  
  110. DoDisplay PROC Message:DWORD,
  111.                MessageLength:DWORD
  112.  
  113.           LOCAL BWritten
  114.  
  115.     INVOKE WriteFile,                   ;Rollup one line.
  116.         hStdOut,                        ;File handle for screen,
  117.         Message,                        ;address of string,
  118.         MessageLength,                  ;length of string,
  119.         ADDR BWritten,                  ;location to return bytes written,
  120.         0                               ;No overlapped mode.
  121.     MOV EAX,BWritten                    ;Return # of bytes actually written
  122.     RET                                 ;in EAX.
  123. DoDisplay ENDP
  124.  
  125.     END Start
  126.