View Single Post
  #10  
Old 01-06-2022, 04:09
chants chants is offline
VIP
 
Join Date: Jul 2016
Posts: 634
Rept. Given: 21
Rept. Rcvd 43 Times in 26 Posts
Thanks Given: 588
Thanks Rcvd at 954 Times in 431 Posts
chants Reputation: 43
Yes the calling convention on 64bit has oddities with 16 byte alignment on calls, shadow spaces needing to be reserved and such. With driver calls it's not surprising these become necessary. The ABI convention is slightly different between Windows and Linux as well.

Quote:
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170
Quote:
Calling convention defaults
The x64 Application Binary Interface (ABI) uses a four-register fast-call calling convention by default. Space is allocated on the call stack as a shadow store for callees to save those registers.

Alignment
Most structures are aligned to their natural alignment. The primary exceptions are the stack pointer and malloc or alloca memory, which are 16-byte aligned to aid performance. Alignment above 16 bytes must be done manually. Since 16 bytes is a common alignment size for XMM operations, this value should work for most code. For more information about structure layout and alignment, see Types and Storage. For information about the stack layout, see x64 stack usage.

The callee is responsible for dumping the register parameters into their shadow space if needed.
Reply With Quote