1 2;--- this is a test app which calls functions Export1 and Export2 in 3;--- Win32_4d.dll. The link step needs import library Win32_4d.lib to find 4;--- the externals used in the source. Some linkers (MS link, PoLink) 5;--- will always generate such an import lib when the dll is written. 6;--- To get one with JWlink, OPTION IMPLIB must be set; it will make JWlink 7;--- launch JWlib internally. 8 9;--- To assembly, use JWasm: 10;--- JWasm -coff Win32_4a.asm 11; 12;--- 1. To link with MS link: 13;--- Link /subsystem:console Win32_4a.obj Win32_4d.lib 14;--- 2. To link with JWlink 15;--- JWlink format win pe file Win32_4a.obj lib Win32_4d.lib 16;--- 3. To link with PoLink: 17;--- PoLink /subsystem:console Win32_4a.obj Win32_4d.lib 18 19 .386 20 .model flat, stdcall 21 22 includelib kernel32.lib 23 includelib user32.lib 24 25;--- prototypes for functions exported by Window4d. 26 27Export1 proto stdcall 28Export2 proto stdcall :ptr DWORD 29 30;--- standard Win32 prototypes 31 32STD_OUTPUT_HANDLE equ -11 33 34WriteConsoleA proto :dword, :dword, :dword, :dword, :dword 35GetStdHandle proto :dword 36ExitProcess proto :dword 37wvsprintfA proto :ptr, :ptr, :ptr 38 39 .data 40 41value2 dd 0 42 43szFormat1 db "Export1() returned %X",13,10,0 44szFormat2 db "Export2() returned %X",13,10,0 45 46 .code 47 48;--- simple printf() emulation 49 50printf proc c uses ebx pszFormat:dword, args:VARARG 51 52local dwWritten:DWORD 53local buffer[256]:byte 54 55 invoke GetStdHandle, STD_OUTPUT_HANDLE 56 mov ebx, eax 57 invoke wvsprintfA, addr buffer, pszFormat, addr args 58 lea ecx, dwWritten 59 invoke WriteConsoleA, ebx, addr buffer, eax, ecx, 0 60 ret 61 62printf endp 63 64start: 65 invoke Export1 66 invoke printf, addr szFormat1, eax 67 invoke Export2, addr value2 68 invoke printf, addr szFormat2, value2 69 invoke ExitProcess, 0 70 71 end start 72 73