Answer the question
In order to leave comments, you need to log in
How to pull out the pointer to the window in the intercepted EnumWindows function?
Hook on EnumWindows
//hook.h
typedef BOOL(WINAPI *PNT_ENUMWINDOWS)(
_In_ WNDENUMPROC lpEnumFunc,
_In_ LPARAM lParam
);
//hook.cpp
PNT_ENUMWINDOWS TrueEnumWindows = (PNT_ENUMWINDOWS)::GetProcAddress(::GetModuleHandle(L"user32"), "EnumWindows");
BOOL WINAPI FalseEnumWindows(
_In_ WNDENUMPROC lpEnumFunc,
_In_ LPARAM lParam
)
{
// Если lParam содержит нужные данные, обработать их
BOOL result = TrueEnumWindows(lpEnumFunc, lParam);
return result;
}
Answer the question
In order to leave comments, you need to log in
As I understand it, lpEnumFunc is just a pointer to a custom callback function, and all data passed to it is encoded in lParam
BOOL CALLBACK EnumWindowsProc(
_In_ HWND hwnd,
_In_ LPARAM lParam
);
struct enumWindowsParams {
WNDENUMPROC lpEnumProc;
LPARAM lParam;
};
BOOL CALLBACK myEnumFunc(
_In_ HWND hwnd,
_In_ LPARAM lParam
)
{
// use hwnd as needed
struct enumWindowsParams *ewp = (struct enumWindowsParams *)lParam;
return ewp->lpEnumProc(hwnd, ewp->lParam);
}
BOOL WINAPI FalseEnumWindows(
_In_ WNDENUMPROC lpEnumFunc,
_In_ LPARAM lParam
)
{
struct enumWindowsParams ewp;
ewp.lpEnumFunc= lpEnumFunc;
ewp.lParam = lParam;
BOOL result = TrueEnumWindows(myEnumFunc, (LPARAM)&ewp);
return result;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question