2 #include "gdipp_config/constant_hook.h"
4 __declspec(dllimport
) LRESULT CALLBACK
gdipp_client_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
);
6 int APIENTRY
wWinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
, LPWSTR lpCmdLine
, int nCmdShow
)
8 const wchar_t *env_var_name
= L
"gdipp_svc_proc_id";
9 DWORD env_var_len
= GetEnvironmentVariableW(env_var_name
, NULL
, 0);
13 wchar_t *hook_env_str
= new wchar_t[env_var_len
];
14 env_var_len
= GetEnvironmentVariableW(env_var_name
, hook_env_str
, env_var_len
);
15 assert(env_var_len
> 0);
17 DWORD gdipp_svc_proc_id
;
18 std::wistringstream(hook_env_str
) >> gdipp_svc_proc_id
;
20 HANDLE h_gdipp_svc
= OpenProcess(SYNCHRONIZE
, FALSE
, gdipp_svc_proc_id
);
21 if (h_gdipp_svc
== NULL
)
25 const wchar_t *client_name
= L
"gdipp_client_64.dll";
27 const wchar_t *client_name
= L
"gdipp_client_32.dll";
30 const HMODULE h_client
= GetModuleHandleW(client_name
);
31 assert(h_client
!= NULL
);
33 const HHOOK h_hook
= SetWindowsHookExW(WH_CBT
, gdipp_client_hook_proc
, h_client
, 0);
37 WaitForSingleObject(h_gdipp_svc
, INFINITE
);
38 UnhookWindowsHookEx(h_hook
);