我正在使用lib EasyHook连接函数EasyHook。
当它返回行return CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);时,如下所示:
X, Y, nWidth, nHeight修改的参数返回原始“截获”函数或
CreateWindowExW函数?如果是2,如何用修改后的值返回original函数调用?
我怀疑是否需要在某个地方定义CreateWindowExW,以及如何使用当前的“拦截”钩子函数“调用”它?
这是完整的代码,我没有在其他地方定义CreateWindowExW:
HWND __stdcall CreateWindowExW_Hook(
DWORD dwExStyle,
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
DWORD dwStyle,
int X,
int Y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
)
{
X = 50; Y = 50; nWidth = 400; nHeight = 300;
return CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
}
extern "C" void __declspec(dllexport) __stdcall NativeInjectionEntryPoint(REMOTE_ENTRY_INFO* inRemoteInfo);
void __stdcall NativeInjectionEntryPoint(REMOTE_ENTRY_INFO* inRemoteInfo)
{
HOOK_TRACE_INFO hHook = { NULL };
NTSTATUS result = LhInstallHook(
GetProcAddress(GetModuleHandle(TEXT("User32")), "CreateWindowExW"),
CreateWindowExW_Hook,
NULL,
&hHook);
ULONG ACLEntries[1] = { 0 };
LhSetExclusiveACL(ACLEntries, 1, &hHook);
}发布于 2021-09-11 20:27:21
CreateWindowExW_Hook函数是CreateWindowExW函数的重定向,它是user32.dll的一部分。
这句话:
NTSTATUS result = LhInstallHook(
GetProcAddress(GetModuleHandle(TEXT("User32")), "CreateWindowExW"),
CreateWindowExW_Hook,
NULL,
&hHook)设置重定向,当CreateWindowExW函数被调用时,它将降落在函数CreateWindowExW_Hook上,这将修改参数,并将从user32.dll调用原始的CreateWindowExW函数。
我已经重写了你的功能以便更容易理解。
HWND __stdcall CreateWindowExW_Hook(
DWORD dwExStyle,
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
DWORD dwStyle,
int X,
int Y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
)
{
int new_X = 50;
int new_Y = 50;
int new_nWidth = 400;
int new_nHeight = 300;
HWND retVal = CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, new_X, new_Y, new_nWidth, new_nHeight, hWndParent, hMenu, hInstance, lpParam);
return retVal;
}https://stackoverflow.com/questions/69143552
复制相似问题