flat assembler
Message board for the users of flat assembler.
Index
> Windows > 64bit COFF + GoLink + MessageBox does not open on Windows |
Author |
|
revolution 02 Feb 2023, 10:24
The Windows 64-bit ABI uses FASTCALL convention. The code you posted seems to be the STDCALL converted to 64-bit. But that won't work.
You need to pass the first four parameters in RCX, RDX, R8, and R9. Plus you need to stack aligned to 16. and to reserve the shadow register space before calling the API. The code you commented out looks like the correct method, but it is still missing the stack adjustments. I'm not sure about how golink/coff does the imports. You might need an indirect call. |
|||
02 Feb 2023, 10:24 |
|
revolution 02 Feb 2023, 10:52
This might have a better chance:
Code: format MS64 COFF extrn MessageBoxA qword extrn ExitProcess qword section '.text' code readable executable public Start Start: push rbp ; align stack sub rsp, 8 * 4 ; shadow space xor r9, r9 lea r8, [_caption] lea rdx, [_message] xor ecx, ecx call [MessageBoxA] mov ecx, eax call [ExitProcess] section '.data' data readable writeable _caption db 'Win64 assembly',0 _message db 'Coffee time!',0 |
|||
02 Feb 2023, 10:52 |
|
wbi 02 Feb 2023, 11:07
Hi revolution,
wow, that was quick and it did in fact solve my problem! I copy pasted your code and it worked right away. And yes, Start seems to be the default label that golink is looking for. It can be changed on the command line using the flag /entry:<label> if needed. For anybody interested, here are the commands to compile: Code: FASM.EXE fastcall_64bit.asm build/fastcall_64bit.obj GoLink.exe -fo build/fastcall_64bit.exe build/fastcall_64bit.obj kernel32.dll user32.dll Thank you very much, revolution! |
|||
02 Feb 2023, 11:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.