56 lines
996 B
C++
56 lines
996 B
C++
#include <hookproc/apientry.hpp>
|
|
|
|
#if defined(_MSC_VER)
|
|
void APIEntry::createThunk(DWORD stackLength)
|
|
{
|
|
pushEBP();
|
|
movEBPESP();
|
|
jmp(0x0008);
|
|
encodeDD();
|
|
encodeDD();
|
|
movEAX(FirstArgument);
|
|
addEAX(stackLength);
|
|
subEAX(0x0004);
|
|
cmpEAX(0x0004);
|
|
je(0x0013);
|
|
pushEBPEAXPLUS(0);
|
|
subEAX(4);
|
|
cmpEAX(FirstArgument);
|
|
jnl(-19);
|
|
push(base()+tell()+0x0014);
|
|
movECXOFFSETCS(base()+IATInstance);
|
|
movEAXOFFSETCS(base()+IATOffset);
|
|
pushEAX();
|
|
retn();
|
|
popEBP();
|
|
retn();
|
|
}
|
|
#else
|
|
void APIEntry::createThunk(DWORD stackLength)
|
|
{
|
|
pushEBP();
|
|
movEBPESP();
|
|
jmp(0x0008);
|
|
encodeDD();
|
|
encodeDD();
|
|
movEAX(FirstArgument);
|
|
addEAX(stackLength);
|
|
subEAX(0x0004);
|
|
cmpEAX(0x0004);
|
|
je(0x0013);
|
|
pushEBPEAXPLUS(0);
|
|
subEAX(4);
|
|
cmpEAX(FirstArgument);
|
|
jnl(-19);
|
|
movECXOFFSETCS(base()+IATInstance);
|
|
pushECX();
|
|
push(base()+tell()+0x000D);
|
|
movEAXOFFSETCS(base()+IATOffset);
|
|
pushEAX();
|
|
retn();
|
|
addESP(stackLength+sizeof(void*));
|
|
popEBP();
|
|
retn(stackLength);
|
|
}
|
|
#endif
|