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