diff --git a/plugins/win-capture/graphics-hook-info.h b/plugins/win-capture/graphics-hook-info.h index f90b2080d..abaf40861 100644 --- a/plugins/win-capture/graphics-hook-info.h +++ b/plugins/win-capture/graphics-hook-info.h @@ -7,21 +7,21 @@ #include "hook-helpers.h" -#define EVENT_CAPTURE_RESTART "CaptureHook_Restart" -#define EVENT_CAPTURE_STOP "CaptureHook_Stop" +#define EVENT_CAPTURE_RESTART L"CaptureHook_Restart" +#define EVENT_CAPTURE_STOP L"CaptureHook_Stop" -#define EVENT_HOOK_READY "CaptureHook_HookReady" -#define EVENT_HOOK_EXIT "CaptureHook_Exit" +#define EVENT_HOOK_READY L"CaptureHook_HookReady" +#define EVENT_HOOK_EXIT L"CaptureHook_Exit" -#define EVENT_HOOK_INIT "CaptureHook_Initialize" +#define EVENT_HOOK_INIT L"CaptureHook_Initialize" #define WINDOW_HOOK_KEEPALIVE L"CaptureHook_KeepAlive" -#define MUTEX_TEXTURE1 "CaptureHook_TextureMutex1" -#define MUTEX_TEXTURE2 "CaptureHook_TextureMutex2" +#define MUTEX_TEXTURE1 L"CaptureHook_TextureMutex1" +#define MUTEX_TEXTURE2 L"CaptureHook_TextureMutex2" -#define SHMEM_HOOK_INFO "CaptureHook_HookInfo" -#define SHMEM_TEXTURE "CaptureHook_Texture" +#define SHMEM_HOOK_INFO L"CaptureHook_HookInfo" +#define SHMEM_TEXTURE L"CaptureHook_Texture" #define PIPE_NAME "CaptureHook_Pipe" @@ -107,17 +107,17 @@ struct hook_info { static inline HANDLE create_hook_info(DWORD id) { - char new_name[64]; - sprintf(new_name, "%s%lu", SHMEM_HOOK_INFO, id); + wchar_t new_name[64]; + _snwprintf(new_name, 64, L"%s%lu", SHMEM_HOOK_INFO, id); - return CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, + return CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(struct hook_info), new_name); } static inline HANDLE open_hook_info(DWORD id) { - char new_name[64]; - sprintf(new_name, "%s%lu", SHMEM_HOOK_INFO, id); + wchar_t new_name[64]; + _snwprintf(new_name, 64, L"%s%lu", SHMEM_HOOK_INFO, id); - return OpenFileMappingA(GC_MAPPING_FLAGS, false, new_name); + return OpenFileMappingW(GC_MAPPING_FLAGS, false, new_name); } diff --git a/plugins/win-capture/graphics-hook/graphics-hook.c b/plugins/win-capture/graphics-hook/graphics-hook.c index 8a642b0bf..4c8ebd1da 100644 --- a/plugins/win-capture/graphics-hook/graphics-hook.c +++ b/plugins/win-capture/graphics-hook/graphics-hook.c @@ -74,7 +74,7 @@ bool init_pipe(void) return true; } -static HANDLE init_event(const char *name, DWORD pid) +static HANDLE init_event(const wchar_t *name, DWORD pid) { HANDLE handle = create_event_plus_id(name, pid); if (!handle) @@ -82,7 +82,7 @@ static HANDLE init_event(const char *name, DWORD pid) return handle; } -static HANDLE init_mutex(const char *name, DWORD pid) +static HANDLE init_mutex(const wchar_t *name, DWORD pid) { HANDLE handle = create_mutex_plus_id(name, pid); if (!handle) @@ -484,10 +484,10 @@ static inline void unlock_shmem_tex(int id) static inline bool init_shared_info(size_t size) { - char name[64]; - sprintf_s(name, 64, "%s%u", SHMEM_TEXTURE, ++shmem_id_counter); + wchar_t name[64]; + _snwprintf(name, 64, L"%s%ld", SHMEM_TEXTURE, ++shmem_id_counter); - shmem_file_handle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, + shmem_file_handle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (DWORD)size, name); if (!shmem_file_handle) { hlog("init_shared_info: Failed to create shared memory: %d", diff --git a/plugins/win-capture/hook-helpers.h b/plugins/win-capture/hook-helpers.h index 1e80a49bc..395f7d948 100644 --- a/plugins/win-capture/hook-helpers.h +++ b/plugins/win-capture/hook-helpers.h @@ -7,51 +7,51 @@ #define GC_EVENT_FLAGS (EVENT_MODIFY_STATE | SYNCHRONIZE) #define GC_MUTEX_FLAGS (SYNCHRONIZE) -static inline HANDLE create_event(const char *name) +static inline HANDLE create_event(const wchar_t *name) { - return CreateEventA(NULL, false, false, name); + return CreateEventW(NULL, false, false, name); } -static inline HANDLE open_event(const char *name) +static inline HANDLE open_event(const wchar_t *name) { - return OpenEventA(GC_EVENT_FLAGS, false, name); + return OpenEventW(GC_EVENT_FLAGS, false, name); } -static inline HANDLE create_mutex(const char *name) +static inline HANDLE create_mutex(const wchar_t *name) { - return CreateMutexA(NULL, false, name); + return CreateMutexW(NULL, false, name); } -static inline HANDLE open_mutex(const char *name) +static inline HANDLE open_mutex(const wchar_t *name) { - return OpenMutexA(GC_MUTEX_FLAGS, false, name); + return OpenMutexW(GC_MUTEX_FLAGS, false, name); } -static inline HANDLE create_event_plus_id(const char *name, DWORD id) +static inline HANDLE create_event_plus_id(const wchar_t *name, DWORD id) { - char new_name[64]; - sprintf(new_name, "%s%lu", name, id); + wchar_t new_name[64]; + _snwprintf(new_name, 64, L"%s%lu", name, id); return create_event(new_name); } -static inline HANDLE open_event_plus_id(const char *name, DWORD id) +static inline HANDLE open_event_plus_id(const wchar_t *name, DWORD id) { - char new_name[64]; - sprintf(new_name, "%s%lu", name, id); + wchar_t new_name[64]; + _snwprintf(new_name, 64, L"%s%lu", name, id); return open_event(new_name); } -static inline HANDLE create_mutex_plus_id(const char *name, DWORD id) +static inline HANDLE create_mutex_plus_id(const wchar_t *name, DWORD id) { - char new_name[64]; - sprintf(new_name, "%s%lu", name, id); + wchar_t new_name[64]; + _snwprintf(new_name, 64, L"%s%lu", name, id); return create_mutex(new_name); } -static inline HANDLE open_mutex_plus_id(const char *name, DWORD id) +static inline HANDLE open_mutex_plus_id(const wchar_t *name, DWORD id) { - char new_name[64]; - sprintf(new_name, "%s%lu", name, id); + wchar_t new_name[64]; + _snwprintf(new_name, 64, L"%s%lu", name, id); return open_mutex(new_name); }