EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

Test t9526: DLL proxy library for 64bit Windows forwards exports to other DLL library


Description
Functions Write.W32, Beep.W32, Exit.W32 exported from the main (proxy) library t9526.dll are in fact forwarded to an auxilliary library t9526_fwd.dll.
Point characters . in forwarded identifiers were replaced with underscore _ because Windows loader does not like points in the name of forwarded DLL and its functions.
Source & expected listing t9526.htm.lst
| | EUROASM AUTOSEGMENT=ON,CPU=X64,DUMPWIDTH=28 |7439353236 |%test %SET t9526 | |;; | |;; Create auxilliary DLL library. | |%test[]_fwd PROGRAM FORMAT=DLL,WIDTH=64,MODEL=FLAT,ICONFILE= |[.text] ::::Section changed. |00000000: |Write_fwd_W64: PROC ; Write ASCIIZ string DS:RSI in 64bit Windows. | | IMPORT GetStdHandle:,WriteFile: ; Declare imported Windows kernel functions. |00000000:4889E5 | MOV RBP,RSP ; Save (perhaps unaligned) stack pointer. |00000003:4883E4F0 | AND RSP,-16 ; OWORD alignment downwards. |00000007:4883EC30 | SUB RSP,5*8+8 ; Allocate shadow space on stack for max 5 arguments. |0000000B:48C7C1F5FFFFFF | MOV RCX,-11 ; %1 Identifier of standard output STD_OUTPUT_HANDLE. |00000012:E8(00000000) | CALL GetStdHandle: ; Fastcall the imported Windows function with 1 argument. |00000017:4889C3 | MOV RBX,RAX ; Temporary save the returned StdOutput handle to RBX. |0000001A:4889F7 | MOV RDI,RSI ; Use RDI to find the end of input string. |0000001D:31C9 | XOR ECX,ECX ; Clear RCX to keep the size of input string. |0000001F:31C0 | XOR EAX,EAX ; Clear AL, the searched terminating character. |00000021:48F7D1 | NOT RCX ; Assume unlimited possible string size. |00000024:F2AE | REPNE SCASB ; Find the zero terminator. |00000026:48F7D1 | NOT RCX ; Get string size to RCX. |00000029:4889442420 | MOV [RSP+20h],RAX ; %5 Overlapped I/O is not used. |0000002E:4C8D4C2418 | LEA R9,[RSP+18h] ; %4 Local variable for the number of written bytes uses shadowed R9. |00000033:4989C8 | MOV R8,RCX ; %3 String size. |00000036:4889F2 | MOV RDX,RSI ; %2 String address. |00000039:4889D9 | MOV RCX,RBX ; %1 Standard output file handle. |0000003C:E8(00000000) | CALL WriteFile: ; Fastcall the imported function with 5 arguments. |00000041:4889EC | MOV RSP,RBP ; Restore the stack. |00000044:C3 | RET ; Return to caller. |00000045: |ENDPROC Write_fwd_W64: | |;; |00000045: |Beep_fwd_W64: PROC ; Play a sound in 64bit Windows. |00000045:488D35(00000000) | LEA RSI,[=B"Beeping..."] ; Define a literal string in [.rodata]. |0000004C:E8AFFFFFFF | CALL Write_fwd_W64:: ; Display the notification "Beeping...". | | IMPORT Beep: ; Declare imported Windows kernel function. |00000051:4889E5 | MOV RBP,RSP ; Save (perhaps unaligned) stack pointer. |00000054:4883E4F0 | AND RSP,-16 ; OWORD alignment downwards. |00000058:4883EC20 | SUB RSP,4*8 ; Allocate shadow space on stack. |0000005C:BAC8000000 | MOV RDX,200 ; %2 Sound duration [ms]. |00000061:B9B8010000 | MOV RCX,440 ; %1 Sound frequency [Hz]. |00000066:E8(00000000) | CALL Beep: ; Fastcall the imported function with 2 arguments. |0000006B:BA90010000 | MOV RDX,400 ; %2 Sound duration [ms]. |00000070:B94B020000 | MOV RCX,587 ; %1 Sound frequency [Hz]. |00000075:E8(00000000) | CALL Beep: ; Fastcall the imported function with 2 arguments. |0000007A:4889EC | MOV RSP,RBP ; Restore the stack. |0000007D:C3 | RET ; Return to caller. |0000007E: |ENDPROC Beep_fwd_W64: | |;; |0000007E: |Exit_fwd_W64: PROC ; Terminate program in 64bit Windows. |0000007E:488D35(00000000) | LEA RSI,[.M:] ; Address in segment [.bss] for the message. |00000085:C706456E6400 | MOVD [RSI+0],"End" ; Dynamically define the message "End". |0000008B:C746030D0A0000 | MOVD [RSI+3],0x0A0D ; CR+LF. |00000092:E869FFFFFF | CALL Write_fwd_W64:: ; Display the notification "End". | | IMPORT ExitProcess ; Declare imported Windows kernel function. |00000097:4883E4F0 | AND RSP,-16 ; OWORD alignment downwards. |0000009B:4883EC20 | SUB RSP,4*8 ; Allocate shadow space on stack. |0000009F:31C9 | XOR ECX,ECX ; %1 Terminate with errorlevel 0. |000000A1:E9(00000000) | JMP ExitProcess: ; Use imported function with 1 argument. No return. |[.bss] ::::Section changed. |00000000:.............. |.M: DB 7*BYTE ; Reserve space for ASCIIZ string "End" in segment [.bss]. |[.text] ::::Section changed. |000000A6: |ENDPROC Exit_fwd_W64: | |;; | | EXPORT Write_fwd_W64,Beep_fwd_W64,Exit_fwd_W64 |[@LT1] ====ListLiterals in section [@LT1]. |00000000:42656570696E672E~=B"Beeping..." | |ENDPROGRAM %test[]_fwd | **** ListMap "t9526_fwd.dll",model=FLAT,groups=0,segments=6,entry=,stack= | [.text],FA=00000400h,VA=10001000h,size=000000A6h=166,width=64,align=0010h,purpose=CODE | [.rodata],FA=00000600h,VA=10002000h,size=0000000Bh=11,width=64,align=0010h,purpose=RODATA+LITERAL | [.bss],FA=00000800h,VA=10003000h,size=00000007h=7,width=64,align=0010h,purpose=BSS | [.idata],FA=00000800h,VA=10004000h,size=000000D3h=211,width=64,align=8,purpose=IMPORT+IAT | [.edata],FA=00000A00h,VA=10005000h,size=0000007Ch=124,width=0,align=8,purpose=EXPORT | [.reloc],FA=00000C00h,VA=10006000h,size=00000010h=16,width=32,align=4,purpose=BASERELOC | **** ListGlobals "t9526_fwd.dll",Global=0,Public=0,Extern=0,eXport=3,Import=4 | Beep,[.idata]:000000C5h,VA=100040C5h,scope='I',lib="kernel32.dll" | Beep_fwd_W64,[.text]:00000045h,VA=10001045h,scope='X' | ExitProcess,[.idata]:000000CCh,VA=100040CCh,scope='I',lib="kernel32.dll" | Exit_fwd_W64,[.text]:0000007Eh,VA=1000107Eh,scope='X' | GetStdHandle,[.idata]:000000B7h,VA=100040B7h,scope='I',lib="kernel32.dll" | WriteFile,[.idata]:000000BEh,VA=100040BEh,scope='I',lib="kernel32.dll" | Write_fwd_W64,[.text]:00000000h,VA=10001000h,scope='X' | |;; | |;; Create the main DLL proxy library. | |%test PROGRAM FORMAT=DLL,MODEL=FLAT,WIDTH=64,ICONFILE= | | EXPORT Write.W64, LIB=%test[]_fwd.dll, FWD=Write_fwd_W64 | | EXPORT Beep.W64, LIB=%test[]_fwd.dll, FWD=Beep_fwd_W64 | | EXPORT Exit.W64, LIB=%test[]_fwd.dll, FWD=Exit_fwd_W64 | |ENDPROGRAM %test | **** ListMap "t9526.dll",model=FLAT,groups=0,segments=1,entry=,stack= | [.edata],FA=00000200h,VA=10001000h,size=000000B2h=178,width=0,align=8,purpose=EXPORT | **** ListGlobals "t9526.dll",Global=0,Public=0,Extern=0,eXport=3,Import=0 | Beep.W64,scope='X',lib="t9526_fwd.dll",fwd=Beep_fwd_W64 | Exit.W64,scope='X',lib="t9526_fwd.dll",fwd=Exit_fwd_W64 | Write.W64,scope='X',lib="t9526_fwd.dll",fwd=Write_fwd_W64
Expected messages t9526.out
I0180 Assembling source file "t9526.htm". I0270 Assembling source "t9526". I0310 Assembling source pass 1. I0330 Assembling source pass 2 - final. I0470 Assembling program "t9526_fwd". "t9526.htm"{51} I0510 Assembling program pass 1. "t9526.htm"{51} I0510 Assembling program pass 2. "t9526.htm"{51} I0530 Assembling program pass 3 - final. "t9526.htm"{51} I0660 64bit FLAT DLL file "t9526_fwd.dll" created, size=3088. "t9526.htm"{112} I0650 Program "t9526_fwd" assembled in 3 passes with errorlevel 0. "t9526.htm"{112} I0470 Assembling program "t9526". "t9526.htm"{130} I0510 Assembling program pass 1. "t9526.htm"{130} I0510 Assembling program pass 2. "t9526.htm"{130} I0530 Assembling program pass 3 - final. "t9526.htm"{130} I0660 64bit FLAT DLL file "t9526.dll" created, size=690. "t9526.htm"{134} I0650 Program "t9526" assembled in 3 passes with errorlevel 0. "t9526.htm"{134} I0750 Source "t9526" (213 lines) assembled in 2 passes with errorlevel 0. I0860 Listing file "t9526.htm.lst" created, size=7696. I0990 EuroAssembler terminated with errorlevel 0.
Expected output file t9526. dll
0000: 4D 5A 89 00 01 00 00 00 04 00 21 00 FF FF 05 00  MZ¤°·°°°·°!°¤¤·°
0010: 00 02 BF A2 00 00 00 00 40 00 00 00 00 00 00 00  °·¤¤°°°°@°°°°°°°
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0030: 00 00 00 00 00 00 00 00 00 00 00 00 90 00 00 00  °°°°°°°°°°°°¤°°°
0040: 0E 1F BA 0E 00 B4 09 CD 21 B8 08 4C CD 21 54 68  ··¤·°¤·¤!¤·L¤!Th
0050: 69 73 20 70 72 6F 67 72 61 6D 20 77 61 73 20 6C  is¯program¯was¯l
0060: 61 75 6E 63 68 65 64 20 69 6E 20 44 4F 53 20 62  aunched¯in¯DOS¯b
0070: 75 74 20 69 74 20 72 65 71 75 69 72 65 73 20 57  ut¯it¯requires¯W
0080: 69 6E 64 6F 77 73 2E 24 00 00 00 00 00 00 00 00  indows.$°°°°°°°°
0090: 50 45 00 00 64 86 01 00 00 00 00 00 00 00 00 00  PE°°d¤·°°°°°°°°°
00A0: 00 00 00 00 F0 00 22 20 0B 02 01 00 00 00 00 00  °°°°¤°"¯···°°°°°
00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
00C0: 00 00 00 10 00 00 00 00 00 10 00 00 00 02 00 00  °°°·°°°°°·°°°·°°
00D0: 04 00 00 00 01 00 00 00 04 00 00 00 00 00 00 00  ·°°°·°°°·°°°°°°°
00E0: 00 20 00 00 C0 01 00 00 00 00 00 00 03 00 0F 00  °¯°°¤·°°°°°°·°·°
00F0: 00 00 10 00 00 00 00 00 00 20 00 00 00 00 00 00  °°·°°°°°°¯°°°°°°
0100: 00 00 00 01 00 00 00 00 00 00 10 00 00 00 00 00  °°°·°°°°°°·°°°°°
0110: 00 00 00 00 10 00 00 00 00 10 00 00 B2 00 00 00  °°°°·°°°°·°°¤°°°
0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0190: 00 00 00 00 00 00 00 00 2E 65 64 61 74 61 00 00  °°°°°°°°.edata°°
01A0: 00 10 00 00 00 10 00 00 B2 00 00 00 00 02 00 00  °·°°°·°°¤°°°°·°°
01B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 40  °°°°°°°°°°°°°°@@
01C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
01D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
01F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0200: 00 00 00 00 00 00 00 00 01 00 00 00 46 10 00 00  °°°°°°°°·°°°F·°°
0210: 01 00 00 00 03 00 00 00 03 00 00 00 28 10 00 00  ·°°°·°°°·°°°(·°°
0220: 34 10 00 00 40 10 00 00 6C 10 00 00 83 10 00 00  4·°°@·°°l·°°¤·°°
0230: 9A 10 00 00 50 10 00 00 59 10 00 00 62 10 00 00  ¤·°°P·°°Y·°°b·°°
0240: 00 00 01 00 02 00 74 39 35 32 36 2E 64 6C 6C 00  °°·°·°t9526.dll°
0250: 42 65 65 70 2E 57 36 34 00 45 78 69 74 2E 57 36  Beep.W64°Exit.W6
0260: 34 00 57 72 69 74 65 2E 57 36 34 00 74 39 35 32  4°Write.W64°t952
0270: 36 5F 66 77 64 2E 42 65 65 70 5F 66 77 64 5F 57  6_fwd.Beep_fwd_W
0280: 36 34 00 74 39 35 32 36 5F 66 77 64 2E 45 78 69  64°t9526_fwd.Exi
0290: 74 5F 66 77 64 5F 57 36 34 00 74 39 35 32 36 5F  t_fwd_W64°t9526_
02A0: 66 77 64 2E 57 72 69 74 65 5F 66 77 64 5F 57 36  fwd.Write_fwd_W6
02B0: 34 00                                            4°

▲Back to the top▲