libobs, win-capture: Share window helper code
Add "ms_" prefix as makeshift namespace.
This commit is contained in:
parent
9b46795d57
commit
69ff026647
@ -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)
|
||||
|
@ -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);
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../c99defs.h"
|
||||
#include <Windows.h>
|
||||
|
||||
#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
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
#include <obs.h>
|
||||
#include "window-helpers.h"
|
||||
|
||||
#include <util/dstr.h>
|
||||
#include <util/windows/obfuscate.h>
|
||||
|
||||
#include <dwmapi.h>
|
||||
#include <psapi.h>
|
||||
#include <windows.h>
|
||||
#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;
|
56
libobs/util/windows/window-helpers.h
Normal file
56
libobs/util/windows/window-helpers.h
Normal file
@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <obs-properties.h>
|
||||
#include <util/c99defs.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#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
|
@ -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")
|
||||
|
||||
|
@ -1,18 +1,19 @@
|
||||
#include <inttypes.h>
|
||||
#include <obs-module.h>
|
||||
#include <obs-hotkey.h>
|
||||
#include <util/dstr.h>
|
||||
#include <util/platform.h>
|
||||
#include <util/threading.h>
|
||||
#include <util/windows/window-helpers.h>
|
||||
#include <windows.h>
|
||||
#include <dxgi.h>
|
||||
#include <util/sse-intrin.h>
|
||||
#include <util/util_uint64.h>
|
||||
#include <ipc-util/pipe.h>
|
||||
#include "obfuscate.h"
|
||||
#include <util/windows/obfuscate.h>
|
||||
#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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <inttypes.h>
|
||||
#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)
|
||||
|
@ -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}/..)
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#include <stdbool.h>
|
||||
#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);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <windows.h>
|
||||
#include <stdbool.h>
|
||||
#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);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <util/dstr.h>
|
||||
#include <util/threading.h>
|
||||
#include <util/windows/window-helpers.h>
|
||||
#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);
|
||||
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <util/dstr.h>
|
||||
|
||||
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);
|
Loading…
x
Reference in New Issue
Block a user