2 #include "gdipp_client/gamma.h"
3 #include "gdipp_client/global.h"
4 #include "gdipp_config/constant_client.h"
5 #include "gdipp_config/exclude_config.h"
6 #include "gdipp_lib/helper.h"
7 #include "gdipp_lib/scoped_rw_lock.h"
12 HANDLE process_heap
= GetProcessHeap();
14 bool init_rpc_client()
16 if (process_heap
== NULL
)
20 RPC_STATUS rpc_status
;
22 rpc_status
= RpcStringBindingCompose(NULL
, reinterpret_cast<RPC_WSTR
>(L
"ncalrpc"), NULL
, reinterpret_cast<RPC_WSTR
>(L
"gdipp"), NULL
, &binding_str
);
23 if (rpc_status
!= RPC_S_OK
)
26 rpc_status
= RpcBindingFromStringBinding(binding_str
, &h_gdipp_rpc
);
27 if (rpc_status
!= RPC_S_OK
)
30 rpc_status
= RpcStringFree(&binding_str
);
31 if (rpc_status
!= RPC_S_OK
)
39 void __RPC_FAR
*__RPC_USER
MIDL_user_allocate(size_t size
)
41 return HeapAlloc(gdipp::process_heap
, HEAP_GENERATE_EXCEPTIONS
, size
);
44 void __RPC_USER
MIDL_user_free(void __RPC_FAR
*ptr
)
46 HeapFree(gdipp::process_heap
, 0, ptr
);
49 BOOL APIENTRY
DllMain(HMODULE hModule
, DWORD ul_reason_for_call
, LPVOID lpReserved
)
53 switch (ul_reason_for_call
)
55 case DLL_PROCESS_ATTACH
:
57 gdipp::h_self
= hModule
;
59 wchar_t this_proc_name
[MAX_PATH
];
60 DWORD dw_ret
= GetModuleBaseNameW(GetCurrentProcess(), NULL
, this_proc_name
, MAX_PATH
);
63 if (gdipp::exclude_config::is_process_excluded(gdipp::config_instance
, this_proc_name
))
66 OSVERSIONINFO ver_info
= {sizeof(OSVERSIONINFO
)};
67 b_ret
= GetVersionEx(&ver_info
);
70 gdipp::os_support_directwrite
= (ver_info
.dwMajorVersion
>= 6);
72 gdipp::scoped_rw_lock::initialize();
74 if (!gdipp::init_rpc_client())
77 gdipp::client_config_instance
.parse(gdipp::config_instance
);
79 if (!gdipp::hook_instance
.start())
84 case DLL_PROCESS_DETACH
:
85 gdipp::hook_instance
.stop();