Compare commits
5 Commits
f4e6a714a4
...
3c1fc7f53d
Author | SHA1 | Date |
---|---|---|
Mr_Goldberg | 3c1fc7f53d | |
Mr_Goldberg | 077e532bd2 | |
Mr_Goldberg | bc4262a494 | |
Mr_Goldberg | 276a9902df | |
Mr_Goldberg | f01bb145b0 |
|
@ -59,7 +59,7 @@ build_windows:
|
||||||
image: fedora:35
|
image: fedora:35
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- dnf -y install wine wget p7zip sed dos2unix
|
- dnf -y install wine wget p7zip sed dos2unix python
|
||||||
- unix2dos *.txt
|
- unix2dos *.txt
|
||||||
- unix2dos files_example/*.txt files_example/*/*.txt
|
- unix2dos files_example/*.txt files_example/*/*.txt
|
||||||
- sed -i 's/..\\vcpkg\\installed\\/.\\protobuf_/g' build_set_protobuf_directories.bat
|
- sed -i 's/..\\vcpkg\\installed\\/.\\protobuf_/g' build_set_protobuf_directories.bat
|
||||||
|
@ -69,27 +69,9 @@ build_windows:
|
||||||
- 7za x protobuf_x86-windows-static.7z -oprotobuf_x86-windows-static
|
- 7za x protobuf_x86-windows-static.7z -oprotobuf_x86-windows-static
|
||||||
- 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static
|
- 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static
|
||||||
- 7za x sdk_standalone.7z -osdk_standalone
|
- 7za x sdk_standalone.7z -osdk_standalone
|
||||||
- DLL_FILES="$(ls dll/*.cpp | tr "\n" " ")"; sed "s|dll/\*.cpp|$DLL_FILES|g" -i *.bat
|
- python generate_build_win_bat.py
|
||||||
- DLL_FILES="$(ls detours/*.cpp | tr "\n" " ")"; sed "s|detours/\*.cpp|$DLL_FILES|g" -i *.bat
|
|
||||||
- DLL_FILES="$(ls overlay_experimental/*.cpp | tr "\n" " ")"; sed "s|overlay_experimental/\*.cpp|$DLL_FILES|g" -i *.bat
|
|
||||||
- DLL_FILES="$(ls overlay_experimental/windows/*.cpp | tr "\n" " ")"; sed "s|overlay_experimental/windows/\*.cpp|$DLL_FILES|g" -i *.bat
|
|
||||||
- DLL_FILES="$(ls ImGui/*.cpp | tr "\n" " ")"; sed "s|ImGui/\*.cpp|$DLL_FILES|g" -i *.bat
|
|
||||||
- DLL_FILES="$(ls ImGui/backends/imgui_impl_dx*.cpp | tr "\n" " ")"; sed "s|ImGui/backends/imgui_impl_dx\*.cpp|$DLL_FILES|g" -i *.bat
|
|
||||||
- DLL_FILES="$(ls overlay_experimental/System/*.cpp | tr "\n" " ")"; sed "s|overlay_experimental/System/\*.cpp|$DLL_FILES|g" -i *.bat
|
|
||||||
- DLL_FILES="$(ls dll/*.proto | tr "\n" " " | sed "s/.proto/.pb.cc/g")"; sed "s|dll/\*.cc|$DLL_FILES|g" -i *.bat
|
|
||||||
- DLL_FILES="$(ls steamclient_loader/*.cpp | tr "\n" " ")"; sed "s|steamclient_loader/\*.cpp|$DLL_FILES|g" -i *.bat
|
|
||||||
- sed "s| /MP12 | /MP4 |g" -i *.bat
|
|
||||||
- export WINEDEBUG=-all
|
- export WINEDEBUG=-all
|
||||||
- wine cmd /c build_win_debug_experimental.bat
|
- wine cmd /c build_win_release_test.bat
|
||||||
- mkdir debug_experimental
|
|
||||||
- mv steam_api.dll steam_api64.dll debug_experimental/
|
|
||||||
- wine cmd /c build_win_release.bat
|
|
||||||
- mv debug_experimental release/
|
|
||||||
- rm -f steamclient.dll steamclient64.dll
|
|
||||||
- wine cmd /c build_win_debug_experimental_steamclient.bat
|
|
||||||
- mkdir release/debug_experimental_steamclient
|
|
||||||
- mv steamclient.dll steamclient64.dll release/debug_experimental_steamclient/
|
|
||||||
- cp Readme_debug.txt release/debug_experimental/Readme.txt
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- release/
|
- release/
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
def files_from_dir(dir, extension, filter=[]):
|
||||||
|
out = []
|
||||||
|
for f in os.listdir(dir):
|
||||||
|
if f.endswith(extension) and f not in filter:
|
||||||
|
out.append(os.path.join(dir, f))
|
||||||
|
return out
|
||||||
|
|
||||||
|
def convert_to_obj(files, obj_dir):
|
||||||
|
out = []
|
||||||
|
for f in files:
|
||||||
|
out.append(os.path.join(obj_dir, os.path.splitext(os.path.basename(f))[0] + ".obj"))
|
||||||
|
return out
|
||||||
|
|
||||||
|
def cl_line_obj(arguments, out_dir):
|
||||||
|
return "rmdir /S /Q {0}\nmkdir {0}\ncl /Fo:{0}/ /c {1}\n".format(out_dir, ' '.join(arguments))
|
||||||
|
|
||||||
|
def cl_line_link(arguments, linker_arguments):
|
||||||
|
return "cl /LD {} /link {}\n".format(' '.join(arguments), ' '.join(linker_arguments))
|
||||||
|
|
||||||
|
def cl_line_exe(arguments, linker_arguments):
|
||||||
|
return "cl {} /link {}\n".format(' '.join(arguments), ' '.join(linker_arguments))
|
||||||
|
|
||||||
|
jobs = 4
|
||||||
|
normal_build_args = ["/EHsc", "/Ox", "/MP{}".format(jobs)]
|
||||||
|
|
||||||
|
includes = ["ImGui", "overlay_experimental"]
|
||||||
|
includes_32 = list(map(lambda a: '/I{}'.format(a), ["%PROTOBUF_X86_DIRECTORY%\\include\\"] + includes))
|
||||||
|
includes_64 = list(map(lambda a: '/I{}'.format(a), ["%PROTOBUF_X64_DIRECTORY%\\include\\"] + includes))
|
||||||
|
|
||||||
|
debug_build_args = []
|
||||||
|
release_build_args = ["/DEMU_RELEASE_BUILD", "/DNDEBUG"]
|
||||||
|
steamclient_build_args = ["/DSTEAMCLIENT_DLL"]
|
||||||
|
|
||||||
|
experimental_build_args = ["/DEMU_EXPERIMENTAL_BUILD", "/DCONTROLLER_SUPPORT", "/DEMU_OVERLAY"]
|
||||||
|
steamclient_experimental_build_args = experimental_build_args + steamclient_build_args
|
||||||
|
|
||||||
|
normal_linker_libs = ["Iphlpapi.lib", "Ws2_32.lib", "rtlgenrandom.lib", "Shell32.lib"]
|
||||||
|
experimental_linker_libs = ["opengl32.lib", "Winmm.lib"] + normal_linker_libs
|
||||||
|
linker_32 = ['"%PROTOBUF_X86_LIBRARY%"']
|
||||||
|
linker_64 = ['"%PROTOBUF_X64_LIBRARY%"']
|
||||||
|
|
||||||
|
controller_deps = ["controller/gamepad.c"]
|
||||||
|
imgui_deps = files_from_dir("ImGui", ".cpp") + ["ImGui/backends/imgui_impl_dx9.cpp", "ImGui/backends/imgui_impl_dx10.cpp", "ImGui/backends/imgui_impl_dx11.cpp", "ImGui/backends/imgui_impl_dx12.cpp", "ImGui/backends/imgui_impl_win32.cpp", "ImGui/backends/imgui_impl_vulkan.cpp", "ImGui/backends/imgui_impl_opengl3.cpp", "ImGui/backends/imgui_win_shader_blobs.cpp"]
|
||||||
|
proto_deps = list(map(lambda a: a.replace(".proto", ".pb.cc"), files_from_dir("dll", ".proto")))
|
||||||
|
all_deps = proto_deps + files_from_dir("detours", ".cpp") + controller_deps + imgui_deps + files_from_dir("overlay_experimental/System", ".cpp")
|
||||||
|
|
||||||
|
sc_different_deps = ["flat.cpp", "dll.cpp"]
|
||||||
|
steam_deps = files_from_dir("dll", ".cpp", sc_different_deps)
|
||||||
|
overlay_deps = files_from_dir("overlay_experimental", ".cpp") + files_from_dir("overlay_experimental/windows", ".cpp")
|
||||||
|
experimental_steam_deps = steam_deps + overlay_deps
|
||||||
|
sc_different_deps = list(map(lambda a: "dll/" + a, sc_different_deps))
|
||||||
|
|
||||||
|
regular_files = []
|
||||||
|
|
||||||
|
head = """@echo off
|
||||||
|
cd /d "%~dp0"
|
||||||
|
rmdir /S /Q release
|
||||||
|
mkdir release
|
||||||
|
mkdir release\experimental
|
||||||
|
mkdir release\experimental_steamclient
|
||||||
|
mkdir release\debug_experimental
|
||||||
|
mkdir release\debug_experimental_steamclient
|
||||||
|
call build_set_protobuf_directories.bat
|
||||||
|
"""
|
||||||
|
|
||||||
|
head_32bit = """"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\\net.proto
|
||||||
|
call build_env_x86.bat
|
||||||
|
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
||||||
|
"""
|
||||||
|
|
||||||
|
head_64bit = """"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\\net.proto
|
||||||
|
call build_env_x64.bat
|
||||||
|
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
||||||
|
"""
|
||||||
|
|
||||||
|
footer = """
|
||||||
|
copy Readme_release.txt release\Readme.txt
|
||||||
|
xcopy /s files_example\* release\\
|
||||||
|
copy Readme_experimental.txt release\experimental\Readme.txt
|
||||||
|
copy Readme_debug.txt release\debug_experimental\Readme.txt
|
||||||
|
copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\\
|
||||||
|
call build_win_lobby_connect.bat
|
||||||
|
call build_win_find_interfaces.bat
|
||||||
|
"""
|
||||||
|
|
||||||
|
out = head
|
||||||
|
out += head_32bit
|
||||||
|
|
||||||
|
deps_folder = "deps"
|
||||||
|
sc_deps_folder = "deps_sc"
|
||||||
|
|
||||||
|
def generate_common(include_arch, linker_arch, steam_api_name, steamclient_name):
|
||||||
|
out = ""
|
||||||
|
out += cl_line_obj(normal_build_args + release_build_args + include_arch + all_deps, deps_folder)
|
||||||
|
out += cl_line_link(normal_build_args + release_build_args + include_arch + steam_deps + sc_different_deps + ["deps/net.pb.obj"] + linker_arch + normal_linker_libs, ["/debug:none", "/OUT:release\\{}".format(steam_api_name)])
|
||||||
|
|
||||||
|
debug_full_args = normal_build_args + debug_build_args + experimental_build_args + include_arch
|
||||||
|
out += cl_line_obj(debug_full_args + experimental_steam_deps, sc_deps_folder)
|
||||||
|
|
||||||
|
debug_full_dll_args = debug_full_args + sc_different_deps + convert_to_obj(all_deps, deps_folder) + convert_to_obj(experimental_steam_deps, sc_deps_folder) + linker_arch + experimental_linker_libs
|
||||||
|
out += cl_line_link(debug_full_dll_args, ["/OUT:release\debug_experimental\\{}".format(steam_api_name)])
|
||||||
|
out += cl_line_link(steamclient_build_args + debug_full_dll_args, ["/OUT:release\debug_experimental_steamclient\\{}".format(steamclient_name)])
|
||||||
|
|
||||||
|
release_full_args = normal_build_args + release_build_args + experimental_build_args + include_arch
|
||||||
|
out += cl_line_obj(release_full_args + experimental_steam_deps, sc_deps_folder)
|
||||||
|
|
||||||
|
release_full_dll_args = release_full_args + sc_different_deps + convert_to_obj(all_deps, deps_folder) + convert_to_obj(experimental_steam_deps, sc_deps_folder) + linker_arch + experimental_linker_libs
|
||||||
|
out += cl_line_link(release_full_dll_args, ["/debug:none", "/OUT:release\experimental\\{}".format(steam_api_name)])
|
||||||
|
out += cl_line_link(steamclient_build_args + release_full_dll_args, ["/debug:none", "/OUT:release\experimental_steamclient\\{}".format(steamclient_name)])
|
||||||
|
out += cl_line_link(release_build_args + experimental_build_args + ["steamclient.cpp"] + normal_build_args, ["/debug:none", "/OUT:release\experimental\\{}".format(steamclient_name)])
|
||||||
|
return out
|
||||||
|
|
||||||
|
out += generate_common(includes_32, linker_32, "steam_api.dll", "steamclient.dll")
|
||||||
|
|
||||||
|
out += cl_line_exe(files_from_dir("steamclient_loader", ".cpp") + ["advapi32.lib", "user32.lib"] + normal_build_args, ["/debug:none", "/OUT:release\experimental_steamclient\steamclient_loader.exe"])
|
||||||
|
|
||||||
|
out += head_64bit
|
||||||
|
out += generate_common(includes_64, linker_64, "steam_api64.dll", "steamclient64.dll")
|
||||||
|
|
||||||
|
|
||||||
|
out += footer
|
||||||
|
|
||||||
|
|
||||||
|
with open("build_win_release_test.bat", "w") as f:
|
||||||
|
f.write(out)
|
|
@ -68,6 +68,15 @@ public:
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void deleteInst()
|
||||||
|
{
|
||||||
|
if (instance != nullptr)
|
||||||
|
{
|
||||||
|
delete instance;
|
||||||
|
instance = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
~Renderer_Detector()
|
~Renderer_Detector()
|
||||||
{
|
{
|
||||||
delete dx9_hook;
|
delete dx9_hook;
|
||||||
|
@ -95,7 +104,8 @@ private:
|
||||||
dx12_hook(nullptr),
|
dx12_hook(nullptr),
|
||||||
opengl_hook(nullptr),
|
opengl_hook(nullptr),
|
||||||
vulkan_hook(nullptr),
|
vulkan_hook(nullptr),
|
||||||
detection_done(false)
|
detection_done(false),
|
||||||
|
force_done(false)
|
||||||
{
|
{
|
||||||
std::wstring tmp(4096, L'\0');
|
std::wstring tmp(4096, L'\0');
|
||||||
tmp.resize(GetSystemDirectoryW(&tmp[0], tmp.size()));
|
tmp.resize(GetSystemDirectoryW(&tmp[0], tmp.size()));
|
||||||
|
@ -142,7 +152,7 @@ private:
|
||||||
OpenGL_Hook* opengl_hook;
|
OpenGL_Hook* opengl_hook;
|
||||||
Vulkan_Hook* vulkan_hook;
|
Vulkan_Hook* vulkan_hook;
|
||||||
|
|
||||||
bool detection_done;
|
bool detection_done, force_done;
|
||||||
std::condition_variable stop_detection_cv;
|
std::condition_variable stop_detection_cv;
|
||||||
std::mutex stop_detection_mutex;
|
std::mutex stop_detection_mutex;
|
||||||
|
|
||||||
|
@ -1043,7 +1053,7 @@ public:
|
||||||
std::lock_guard<std::mutex> lk(renderer_mutex);
|
std::lock_guard<std::mutex> lk(renderer_mutex);
|
||||||
if (detection_done)
|
if (detection_done)
|
||||||
{
|
{
|
||||||
if (renderer_hook != nullptr)
|
if (renderer_hook != nullptr || force_done)
|
||||||
return renderer_hook;
|
return renderer_hook;
|
||||||
|
|
||||||
detection_done = false;
|
detection_done = false;
|
||||||
|
@ -1122,6 +1132,7 @@ public:
|
||||||
{
|
{
|
||||||
System::scoped_lock lk(renderer_mutex, stop_detection_mutex);
|
System::scoped_lock lk(renderer_mutex, stop_detection_mutex);
|
||||||
detection_done = true;
|
detection_done = true;
|
||||||
|
force_done = true;
|
||||||
}
|
}
|
||||||
stop_detection_cv.notify_all();
|
stop_detection_cv.notify_all();
|
||||||
}
|
}
|
||||||
|
@ -1253,7 +1264,7 @@ public:
|
||||||
std::lock_guard<std::mutex> lk(renderer_mutex);
|
std::lock_guard<std::mutex> lk(renderer_mutex);
|
||||||
if (detection_done)
|
if (detection_done)
|
||||||
{
|
{
|
||||||
if (renderer_hook != nullptr)
|
if (renderer_hook != nullptr || force_done)
|
||||||
return renderer_hook;
|
return renderer_hook;
|
||||||
|
|
||||||
detection_done = false;
|
detection_done = false;
|
||||||
|
@ -1305,6 +1316,7 @@ public:
|
||||||
{
|
{
|
||||||
System::scoped_lock lk(renderer_mutex, stop_detection_mutex);
|
System::scoped_lock lk(renderer_mutex, stop_detection_mutex);
|
||||||
detection_done = true;
|
detection_done = true;
|
||||||
|
force_done = true;
|
||||||
}
|
}
|
||||||
stop_detection_cv.notify_all();
|
stop_detection_cv.notify_all();
|
||||||
}
|
}
|
||||||
|
@ -1432,7 +1444,7 @@ public:
|
||||||
std::lock_guard<std::mutex> lk(renderer_mutex);
|
std::lock_guard<std::mutex> lk(renderer_mutex);
|
||||||
if (detection_done)
|
if (detection_done)
|
||||||
{
|
{
|
||||||
if (renderer_hook != nullptr)
|
if (renderer_hook != nullptr || force_done)
|
||||||
return renderer_hook;
|
return renderer_hook;
|
||||||
|
|
||||||
detection_done = false;
|
detection_done = false;
|
||||||
|
@ -1484,6 +1496,7 @@ public:
|
||||||
{
|
{
|
||||||
System::scoped_lock lk(renderer_mutex, stop_detection_mutex);
|
System::scoped_lock lk(renderer_mutex, stop_detection_mutex);
|
||||||
detection_done = true;
|
detection_done = true;
|
||||||
|
force_done = true;
|
||||||
}
|
}
|
||||||
stop_detection_cv.notify_all();
|
stop_detection_cv.notify_all();
|
||||||
}
|
}
|
||||||
|
@ -1505,4 +1518,9 @@ void StopRendererDetection()
|
||||||
Renderer_Detector::Inst()->stop_detection();
|
Renderer_Detector::Inst()->stop_detection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreeRendererDetection()
|
||||||
|
{
|
||||||
|
Renderer_Detector::deleteInst();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,5 +31,5 @@ namespace ingame_overlay {
|
||||||
|
|
||||||
std::future<Renderer_Hook*> DetectRenderer(std::chrono::milliseconds timeout = std::chrono::milliseconds{ -1 });
|
std::future<Renderer_Hook*> DetectRenderer(std::chrono::milliseconds timeout = std::chrono::milliseconds{ -1 });
|
||||||
void StopRendererDetection();
|
void StopRendererDetection();
|
||||||
|
void FreeRendererDetection();
|
||||||
}
|
}
|
|
@ -101,14 +101,25 @@ bool X11_Hook::StartHook(std::function<bool(bool)>& _key_combination_callback, s
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XEventsQueued = libX11.GetSymbol<decltype(::XEventsQueued)>("XEventsQueued");
|
struct {
|
||||||
XPending = libX11.GetSymbol<decltype(::XPending)>("XPending");
|
void** func_ptr;
|
||||||
|
void* hook_ptr;
|
||||||
|
const char* func_name;
|
||||||
|
} hook_array[] = {
|
||||||
|
{ (void**)&XEventsQueued, &X11_Hook::MyXEventsQueued, "XEventsQueued" },
|
||||||
|
{ (void**)&XPending , &X11_Hook::MyXPending , "XPending" },
|
||||||
|
};
|
||||||
|
|
||||||
if (XPending == nullptr || XEventsQueued == nullptr)
|
for (auto& entry : hook_array)
|
||||||
{
|
{
|
||||||
SPDLOG_WARN("Failed to hook X11: Cannot load functions.({}, {})", DLL_NAME, (void*)XEventsQueued, (void*)XPending);
|
*entry.func_ptr = libX11.GetSymbol<void*>(entry.func_name);
|
||||||
return false;
|
if (entry.func_ptr == nullptr)
|
||||||
|
{
|
||||||
|
SPDLOG_ERROR("Failed to hook X11: Event function {} missing.", entry.func_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INFO("Hooked X11");
|
SPDLOG_INFO("Hooked X11");
|
||||||
|
|
||||||
_KeyCombinationCallback = std::move(_key_combination_callback);
|
_KeyCombinationCallback = std::move(_key_combination_callback);
|
||||||
|
@ -124,12 +135,13 @@ bool X11_Hook::StartHook(std::function<bool(bool)>& _key_combination_callback, s
|
||||||
|
|
||||||
_Hooked = true;
|
_Hooked = true;
|
||||||
|
|
||||||
UnhookAll();
|
|
||||||
BeginHook();
|
BeginHook();
|
||||||
HookFuncs(
|
|
||||||
std::make_pair<void**, void*>(&(void*&)XEventsQueued, (void*)&X11_Hook::MyXEventsQueued),
|
for (auto& entry : hook_array)
|
||||||
std::make_pair<void**, void*>(&(void*&)XPending, (void*)&X11_Hook::MyXPending)
|
{
|
||||||
);
|
HookFunc(std::make_pair(entry.func_ptr, entry.hook_ptr));
|
||||||
|
}
|
||||||
|
|
||||||
EndHook();
|
EndHook();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -207,6 +207,7 @@ void Steam_Overlay::UnSetupOverlay()
|
||||||
if (!Ready() && future_renderer.valid()) {
|
if (!Ready() && future_renderer.valid()) {
|
||||||
if (future_renderer.wait_for(std::chrono::milliseconds{500}) == std::future_status::ready) {
|
if (future_renderer.wait_for(std::chrono::milliseconds{500}) == std::future_status::ready) {
|
||||||
future_renderer.get();
|
future_renderer.get();
|
||||||
|
ingame_overlay::FreeRendererDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,24 +93,30 @@ bool Windows_Hook::StartHook(std::function<bool(bool)>& _key_combination_callbac
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetRawInputBuffer = libUser32.GetSymbol<decltype(::GetRawInputBuffer)>("GetRawInputBuffer");
|
struct {
|
||||||
GetRawInputData = libUser32.GetSymbol<decltype(::GetRawInputData)>("GetRawInputData");
|
void** func_ptr;
|
||||||
GetKeyState = libUser32.GetSymbol<decltype(::GetKeyState)>("GetKeyState");
|
void* hook_ptr;
|
||||||
GetAsyncKeyState = libUser32.GetSymbol<decltype(::GetAsyncKeyState)>("GetAsyncKeyState");
|
const char* func_name;
|
||||||
GetKeyboardState = libUser32.GetSymbol<decltype(::GetKeyboardState)>("GetKeyboardState");
|
} hook_array[] = {
|
||||||
GetCursorPos = libUser32.GetSymbol<decltype(::GetCursorPos)>("GetCursorPos");
|
{ (void**)&GetRawInputBuffer, &Windows_Hook::MyGetRawInputBuffer, "GetRawInputBuffer" },
|
||||||
SetCursorPos = libUser32.GetSymbol<decltype(::SetCursorPos)>("SetCursorPos");
|
{ (void**)&GetRawInputData , &Windows_Hook::MyGetRawInputData , "GetRawInputData" },
|
||||||
|
{ (void**)&GetKeyState , &Windows_Hook::MyGetKeyState , "GetKeyState" },
|
||||||
|
{ (void**)&GetAsyncKeyState , &Windows_Hook::MyGetAsyncKeyState , "GetAsyncKeyState" },
|
||||||
|
{ (void**)&GetKeyboardState , &Windows_Hook::MyGetKeyboardState , "GetKeyboardState" },
|
||||||
|
{ (void**)&GetCursorPos , &Windows_Hook::MyGetCursorPos , "GetCursorPos" },
|
||||||
|
{ (void**)&SetCursorPos , &Windows_Hook::MySetCursorPos , "SetCursorPos" },
|
||||||
|
{ (void**)&GetClipCursor , &Windows_Hook::MyGetClipCursor , "GetClipCursor" },
|
||||||
|
{ (void**)&ClipCursor , &Windows_Hook::MyClipCursor , "ClipCursor" },
|
||||||
|
};
|
||||||
|
|
||||||
if(GetRawInputBuffer == nullptr ||
|
for (auto& entry : hook_array)
|
||||||
GetRawInputData == nullptr ||
|
|
||||||
GetKeyState == nullptr ||
|
|
||||||
GetAsyncKeyState == nullptr ||
|
|
||||||
GetKeyboardState == nullptr ||
|
|
||||||
GetCursorPos == nullptr ||
|
|
||||||
SetCursorPos == nullptr)
|
|
||||||
{
|
{
|
||||||
SPDLOG_ERROR("Failed to hook Windows: Events functions missing.");
|
*entry.func_ptr = libUser32.GetSymbol<void*>(entry.func_name);
|
||||||
return false;
|
if (entry.func_ptr == nullptr)
|
||||||
|
{
|
||||||
|
SPDLOG_ERROR("Failed to hook Windows: Events function {} missing.", entry.func_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INFO("Hooked Windows");
|
SPDLOG_INFO("Hooked Windows");
|
||||||
|
@ -126,15 +132,12 @@ bool Windows_Hook::StartHook(std::function<bool(bool)>& _key_combination_callbac
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginHook();
|
BeginHook();
|
||||||
HookFuncs(
|
|
||||||
std::make_pair<void**, void*>(&(PVOID&)GetRawInputBuffer, &Windows_Hook::MyGetRawInputBuffer),
|
for (auto& entry : hook_array)
|
||||||
std::make_pair<void**, void*>(&(PVOID&)GetRawInputData , &Windows_Hook::MyGetRawInputData),
|
{
|
||||||
std::make_pair<void**, void*>(&(PVOID&)GetKeyState , &Windows_Hook::MyGetKeyState),
|
HookFunc(std::make_pair(entry.func_ptr, entry.hook_ptr));
|
||||||
std::make_pair<void**, void*>(&(PVOID&)GetAsyncKeyState , &Windows_Hook::MyGetAsyncKeyState),
|
}
|
||||||
std::make_pair<void**, void*>(&(PVOID&)GetKeyboardState , &Windows_Hook::MyGetKeyboardState),
|
|
||||||
std::make_pair<void**, void*>(&(PVOID&)GetCursorPos , &Windows_Hook::MyGetCursorPos),
|
|
||||||
std::make_pair<void**, void*>(&(PVOID&)SetCursorPos , &Windows_Hook::MySetCursorPos)
|
|
||||||
);
|
|
||||||
EndHook();
|
EndHook();
|
||||||
|
|
||||||
_Hooked = true;
|
_Hooked = true;
|
||||||
|
@ -289,6 +292,11 @@ LRESULT CALLBACK Windows_Hook::HookWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||||
// Save the last known cursor pos when opening the overlay
|
// Save the last known cursor pos when opening the overlay
|
||||||
// so we can spoof the GetCursorPos return value.
|
// so we can spoof the GetCursorPos return value.
|
||||||
inst->GetCursorPos(&inst->_SavedCursorPos);
|
inst->GetCursorPos(&inst->_SavedCursorPos);
|
||||||
|
inst->GetClipCursor(&inst->_SavedClipCursor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inst->ClipCursor(&inst->_SavedClipCursor);
|
||||||
}
|
}
|
||||||
inst->_KeyCombinationPushed = true;
|
inst->_KeyCombinationPushed = true;
|
||||||
}
|
}
|
||||||
|
@ -407,16 +415,33 @@ BOOL WINAPI Windows_Hook::MySetCursorPos(int X, int Y)
|
||||||
{
|
{
|
||||||
Windows_Hook* inst = Windows_Hook::Inst();
|
Windows_Hook* inst = Windows_Hook::Inst();
|
||||||
|
|
||||||
if (inst->_Initialized && inst->_KeyCombinationCallback(false))
|
if (!inst->_Initialized || !inst->_KeyCombinationCallback(false))
|
||||||
{// That way, it will fail only if the real API fails.
|
return inst->SetCursorPos(X, Y);
|
||||||
// Hides error messages on some Unity debug builds.
|
|
||||||
POINT pos;
|
|
||||||
inst->GetCursorPos(&pos);
|
|
||||||
X = pos.x;
|
|
||||||
Y = pos.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return inst->SetCursorPos(X, Y);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Windows_Hook::MyGetClipCursor(RECT* lpRect)
|
||||||
|
{
|
||||||
|
Windows_Hook* inst = Windows_Hook::Inst();
|
||||||
|
if (lpRect == nullptr || !inst->_Initialized || !inst->_KeyCombinationCallback(false))
|
||||||
|
return inst->GetClipCursor(lpRect);
|
||||||
|
|
||||||
|
*lpRect = inst->_SavedClipCursor;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Windows_Hook::MyClipCursor(CONST RECT* lpRect)
|
||||||
|
{
|
||||||
|
Windows_Hook* inst = Windows_Hook::Inst();
|
||||||
|
CONST RECT* v = lpRect == nullptr ? &inst->_DefaultClipCursor : lpRect;
|
||||||
|
|
||||||
|
inst->_SavedClipCursor = *v;
|
||||||
|
|
||||||
|
if (!inst->_Initialized || !inst->_KeyCombinationCallback(false))
|
||||||
|
return inst->ClipCursor(v);
|
||||||
|
|
||||||
|
return inst->ClipCursor(&inst->_DefaultClipCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -427,12 +452,8 @@ Windows_Hook::Windows_Hook() :
|
||||||
_RecurseCallCount(0),
|
_RecurseCallCount(0),
|
||||||
_GameHwnd(nullptr),
|
_GameHwnd(nullptr),
|
||||||
_GameWndProc(nullptr),
|
_GameWndProc(nullptr),
|
||||||
_KeyCombinationPushed(false),
|
_DefaultClipCursor{ LONG(0xFFFF8000), LONG(0xFFFF8000), LONG(0x00007FFF), LONG(0x00007FFF) },
|
||||||
GetRawInputBuffer(nullptr),
|
_KeyCombinationPushed(false)
|
||||||
GetRawInputData(nullptr),
|
|
||||||
GetKeyState(nullptr),
|
|
||||||
GetAsyncKeyState(nullptr),
|
|
||||||
GetKeyboardState(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ private:
|
||||||
HWND _GameHwnd;
|
HWND _GameHwnd;
|
||||||
WNDPROC _GameWndProc;
|
WNDPROC _GameWndProc;
|
||||||
POINT _SavedCursorPos;
|
POINT _SavedCursorPos;
|
||||||
|
RECT _SavedClipCursor;
|
||||||
|
CONST RECT _DefaultClipCursor;
|
||||||
|
|
||||||
// In (bool): Is toggle wanted
|
// In (bool): Is toggle wanted
|
||||||
// Out(bool): Is the overlay visible, if true, inputs will be disabled
|
// Out(bool): Is the overlay visible, if true, inputs will be disabled
|
||||||
|
@ -55,6 +57,8 @@ private:
|
||||||
decltype(::GetKeyboardState) *GetKeyboardState;
|
decltype(::GetKeyboardState) *GetKeyboardState;
|
||||||
decltype(::GetCursorPos) *GetCursorPos;
|
decltype(::GetCursorPos) *GetCursorPos;
|
||||||
decltype(::SetCursorPos) *SetCursorPos;
|
decltype(::SetCursorPos) *SetCursorPos;
|
||||||
|
decltype(::GetClipCursor) *GetClipCursor;
|
||||||
|
decltype(::ClipCursor) *ClipCursor;
|
||||||
|
|
||||||
static LRESULT CALLBACK HookWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK HookWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
static UINT WINAPI MyGetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader);
|
static UINT WINAPI MyGetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader);
|
||||||
|
@ -64,6 +68,8 @@ private:
|
||||||
static BOOL WINAPI MyGetKeyboardState(PBYTE lpKeyState);
|
static BOOL WINAPI MyGetKeyboardState(PBYTE lpKeyState);
|
||||||
static BOOL WINAPI MyGetCursorPos(LPPOINT lpPoint);
|
static BOOL WINAPI MyGetCursorPos(LPPOINT lpPoint);
|
||||||
static BOOL WINAPI MySetCursorPos(int X, int Y);
|
static BOOL WINAPI MySetCursorPos(int X, int Y);
|
||||||
|
static BOOL WINAPI MyGetClipCursor(RECT* lpRect);
|
||||||
|
static BOOL WINAPI MyClipCursor(CONST RECT* lpRect);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string LibraryName;
|
std::string LibraryName;
|
||||||
|
|
|
@ -11,6 +11,7 @@ STAT_TYPE_BITS = '4'
|
||||||
|
|
||||||
def generate_stats_achievements(schema, config_directory):
|
def generate_stats_achievements(schema, config_directory):
|
||||||
schema = vdf.binary_loads(schema)
|
schema = vdf.binary_loads(schema)
|
||||||
|
# print(schema)
|
||||||
achievements_out = []
|
achievements_out = []
|
||||||
stats_out = []
|
stats_out = []
|
||||||
|
|
||||||
|
@ -54,14 +55,19 @@ def generate_stats_achievements(schema, config_directory):
|
||||||
out['default'] = stat['default']
|
out['default'] = stat['default']
|
||||||
|
|
||||||
stats_out += [out]
|
stats_out += [out]
|
||||||
# print(stat_info[s])
|
#print(stat_info[s])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output_ach = json.dumps(achievements_out, indent=4)
|
output_ach = json.dumps(achievements_out, indent=4)
|
||||||
output_stats = ""
|
output_stats = ""
|
||||||
for s in stats_out:
|
for s in stats_out:
|
||||||
output_stats += "{}={}={}\n".format(s['name'], s['type'], s['default'])
|
default_num = 0
|
||||||
|
if (s['type'] == 'int'):
|
||||||
|
default_num = int(s['default'])
|
||||||
|
else:
|
||||||
|
default_num = float(s['default'])
|
||||||
|
output_stats += "{}={}={}\n".format(s['name'], s['type'], default_num)
|
||||||
|
|
||||||
# print(output_ach)
|
# print(output_ach)
|
||||||
# print(output_stats)
|
# print(output_stats)
|
||||||
|
@ -72,7 +78,7 @@ def generate_stats_achievements(schema, config_directory):
|
||||||
with open(os.path.join(config_directory, "achievements.json"), 'w') as f:
|
with open(os.path.join(config_directory, "achievements.json"), 'w') as f:
|
||||||
f.write(output_ach)
|
f.write(output_ach)
|
||||||
|
|
||||||
with open(os.path.join(config_directory, "stats.txt"), 'w') as f:
|
with open(os.path.join(config_directory, "stats.txt"), 'w', encoding='utf-8') as f:
|
||||||
f.write(output_stats)
|
f.write(output_stats)
|
||||||
|
|
||||||
return (achievements_out, stats_out)
|
return (achievements_out, stats_out)
|
||||||
|
|
Loading…
Reference in New Issue