These are chat archives for EasyHook/EasyHook

14th
Apr 2017
Justin Stenning
@spazzarama
Apr 14 2017 06:36
@zezba9000 in x64 try without the int edx
@zezba9000 or try with a pointer sized argument (e.g. void*)
Since there are no other parameters tho I can't see that you would ever need to add the dummy EDX for x32 fastcalls
Andrew
@zezba9000
Apr 14 2017 20:47
@spazzarama I tried without EDX, tried with other ptr regerster types ect ect. I ended up using PolyHook.
I think the issue was with the return object being larger then 64bits
when this happens it can no longer store the return value in the RAX register.
so the VC++ compilers calling convention becomes a little tricky. PolyHook seems to handle this x64 situation. I couldn't find anything in EasyHook I could use that did this so idk: https://www.codeproject.com/articles/1100579/polyhook-the-cplusplus-x-x-hooking-library
QUOTE: "In x64 it's a bit more complicated because there is no single instruction that can jump the entire x64 address range. So instead I use two different assembly snippets, and choose which to use based on the size of the prologue:"
QUOTE: "In the Microsoft x64 calling convention, it's the caller's responsibility to allocate 32 bytes of "shadow space" on the stack right before calling the function (regardless of the actual number of parameters used), and to pop the stack after the call. The shadow space is used to spill RCX, RDX, R8, and R9,[14] but must be made available to all functions, even those with fewer than four parameters."
Andrew
@zezba9000
Apr 14 2017 21:22
Also this is the return structure:
struct DriverPose_t
{
    double poseTimeOffset;
    HmdQuaternion_t qWorldFromDriverRotation;
    double vecWorldFromDriverTranslation[3];
    HmdQuaternion_t qDriverFromHeadRotation;
    double vecDriverFromHeadTranslation[3];
    double vecPosition[3];
    double vecVelocity[3];
    double vecAcceleration[3];
    HmdQuaternion_t qRotation;
    double vecAngularVelocity[3];
    double vecAngularAcceleration[3];
    ETrackingResult result;
    bool poseIsValid;
    bool willDriftInYaw;
    bool shouldApplyHeadModel;
    bool deviceIsConnected;
};