diff --git a/CheatMenu/Hook.cpp b/CheatMenu/Hook.cpp index 30a385a..96b2049 100644 --- a/CheatMenu/Hook.cpp +++ b/CheatMenu/Hook.cpp @@ -30,10 +30,10 @@ HRESULT Hook::Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentat { ImGui_ImplDX9_InvalidateDeviceObjects(); - return oReset9(pDevice, pPresentationParameters); + return oReset(pDevice, pPresentationParameters); } -void Hook::Present(void* ptr) +void Hook::RenderFrame(void* ptr) { if (!ImGui::GetCurrentContext() || Globals::menu_closing) return; @@ -127,21 +127,22 @@ void Hook::Present(void* ptr) io.IniFilename = NULL; io.LogFilename = NULL; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad && ImGuiConfigFlags_NavEnableKeyboard; style.WindowTitleAlign = ImVec2(0.5, 0.5); oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); } } -HRESULT Hook::PresentDx9Handler(IDirect3DDevice9* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion) +HRESULT Hook::Dx9Handler(IDirect3DDevice9* pDevice) { - Present(pDevice); - return oPresent9(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); + RenderFrame(pDevice); + return oEndScene(pDevice); } -HRESULT Hook::PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) +HRESULT Hook::Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) { - Present(pSwapChain); + RenderFrame(pSwapChain); return oPresent11(pSwapChain, SyncInterval, Flags); } @@ -193,15 +194,15 @@ Hook::Hook() if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success) { Globals::renderer = Render_DirectX11; - kiero::bind(8, (void**)&oPresent11, PresentDx11Handler); + kiero::bind(8, (void**)&oPresent11, Dx11Handler); } else { if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success) { Globals::renderer = Render_DirectX9; - kiero::bind(16, (void**)&oReset9, Reset); - kiero::bind(17, (void**)&oPresent9, PresentDx9Handler); + kiero::bind(16, (void**)&oReset, Reset); + kiero::bind(42, (void**)&oEndScene, Dx9Handler); } } } diff --git a/CheatMenu/Hook.h b/CheatMenu/Hook.h index f9abf17..fdd0d30 100644 --- a/CheatMenu/Hook.h +++ b/CheatMenu/Hook.h @@ -1,7 +1,7 @@ #pragma once #include "pch.h" -typedef HRESULT(CALLBACK* f_Present9)(IDirect3DDevice9*, RECT*, RECT*, HWND, RGNDATA*); +typedef HRESULT(CALLBACK* f_EndScene)(IDirect3DDevice9*); typedef HRESULT(CALLBACK* f_Present11)(IDXGISwapChain*, UINT, UINT); typedef HRESULT(CALLBACK* f_Reset)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*); @@ -12,13 +12,13 @@ class Hook private: inline static WNDPROC oWndProc = NULL; inline static f_Present11 oPresent11 = NULL; - inline static f_Present9 oPresent9 = NULL; - inline static f_Reset oReset9 = NULL; + inline static f_EndScene oEndScene = NULL; + inline static f_Reset oReset = NULL; inline static bool mouse_visibility = false; - static void CALLBACK Present(void* ptr); - static HRESULT CALLBACK PresentDx9Handler(IDirect3DDevice9* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion); - static HRESULT CALLBACK PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags); + static void CALLBACK RenderFrame(void* ptr); + static HRESULT CALLBACK Dx9Handler(IDirect3DDevice9* pDevice); + static HRESULT CALLBACK Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags); static HRESULT CALLBACK Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters); static LRESULT CALLBACK WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static void ShowMouse(bool state); diff --git a/CheatMenu/MenuInfo.h b/CheatMenu/MenuInfo.h index 84f99de..bd948c3 100644 --- a/CheatMenu/MenuInfo.h +++ b/CheatMenu/MenuInfo.h @@ -2,5 +2,5 @@ #define MENU_NAME "Cheat Menu" #define MENU_VERSION_NUMBER "2.7" #define MENU_VERSION MENU_VERSION_NUMBER"-beta" -#define BUILD_NUMBER "20210413" +#define BUILD_NUMBER "20210423" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" \ No newline at end of file diff --git a/Depend/Depend.vcxproj b/Depend/Depend.vcxproj index 93e87eb..f1e6750 100644 --- a/Depend/Depend.vcxproj +++ b/Depend/Depend.vcxproj @@ -173,7 +173,7 @@ true Use pch.h - $(PLUGIN_SDK_DIR)\shared\game\;$(PLUGIN_SDK_DIR)\shared\;$(PLUGIN_SDK_DIR)\plugin_sa\game_sa\;$(PLUGIN_SDK_DIR)\plugin_sa\;%(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) MultiThreadedDebug diff --git a/Depend/Release/Depend.Build.CppClean.log b/Depend/Release/Depend.Build.CppClean.log index c754e5d..dacbc01 100644 --- a/Depend/Release/Depend.Build.CppClean.log +++ b/Depend/Release/Depend.Build.CppClean.log @@ -1,25 +1,25 @@ -c:\users\grinch_\source\repos\cheatmenu\depend\release\depend.pdb -c:\users\grinch_\source\repos\cheatmenu\depend\release\kiero.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui_widgets.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui_tables.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui_impl_win32.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui_impl_dx9.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui_impl_dx11.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui_draw.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui_demo.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\imgui.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\main.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\library.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\idaccess.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\zip.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\trampoline.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\hook.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\hde32.obj -c:\users\grinch_\source\repos\cheatmenu\depend\release\buffer.obj -c:\users\grinch_\source\repos\cheatmenu\release\depend.lib -c:\users\grinch_\source\repos\cheatmenu\depend\release\depend.tlog\cl.command.1.tlog -c:\users\grinch_\source\repos\cheatmenu\depend\release\depend.tlog\cl.read.1.tlog -c:\users\grinch_\source\repos\cheatmenu\depend\release\depend.tlog\cl.write.1.tlog -c:\users\grinch_\source\repos\cheatmenu\depend\release\depend.tlog\lib-link.read.1.tlog -c:\users\grinch_\source\repos\cheatmenu\depend\release\depend.tlog\lib-link.write.1.tlog -c:\users\grinch_\source\repos\cheatmenu\depend\release\depend.tlog\lib.command.1.tlog +c:\work\cheat-menu\depend\release\depend.pdb +c:\work\cheat-menu\depend\release\kiero.obj +c:\work\cheat-menu\depend\release\imgui_widgets.obj +c:\work\cheat-menu\depend\release\imgui_tables.obj +c:\work\cheat-menu\depend\release\imgui_impl_win32.obj +c:\work\cheat-menu\depend\release\imgui_impl_dx9.obj +c:\work\cheat-menu\depend\release\imgui_impl_dx11.obj +c:\work\cheat-menu\depend\release\imgui_draw.obj +c:\work\cheat-menu\depend\release\imgui_demo.obj +c:\work\cheat-menu\depend\release\imgui.obj +c:\work\cheat-menu\depend\release\main.obj +c:\work\cheat-menu\depend\release\library.obj +c:\work\cheat-menu\depend\release\idaccess.obj +c:\work\cheat-menu\depend\release\zip.obj +c:\work\cheat-menu\depend\release\trampoline.obj +c:\work\cheat-menu\depend\release\hook.obj +c:\work\cheat-menu\depend\release\hde32.obj +c:\work\cheat-menu\depend\release\buffer.obj +c:\work\cheat-menu\release\depend.lib +c:\work\cheat-menu\depend\release\depend.tlog\cl.command.1.tlog +c:\work\cheat-menu\depend\release\depend.tlog\cl.read.1.tlog +c:\work\cheat-menu\depend\release\depend.tlog\cl.write.1.tlog +c:\work\cheat-menu\depend\release\depend.tlog\lib-link.read.1.tlog +c:\work\cheat-menu\depend\release\depend.tlog\lib-link.write.1.tlog +c:\work\cheat-menu\depend\release\depend.tlog\lib.command.1.tlog diff --git a/Depend/Release/Depend.log b/Depend/Release/Depend.log index ef00360..87863a2 100644 --- a/Depend/Release/Depend.log +++ b/Depend/Release/Depend.log @@ -15,16 +15,16 @@ hook.c trampoline.c zip.c -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\miniz.h(6104,45): warning C4244: 'return': conversion from 'mz_uint64' to 'mz_uint', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1252,32): warning C4244: 'function': conversion from 'const mz_uint64' to 'size_t', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1260,33): warning C4244: 'function': conversion from 'const mz_uint64' to 'size_t', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1270,55): warning C4244: 'function': conversion from 'const mz_int64' to 'size_t', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1320,52): warning C4244: 'function': conversion from 'mz_uint64' to 'size_t', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1321,33): warning C4244: 'function': conversion from 'mz_uint64' to 'size_t', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1324,17): warning C4244: '-=': conversion from 'mz_uint64' to 'mz_uint32', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1329,34): warning C4244: 'function': conversion from 'mz_uint64' to 'size_t', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1332,17): warning C4244: '-=': conversion from 'mz_uint64' to 'mz_uint32', possible loss of data -C:\Users\Grinch_\source\repos\CheatMenu\Depend\zip\zip.c(1336,49): warning C4244: '=': conversion from 'mz_uint64' to 'size_t', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\miniz.h(6104,45): warning C4244: 'return': conversion from 'mz_uint64' to 'mz_uint', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1252,32): warning C4244: 'function': conversion from 'const mz_uint64' to 'size_t', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1260,33): warning C4244: 'function': conversion from 'const mz_uint64' to 'size_t', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1270,55): warning C4244: 'function': conversion from 'const mz_int64' to 'size_t', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1320,52): warning C4244: 'function': conversion from 'mz_uint64' to 'size_t', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1321,33): warning C4244: 'function': conversion from 'mz_uint64' to 'size_t', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1324,17): warning C4244: '-=': conversion from 'mz_uint64' to 'mz_uint32', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1329,34): warning C4244: 'function': conversion from 'mz_uint64' to 'size_t', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1332,17): warning C4244: '-=': conversion from 'mz_uint64' to 'mz_uint32', possible loss of data +C:\Work\Cheat-Menu\Depend\zip\zip.c(1336,49): warning C4244: '=': conversion from 'mz_uint64' to 'size_t', possible loss of data d3d11.lib(d3d11.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in d3d9.lib(d3d9.dll); second definition ignored XInput9_1_0.lib(XINPUT9_1_0.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in d3d9.lib(d3d9.dll); second definition ignored - Depend.vcxproj -> C:\Users\Grinch_\source\repos\CheatMenu\Release\Depend.lib + Depend.vcxproj -> C:\Work\Cheat-Menu\Release\Depend.lib diff --git a/Depend/Release/Depend.pdb b/Depend/Release/Depend.pdb index dd6d33a..8731e88 100644 Binary files a/Depend/Release/Depend.pdb and b/Depend/Release/Depend.pdb differ diff --git a/Depend/Release/Depend.tlog/CL.command.1.tlog b/Depend/Release/Depend.tlog/CL.command.1.tlog index 154cd9f..310a8dc 100644 Binary files a/Depend/Release/Depend.tlog/CL.command.1.tlog and b/Depend/Release/Depend.tlog/CL.command.1.tlog differ diff --git a/Depend/Release/Depend.tlog/CL.read.1.tlog b/Depend/Release/Depend.tlog/CL.read.1.tlog index 3438f01..aa5a08c 100644 Binary files a/Depend/Release/Depend.tlog/CL.read.1.tlog and b/Depend/Release/Depend.tlog/CL.read.1.tlog differ diff --git a/Depend/Release/Depend.tlog/CL.write.1.tlog b/Depend/Release/Depend.tlog/CL.write.1.tlog index 75fc526..8867658 100644 Binary files a/Depend/Release/Depend.tlog/CL.write.1.tlog and b/Depend/Release/Depend.tlog/CL.write.1.tlog differ diff --git a/Depend/Release/Depend.tlog/Depend.lastbuildstate b/Depend/Release/Depend.tlog/Depend.lastbuildstate index fbc70e9..8a45e42 100644 --- a/Depend/Release/Depend.tlog/Depend.lastbuildstate +++ b/Depend/Release/Depend.tlog/Depend.lastbuildstate @@ -1,2 +1,2 @@ PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29910:TargetPlatformVersion=10.0.19041.0: -Release|Win32|C:\Users\Grinch_\source\repos\CheatMenu\| +Release|Win32|C:\Work\Cheat-Menu\| diff --git a/Depend/Release/Depend.tlog/Lib-link.read.1.tlog b/Depend/Release/Depend.tlog/Lib-link.read.1.tlog index 2c57dd7..86df882 100644 Binary files a/Depend/Release/Depend.tlog/Lib-link.read.1.tlog and b/Depend/Release/Depend.tlog/Lib-link.read.1.tlog differ diff --git a/Depend/Release/Depend.tlog/Lib-link.write.1.tlog b/Depend/Release/Depend.tlog/Lib-link.write.1.tlog index 8b4f2b4..2913401 100644 Binary files a/Depend/Release/Depend.tlog/Lib-link.write.1.tlog and b/Depend/Release/Depend.tlog/Lib-link.write.1.tlog differ diff --git a/Depend/Release/Depend.tlog/Lib.command.1.tlog b/Depend/Release/Depend.tlog/Lib.command.1.tlog index fa97a90..f0f2792 100644 Binary files a/Depend/Release/Depend.tlog/Lib.command.1.tlog and b/Depend/Release/Depend.tlog/Lib.command.1.tlog differ diff --git a/Depend/Release/IDaccess.obj b/Depend/Release/IDaccess.obj index 3b2dc3d..55064e0 100644 Binary files a/Depend/Release/IDaccess.obj and b/Depend/Release/IDaccess.obj differ diff --git a/Depend/Release/Library.obj b/Depend/Release/Library.obj index 0f4886d..4c390aa 100644 Binary files a/Depend/Release/Library.obj and b/Depend/Release/Library.obj differ diff --git a/Depend/Release/Main.obj b/Depend/Release/Main.obj index 6454e8c..4aaa8d7 100644 Binary files a/Depend/Release/Main.obj and b/Depend/Release/Main.obj differ diff --git a/Depend/Release/buffer.obj b/Depend/Release/buffer.obj index 4c62def..e928d33 100644 Binary files a/Depend/Release/buffer.obj and b/Depend/Release/buffer.obj differ diff --git a/Depend/Release/hde32.obj b/Depend/Release/hde32.obj index 50588ee..0b8e964 100644 Binary files a/Depend/Release/hde32.obj and b/Depend/Release/hde32.obj differ diff --git a/Depend/Release/hook.obj b/Depend/Release/hook.obj index 9eaff1c..46a37f7 100644 Binary files a/Depend/Release/hook.obj and b/Depend/Release/hook.obj differ diff --git a/Depend/Release/imgui.obj b/Depend/Release/imgui.obj index 08a7935..261b441 100644 Binary files a/Depend/Release/imgui.obj and b/Depend/Release/imgui.obj differ diff --git a/Depend/Release/imgui_demo.obj b/Depend/Release/imgui_demo.obj index 2034d96..6c1c190 100644 Binary files a/Depend/Release/imgui_demo.obj and b/Depend/Release/imgui_demo.obj differ diff --git a/Depend/Release/imgui_draw.obj b/Depend/Release/imgui_draw.obj index 7a89dd4..e1ee177 100644 Binary files a/Depend/Release/imgui_draw.obj and b/Depend/Release/imgui_draw.obj differ diff --git a/Depend/Release/imgui_impl_dx11.obj b/Depend/Release/imgui_impl_dx11.obj index ce8eba9..701313a 100644 Binary files a/Depend/Release/imgui_impl_dx11.obj and b/Depend/Release/imgui_impl_dx11.obj differ diff --git a/Depend/Release/imgui_impl_dx9.obj b/Depend/Release/imgui_impl_dx9.obj index fa316c8..0950d78 100644 Binary files a/Depend/Release/imgui_impl_dx9.obj and b/Depend/Release/imgui_impl_dx9.obj differ diff --git a/Depend/Release/imgui_impl_win32.obj b/Depend/Release/imgui_impl_win32.obj index cda2902..9907197 100644 Binary files a/Depend/Release/imgui_impl_win32.obj and b/Depend/Release/imgui_impl_win32.obj differ diff --git a/Depend/Release/imgui_tables.obj b/Depend/Release/imgui_tables.obj index 26ba076..1b1bce1 100644 Binary files a/Depend/Release/imgui_tables.obj and b/Depend/Release/imgui_tables.obj differ diff --git a/Depend/Release/imgui_widgets.obj b/Depend/Release/imgui_widgets.obj index 22bade1..1e7ad11 100644 Binary files a/Depend/Release/imgui_widgets.obj and b/Depend/Release/imgui_widgets.obj differ diff --git a/Depend/Release/kiero.obj b/Depend/Release/kiero.obj index fdc43c4..a1d7238 100644 Binary files a/Depend/Release/kiero.obj and b/Depend/Release/kiero.obj differ diff --git a/Depend/Release/trampoline.obj b/Depend/Release/trampoline.obj index 6923868..be640c6 100644 Binary files a/Depend/Release/trampoline.obj and b/Depend/Release/trampoline.obj differ diff --git a/Depend/Release/zip.obj b/Depend/Release/zip.obj index b931a48..00d1d53 100644 Binary files a/Depend/Release/zip.obj and b/Depend/Release/zip.obj differ diff --git a/Depend/kiero/kiero.cpp b/Depend/kiero/kiero.cpp index bf91972..5582fe1 100644 --- a/Depend/kiero/kiero.cpp +++ b/Depend/kiero/kiero.cpp @@ -1,33 +1,6 @@ -/* Modified version of https://github.com/Rebzzel/kiero - -MIT License - -Copyright(c) 2014 - 2020 Rebzzel -Copyright(c) 2021 Grinch_ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - #include "kiero.h" #include #include -#include "Renderware.h" #if KIERO_INCLUDE_D3D9 # include @@ -54,11 +27,11 @@ SOFTWARE. #endif #if KIERO_INCLUDE_VULKAN -#include +# include #endif #if KIERO_USE_MINHOOK -#include "minhook/MinHook.h" +# include "minhook/MinHook.h" #endif #ifdef _UNICODE @@ -83,22 +56,94 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) { if (_renderType >= RenderType::D3D9 && _renderType <= RenderType::D3D12) { + WNDCLASSEX windowClass; + windowClass.cbSize = sizeof(WNDCLASSEX); + windowClass.style = CS_HREDRAW | CS_VREDRAW; + windowClass.lpfnWndProc = DefWindowProc; + windowClass.cbClsExtra = 0; + windowClass.cbWndExtra = 0; + windowClass.hInstance = GetModuleHandle(NULL); + windowClass.hIcon = NULL; + windowClass.hCursor = NULL; + windowClass.hbrBackground = NULL; + windowClass.lpszMenuName = NULL; + windowClass.lpszClassName = KIERO_TEXT("Kiero"); + windowClass.hIconSm = NULL; + + ::RegisterClassEx(&windowClass); + + HWND window = ::CreateWindow(windowClass.lpszClassName, KIERO_TEXT("Kiero DirectX Window"), WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, NULL, NULL, windowClass.hInstance, NULL); + if (_renderType == RenderType::D3D9) { #if KIERO_INCLUDE_D3D9 - - if (GetModuleHandle(KIERO_TEXT("d3d9.dll")) == NULL) + HMODULE libD3D9; + if ((libD3D9 = ::GetModuleHandle(KIERO_TEXT("d3d9.dll"))) == NULL) { + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); return Status::ModuleNotFoundError; } + + void* Direct3DCreate9; + if ((Direct3DCreate9 = ::GetProcAddress(libD3D9, "Direct3DCreate9")) == NULL) + { + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); + return Status::UnknownError; + } + + LPDIRECT3D9 direct3D9; + if ((direct3D9 = ((LPDIRECT3D9(__stdcall*)(uint32_t))(Direct3DCreate9))(D3D_SDK_VERSION)) == NULL) + { + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); + return Status::UnknownError; + } + + D3DPRESENT_PARAMETERS params; + params.BackBufferWidth = 0; + params.BackBufferHeight = 0; + params.BackBufferFormat = D3DFMT_UNKNOWN; + params.BackBufferCount = 0; + params.MultiSampleType = D3DMULTISAMPLE_NONE; + params.MultiSampleQuality = NULL; + params.SwapEffect = D3DSWAPEFFECT_DISCARD; + params.hDeviceWindow = window; + params.Windowed = 1; + params.EnableAutoDepthStencil = 0; + params.AutoDepthStencilFormat = D3DFMT_UNKNOWN; + params.Flags = NULL; + params.FullScreen_RefreshRateInHz = 0; + params.PresentationInterval = 0; + + LPDIRECT3DDEVICE9 device; + if (direct3D9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF, window, D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_DISABLE_DRIVER_MANAGEMENT, ¶ms, &device) < 0) + { + direct3D9->Release(); + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); + return Status::UnknownError; + } + g_methodsTable = (uint150_t*)::calloc(119, sizeof(uint150_t)); - ::memcpy(g_methodsTable, *(uint150_t**)GetD3DDevice(), 119 * sizeof(uint150_t)); + ::memcpy(g_methodsTable, *(uint150_t**)device, 119 * sizeof(uint150_t)); #if KIERO_USE_MINHOOK MH_Initialize(); #endif + + device->Release(); + device = NULL; + + direct3D9->Release(); + direct3D9 = NULL; + g_renderType = RenderType::D3D9; + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); + return Status::Success; #endif } @@ -218,12 +263,16 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) HMODULE libD3D11; if ((libD3D11 = ::GetModuleHandle(KIERO_TEXT("d3d11.dll"))) == NULL) { + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); return Status::ModuleNotFoundError; } void* D3D11CreateDeviceAndSwapChain; if ((D3D11CreateDeviceAndSwapChain = ::GetProcAddress(libD3D11, "D3D11CreateDeviceAndSwapChain")) == NULL) { + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); return Status::UnknownError; } @@ -251,7 +300,7 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) swapChainDesc.SampleDesc = sampleDesc; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.BufferCount = 1; - swapChainDesc.OutputWindow = RsGlobal.ps->window; + swapChainDesc.OutputWindow = window; swapChainDesc.Windowed = 1; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; @@ -274,6 +323,8 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) D3D_FEATURE_LEVEL*, ID3D11DeviceContext**))(D3D11CreateDeviceAndSwapChain))(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, featureLevels, 2, D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &device, &featureLevel, &context) < 0) { + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); return Status::UnknownError; } @@ -295,6 +346,9 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) context->Release(); context = NULL; + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); + g_renderType = RenderType::D3D11; return Status::Success; @@ -451,6 +505,9 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) #endif } + ::DestroyWindow(window); + ::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); + return Status::NotSupportedError; } else if (_renderType != RenderType::Auto) @@ -548,7 +605,7 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) g_methodsTable = (uint150_t*)::calloc(size, sizeof(uint150_t)); - for (unsigned int i = 0; i < size; i++) + for (int i = 0; i < size; i++) { g_methodsTable[i] = (uint150_t)::GetProcAddress(libVulkan, methodsNames[i]); } diff --git a/Depend/kiero/kiero.h b/Depend/kiero/kiero.h index 26ebae8..1260cd7 100644 --- a/Depend/kiero/kiero.h +++ b/Depend/kiero/kiero.h @@ -1,34 +1,9 @@ -/* Modified version of https://github.com/Rebzzel/kiero - -MIT License - -Copyright(c) 2014 - 2020 Rebzzel -Copyright(c) 2021 Grinch_ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ #ifndef __KIERO_H__ #define __KIERO_H__ #include -#define KIERO_VERSION "1.2.10" +#define KIERO_VERSION "1.2.12" #define KIERO_INCLUDE_D3D9 1 // 1 if you need D3D9 hook #define KIERO_INCLUDE_D3D10 0 // 1 if you need D3D10 hook