diff --git a/plugins/win-capture/CMakeLists.txt b/plugins/win-capture/CMakeLists.txt index a3a4da478..af5db8fa6 100644 --- a/plugins/win-capture/CMakeLists.txt +++ b/plugins/win-capture/CMakeLists.txt @@ -2,6 +2,7 @@ project(win-capture) set(win-capture_HEADERS obfuscate.h + hook-helpers.h window-helpers.h dc-capture.h) diff --git a/plugins/win-capture/hook-helpers.h b/plugins/win-capture/hook-helpers.h new file mode 100644 index 000000000..f0e7610b4 --- /dev/null +++ b/plugins/win-capture/hook-helpers.h @@ -0,0 +1,46 @@ +#pragma once + +#if !defined(__cplusplus) && !defined(inline) +#define inline __inline +#endif + +static inline HANDLE get_event(const char *name) +{ + HANDLE event = CreateEventA(NULL, false, false, name); + if (!event) + event = OpenEventA(EVENT_ALL_ACCESS, false, name); + + return event; +} + +static inline HANDLE get_mutex(const char *name) +{ + HANDLE event = CreateMutexA(NULL, false, name); + if (!event) + event = OpenMutexA(MUTEX_ALL_ACCESS, false, name); + + return event; +} + +static inline HANDLE get_event_plus_id(const char *name, DWORD id) +{ + char new_name[64]; + sprintf(new_name, "%s%d", name, id); + return get_event(new_name); +} + +static inline HANDLE get_mutex_plus_id(const char *name, DWORD id) +{ + char new_name[64]; + sprintf(new_name, "%s%d", name, id); + return get_mutex(new_name); +} + +static inline bool object_signalled(HANDLE event) +{ + if (!event) + return false; + + return WaitForSingleObject(event, 0) == WAIT_OBJECT_0; +} +