From 69ff026647b8f3e9a3183eec760e9047ba667520 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Wed, 15 Sep 2021 19:55:09 -0700 Subject: [PATCH] libobs, win-capture: Share window helper code Add "ms_" prefix as makeshift namespace. --- libobs/CMakeLists.txt | 6 +- .../util/windows}/obfuscate.c | 2 +- .../util/windows}/obfuscate.h | 6 +- .../util/windows}/window-helpers.c | 109 +++++++++++++----- libobs/util/windows/window-helpers.h | 56 +++++++++ plugins/win-capture/CMakeLists.txt | 8 +- plugins/win-capture/game-capture.c | 89 +++----------- .../win-capture/graphics-hook/CMakeLists.txt | 4 +- .../win-capture/graphics-hook/graphics-hook.c | 4 +- .../win-capture/inject-helper/CMakeLists.txt | 6 +- .../win-capture/inject-helper/inject-helper.c | 8 +- plugins/win-capture/inject-library.c | 16 +-- plugins/win-capture/window-capture.c | 32 +++-- plugins/win-capture/window-helpers.h | 37 ------ 14 files changed, 201 insertions(+), 182 deletions(-) rename {plugins/win-capture => libobs/util/windows}/obfuscate.c (90%) rename {plugins/win-capture => libobs/util/windows}/obfuscate.h (58%) rename {plugins/win-capture => libobs/util/windows}/window-helpers.c (81%) create mode 100644 libobs/util/windows/window-helpers.h delete mode 100644 plugins/win-capture/window-helpers.h diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index d65e9847d..8bfd833b4 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -284,8 +284,12 @@ if(OS_WINDOWS) util/threading-windows.h util/pipe-windows.c util/platform-windows.c + util/windows/obfuscate.c + util/windows/obfuscate.h util/windows/win-registry.h util/windows/win-version.h + util/windows/window-helpers.c + util/windows/window-helpers.h util/windows/ComPtr.hpp util/windows/CoTaskMemPtr.hpp util/windows/HRError.hpp @@ -300,7 +304,7 @@ if(OS_WINDOWS) libobs PRIVATE UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS) - target_link_libraries(libobs PRIVATE Avrt winmm) + target_link_libraries(libobs PRIVATE Avrt Dwmapi winmm) if(MSVC) target_link_libraries(libobs PRIVATE OBS::w32-pthreads) diff --git a/plugins/win-capture/obfuscate.c b/libobs/util/windows/obfuscate.c similarity index 90% rename from plugins/win-capture/obfuscate.c rename to libobs/util/windows/obfuscate.c index 0272d69ba..ae19e33d1 100644 --- a/plugins/win-capture/obfuscate.c +++ b/libobs/util/windows/obfuscate.c @@ -30,7 +30,7 @@ static void deobfuscate_str(char *str, uint64_t val) } } -void *get_obfuscated_func(HMODULE module, const char *str, uint64_t val) +void *ms_get_obfuscated_func(HMODULE module, const char *str, uint64_t val) { char new_name[128]; strcpy(new_name, str); diff --git a/plugins/win-capture/obfuscate.h b/libobs/util/windows/obfuscate.h similarity index 58% rename from plugins/win-capture/obfuscate.h rename to libobs/util/windows/obfuscate.h index 5dcffe8de..a1ec865f4 100644 --- a/plugins/win-capture/obfuscate.h +++ b/libobs/util/windows/obfuscate.h @@ -1,6 +1,7 @@ #pragma once -#include +#include "../c99defs.h" +#include #ifdef __cplusplus extern "C" { @@ -8,7 +9,8 @@ extern "C" { /* this is a workaround to A/Vs going crazy whenever certain functions (such as * OpenProcess) are used */ -extern void *get_obfuscated_func(HMODULE module, const char *str, uint64_t val); +EXPORT void *ms_get_obfuscated_func(HMODULE module, const char *str, + uint64_t val); #ifdef __cplusplus } diff --git a/plugins/win-capture/window-helpers.c b/libobs/util/windows/window-helpers.c similarity index 81% rename from plugins/win-capture/window-helpers.c rename to libobs/util/windows/window-helpers.c index f5abb97fa..3d66cec57 100644 --- a/plugins/win-capture/window-helpers.c +++ b/libobs/util/windows/window-helpers.c @@ -1,11 +1,10 @@ -#include +#include "window-helpers.h" + #include +#include #include #include -#include -#include "window-helpers.h" -#include "obfuscate.h" static inline void encode_dstr(struct dstr *str) { @@ -22,8 +21,8 @@ static inline char *decode_str(const char *src) return str.array; } -extern void build_window_strings(const char *str, char **class, char **title, - char **exe) +void ms_build_window_strings(const char *str, char **class, char **title, + char **exe) { char **strlist; @@ -46,6 +45,58 @@ extern void build_window_strings(const char *str, char **class, char **title, strlist_free(strlist); } +static void insert_preserved_val(obs_property_t *p, const char *val, size_t idx) +{ + char *window_class = NULL; + char *title = NULL; + char *executable = NULL; + struct dstr desc = {0}; + + ms_build_window_strings(val, &window_class, &title, &executable); + + dstr_printf(&desc, "[%s]: %s", executable, title); + obs_property_list_insert_string(p, idx, desc.array, val); + obs_property_list_item_disable(p, idx, true); + + dstr_free(&desc); + bfree(window_class); + bfree(title); + bfree(executable); +} + +bool ms_check_window_property_setting(obs_properties_t *ppts, obs_property_t *p, + obs_data_t *settings, const char *val, + size_t idx) +{ + const char *cur_val; + bool match = false; + size_t i = 0; + + cur_val = obs_data_get_string(settings, val); + if (!cur_val) { + return false; + } + + for (;;) { + const char *val = obs_property_list_item_string(p, i++); + if (!val) + break; + + if (strcmp(val, cur_val) == 0) { + match = true; + break; + } + } + + if (cur_val && *cur_val && !match) { + insert_preserved_val(p, cur_val, idx); + return true; + } + + UNUSED_PARAMETER(ppts); + return false; +} + static HMODULE kernel32(void) { static HMODULE kernel32_handle = NULL; @@ -60,13 +111,13 @@ static inline HANDLE open_process(DWORD desired_access, bool inherit_handle, typedef HANDLE(WINAPI * PFN_OpenProcess)(DWORD, BOOL, DWORD); static PFN_OpenProcess open_process_proc = NULL; if (!open_process_proc) - open_process_proc = (PFN_OpenProcess)get_obfuscated_func( + open_process_proc = (PFN_OpenProcess)ms_get_obfuscated_func( kernel32(), "B}caZyah`~q", 0x2D5BEBAF6DDULL); return open_process_proc(desired_access, inherit_handle, process_id); } -bool get_window_exe(struct dstr *name, HWND window) +bool ms_get_window_exe(struct dstr *name, HWND window) { wchar_t wname[MAX_PATH]; struct dstr temp = {0}; @@ -103,7 +154,7 @@ fail: return true; } -void get_window_title(struct dstr *name, HWND hwnd) +void ms_get_window_title(struct dstr *name, HWND hwnd) { int len; @@ -130,7 +181,7 @@ void get_window_title(struct dstr *name, HWND hwnd) } } -void get_window_class(struct dstr *class, HWND hwnd) +void ms_get_window_class(struct dstr *class, HWND hwnd) { wchar_t temp[256]; @@ -192,21 +243,21 @@ static void add_window(obs_property_t *p, HWND hwnd, add_window_cb callback) struct dstr encoded = {0}; struct dstr desc = {0}; - if (!get_window_exe(&exe, hwnd)) + if (!ms_get_window_exe(&exe, hwnd)) return; if (is_microsoft_internal_window_exe(exe.array)) { dstr_free(&exe); return; } - get_window_title(&title, hwnd); + ms_get_window_title(&title, hwnd); if (dstr_cmp(&exe, "explorer.exe") == 0 && dstr_is_empty(&title)) { dstr_free(&exe); dstr_free(&title); return; } - get_window_class(&class, hwnd); + ms_get_window_class(&class, hwnd); if (callback && !callback(title.array, class.array, exe.array)) { dstr_free(&title); @@ -268,7 +319,7 @@ static bool check_window_valid(HWND window, enum window_search_mode mode) return true; } -bool is_uwp_window(HWND hwnd) +bool ms_is_uwp_window(HWND hwnd) { wchar_t name[256]; @@ -279,7 +330,7 @@ bool is_uwp_window(HWND hwnd) return wcscmp(name, L"ApplicationFrameWindow") == 0; } -HWND get_uwp_actual_window(HWND parent) +HWND ms_get_uwp_actual_window(HWND parent) { DWORD parent_id = 0; HWND child; @@ -319,8 +370,8 @@ static HWND next_window(HWND window, enum window_search_mode mode, HWND *parent, break; } - if (is_uwp_window(window)) { - HWND child = get_uwp_actual_window(window); + if (ms_is_uwp_window(window)) { + HWND child = ms_get_uwp_actual_window(window); if (child) { *parent = window; return child; @@ -357,8 +408,8 @@ static HWND first_window(enum window_search_mode mode, HWND *parent, } } - if (is_uwp_window(window)) { - HWND child = get_uwp_actual_window(window); + if (ms_is_uwp_window(window)) { + HWND child = ms_get_uwp_actual_window(window); if (child) { *parent = window; return child; @@ -368,8 +419,8 @@ static HWND first_window(enum window_search_mode mode, HWND *parent, return window; } -void fill_window_list(obs_property_t *p, enum window_search_mode mode, - add_window_cb callback) +void ms_fill_window_list(obs_property_t *p, enum window_search_mode mode, + add_window_cb callback) { HWND parent; bool use_findwindowex = false; @@ -391,10 +442,10 @@ static int window_rating(HWND window, enum window_priority priority, struct dstr cur_exe = {0}; int val = 0x7FFFFFFF; - if (!get_window_exe(&cur_exe, window)) + if (!ms_get_window_exe(&cur_exe, window)) return 0x7FFFFFFF; - get_window_title(&cur_title, window); - get_window_class(&cur_class, window); + ms_get_window_title(&cur_title, window); + ms_get_window_class(&cur_class, window); bool class_matches = dstr_cmpi(&cur_class, class) == 0; bool exe_matches = dstr_cmpi(&cur_exe, exe) == 0; @@ -457,8 +508,8 @@ static bool is_generic_class(const char *current_class) return false; } -HWND find_window(enum window_search_mode mode, enum window_priority priority, - const char *class, const char *title, const char *exe) +HWND ms_find_window(enum window_search_mode mode, enum window_priority priority, + const char *class, const char *title, const char *exe) { HWND parent; bool use_findwindowex = false; @@ -520,9 +571,9 @@ BOOL CALLBACK enum_windows_proc(HWND window, LPARAM lParam) return rating > 0; } -HWND find_window_top_level(enum window_search_mode mode, - enum window_priority priority, const char *class, - const char *title, const char *exe) +HWND ms_find_window_top_level(enum window_search_mode mode, + enum window_priority priority, const char *class, + const char *title, const char *exe) { if (!class) return NULL; diff --git a/libobs/util/windows/window-helpers.h b/libobs/util/windows/window-helpers.h new file mode 100644 index 000000000..1349981b3 --- /dev/null +++ b/libobs/util/windows/window-helpers.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum window_priority { + WINDOW_PRIORITY_CLASS, + WINDOW_PRIORITY_TITLE, + WINDOW_PRIORITY_EXE, +}; + +enum window_search_mode { + INCLUDE_MINIMIZED, + EXCLUDE_MINIMIZED, +}; + +EXPORT bool ms_get_window_exe(struct dstr *name, HWND window); +EXPORT void ms_get_window_title(struct dstr *name, HWND hwnd); +EXPORT void ms_get_window_class(struct dstr *window_class, HWND hwnd); +EXPORT bool ms_is_uwp_window(HWND hwnd); +EXPORT HWND ms_get_uwp_actual_window(HWND parent); + +typedef bool (*add_window_cb)(const char *title, const char *window_class, + const char *exe); + +EXPORT void ms_fill_window_list(obs_property_t *p, enum window_search_mode mode, + add_window_cb callback); + +EXPORT void ms_build_window_strings(const char *str, char **window_class, + char **title, char **exe); + +EXPORT bool ms_check_window_property_setting(obs_properties_t *ppts, + obs_property_t *p, + obs_data_t *settings, + const char *val, size_t idx); + +EXPORT void ms_build_window_strings(const char *str, char **window_class, + char **title, char **exe); + +EXPORT HWND ms_find_window(enum window_search_mode mode, + enum window_priority priority, + const char *window_class, const char *title, + const char *exe); +EXPORT HWND ms_find_window_top_level(enum window_search_mode mode, + enum window_priority priority, + const char *window_class, + const char *title, const char *exe); + +#ifdef __cplusplus +} +#endif diff --git a/plugins/win-capture/CMakeLists.txt b/plugins/win-capture/CMakeLists.txt index 276ec562e..8918c369f 100644 --- a/plugins/win-capture/CMakeLists.txt +++ b/plugins/win-capture/CMakeLists.txt @@ -24,13 +24,9 @@ target_sources( monitor-capture.c nt-stuff.c nt-stuff.h - obfuscate.c - obfuscate.h - window-capture.c - window-helpers.c - window-helpers.h) + window-capture.c) -target_link_libraries(win-capture PRIVATE OBS::libobs OBS::ipc-util Dwmapi) +target_link_libraries(win-capture PRIVATE OBS::libobs OBS::ipc-util) set_target_properties(win-capture PROPERTIES FOLDER "plugins/win-capture") diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index c984d57b7..475cc7656 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -1,18 +1,19 @@ #include #include #include +#include #include #include +#include #include #include #include #include #include -#include "obfuscate.h" +#include #include "inject-library.h" #include "graphics-hook-info.h" #include "graphics-hook-ver.h" -#include "window-helpers.h" #include "cursor-capture.h" #include "app-helpers.h" #include "nt-stuff.h" @@ -297,7 +298,7 @@ static inline HANDLE open_process(DWORD desired_access, bool inherit_handle, typedef HANDLE(WINAPI * PFN_OpenProcess)(DWORD, BOOL, DWORD); static PFN_OpenProcess open_process_proc = NULL; if (!open_process_proc) - open_process_proc = (PFN_OpenProcess)get_obfuscated_func( + open_process_proc = (PFN_OpenProcess)ms_get_obfuscated_func( kernel32(), "NuagUykjcxr", 0x1B694B59451ULL); return open_process_proc(desired_access, inherit_handle, process_id); @@ -411,8 +412,8 @@ static inline void get_config(struct game_capture_config *cfg, { const char *mode_str = NULL; - build_window_strings(window, &cfg->class, &cfg->title, - &cfg->executable); + ms_build_window_strings(window, &cfg->class, &cfg->title, + &cfg->executable); if (using_older_non_mode_format(settings)) { bool any = obs_data_get_bool(settings, SETTING_ANY_FULLSCREEN); @@ -1021,12 +1022,12 @@ static bool init_hook(struct game_capture *gc) bool blacklisted_process = false; if (gc->config.mode == CAPTURE_MODE_ANY) { - if (get_window_exe(&exe, gc->next_window)) { + if (ms_get_window_exe(&exe, gc->next_window)) { info("attempting to hook fullscreen process: %s", exe.array); } } else { - if (get_window_exe(&exe, gc->next_window)) { + if (ms_get_window_exe(&exe, gc->next_window)) { info("attempting to hook process: %s", exe.array); } } @@ -1166,9 +1167,9 @@ static void get_selected_window(struct game_capture *gc) os_utf8_to_wcs(gc->class.array, 0, class_w, 512); window = FindWindowW(class_w, NULL); } else { - window = find_window(INCLUDE_MINIMIZED, gc->priority, - gc->class.array, gc->title.array, - gc->executable.array); + window = ms_find_window(INCLUDE_MINIMIZED, gc->priority, + gc->class.array, gc->title.array, + gc->executable.array); } if (window) { @@ -1780,12 +1781,12 @@ static void game_capture_tick(void *data, float seconds) HWND hwnd = (HWND)(uintptr_t)os_atomic_load_long( &gc->hotkey_window); - if (is_uwp_window(hwnd)) - hwnd = get_uwp_actual_window(hwnd); + if (ms_is_uwp_window(hwnd)) + hwnd = ms_get_uwp_actual_window(hwnd); - if (get_window_exe(&gc->executable, hwnd)) { - get_window_title(&gc->title, hwnd); - get_window_class(&gc->class, hwnd); + if (ms_get_window_exe(&gc->executable, hwnd)) { + ms_get_window_title(&gc->title, hwnd); + ms_get_window_class(&gc->class, hwnd); gc->priority = WINDOW_PRIORITY_CLASS; gc->retry_time = 10.0f * hook_rate_to_float( @@ -2247,63 +2248,11 @@ static bool mode_callback(obs_properties_t *ppts, obs_property_t *p, return true; } -static void insert_preserved_val(obs_property_t *p, const char *val, size_t idx) -{ - char *class = NULL; - char *title = NULL; - char *executable = NULL; - struct dstr desc = {0}; - - build_window_strings(val, &class, &title, &executable); - - dstr_printf(&desc, "[%s]: %s", executable, title); - obs_property_list_insert_string(p, idx, desc.array, val); - obs_property_list_item_disable(p, idx, true); - - dstr_free(&desc); - bfree(class); - bfree(title); - bfree(executable); -} - -bool check_window_property_setting(obs_properties_t *ppts, obs_property_t *p, - obs_data_t *settings, const char *val, - size_t idx) -{ - const char *cur_val; - bool match = false; - size_t i = 0; - - cur_val = obs_data_get_string(settings, val); - if (!cur_val) { - return false; - } - - for (;;) { - const char *val = obs_property_list_item_string(p, i++); - if (!val) - break; - - if (strcmp(val, cur_val) == 0) { - match = true; - break; - } - } - - if (cur_val && *cur_val && !match) { - insert_preserved_val(p, cur_val, idx); - return true; - } - - UNUSED_PARAMETER(ppts); - return false; -} - static bool window_changed_callback(obs_properties_t *ppts, obs_property_t *p, obs_data_t *settings) { - return check_window_property_setting(ppts, p, settings, - SETTING_CAPTURE_WINDOW, 1); + return ms_check_window_property_setting(ppts, p, settings, + SETTING_CAPTURE_WINDOW, 1); } static BOOL CALLBACK EnumFirstMonitor(HMONITOR monitor, HDC hdc, LPRECT rc, @@ -2377,7 +2326,7 @@ static obs_properties_t *game_capture_properties(void *data) OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, "", ""); - fill_window_list(p, INCLUDE_MINIMIZED, window_not_blacklisted); + ms_fill_window_list(p, INCLUDE_MINIMIZED, window_not_blacklisted); obs_property_set_modified_callback(p, window_changed_callback); diff --git a/plugins/win-capture/graphics-hook/CMakeLists.txt b/plugins/win-capture/graphics-hook/CMakeLists.txt index 0e37aa4f1..10cf8762a 100644 --- a/plugins/win-capture/graphics-hook/CMakeLists.txt +++ b/plugins/win-capture/graphics-hook/CMakeLists.txt @@ -19,8 +19,8 @@ target_sources( d3d10-capture.cpp d3d11-capture.cpp d3d12-capture.cpp - ../obfuscate.c - ../obfuscate.h + ../../../libobs/util/windows/obfuscate.c + ../../../libobs/util/windows/obfuscate.h ../graphics-hook-ver.h ../graphics-hook-info.h ../hook-helpers.h diff --git a/plugins/win-capture/graphics-hook/graphics-hook.c b/plugins/win-capture/graphics-hook/graphics-hook.c index c123db186..977a6f4de 100644 --- a/plugins/win-capture/graphics-hook/graphics-hook.c +++ b/plugins/win-capture/graphics-hook/graphics-hook.c @@ -3,7 +3,7 @@ #include #include "graphics-hook.h" #include "../graphics-hook-ver.h" -#include "../obfuscate.h" +#include "../../libobs/util/windows/obfuscate.h" #define DEBUG_OUTPUT @@ -931,7 +931,7 @@ __declspec(dllexport) LRESULT CALLBACK HMODULE user32 = GetModuleHandleW(L"USER32"); BOOL(WINAPI * unhook_windows_hook_ex)(HHOOK) = NULL; - unhook_windows_hook_ex = get_obfuscated_func( + unhook_windows_hook_ex = ms_get_obfuscated_func( user32, "VojeleY`bdgxvM`hhDz", 0x7F55F80C9EE3A213ULL); if (unhook_windows_hook_ex) diff --git a/plugins/win-capture/inject-helper/CMakeLists.txt b/plugins/win-capture/inject-helper/CMakeLists.txt index aa877fff8..5094260f9 100644 --- a/plugins/win-capture/inject-helper/CMakeLists.txt +++ b/plugins/win-capture/inject-helper/CMakeLists.txt @@ -3,8 +3,10 @@ project(inject-helper) add_executable(inject-helper) target_sources( - inject-helper PRIVATE inject-helper.c ../inject-library.c ../inject-library.h - ../obfuscate.c ../obfuscate.h) + inject-helper + PRIVATE inject-helper.c ../inject-library.c ../inject-library.h + ../../../libobs/util/windows/obfuscate.c + ../../../libobs/util/windows/obfuscate.h) target_include_directories(inject-helper PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) diff --git a/plugins/win-capture/inject-helper/inject-helper.c b/plugins/win-capture/inject-helper/inject-helper.c index 396dbe2d5..4026536e7 100644 --- a/plugins/win-capture/inject-helper/inject-helper.c +++ b/plugins/win-capture/inject-helper/inject-helper.c @@ -4,7 +4,7 @@ #include #include #include -#include "../obfuscate.h" +#include "../../../libobs/util/windows/obfuscate.h" #include "../inject-library.h" #if defined(_MSC_VER) && !defined(inline) @@ -38,9 +38,9 @@ static inline HANDLE open_process(DWORD desired_access, bool inherit_handle, DWORD process_id) { HANDLE(WINAPI * open_process_proc)(DWORD, BOOL, DWORD); - open_process_proc = get_obfuscated_func(GetModuleHandleW(L"KERNEL32"), - "HxjcQrmkb|~", - 0xc82efdf78201df87); + open_process_proc = + ms_get_obfuscated_func(GetModuleHandleW(L"KERNEL32"), + "HxjcQrmkb|~", 0xc82efdf78201df87); return open_process_proc(desired_access, inherit_handle, process_id); } diff --git a/plugins/win-capture/inject-library.c b/plugins/win-capture/inject-library.c index d35e774ad..f1226c9f7 100644 --- a/plugins/win-capture/inject-library.c +++ b/plugins/win-capture/inject-library.c @@ -1,6 +1,6 @@ #include #include -#include "obfuscate.h" +#include "../../libobs/util/windows/obfuscate.h" #include "inject-library.h" typedef HANDLE(WINAPI *create_remote_thread_t)(HANDLE, LPSECURITY_ATTRIBUTES, @@ -37,16 +37,16 @@ int inject_library_obf(HANDLE process, const wchar_t *dll, virtual_free_ex_t virtual_free_ex; FARPROC load_library_w; - create_remote_thread = (create_remote_thread_t)get_obfuscated_func( + create_remote_thread = (create_remote_thread_t)ms_get_obfuscated_func( kernel32, create_remote_thread_obf, obf1); - write_process_memory = (write_process_memory_t)get_obfuscated_func( + write_process_memory = (write_process_memory_t)ms_get_obfuscated_func( kernel32, write_process_memory_obf, obf2); - virtual_alloc_ex = (virtual_alloc_ex_t)get_obfuscated_func( + virtual_alloc_ex = (virtual_alloc_ex_t)ms_get_obfuscated_func( kernel32, virtual_alloc_ex_obf, obf3); - virtual_free_ex = (virtual_free_ex_t)get_obfuscated_func( + virtual_free_ex = (virtual_free_ex_t)ms_get_obfuscated_func( kernel32, virtual_free_ex_obf, obf4); - load_library_w = (FARPROC)get_obfuscated_func(kernel32, - load_library_w_obf, obf5); + load_library_w = (FARPROC)ms_get_obfuscated_func( + kernel32, load_library_w_obf, obf5); /* -------------------------------- */ @@ -126,7 +126,7 @@ int inject_library_safe_obf(DWORD thread_id, const wchar_t *dll, return INJECT_ERROR_UNLIKELY_FAIL; } - set_windows_hook_ex = (set_windows_hook_ex_t)get_obfuscated_func( + set_windows_hook_ex = (set_windows_hook_ex_t)ms_get_obfuscated_func( user32, set_windows_hook_ex_obf, obf1); hook = set_windows_hook_ex(WH_GETMESSAGE, proc, lib, thread_id); diff --git a/plugins/win-capture/window-capture.c b/plugins/win-capture/window-capture.c index 1ca02648a..84808bdae 100644 --- a/plugins/win-capture/window-capture.c +++ b/plugins/win-capture/window-capture.c @@ -1,8 +1,8 @@ #include #include #include +#include #include "dc-capture.h" -#include "window-helpers.h" #include "../../libobs/util/platform.h" #include "../../libobs-winrt/winrt-capture.h" @@ -198,7 +198,8 @@ static void update_settings(struct window_capture *wc, obs_data_t *s) bfree(wc->class); bfree(wc->executable); - build_window_strings(window, &wc->class, &wc->title, &wc->executable); + ms_build_window_strings(window, &wc->class, &wc->title, + &wc->executable); wc->method = choose_method(method, wgc_supported, wc->class); wc->priority = (enum window_priority)priority; @@ -414,11 +415,6 @@ static bool wc_capture_method_changed(obs_properties_t *props, return true; } -extern bool check_window_property_setting(obs_properties_t *ppts, - obs_property_t *p, - obs_data_t *settings, const char *val, - size_t idx); - static bool wc_window_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { @@ -430,7 +426,7 @@ static bool wc_window_changed(obs_properties_t *props, obs_property_t *p, update_settings_visibility(props, wc); - check_window_property_setting(props, p, settings, "window", 0); + ms_check_window_property_setting(props, p, settings, "window", 0); return true; } @@ -446,7 +442,7 @@ static obs_properties_t *wc_properties(void *data) p = obs_properties_add_list(ppts, "window", TEXT_WINDOW, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - fill_window_list(p, EXCLUDE_MINIMIZED, NULL); + ms_fill_window_list(p, EXCLUDE_MINIMIZED, NULL); obs_property_set_modified_callback(p, wc_window_changed); p = obs_properties_add_list(ppts, "method", TEXT_METHOD, @@ -515,15 +511,15 @@ static void wc_tick(void *data, float seconds) wc->check_window_timer = 0.0f; - wc->window = (wc->method == METHOD_WGC) - ? find_window_top_level(INCLUDE_MINIMIZED, - wc->priority, - wc->class, - wc->title, - wc->executable) - : find_window(INCLUDE_MINIMIZED, - wc->priority, wc->class, - wc->title, wc->executable); + wc->window = + (wc->method == METHOD_WGC) + ? ms_find_window_top_level(INCLUDE_MINIMIZED, + wc->priority, + wc->class, wc->title, + wc->executable) + : ms_find_window(INCLUDE_MINIMIZED, + wc->priority, wc->class, + wc->title, wc->executable); if (!wc->window) { if (wc->capture.valid) dc_capture_free(&wc->capture); diff --git a/plugins/win-capture/window-helpers.h b/plugins/win-capture/window-helpers.h deleted file mode 100644 index 1537b57a3..000000000 --- a/plugins/win-capture/window-helpers.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include - -enum window_priority { - WINDOW_PRIORITY_CLASS, - WINDOW_PRIORITY_TITLE, - WINDOW_PRIORITY_EXE, -}; - -enum window_search_mode { - INCLUDE_MINIMIZED, - EXCLUDE_MINIMIZED, -}; - -extern bool get_window_exe(struct dstr *name, HWND window); -extern void get_window_title(struct dstr *name, HWND hwnd); -extern void get_window_class(struct dstr *class, HWND hwnd); -extern bool is_uwp_window(HWND hwnd); -extern HWND get_uwp_actual_window(HWND parent); - -typedef bool (*add_window_cb)(const char *title, const char *class, - const char *exe); - -extern void fill_window_list(obs_property_t *p, enum window_search_mode mode, - add_window_cb callback); - -extern void build_window_strings(const char *str, char **class, char **title, - char **exe); - -extern HWND find_window(enum window_search_mode mode, - enum window_priority priority, const char *class, - const char *title, const char *exe); -extern HWND find_window_top_level(enum window_search_mode mode, - enum window_priority priority, - const char *class, const char *title, - const char *exe);