FreeRDP
callback.c
1 
20 #include <winpr/config.h>
21 
22 #include <winpr/crt.h>
23 #include <winpr/pool.h>
24 #include <winpr/library.h>
25 
26 #ifdef WINPR_THREAD_POOL
27 
28 #ifdef _WIN32
29 typedef BOOL(WINAPI* pCallbackMayRunLong_t)(PTP_CALLBACK_INSTANCE pci);
30 static INIT_ONCE init_once_module = INIT_ONCE_STATIC_INIT;
31 static pCallbackMayRunLong_t pCallbackMayRunLong = NULL;
32 
33 static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
34 {
35  HMODULE kernel32 = LoadLibraryA("kernel32.dll");
36  if (kernel32)
37  pCallbackMayRunLong =
38  GetProcAddressAs(kernel32, "CallbackMayRunLong", pCallbackMayRunLong_t);
39  return TRUE;
40 }
41 #endif
42 
43 BOOL winpr_CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci)
44 {
45 #ifdef _WIN32
46  InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
47  if (pCallbackMayRunLong)
48  return pCallbackMayRunLong(pci);
49 #endif
50  /* No default implementation */
51  return FALSE;
52 }
53 
54 #endif /* WINPR_THREAD_POOL defined */