Related Projects > NASMX

Typo in nasmx.inc and issue with invoke on win64

<< < (2/2)

Bryant Keller:

--- Quote from: miz on September 10, 2013, 12:11:03 PM ---Also, it seems that the invoke macro on win64 always writes the first four parameters to the stack, which is quite unnecessary.
--- End quote ---

Actually it's not unnecessary, it's a requirement.

"The x64 Application Binary Interface (ABI) is a 4 register fast-call calling convention, with stack-backing for those registers." (MSDN)
"The caller is responsible for allocating space for parameters to the callee, and must always allocate sufficient space for the 4 register parameters, even if the callee doesn’t have that many parameters." (MSDN)

miz:
Allocating the space is, writing the register parameters into that space is not.

encryptor256:

--- Quote from: miz on October 18, 2013, 09:12:07 AM ---Allocating the space is, writing the register parameters into that space is not.

--- End quote ---

Confirm!

Bryant Keller:

--- Quote from: miz on October 18, 2013, 09:12:07 AM ---Allocating the space is, writing the register parameters into that space is not.

--- End quote ---

I would suggest testing this quite a bit. Early versions of NASMX implemented the stack space without adding the registers on stack and IIRC we had some issues with programs that used exception handling for stack unwinding (they would crash). The fix in that case was to put the registers themselves onto the stack in proper order. The justification for this was always the two comments posted below. It worked at the time, but if there isn't a reason to do this anymore then by all means just change it to a SUB instruction (that's the way it was originally written). :D

Navigation

[0] Message Index

[*] Previous page

Go to full version