[英]Porting VC++ inline assembler to x64 (of a __stdcall hook)
I need to port the inline assembler to be able to compile on x64.我需要移植内联汇编器才能在 x64 上编译。 I'm trying to get familiar with the x64 Intrinsics etc but I guess someone being into it could easily help me out.
我正在尝试熟悉 x64 Intrinsics 等,但我想有人可以很容易地帮助我。
void __stdcall Hook(P1, P2)
{
__asm pushad
static void* OriginalFunctionPointer =
GetProcAddress(GetModuleHandleA("Some.dll"), "[...]");
// [...]
__asm popad
__asm push (P2)
__asm push (P1)
__asm call (OriginalFunctionPointer)
}
seems you need a hooking library like this one (orthis if you want a C++ API) along with a function proto, then no inline assembly is needed, in 32 or 64-bit mode.似乎你需要一个像这样的挂钩库(或者如果你想要一个 C++ API)和一个 function 原型,那么在 32 位或 64 位模式下不需要内联汇编。 also, those pushad/popad's aren't needed when you are doing inline assembly.
此外,当您进行内联汇编时,不需要那些 pushad/poppad。
typedef void (__stdcall*myfp)(int,int);
void __stdcall MyHook(int arg1, int arg2)
{
static myfp TheFP = (myfp)GetProcAddress(GetModuleHandleA("Some.dll"), "[...]");
//your extra code
TheFP(arg1,arg2);
}
of course the injection of this hook needs to take place somewhere else.当然,这个钩子的注入需要在其他地方进行。 for hooking classes you need to account for the hidden
this
pointer ( pDevice
in this case):对于挂钩类,您需要考虑隐藏的
this
指针(在本例中为pDevice
):
#define D3D8FUNC(name,...) typedef HRESULT (__stdcall * name)(__VA_ARGS__)
D3D8FUNC(D3D8SetTexture,void* pDevice, DWORD dwStage, void* pTexture);
HRESULT __stdcall D3DSetTexture(void* pDevice, DWORD dwStage, void* pTexture)
{
LOG("[D3DSetTexture][0x%p] Device: 0x%p Stage: %u Texture: 0x%p\n",_ReturnAddress(),pDevice,dwStage,pTexture);
return Direct3D::gpfD3D8SetTexture(pDevice,dwStage,pTexture);
}
//in the init
Direct3D::gpfD3D8SetTexture = System::VirtualFunctionHook<Direct3D::D3D8SetTexture>(Direct3D::gpDevice,61,D3DSetTexture);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.