From 7a3ed4e25267eb850bf466e440f0d55bc95a0ef7 Mon Sep 17 00:00:00 2001 From: Elisha Riedlinger Date: Sun, 1 Oct 2017 23:28:50 -0700 Subject: [PATCH] Create wrapper stub and wrap more dlls - Created a new wrapper stub to allow loading dxwrapper.dll from memory - Added MemoryModule to load DxWrapper from memory using the stub - Added support for wrapping additional dlls: d2d1.dll, d3d10.dll, d3d10core.dll, d3d11.dll, d3d12.dll, d3dim.dll, d3dim700.dll, dinput8.dll, msacm32.dll, msvfw32.dll, vorbisfile.dll, winmmbase.dll and xlive.dll - Updated to support getting loaded from memory rather than disk - Fixed issue where memory verification would fail sometimes after compiling - Added macros for config settings to simplify the code - Updated the names of the Config varables to match thier ini file names - Removed wrapper mode from config file - Updated wrapper functions to use original API names rather than fake names --- D3d8to9/d3d8.h | 14 +- D3d8to9/d3d8to9.cpp | 8 +- D3d9/D3d9External.h | 11 + D3d9/d3d9.cpp | 18 +- DDrawCompat/DDrawCompatExternal.h | 20 +- DDrawCompat/v0.2.0b/DDrawLog.h | 24 +- DDrawCompat/v0.2.0b/DllMainCompat.cpp | 27 +- DDrawCompat/v0.2.0b/UnmodifiedDDrawProcs.cpp | 2 +- DDrawCompat/v0.2.1/DDrawLog.h | 24 +- DDrawCompat/v0.2.1/DllMainCompat.cpp | 30 +- DDrawCompat/v0.2.1/UnmodifiedDDrawProcs.cpp | 2 +- DSoundCtrl/DSoundCtrl.cpp | 85 +- DSoundCtrl/DSoundCtrlExternal.h | 15 +- Dllmain/BuildNo.rc | 2 +- Dllmain/Dllmain.cpp | 155 +- Dllmain/dxwrapper.def | 718 --------- Dllmain/dxwrapper.h | 6 +- Libraries/d3dx9.cpp | 14 +- Libraries/d3dx9.h | 2 - Libraries/dwmapi.cpp | 13 +- Libraries/dwmapi.h | 2 - Libraries/uxtheme.cpp | 13 +- Libraries/uxtheme.h | 1 - Libraries/winmm.cpp | 4 +- Logging/Logging.h | 1 + MemoryModule/LICENSE.txt | 373 +++++ MemoryModule/MemoryModule.c | 1090 ++++++++++++++ MemoryModule/MemoryModule.h | 168 +++ README.md | 36 +- Settings/AllSettings.ini | 3 +- Settings/Settings.cpp | 738 +++------- Settings/Settings.h | 137 +- Stub/BuildNo.rc | 1 + Stub/Dllmain.cpp | 92 ++ Stub/License.txt | 15 + Stub/stub.h | 34 + Stub/stub.rc | 103 ++ Stub/stub.vcxproj | 160 ++ Utils/Fullscreen.cpp | 10 +- Utils/Utils.cpp | 201 ++- Utils/Utils.h | 5 + Utils/WriteMemory.cpp | 14 +- Wrappers/bcrypt.h | 33 +- Wrappers/cryptsp.h | 33 +- Wrappers/d2d1.h | 22 + Wrappers/d3d10.h | 37 + Wrappers/d3d10core.h | 11 + Wrappers/d3d11.h | 22 + Wrappers/d3d12.h | 18 + Wrappers/d3d8.h | 55 +- Wrappers/d3d9.h | 60 +- Wrappers/d3dim.h | 10 + Wrappers/d3dim700.h | 15 + Wrappers/dciman32.h | 33 +- Wrappers/ddraw.h | 59 +- Wrappers/dinput.h | 41 +- Wrappers/dinput8.h | 9 + Wrappers/dplayx.h | 33 +- Wrappers/dsound.h | 74 +- Wrappers/dxgi.h | 72 +- Wrappers/msacm32.h | 51 + Wrappers/msvfw32.h | 54 + Wrappers/shared.h | 71 + Wrappers/vorbisFile.h | 42 + Wrappers/winmm.h | 40 +- Wrappers/winspool.h | 37 +- Wrappers/wrapper.cpp | 351 ++--- Wrappers/wrapper.def | 1374 ++++++++++++++++++ Wrappers/wrapper.h | 112 +- Wrappers/xlive.h | 144 ++ dxwrapper.sln | 6 + dxwrapper.vcproj | 8 +- dxwrapper.vcxproj | 56 +- dxwrapper.vcxproj.filters | 55 +- 74 files changed, 5027 insertions(+), 2402 deletions(-) create mode 100644 D3d9/D3d9External.h delete mode 100644 Dllmain/dxwrapper.def create mode 100644 MemoryModule/LICENSE.txt create mode 100644 MemoryModule/MemoryModule.c create mode 100644 MemoryModule/MemoryModule.h create mode 100644 Stub/BuildNo.rc create mode 100644 Stub/Dllmain.cpp create mode 100644 Stub/License.txt create mode 100644 Stub/stub.h create mode 100644 Stub/stub.rc create mode 100644 Stub/stub.vcxproj create mode 100644 Wrappers/d2d1.h create mode 100644 Wrappers/d3d10.h create mode 100644 Wrappers/d3d10core.h create mode 100644 Wrappers/d3d11.h create mode 100644 Wrappers/d3d12.h create mode 100644 Wrappers/d3dim.h create mode 100644 Wrappers/d3dim700.h create mode 100644 Wrappers/dinput8.h create mode 100644 Wrappers/msacm32.h create mode 100644 Wrappers/msvfw32.h create mode 100644 Wrappers/shared.h create mode 100644 Wrappers/vorbisFile.h create mode 100644 Wrappers/wrapper.def create mode 100644 Wrappers/xlive.h diff --git a/D3d8to9/d3d8.h b/D3d8to9/d3d8.h index 6e77c863..d2acf85c 100644 --- a/D3d8to9/d3d8.h +++ b/D3d8to9/d3d8.h @@ -1,18 +1,12 @@ #pragma once -#include "wrappers\wrapper.h" - class __declspec(uuid("1DD9E8DA-1C77-4D40-B0CF-98FEFDFF9512")) Direct3D8; -extern "C" Direct3D8 *WINAPI Direct3DCreate8(UINT); +extern "C" Direct3D8 *WINAPI _Direct3DCreate8(UINT); HRESULT WINAPI _ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, BOOL flag, DWORD* toto); HRESULT WINAPI _ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL flag, DWORD* toto); -namespace Wrapper +namespace D3d8to9 { - namespace D3d8to9 - { - FARPROC _Direct3DCreate8 = (FARPROC)*Direct3DCreate8; - FARPROC _Direct3DCreate9 = nullptr; - } -} \ No newline at end of file + FARPROC Direct3DCreate8 = (FARPROC)*_Direct3DCreate8; +} diff --git a/D3d8to9/d3d8to9.cpp b/D3d8to9/d3d8to9.cpp index a6c69c74..f45864d6 100644 --- a/D3d8to9/d3d8to9.cpp +++ b/D3d8to9/d3d8to9.cpp @@ -7,18 +7,20 @@ //********** Begin Edit ************* #include "d3d8to9.hpp" -#include "wrappers\wrapper.h" +#include "Utils\Utils.h" +#include "Hooking\Hook.h" typedef LPDIRECT3D9(WINAPI *PFN_Direct3DCreate9)(UINT SDKVersion); //********** End Edit *************** -extern "C" Direct3D8 *WINAPI Direct3DCreate8(UINT SDKVersion) +extern "C" Direct3D8 *WINAPI _Direct3DCreate8(UINT SDKVersion) { //********** Begin Edit ************* LOG << "Enabling D3d8to9 function (" << SDKVersion << ")"; // Declare Direct3DCreate9 - static PFN_Direct3DCreate9 Direct3DCreate9 = reinterpret_cast(Wrapper::D3d8to9::_Direct3DCreate9); + HMODULE dll = Utils::LoadLibrary(dtypename[dtype.d3d9]); + static PFN_Direct3DCreate9 Direct3DCreate9 = reinterpret_cast(Hook::GetProcAddress(dll, "Direct3DCreate9")); if (!Direct3DCreate9) { LOG << "Failed to get 'Direct3DCreate9' ProcAddress of d3d9.dll!"; diff --git a/D3d9/D3d9External.h b/D3d9/D3d9External.h new file mode 100644 index 00000000..8eac5254 --- /dev/null +++ b/D3d9/D3d9External.h @@ -0,0 +1,11 @@ +#pragma once + +struct __declspec(uuid("81BDCBCA-64D4-426d-AE8D-AD0147F4275C")) IDirect3D9; + +IDirect3D9 *WINAPI _Direct3DCreate9(UINT); + +namespace d3d9_wrap +{ + constexpr FARPROC Direct3DCreate9 = (FARPROC)*_Direct3DCreate9; + extern FARPROC Direct3DCreate9_Proxy; +} diff --git a/D3d9/d3d9.cpp b/D3d9/d3d9.cpp index 77e74f26..fa8aecf3 100644 --- a/D3d9/d3d9.cpp +++ b/D3d9/d3d9.cpp @@ -17,25 +17,21 @@ */ #include "Settings\Settings.h" -#include "Wrappers\Wrapper.h" #include "d3d9.h" +#include "d3d9External.h" #include "d3dx9.h" #include "Logging\Logging.h" -IDirect3D9 *WINAPI _Direct3DCreate9_Wrapper(UINT SDKVersion) +namespace d3d9_wrap { - Logging::Log() << "Direct3DCreate9 function (" << SDKVersion << ")"; - orig_Direct3DCreate9 = (D3DC9)Wrapper::d3d9_Wrapper::_Direct3DCreate9_RealProc; - return new f_iD3D9(orig_Direct3DCreate9(SDKVersion)); + FARPROC Direct3DCreate9_Proxy = nullptr; } -namespace Wrapper +IDirect3D9 *WINAPI _Direct3DCreate9(UINT SDKVersion) { - namespace d3d9_Wrapper - { - FARPROC _Direct3DCreate9_RealProc; - FARPROC _Direct3DCreate9_WrapperProc = (FARPROC)*_Direct3DCreate9_Wrapper; - } + Logging::Log() << "Direct3DCreate9 function (" << SDKVersion << ")"; + orig_Direct3DCreate9 = (D3DC9)d3d9_wrap::Direct3DCreate9_Proxy; + return new f_iD3D9(orig_Direct3DCreate9(SDKVersion)); } HRESULT f_iD3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, diff --git a/DDrawCompat/DDrawCompatExternal.h b/DDrawCompat/DDrawCompatExternal.h index 09f89337..39c58c8e 100644 --- a/DDrawCompat/DDrawCompatExternal.h +++ b/DDrawCompat/DDrawCompatExternal.h @@ -1,20 +1,14 @@ #pragma once -#include "Wrappers\Wrapper.h" - BOOL WINAPI DllMain_DDrawCompat(HINSTANCE, DWORD, LPVOID); -extern "C" HRESULT WINAPI DirectDrawCreate(GUID*, LPDIRECTDRAW*, IUnknown*); -extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID*, LPVOID*, REFIID, IUnknown*); -extern "C" HRESULT WINAPI DllGetClassObject(REFCLSID, REFIID, LPVOID*); +extern "C" HRESULT WINAPI _DirectDrawCreate(GUID*, LPDIRECTDRAW*, IUnknown*); +extern "C" HRESULT WINAPI _DirectDrawCreateEx(GUID*, LPVOID*, REFIID, IUnknown*); +extern "C" HRESULT WINAPI _DllGetClassObject(REFCLSID, REFIID, LPVOID*); -namespace Wrapper +namespace DDrawCompat { - namespace DDrawCompat - { - FARPROC _DirectDrawCreate = (FARPROC)*DirectDrawCreate; - FARPROC _DirectDrawCreateEx = (FARPROC)*DirectDrawCreateEx; - FARPROC _DllGetClassObject = (FARPROC)*DllGetClassObject; - } - + constexpr FARPROC DirectDrawCreate = (FARPROC)*_DirectDrawCreate; + constexpr FARPROC DirectDrawCreateEx = (FARPROC)*_DirectDrawCreateEx; + constexpr FARPROC DllGetClassObject = (FARPROC)*_DllGetClassObject; } diff --git a/DDrawCompat/v0.2.0b/DDrawLog.h b/DDrawCompat/v0.2.0b/DDrawLog.h index 05352b2e..19e8d154 100644 --- a/DDrawCompat/v0.2.0b/DDrawLog.h +++ b/DDrawCompat/v0.2.0b/DDrawLog.h @@ -108,20 +108,28 @@ namespace Compat GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)Init, &hModule); GetModuleFileName(hModule, wrappername, MAX_PATH); - // Set lower case, remove extension and add dash (-) - for (int z = 0; z < MAX_PATH && wrappername[z] != '\0'; z++) { wrappername[z] = (char)tolower(wrappername[z]); } - strcpy_s(strrchr(wrappername, '.'), MAX_PATH - strlen(wrappername), "-"); - // Get process name - char exepath[MAX_PATH]; - GetModuleFileName(NULL, exepath, MAX_PATH); + char processname[MAX_PATH]; + GetModuleFileName(nullptr, processname, MAX_PATH); + + // Check if module name is the same as process name + if (_strcmpi(strrchr(wrappername, '\\') + 1, strrchr(processname, '\\') + 1) == 0) + { + strcpy_s(strrchr(wrappername, '\\') + 1, MAX_PATH - strlen(wrappername), "dxwrapper.dll"); + } - // Remove path and add process name - strcat_s(wrappername, MAX_PATH, strrchr(exepath, '\\') + 1); + // Remove extension and add dash (-) + strcpy_s(strrchr(wrappername, '.'), MAX_PATH - strlen(wrappername), "-"); + + // Add process name + strcat_s(wrappername, MAX_PATH, strrchr(processname, '\\') + 1); // Change extension to .log strcpy_s(strrchr(wrappername, '.'), MAX_PATH - strlen(wrappername), ".log"); + // Set lower case + for (int z = 0; z < MAX_PATH && wrappername[z] != '\0'; z++) { wrappername[z] = (char)tolower(wrappername[z]); } + return wrappername; } //********** End Edit *************** diff --git a/DDrawCompat/v0.2.0b/DllMainCompat.cpp b/DDrawCompat/v0.2.0b/DllMainCompat.cpp index e61acc67..f9b3573e 100644 --- a/DDrawCompat/v0.2.0b/DllMainCompat.cpp +++ b/DDrawCompat/v0.2.0b/DllMainCompat.cpp @@ -16,7 +16,10 @@ #include "DDrawProcs.h" //********** Begin Edit ************* #include "Settings\Settings.h" -#include "Wrappers\wrapper.h" +#include "Hooking\Hook.h" +#include "Utils\Utils.h" +#define DllMain DllMain_DDrawCompat +#define GetProcAddress Hook::GetProcAddress //********** End Edit *************** struct IDirectInput; @@ -152,10 +155,10 @@ namespace #define LOAD_ORIGINAL_DDRAW_PROC(procName) \ Compat::origProcs.procName = GetProcAddress(g_origDDrawModule, #procName); -//********** Begin Edit ************* -BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lpvReserved*/) -//********** End Edit *************** +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + UNREFERENCED_PARAMETER(lpvReserved); + if (fdwReason == DLL_PROCESS_ATTACH) { char currentDllPath[MAX_PATH] = {}; @@ -175,13 +178,13 @@ BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lp //********** Begin Edit ************* if (Config.RealWrapperMode == dtype.ddraw) { - g_origDDrawModule = Wrapper::LoadDll(dtype.ddraw); + g_origDDrawModule = Utils::LoadLibrary("ddraw.dll"); } else { g_origDDrawModule = hinstDLL; } - g_origDInputModule = Wrapper::LoadDll(dtype.dinput); + g_origDInputModule = Utils::LoadLibrary("dinput.dll"); if (!g_origDDrawModule || !g_origDInputModule) { return false; @@ -192,7 +195,7 @@ BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lp Compat::origProcs.DirectInputCreateA = GetProcAddress(g_origDInputModule, "DirectInputCreateA"); //********** Begin Edit ************* - if (Config.AffinityNotSet) SetProcessAffinityMask(GetCurrentProcess(), 1); + if (Config.SingleProcAffinityNotSet) SetProcessAffinityMask(GetCurrentProcess(), 1); //********** End Edit *************** //********** Begin Edit ************* @@ -221,7 +224,7 @@ BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lp return TRUE; } -extern "C" HRESULT WINAPI DirectDrawCreate( +extern "C" HRESULT WINAPI _DirectDrawCreate( GUID* lpGUID, LPDIRECTDRAW* lplpDD, IUnknown* pUnkOuter) @@ -234,7 +237,7 @@ extern "C" HRESULT WINAPI DirectDrawCreate( return result; } -extern "C" HRESULT WINAPI DirectDrawCreateEx( +extern "C" HRESULT WINAPI _DirectDrawCreateEx( GUID* lpGUID, LPVOID* lplpDD, REFIID iid, @@ -249,7 +252,7 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx( } //********** Begin Edit ************* -extern "C" HRESULT WINAPI DllGetClassObject( +extern "C" HRESULT WINAPI _DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID *ppv) @@ -262,7 +265,7 @@ extern "C" HRESULT WINAPI DllGetClassObject( } //********** End Edit *************** -extern "C" HRESULT WINAPI DirectInputCreateA( +/*extern "C" HRESULT WINAPI DirectInputCreateA( HINSTANCE hinst, DWORD dwVersion, IDirectInput** lplpDirectInput, @@ -272,4 +275,4 @@ extern "C" HRESULT WINAPI DirectInputCreateA( HRESULT result = CALL_ORIG_DDRAW(DirectInputCreateA, hinst, dwVersion, lplpDirectInput, punkOuter); Compat::LogLeave(__func__, hinst, dwVersion, lplpDirectInput, punkOuter) << result; return result; -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/DDrawCompat/v0.2.0b/UnmodifiedDDrawProcs.cpp b/DDrawCompat/v0.2.0b/UnmodifiedDDrawProcs.cpp index 0a74b1f8..b57f5f32 100644 --- a/DDrawCompat/v0.2.0b/UnmodifiedDDrawProcs.cpp +++ b/DDrawCompat/v0.2.0b/UnmodifiedDDrawProcs.cpp @@ -1,7 +1,7 @@ #include "DDrawProcs.h" #define CREATE_DDRAW_PROC_STUB(procName) \ - extern "C" __declspec(naked) void __stdcall procName() \ + extern "C" __declspec(naked) void __stdcall _ ## procName() \ { \ __asm jmp Compat::origProcs.procName \ } diff --git a/DDrawCompat/v0.2.1/DDrawLog.h b/DDrawCompat/v0.2.1/DDrawLog.h index 0c25e909..0191fc99 100644 --- a/DDrawCompat/v0.2.1/DDrawLog.h +++ b/DDrawCompat/v0.2.1/DDrawLog.h @@ -114,20 +114,28 @@ namespace Compat GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)Init, &hModule); GetModuleFileName(hModule, wrappername, MAX_PATH); - // Set lower case, remove extension and add dash (-) - for (int z = 0; z < MAX_PATH && wrappername[z] != '\0'; z++) { wrappername[z] = (char)tolower(wrappername[z]); } - strcpy_s(strrchr(wrappername, '.'), MAX_PATH - strlen(wrappername), "-"); - // Get process name - char exepath[MAX_PATH]; - GetModuleFileName(NULL, exepath, MAX_PATH); + char processname[MAX_PATH]; + GetModuleFileName(nullptr, processname, MAX_PATH); + + // Check if module name is the same as process name + if (_strcmpi(strrchr(wrappername, '\\') + 1, strrchr(processname, '\\') + 1) == 0) + { + strcpy_s(strrchr(wrappername, '\\') + 1, MAX_PATH - strlen(wrappername), "dxwrapper.dll"); + } - // Remove path and add process name - strcat_s(wrappername, MAX_PATH, strrchr(exepath, '\\') + 1); + // Remove extension and add dash (-) + strcpy_s(strrchr(wrappername, '.'), MAX_PATH - strlen(wrappername), "-"); + + // Add process name + strcat_s(wrappername, MAX_PATH, strrchr(processname, '\\') + 1); // Change extension to .log strcpy_s(strrchr(wrappername, '.'), MAX_PATH - strlen(wrappername), ".log"); + // Set lower case + for (int z = 0; z < MAX_PATH && wrappername[z] != '\0'; z++) { wrappername[z] = (char)tolower(wrappername[z]); } + return wrappername; } //********** End Edit *************** diff --git a/DDrawCompat/v0.2.1/DllMainCompat.cpp b/DDrawCompat/v0.2.1/DllMainCompat.cpp index f429212b..75b74149 100644 --- a/DDrawCompat/v0.2.1/DllMainCompat.cpp +++ b/DDrawCompat/v0.2.1/DllMainCompat.cpp @@ -25,7 +25,10 @@ #include "Time1.h" //********** Begin Edit ************* #include "Settings\Settings.h" -#include "Wrappers\wrapper.h" +#include "Hooking\Hook.h" +#include "Utils\Utils.h" +#define DllMain DllMain_DDrawCompat +#define GetProcAddress Hook::GetProcAddress //********** End Edit *************** struct IDirectInput; @@ -157,13 +160,10 @@ namespace #define LOAD_ORIGINAL_DDRAW_PROC(procName) \ Compat::origProcs.procName = GetProcAddress(g_origDDrawModule, #procName); -#define LOAD_ORIGINAL_DDRAW_PROC(procName) \ - Compat::origProcs.procName = GetProcAddress(g_origDDrawModule, #procName); - -//********** Begin Edit ************* -BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lpvReserved*/) -//********** End Edit *************** +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + UNREFERENCED_PARAMETER(lpvReserved); + if (fdwReason == DLL_PROCESS_ATTACH) { char currentProcessPath[MAX_PATH] = {}; @@ -187,13 +187,13 @@ BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lp //********** Begin Edit ************* if (Config.RealWrapperMode == dtype.ddraw) { - g_origDDrawModule = Wrapper::LoadDll(dtype.ddraw); + g_origDDrawModule = Utils::LoadLibrary("ddraw.dll"); } else { g_origDDrawModule = hinstDLL; } - g_origDInputModule = Wrapper::LoadDll(dtype.dinput); + g_origDInputModule = Utils::LoadLibrary("dinput.dll"); if (!g_origDDrawModule || !g_origDInputModule) { return false; @@ -204,7 +204,7 @@ BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lp Compat::origProcs.DirectInputCreateA = GetProcAddress(g_origDInputModule, "DirectInputCreateA"); //********** Begin Edit ************* - if (Config.AffinityNotSet) SetProcessAffinityMask(GetCurrentProcess(), 1); + if (Config.SingleProcAffinityNotSet) SetProcessAffinityMask(GetCurrentProcess(), 1); //********** End Edit *************** SetThemeAppProperties(0); Time::init(); @@ -246,7 +246,7 @@ BOOL WINAPI DllMain_DDrawCompat(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lp return TRUE; } -extern "C" HRESULT WINAPI DirectDrawCreate( +extern "C" HRESULT WINAPI _DirectDrawCreate( GUID* lpGUID, LPDIRECTDRAW* lplpDD, IUnknown* pUnkOuter) @@ -259,7 +259,7 @@ extern "C" HRESULT WINAPI DirectDrawCreate( return result; } -extern "C" HRESULT WINAPI DirectDrawCreateEx( +extern "C" HRESULT WINAPI _DirectDrawCreateEx( GUID* lpGUID, LPVOID* lplpDD, REFIID iid, @@ -274,7 +274,7 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx( } //********** Begin Edit ************* -extern "C" HRESULT WINAPI DllGetClassObject( +extern "C" HRESULT WINAPI _DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID *ppv) @@ -287,7 +287,7 @@ extern "C" HRESULT WINAPI DllGetClassObject( } //********** End Edit *************** -extern "C" HRESULT WINAPI DirectInputCreateA( +/*extern "C" HRESULT WINAPI DirectInputCreateA( HINSTANCE hinst, DWORD dwVersion, IDirectInput** lplpDirectInput, @@ -297,4 +297,4 @@ extern "C" HRESULT WINAPI DirectInputCreateA( HRESULT result = CALL_ORIG_DDRAW(DirectInputCreateA, hinst, dwVersion, lplpDirectInput, punkOuter); Compat::LogLeave(__func__, hinst, dwVersion, lplpDirectInput, punkOuter) << result; return result; -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/DDrawCompat/v0.2.1/UnmodifiedDDrawProcs.cpp b/DDrawCompat/v0.2.1/UnmodifiedDDrawProcs.cpp index 0a74b1f8..b57f5f32 100644 --- a/DDrawCompat/v0.2.1/UnmodifiedDDrawProcs.cpp +++ b/DDrawCompat/v0.2.1/UnmodifiedDDrawProcs.cpp @@ -1,7 +1,7 @@ #include "DDrawProcs.h" #define CREATE_DDRAW_PROC_STUB(procName) \ - extern "C" __declspec(naked) void __stdcall procName() \ + extern "C" __declspec(naked) void __stdcall _ ## procName() \ { \ __asm jmp Compat::origProcs.procName \ } diff --git a/DSoundCtrl/DSoundCtrl.cpp b/DSoundCtrl/DSoundCtrl.cpp index abcf5eb4..74e4f208 100644 --- a/DSoundCtrl/DSoundCtrl.cpp +++ b/DSoundCtrl/DSoundCtrl.cpp @@ -30,10 +30,12 @@ #include "dsound.h" #include "DSoundTypes.h" #include "DSoundCtrl.h" -#include "DSoundCtrlExternal.h" #include "IDirectSoundClassFactoryEx.h" -#include "Wrappers\wrapper.h" #include "Logging\Logging.h" +#include "Hooking\Hook.h" +#include "Utils\Utils.h" + +#define DllMain DllMain_DSoundCtrl LPDSENUMCALLBACKA g_pAppDSEnumCallbackA; LPDSENUMCALLBACKW g_pAppDSEnumCallbackW; @@ -141,7 +143,7 @@ BOOL CDSoundCtrlApp::InitInstance(HMODULE hModule) // Load DSOUND.DLL and get entry points if (Config.RealWrapperMode == dtype.dsound) { - g_hDLL = Wrapper::LoadDll(dtype.dsound); + g_hDLL = Utils::LoadLibrary("dsound.dll"); } else { @@ -155,18 +157,18 @@ BOOL CDSoundCtrlApp::InitInstance(HMODULE hModule) return FALSE; } - g_pDirectSoundCreate = (DirectSoundCreatefunc) ::GetProcAddress(g_hDLL, "DirectSoundCreate"); - g_pDirectSoundCreate8 = (DirectSoundCreate8func) ::GetProcAddress(g_hDLL, "DirectSoundCreate8"); - g_pGetDeviceIDfunc = (GetDeviceIDfunc) ::GetProcAddress(g_hDLL, "GetDeviceID"); - g_pDirectSoundEnumerateAfunc = (DirectSoundEnumerateAfunc) ::GetProcAddress(g_hDLL, "DirectSoundEnumerateA"); - g_pDirectSoundEnumerateWfunc = (DirectSoundEnumerateWfunc) ::GetProcAddress(g_hDLL, "DirectSoundEnumerateW"); - g_pDirectSoundCaptureCreatefunc = (DirectSoundCaptureCreatefunc) ::GetProcAddress(g_hDLL, "DirectSoundCaptureCreate"); - g_pDirectSoundCaptureEnumerateAfunc = (DirectSoundCaptureEnumerateAfunc) ::GetProcAddress(g_hDLL, "DirectSoundCaptureEnumerateA"); - g_pDirectSoundCaptureEnumerateWfunc = (DirectSoundCaptureEnumerateWfunc) ::GetProcAddress(g_hDLL, "DirectSoundCaptureEnumerateW"); - g_pDirectSoundCaptureCreate8func = (DirectSoundCaptureCreate8func) ::GetProcAddress(g_hDLL, "DirectSoundCaptureCreate8"); - g_pDirectSoundFullDuplexCreatefunc = (DirectSoundFullDuplexCreatefunc) ::GetProcAddress(g_hDLL, "DirectSoundFullDuplexCreate"); - g_pDllGetClassObjectfunc = (DllGetClassObjectfunc) ::GetProcAddress(g_hDLL, "DllGetClassObject"); - g_pDllCanUnloadNowfunc = (DllCanUnloadNowfunc) ::GetProcAddress(g_hDLL, "DllCanUnloadNow"); + g_pDirectSoundCreate = (DirectSoundCreatefunc)Hook::GetProcAddress(g_hDLL, "DirectSoundCreate"); + g_pDirectSoundCreate8 = (DirectSoundCreate8func)Hook::GetProcAddress(g_hDLL, "DirectSoundCreate8"); + g_pGetDeviceIDfunc = (GetDeviceIDfunc)Hook::GetProcAddress(g_hDLL, "GetDeviceID"); + g_pDirectSoundEnumerateAfunc = (DirectSoundEnumerateAfunc)Hook::GetProcAddress(g_hDLL, "DirectSoundEnumerateA"); + g_pDirectSoundEnumerateWfunc = (DirectSoundEnumerateWfunc)Hook::GetProcAddress(g_hDLL, "DirectSoundEnumerateW"); + g_pDirectSoundCaptureCreatefunc = (DirectSoundCaptureCreatefunc)Hook::GetProcAddress(g_hDLL, "DirectSoundCaptureCreate"); + g_pDirectSoundCaptureEnumerateAfunc = (DirectSoundCaptureEnumerateAfunc)Hook::GetProcAddress(g_hDLL, "DirectSoundCaptureEnumerateA"); + g_pDirectSoundCaptureEnumerateWfunc = (DirectSoundCaptureEnumerateWfunc)Hook::GetProcAddress(g_hDLL, "DirectSoundCaptureEnumerateW"); + g_pDirectSoundCaptureCreate8func = (DirectSoundCaptureCreate8func)Hook::GetProcAddress(g_hDLL, "DirectSoundCaptureCreate8"); + g_pDirectSoundFullDuplexCreatefunc = (DirectSoundFullDuplexCreatefunc)Hook::GetProcAddress(g_hDLL, "DirectSoundFullDuplexCreate"); + g_pDllGetClassObjectfunc = (DllGetClassObjectfunc)Hook::GetProcAddress(g_hDLL, "DllGetClassObject"); + g_pDllCanUnloadNowfunc = (DllCanUnloadNowfunc)Hook::GetProcAddress(g_hDLL, "DllCanUnloadNow"); #ifdef _DEBUG if (g_bDebugBeep) @@ -205,7 +207,7 @@ bool CDSoundCtrlApp::EnumCallback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPC } #endif -HRESULT STDMETHODCALLTYPE DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) +HRESULT STDMETHODCALLTYPE _DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) { #ifdef _DEBUG if (g_bLogSystem) @@ -238,7 +240,7 @@ HRESULT STDMETHODCALLTYPE DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND return hRes; } -BOOL STDMETHODCALLTYPE DSDLLEnumCallbackA(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) +BOOL STDMETHODCALLTYPE _DSDLLEnumCallbackA(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) { #ifdef _DEBUG if (g_bLogSystem) @@ -252,7 +254,7 @@ BOOL STDMETHODCALLTYPE DSDLLEnumCallbackA(LPGUID lpGuid, LPCSTR lpcstrDescriptio return g_pAppDSEnumCallbackA(lpGuid, lpcstrDescription, lpcstrModule, lpContext); } -BOOL STDMETHODCALLTYPE DSDLLEnumCallbackW(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR lpcstrModule, LPVOID lpContext) +BOOL STDMETHODCALLTYPE _DSDLLEnumCallbackW(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR lpcstrModule, LPVOID lpContext) { #ifdef _DEBUG if (g_bLogSystem) @@ -266,7 +268,7 @@ BOOL STDMETHODCALLTYPE DSDLLEnumCallbackW(LPGUID lpGuid, LPCWSTR lpcstrDescripti return g_pAppDSEnumCallbackW(lpGuid, lpcstrDescription, lpcstrModule, lpContext); } -HRESULT STDMETHODCALLTYPE DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext) +HRESULT STDMETHODCALLTYPE _DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext) { #ifdef _DEBUG if (g_bLogSystem) @@ -277,10 +279,10 @@ HRESULT STDMETHODCALLTYPE DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallbac g_pAppDSEnumCallbackA = pDSEnumCallback; - return g_pDirectSoundEnumerateAfunc((LPDSENUMCALLBACKA)DSDLLEnumCallbackA, pContext); + return g_pDirectSoundEnumerateAfunc((LPDSENUMCALLBACKA)_DSDLLEnumCallbackA, pContext); } -HRESULT STDMETHODCALLTYPE DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext) +HRESULT STDMETHODCALLTYPE _DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext) { #ifdef _DEBUG if (g_bLogSystem) @@ -291,10 +293,10 @@ HRESULT STDMETHODCALLTYPE DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallbac g_pAppDSEnumCallbackW = pDSEnumCallback; - return g_pDirectSoundEnumerateWfunc((LPDSENUMCALLBACKW)DSDLLEnumCallbackW, pContext); + return g_pDirectSoundEnumerateWfunc((LPDSENUMCALLBACKW)_DSDLLEnumCallbackW, pContext); } -HRESULT STDMETHODCALLTYPE DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter) +HRESULT STDMETHODCALLTYPE _DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter) { #ifdef _DEBUG if (g_bLogSystem) @@ -306,7 +308,7 @@ HRESULT STDMETHODCALLTYPE DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIREC return g_pDirectSoundCaptureCreatefunc(pcGuidDevice, ppDSC, pUnkOuter); } -HRESULT STDMETHODCALLTYPE DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext) +HRESULT STDMETHODCALLTYPE _DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext) { #ifdef _DEBUG if (g_bLogSystem) @@ -318,7 +320,7 @@ HRESULT STDMETHODCALLTYPE DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnum return g_pDirectSoundCaptureEnumerateAfunc(pDSEnumCallback, pContext); } -HRESULT STDMETHODCALLTYPE DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext) +HRESULT STDMETHODCALLTYPE _DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext) { #ifdef _DEBUG if (g_bLogSystem) @@ -330,7 +332,7 @@ HRESULT STDMETHODCALLTYPE DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnum return g_pDirectSoundCaptureEnumerateWfunc(pDSEnumCallback, pContext); } -HRESULT STDMETHODCALLTYPE DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter) +HRESULT STDMETHODCALLTYPE _DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter) { #ifdef _DEBUG if (g_bLogSystem) @@ -361,7 +363,7 @@ HRESULT STDMETHODCALLTYPE DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND return hRes; } -HRESULT STDMETHODCALLTYPE DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter) +HRESULT STDMETHODCALLTYPE _DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter) { #ifdef _DEBUG if (g_bLogSystem) @@ -373,7 +375,7 @@ HRESULT STDMETHODCALLTYPE DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRE return g_pDirectSoundCaptureCreate8func(pcGuidDevice, ppDSC8, pUnkOuter); } -HRESULT STDMETHODCALLTYPE DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, +HRESULT STDMETHODCALLTYPE _DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter) @@ -391,7 +393,7 @@ HRESULT STDMETHODCALLTYPE DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevic ppDSBuffer8, pUnkOuter); } -HRESULT STDMETHODCALLTYPE GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest) +HRESULT STDMETHODCALLTYPE _GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest) { #ifdef _DEBUG if (g_bLogSystem) @@ -403,7 +405,7 @@ HRESULT STDMETHODCALLTYPE GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest) return g_pGetDeviceIDfunc(pGuidSrc, pGuidDest); } -STDAPI STDMETHODCALLTYPE DllCanUnloadNow_DSoundCtrl() +STDAPI STDMETHODCALLTYPE _DllCanUnloadNow_DSoundCtrl() { #ifdef _DEBUG if (g_bLogSystem) @@ -415,7 +417,7 @@ STDAPI STDMETHODCALLTYPE DllCanUnloadNow_DSoundCtrl() return g_pDllCanUnloadNowfunc(); } -STDAPI STDMETHODCALLTYPE DllGetClassObject_DSoundCtrl(IN REFCLSID rclsid, IN REFIID riid, OUT LPVOID FAR* ppv) +STDAPI STDMETHODCALLTYPE _DllGetClassObject_DSoundCtrl(IN REFCLSID rclsid, IN REFIID riid, OUT LPVOID FAR* ppv) { *ppv = nullptr; @@ -472,7 +474,7 @@ STDAPI STDMETHODCALLTYPE DllGetClassObject_DSoundCtrl(IN REFCLSID rclsid, IN REF return g_pDllGetClassObjectfunc(rclsid, riid, ppv); } -BOOL APIENTRY DllMain_DSoundCtrl(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) +BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) { UNREFERENCED_PARAMETER(lpReserved); @@ -496,22 +498,3 @@ BOOL APIENTRY DllMain_DSoundCtrl(HMODULE hModule, DWORD fdwReason, LPVOID lpRese return TRUE; } - -namespace Wrapper -{ - namespace DSoundCtrl - { - FARPROC _DirectSoundCreate = (FARPROC)*DirectSoundCreate; - FARPROC _DirectSoundEnumerateA = (FARPROC)*DirectSoundEnumerateA; - FARPROC _DirectSoundEnumerateW = (FARPROC)*DirectSoundEnumerateW; - FARPROC _DllCanUnloadNow = (FARPROC)*DllCanUnloadNow_DSoundCtrl; - FARPROC _DllGetClassObject = (FARPROC)*DllGetClassObject_DSoundCtrl; - FARPROC _DirectSoundCaptureCreate = (FARPROC)*DirectSoundCaptureCreate; - FARPROC _DirectSoundCaptureEnumerateA = (FARPROC)*DirectSoundCaptureEnumerateA; - FARPROC _DirectSoundCaptureEnumerateW = (FARPROC)*DirectSoundCaptureEnumerateW; - FARPROC _GetDeviceID = (FARPROC)*GetDeviceID; - FARPROC _DirectSoundFullDuplexCreate = (FARPROC)*DirectSoundFullDuplexCreate; - FARPROC _DirectSoundCreate8 = (FARPROC)*DirectSoundCreate8; - FARPROC _DirectSoundCaptureCreate8 = (FARPROC)*DirectSoundCaptureCreate8; - } -} diff --git a/DSoundCtrl/DSoundCtrlExternal.h b/DSoundCtrl/DSoundCtrlExternal.h index 8d3c3b8b..32356d11 100644 --- a/DSoundCtrl/DSoundCtrlExternal.h +++ b/DSoundCtrl/DSoundCtrlExternal.h @@ -1,3 +1,16 @@ #pragma once -BOOL APIENTRY DllMain_DSoundCtrl(HMODULE, DWORD, LPVOID); \ No newline at end of file +typedef struct IDirectSound *LPDIRECTSOUND; +typedef struct IDirectSound8 *LPDIRECTSOUND8; + +BOOL APIENTRY DllMain_DSoundCtrl(HMODULE, DWORD, LPVOID); +HRESULT STDMETHODCALLTYPE _DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); +HRESULT STDMETHODCALLTYPE _DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter); +STDAPI STDMETHODCALLTYPE _DllGetClassObject_DSoundCtrl(IN REFCLSID rclsid, IN REFIID riid, OUT LPVOID FAR* ppv); + +namespace DSoundCtrl +{ + constexpr FARPROC DirectSoundCreate = (FARPROC)*_DirectSoundCreate; + constexpr FARPROC DirectSoundCreate8 = (FARPROC)*_DirectSoundCreate8; + constexpr FARPROC DllGetClassObject = (FARPROC)*_DllGetClassObject_DSoundCtrl; +} diff --git a/Dllmain/BuildNo.rc b/Dllmain/BuildNo.rc index a244876a..3ee66c58 100644 --- a/Dllmain/BuildNo.rc +++ b/Dllmain/BuildNo.rc @@ -1 +1 @@ -#define BUILD_NUMBER 1594 +#define BUILD_NUMBER 1962 diff --git a/Dllmain/Dllmain.cpp b/Dllmain/Dllmain.cpp index 7eba3622..18835e49 100644 --- a/Dllmain/Dllmain.cpp +++ b/Dllmain/Dllmain.cpp @@ -18,6 +18,8 @@ #include "dxwrapper.h" #include "Wrappers\wrapper.h" #include "Hooking\Hook.h" +#include "D3d8to9\d3d8.h" +#include "D3d9\D3d9External.h" #include "DDrawCompat\DDrawCompatExternal.h" #include "DxWnd\DxWndExternal.h" #include "DSoundCtrl\DSoundCtrlExternal.h" @@ -33,7 +35,6 @@ bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) UNREFERENCED_PARAMETER(lpReserved); static bool FullscreenThreadStartedFlag = false; - static HMODULE dxwnd_dll = nullptr; switch (fdwReason) { @@ -55,9 +56,9 @@ bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) Config.Init(); // Launch processes - if (!Config.szShellPath.empty()) + if (!Config.RunProcess.empty()) { - Utils::Shell(Config.szShellPath.c_str()); + Utils::Shell(Config.RunProcess.c_str()); } // Set application compatibility options @@ -65,12 +66,12 @@ bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) { Utils::WriteMemory::WriteMemory(); } - if (Config.DpiAware) + if (Config.DisableHighDPIScaling) { Utils::DisableHighDPIScaling(); } Utils::SetAppCompat(); - if (Config.Affinity) + if (Config.SingleProcAffinity) { Utils::SetProcessAffinity(); } @@ -79,22 +80,150 @@ bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) Utils::HookExceptionHandler(); } - // Attach real wrapper dll, load custom dlls and load asi plugins - Wrapper::DllAttach(); + // Attach real wrapper dll + if (Config.RealWrapperMode != dtype.dxwrapper) + { + HMODULE dll = Wrapper::CreateWrapper(hModule_dll); + if (dll) + { + Utils::AddHandleToVector(dll, Config.WrapperName.c_str()); + } + } + + // Load custom dlls + if (Config.LoadCustomDllPath.size() != 0) + { + Utils::LoadCustomDll(); + } - // Start compatibility modules + // Load ASI plugins + if (Config.LoadPlugins) + { + Utils::LoadPlugins(); + } + + // Start DDrawCompat module if (Config.DDrawCompat) { + // If wrapper mode is ddraw update wrapper + if (Config.RealWrapperMode == dtype.ddraw) + { + // Update dxwrapper.dll -> DDrawCompat + ddraw::DirectDrawCreate_var = DDrawCompat::DirectDrawCreate; + ddraw::DirectDrawCreateEx_var = DDrawCompat::DirectDrawCreateEx; + ShardProcs::DllGetClassObject_var = DDrawCompat::DllGetClassObject; + } + // Hook ddraw APIs for DDrawCompat + else + { + // Load ddraw procs + HMODULE dll = ddraw::Load(); + if (dll) + { + Utils::AddHandleToVector(dll, dtypename[dtype.ddraw]); + } + + // Hook ddraw.dll -> DDrawCompat + Logging::Log() << "Hooking ddraw.dll APIs..."; + ddraw::DirectDrawCreate_var = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.ddraw], Hook::GetProcAddress(dll, "DirectDrawCreate"), "DirectDrawCreate", DDrawCompat::DirectDrawCreate); + ddraw::DirectDrawCreateEx_var = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.ddraw], Hook::GetProcAddress(dll, "DirectDrawCreateEx"), "DirectDrawCreateEx", DDrawCompat::DirectDrawCreateEx); + ShardProcs::DllGetClassObject_var = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.ddraw], Hook::GetProcAddress(dll, "DllGetClassObject"), "DllGetClassObject", DDrawCompat::DllGetClassObject); + } + + // Start DDrawCompat Config.DDrawCompat = (DllMain_DDrawCompat(hModule_dll, fdwReason, nullptr) == TRUE); } + + // Start D3d8to9 module + if (Config.D3d8to9) + { + // If wrapper mode is d3d8 update wrapper + if (Config.RealWrapperMode == dtype.d3d8) + { + // Update dxwrapper.dll -> D3d8to9 + d3d8::Direct3DCreate8_var = D3d8to9::Direct3DCreate8; + } + // Hook d3d8 APIs for D3d8to9 + else + { + // Load d3d8 + HMODULE dll = Utils::LoadLibrary(dtypename[dtype.d3d8]); + + // Hook d3d8.dll -> D3d8to9 + Logging::Log() << "Hooking d3d8.dll APIs..."; + (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.d3d8], Hook::GetProcAddress(dll, "Direct3DCreate8"), "Direct3DCreate8", D3d8to9::Direct3DCreate8); + } + } + + // Check for d3d9_wrap module + bool StartD3d9Wrap = false; + if (Config.AntiAliasing) + { + StartD3d9Wrap = true; + } +#ifdef D3D9LOGGING + StartD3d9Wrap = true; +#endif // D3D9LOGGING + + // Start d3d9_wrap module + if (StartD3d9Wrap) + { + // Load d3d9 procs + HMODULE dll = Utils::LoadLibrary(dtypename[dtype.d3d9]); + d3d9_wrap::Direct3DCreate9_Proxy = Hook::GetProcAddress(dll, "Direct3DCreate9"); + + // If wrapper mode is d3d9 update wrapper + if (Config.RealWrapperMode == dtype.d3d9) + { + // Update dxwrapper.dll -> d3d9_wrap + d3d8::Direct3DCreate8_var = d3d9_wrap::Direct3DCreate9; + } + // Hook d3d9 APIs for d3d9_wrap + else + { + // Hook d3d9.dll -> d3d9_wrap + Logging::Log() << "Hooking d3d9.dll APIs..."; + d3d9_wrap::Direct3DCreate9_Proxy = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.d3d9], Hook::GetProcAddress(dll, "Direct3DCreate9"), "Direct3DCreate9", d3d9_wrap::Direct3DCreate9); + } + } + + // Start DSoundCtrl module if (Config.DSoundCtrl) { + // If wrapper mode is dsound update wrapper + if (Config.RealWrapperMode == dtype.dsound) + { + // Update dxwrapper.dll -> DSoundCtrl + dsound::DirectSoundCreate_var = DSoundCtrl::DirectSoundCreate; + dsound::DirectSoundCreate8_var = DSoundCtrl::DirectSoundCreate8; + ShardProcs::DllGetClassObject_var = DSoundCtrl::DllGetClassObject; + } + // Hook dsound APIs for DSoundCtrl + else + { + // Load dsound procs + HMODULE dll = dsound::Load(); + if (dll) + { + Utils::AddHandleToVector(dll, dtypename[dtype.dsound]); + } + + // Hook dsound.dll -> DSoundCtrl + Logging::Log() << "Hooking dsound.dll APIs..."; + dsound::DirectSoundCreate_var = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.dsound], Hook::GetProcAddress(dll, "DirectSoundCreate"), "DirectSoundCreate", DSoundCtrl::DirectSoundCreate); + dsound::DirectSoundCreate8_var = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.dsound], Hook::GetProcAddress(dll, "DirectSoundCreate8"), "DirectSoundCreate8", DSoundCtrl::DirectSoundCreate8); + ShardProcs::DllGetClassObject_var = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.dsound], Hook::GetProcAddress(dll, "DllGetClassObject"), "DllGetClassObject", DSoundCtrl::DllGetClassObject); + } + + // Start DSoundCtrl DllMain_DSoundCtrl(hModule, fdwReason, nullptr); } + + // Start DxWnd module if (Config.DxWnd) { // Check if dxwnd.dll exists then load it - dxwnd_dll = LoadLibrary("dxwnd.dll"); + HMODULE dxwnd_dll = Utils::LoadLibrary("dxwnd.dll"); if (dxwnd_dll) { Logging::Log() << "Loading dxwnd"; @@ -172,10 +301,6 @@ bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) { Logging::Log() << "Unloading DxWnd"; DxWndEndHook(); - if (dxwnd_dll) - { - FreeLibrary(dxwnd_dll); - } } // Unload and Unhook DDrawCompat @@ -194,8 +319,8 @@ bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) Logging::Log() << "Unhooking APIs"; Hook::UnhookAll(); - // Unload dlls - Wrapper::DllDetach(); + // Unload loaded dlls + Utils::UnloadAllDlls(); // Unload exception handler if (Config.HandleExceptions) diff --git a/Dllmain/dxwrapper.def b/Dllmain/dxwrapper.def deleted file mode 100644 index 27288d3f..00000000 --- a/Dllmain/dxwrapper.def +++ /dev/null @@ -1,718 +0,0 @@ -LIBRARY "dxwrapper" -EXPORTS - - -; **** -;LIBRARY "dsound" <--- Needs to have the correct ordinals since some programs use the ordinal numbers for dsound APIs -; **** -DirectSoundCreate = FakeDirectSoundCreate @1 -DirectSoundEnumerateA = FakeDirectSoundEnumerateA @2 -DirectSoundEnumerateW = FakeDirectSoundEnumerateW @3 -DllCanUnloadNow = FakeDllCanUnloadNow PRIVATE -DllGetClassObject = FakeDllGetClassObject PRIVATE -DirectSoundCaptureCreate = FakeDirectSoundCaptureCreate @6 -DirectSoundCaptureEnumerateA = FakeDirectSoundCaptureEnumerateA @7 -DirectSoundCaptureEnumerateW = FakeDirectSoundCaptureEnumerateW @8 -GetDeviceID = FakeGetDeviceID @9 -DirectSoundFullDuplexCreate = FakeDirectSoundFullDuplexCreate @10 -DirectSoundCreate8 = FakeDirectSoundCreate8 @11 -DirectSoundCaptureCreate8 = FakeDirectSoundCaptureCreate8 @12 - - -; **** -;LIBRARY "d3d8" -; **** -DebugSetMute = FakeDebugSetMute @13 -Direct3DCreate8 = FakeDirect3DCreate8 @14 -ValidatePixelShader = FakeValidatePixelShader @15 -ValidateVertexShader = FakeValidateVertexShader @16 - - -; **** -;LIBRARY "d3d9" -; **** -Direct3DShaderValidatorCreate9 = FakeDirect3DShaderValidatorCreate9 @17 -PSGPError = FakePSGPError @18 -PSGPSampleTexture = FakePSGPSampleTexture @19 -D3DPERF_BeginEvent = FakeD3DPERF_BeginEvent @20 -D3DPERF_EndEvent = FakeD3DPERF_EndEvent @21 -D3DPERF_GetStatus = FakeD3DPERF_GetStatus @22 -D3DPERF_QueryRepeatFrame = FakeD3DPERF_QueryRepeatFrame @23 -D3DPERF_SetMarker = FakeD3DPERF_SetMarker @24 -D3DPERF_SetOptions = FakeD3DPERF_SetOptions @25 -D3DPERF_SetRegion = FakeD3DPERF_SetRegion @26 -DebugSetLevel = FakeDebugSetLevel @27 -;DebugSetMute = FakeDebugSetMute PRIVATE <--- Shared with d3d9.dll -Direct3D9EnableMaximizedWindowedModeShim = FakeDirect3D9EnableMaximizedWindowedModeShim @28 -Direct3DCreate9 = FakeDirect3DCreate9 @29 -Direct3DCreate9Ex = FakeDirect3DCreate9Ex @30 - - -; **** -;LIBRARY "dinput" -; **** -DirectInputCreateA = FakeDirectInputCreateA @31 -DirectInputCreateEx = FakeDirectInputCreateEx @32 -DirectInputCreateW = FakeDirectInputCreateW @33 -;DllCanUnloadNow = FakeDllCanUnloadNow PRIVATE <--- Shared with dsound.dll -;DllGetClassObject = FakeDllGetClassObject PRIVATE <--- Shared with dsound.dll -DllRegisterServer = FakeDllRegisterServer PRIVATE -DllUnregisterServer = FakeDllUnregisterServer PRIVATE - - -; **** -;LIBRARY dplayx.dll -; **** -DirectPlayCreate = FakeDirectPlayCreate @34 -DirectPlayEnumerate = FakeDirectPlayEnumerate @35 -DirectPlayEnumerateA = FakeDirectPlayEnumerateA @36 -DirectPlayEnumerateW = FakeDirectPlayEnumerateW @37 -DirectPlayLobbyCreateA = FakeDirectPlayLobbyCreateA @38 -DirectPlayLobbyCreateW = FakeDirectPlayLobbyCreateW @40 - - -; **** -;LIBRARY "ddraw" -; **** -AcquireDDThreadLock = FakeAcquireDDThreadLock @41 -CheckFullscreen = FakeCheckFullscreen @42 -CompleteCreateSysmemSurface = FakeCompleteCreateSysmemSurface @43 -D3DParseUnknownCommand = FakeD3DParseUnknownCommand @44 -DDGetAttachedSurfaceLcl = FakeDDGetAttachedSurfaceLcl @45 -DDInternalLock = FakeDDInternalLock @46 -DDInternalUnlock = FakeDDInternalUnlock @47 -DSoundHelp = FakeDSoundHelp @48 -DirectDrawCreate = FakeDirectDrawCreate @49 -DirectDrawCreateClipper = FakeDirectDrawCreateClipper @50 -DirectDrawCreateEx = FakeDirectDrawCreateEx @51 -DirectDrawEnumerateA = FakeDirectDrawEnumerateA @52 -DirectDrawEnumerateExA = FakeDirectDrawEnumerateExA @53 -DirectDrawEnumerateExW = FakeDirectDrawEnumerateExW @54 -DirectDrawEnumerateW = FakeDirectDrawEnumerateW @55 -;DllCanUnloadNow = FakeDllCanUnloadNow PRIVATE <--- Shared with dsound.dll -;DllGetClassObject = FakeDllGetClassObject PRIVATE <--- Shared with dsound.dll -GetDDSurfaceLocal = FakeGetDDSurfaceLocal @56 -GetOLEThunkData = FakeGetOLEThunkData @57 -GetSurfaceFromDC = FakeGetSurfaceFromDC @58 -RegisterSpecialCase = FakeRegisterSpecialCase @59 -ReleaseDDThreadLock = FakeReleaseDDThreadLock @60 -SetAppCompatData = FakeSetAppCompatData @61 - - -; **** -;LIBRARY "dxgi" -; **** -ApplyCompatResolutionQuirking = FakeApplyCompatResolutionQuirking @62 -CompatString = FakeCompatString @63 -CompatValue = FakeCompatValue @64 -DXGIDumpJournal = FakeDXGIDumpJournal @65 -DXGIRevertToSxS = FakeDXGIRevertToSxS @66 -PIXBeginCapture = FakePIXBeginCapture @67 -PIXEndCapture = FakePIXEndCapture @68 -PIXGetCaptureState = FakePIXGetCaptureState @69 -SetAppCompatStringPointer = FakeSetAppCompatStringPointer @70 -CreateDXGIFactory1 = FakeCreateDXGIFactory1 @71 -CreateDXGIFactory2 = FakeCreateDXGIFactory2 @72 -CreateDXGIFactory = FakeCreateDXGIFactory @73 -DXGID3D10CreateDevice = FakeDXGID3D10CreateDevice @74 -DXGID3D10CreateLayeredDevice = FakeDXGID3D10CreateLayeredDevice @75 -DXGID3D10ETWRundown = FakeDXGID3D10ETWRundown @76 -DXGID3D10GetLayeredDeviceSize = FakeDXGID3D10GetLayeredDeviceSize @77 -DXGID3D10RegisterLayers = FakeDXGID3D10RegisterLayers @78 -DXGIGetDebugInterface1 = FakeDXGIGetDebugInterface1 @79 -DXGIReportAdapterConfiguration = FakeDXGIReportAdapterConfiguration @80 -D3DKMTCloseAdapter = FakeD3DKMTCloseAdapter @81 -D3DKMTDestroyAllocation = FakeD3DKMTDestroyAllocation @82 -D3DKMTDestroyContext = FakeD3DKMTDestroyContext @83 -D3DKMTDestroyDevice = FakeD3DKMTDestroyDevice @84 -D3DKMTDestroySynchronizationObject = FakeD3DKMTDestroySynchronizationObject @85 -D3DKMTQueryAdapterInfo = FakeD3DKMTQueryAdapterInfo @86 -D3DKMTSetDisplayPrivateDriverFormat = FakeD3DKMTSetDisplayPrivateDriverFormat @87 -D3DKMTSignalSynchronizationObject = FakeD3DKMTSignalSynchronizationObject @88 -D3DKMTUnlock = FakeD3DKMTUnlock @89 -OpenAdapter10 = FakeOpenAdapter10 @90 -OpenAdapter10_2 = FakeOpenAdapter10_2 @91 -D3DKMTCreateAllocation = FakeD3DKMTCreateAllocation @92 -D3DKMTCreateContext = FakeD3DKMTCreateContext @93 -D3DKMTCreateDevice = FakeD3DKMTCreateDevice @94 -D3DKMTCreateSynchronizationObject = FakeD3DKMTCreateSynchronizationObject @95 -D3DKMTEscape = FakeD3DKMTEscape @96 -D3DKMTGetContextSchedulingPriority = FakeD3DKMTGetContextSchedulingPriority @97 -D3DKMTGetDeviceState = FakeD3DKMTGetDeviceState @98 -D3DKMTGetDisplayModeList = FakeD3DKMTGetDisplayModeList @99 -D3DKMTGetMultisampleMethodList = FakeD3DKMTGetMultisampleMethodList @100 -D3DKMTGetRuntimeData = FakeD3DKMTGetRuntimeData @101 -D3DKMTGetSharedPrimaryHandle = FakeD3DKMTGetSharedPrimaryHandle @102 -D3DKMTLock = FakeD3DKMTLock @103 -D3DKMTOpenAdapterFromHdc = FakeD3DKMTOpenAdapterFromHdc @104 -D3DKMTOpenResource = FakeD3DKMTOpenResource @105 -D3DKMTPresent = FakeD3DKMTPresent @106 -D3DKMTQueryAllocationResidency = FakeD3DKMTQueryAllocationResidency @107 -D3DKMTQueryResourceInfo = FakeD3DKMTQueryResourceInfo @108 -D3DKMTRender = FakeD3DKMTRender @109 -D3DKMTSetAllocationPriority = FakeD3DKMTSetAllocationPriority @110 -D3DKMTSetContextSchedulingPriority = FakeD3DKMTSetContextSchedulingPriority @111 -D3DKMTSetDisplayMode = FakeD3DKMTSetDisplayMode @112 -D3DKMTSetGammaRamp = FakeD3DKMTSetGammaRamp @113 -D3DKMTSetVidPnSourceOwner = FakeD3DKMTSetVidPnSourceOwner @114 -D3DKMTWaitForSynchronizationObject = FakeD3DKMTWaitForSynchronizationObject @115 -D3DKMTWaitForVerticalBlankEvent = FakeD3DKMTWaitForVerticalBlankEvent @116 - - -; **** -;LIBRARY "bcrypt" -; **** -BCryptAddContextFunction = FakeBCryptAddContextFunction @117 -BCryptAddContextFunctionProvider = FakeBCryptAddContextFunctionProvider @118 -BCryptCloseAlgorithmProvider = FakeBCryptCloseAlgorithmProvider @119 -BCryptConfigureContext = FakeBCryptConfigureContext @120 -BCryptConfigureContextFunction = FakeBCryptConfigureContextFunction @121 -BCryptCreateContext = FakeBCryptCreateContext @122 -BCryptCreateHash = FakeBCryptCreateHash @123 -BCryptCreateMultiHash = FakeBCryptCreateMultiHash @124 -BCryptDecrypt = FakeBCryptDecrypt @125 -BCryptDeleteContext = FakeBCryptDeleteContext @126 -BCryptDeriveKey = FakeBCryptDeriveKey @127 -BCryptDeriveKeyCapi = FakeBCryptDeriveKeyCapi @128 -BCryptDeriveKeyPBKDF2 = FakeBCryptDeriveKeyPBKDF2 @129 -BCryptDestroyHash = FakeBCryptDestroyHash @130 -BCryptDestroyKey = FakeBCryptDestroyKey @131 -BCryptDestroySecret = FakeBCryptDestroySecret @132 -BCryptDuplicateHash = FakeBCryptDuplicateHash @133 -BCryptDuplicateKey = FakeBCryptDuplicateKey @134 -BCryptEncrypt = FakeBCryptEncrypt @135 -BCryptEnumAlgorithms = FakeBCryptEnumAlgorithms @136 -BCryptEnumContextFunctionProviders = FakeBCryptEnumContextFunctionProviders @137 -BCryptEnumContextFunctions = FakeBCryptEnumContextFunctions @138 -BCryptEnumContexts = FakeBCryptEnumContexts @139 -BCryptEnumProviders = FakeBCryptEnumProviders @140 -BCryptEnumRegisteredProviders = FakeBCryptEnumRegisteredProviders @141 -BCryptExportKey = FakeBCryptExportKey @142 -BCryptFinalizeKeyPair = FakeBCryptFinalizeKeyPair @143 -BCryptFinishHash = FakeBCryptFinishHash @144 -BCryptFreeBuffer = FakeBCryptFreeBuffer @145 -BCryptGenRandom = FakeBCryptGenRandom @146 -BCryptGenerateKeyPair = FakeBCryptGenerateKeyPair @147 -BCryptGenerateSymmetricKey = FakeBCryptGenerateSymmetricKey @148 -BCryptGetFipsAlgorithmMode = FakeBCryptGetFipsAlgorithmMode @149 -BCryptGetProperty = FakeBCryptGetProperty @150 -BCryptHash = FakeBCryptHash @151 -BCryptHashData = FakeBCryptHashData @152 -BCryptImportKey = FakeBCryptImportKey @153 -BCryptImportKeyPair = FakeBCryptImportKeyPair @154 -BCryptKeyDerivation = FakeBCryptKeyDerivation @155 -BCryptOpenAlgorithmProvider = FakeBCryptOpenAlgorithmProvider @156 -BCryptProcessMultiOperations = FakeBCryptProcessMultiOperations @157 -BCryptQueryContextConfiguration = FakeBCryptQueryContextConfiguration @158 -BCryptQueryContextFunctionConfiguration = FakeBCryptQueryContextFunctionConfiguration @159 -BCryptQueryContextFunctionProperty = FakeBCryptQueryContextFunctionProperty @160 -BCryptQueryProviderRegistration = FakeBCryptQueryProviderRegistration @161 -BCryptRegisterConfigChangeNotify = FakeBCryptRegisterConfigChangeNotify @162 -BCryptRegisterProvider = FakeBCryptRegisterProvider @163 -BCryptRemoveContextFunction = FakeBCryptRemoveContextFunction @164 -BCryptRemoveContextFunctionProvider = FakeBCryptRemoveContextFunctionProvider @165 -BCryptResolveProviders = FakeBCryptResolveProviders @166 -BCryptSecretAgreement = FakeBCryptSecretAgreement @167 -BCryptSetAuditingInterface = FakeBCryptSetAuditingInterface @168 -BCryptSetContextFunctionProperty = FakeBCryptSetContextFunctionProperty @169 -BCryptSetProperty = FakeBCryptSetProperty @170 -BCryptSignHash = FakeBCryptSignHash @171 -BCryptUnregisterConfigChangeNotify = FakeBCryptUnregisterConfigChangeNotify @172 -BCryptUnregisterProvider = FakeBCryptUnregisterProvider @173 -BCryptVerifySignature = FakeBCryptVerifySignature @174 - - -; **** -;LIBRARY "winmm" -; **** -CloseDriver = FakeCloseDriver @175 -DefDriverProc = FakeDefDriverProc @176 -DriverCallback = FakeDriverCallback @177 -DrvGetModuleHandle = FakeDrvGetModuleHandle @178 -GetDriverModuleHandle = FakeGetDriverModuleHandle @179 -NotifyCallbackData = FakeNotifyCallbackData @180 -OpenDriver = FakeOpenDriver @181 -PlaySound = FakePlaySound @182 -PlaySoundA = FakePlaySoundA @183 -PlaySoundW = FakePlaySoundW @184 -SendDriverMessage = FakeSendDriverMessage @185 -WOW32DriverCallback = FakeWOW32DriverCallback @186 -WOW32ResolveMultiMediaHandle = FakeWOW32ResolveMultiMediaHandle @187 -WOWAppExit = FakeWOWAppExit @188 -aux32Message = Fakeaux32Message @189 -auxGetDevCapsA = FakeauxGetDevCapsA @190 -auxGetDevCapsW = FakeauxGetDevCapsW @191 -auxGetNumDevs = FakeauxGetNumDevs @192 -auxGetVolume = FakeauxGetVolume @193 -auxOutMessage = FakeauxOutMessage @194 -auxSetVolume = FakeauxSetVolume @195 -joy32Message = Fakejoy32Message @196 -joyConfigChanged = FakejoyConfigChanged @197 -joyGetDevCapsA = FakejoyGetDevCapsA @198 -joyGetDevCapsW = FakejoyGetDevCapsW @199 -joyGetNumDevs = FakejoyGetNumDevs @200 -joyGetPos = FakejoyGetPos @201 -joyGetPosEx = FakejoyGetPosEx @202 -joyGetThreshold = FakejoyGetThreshold @203 -joyReleaseCapture = FakejoyReleaseCapture @204 -joySetCapture = FakejoySetCapture @205 -joySetThreshold = FakejoySetThreshold @206 -mci32Message = Fakemci32Message @207 -mciDriverNotify = FakemciDriverNotify @208 -mciDriverYield = FakemciDriverYield @209 -mciExecute = FakemciExecute @210 -mciFreeCommandResource = FakemciFreeCommandResource @211 -mciGetCreatorTask = FakemciGetCreatorTask @212 -mciGetDeviceIDA = FakemciGetDeviceIDA @213 -mciGetDeviceIDFromElementIDA = FakemciGetDeviceIDFromElementIDA @214 -mciGetDeviceIDFromElementIDW = FakemciGetDeviceIDFromElementIDW @215 -mciGetDeviceIDW = FakemciGetDeviceIDW @216 -mciGetDriverData = FakemciGetDriverData @217 -mciGetErrorStringA = FakemciGetErrorStringA @218 -mciGetErrorStringW = FakemciGetErrorStringW @219 -mciGetYieldProc = FakemciGetYieldProc @220 -mciLoadCommandResource = FakemciLoadCommandResource @221 -mciSendCommandA = FakemciSendCommandA @222 -mciSendCommandW = FakemciSendCommandW @223 -mciSendStringA = FakemciSendStringA @224 -mciSendStringW = FakemciSendStringW @225 -mciSetDriverData = FakemciSetDriverData @226 -mciSetYieldProc = FakemciSetYieldProc @227 -mid32Message = Fakemid32Message @228 -midiConnect = FakemidiConnect @229 -midiDisconnect = FakemidiDisconnect @230 -midiInAddBuffer = FakemidiInAddBuffer @231 -midiInClose = FakemidiInClose @232 -midiInGetDevCapsA = FakemidiInGetDevCapsA @233 -midiInGetDevCapsW = FakemidiInGetDevCapsW @234 -midiInGetErrorTextA = FakemidiInGetErrorTextA @235 -midiInGetErrorTextW = FakemidiInGetErrorTextW @236 -midiInGetID = FakemidiInGetID @237 -midiInGetNumDevs = FakemidiInGetNumDevs @238 -midiInMessage = FakemidiInMessage @239 -midiInOpen = FakemidiInOpen @240 -midiInPrepareHeader = FakemidiInPrepareHeader @241 -midiInReset = FakemidiInReset @242 -midiInStart = FakemidiInStart @243 -midiInStop = FakemidiInStop @244 -midiInUnprepareHeader = FakemidiInUnprepareHeader @245 -midiOutCacheDrumPatches = FakemidiOutCacheDrumPatches @246 -midiOutCachePatches = FakemidiOutCachePatches @247 -midiOutClose = FakemidiOutClose @248 -midiOutGetDevCapsA = FakemidiOutGetDevCapsA @249 -midiOutGetDevCapsW = FakemidiOutGetDevCapsW @250 -midiOutGetErrorTextA = FakemidiOutGetErrorTextA @251 -midiOutGetErrorTextW = FakemidiOutGetErrorTextW @252 -midiOutGetID = FakemidiOutGetID @253 -midiOutGetNumDevs = FakemidiOutGetNumDevs @254 -midiOutGetVolume = FakemidiOutGetVolume @255 -midiOutLongMsg = FakemidiOutLongMsg @256 -midiOutMessage = FakemidiOutMessage @257 -midiOutOpen = FakemidiOutOpen @258 -midiOutPrepareHeader = FakemidiOutPrepareHeader @259 -midiOutReset = FakemidiOutReset @260 -midiOutSetVolume = FakemidiOutSetVolume @261 -midiOutShortMsg = FakemidiOutShortMsg @262 -midiOutUnprepareHeader = FakemidiOutUnprepareHeader @263 -midiStreamClose = FakemidiStreamClose @264 -midiStreamOpen = FakemidiStreamOpen @265 -midiStreamOut = FakemidiStreamOut @266 -midiStreamPause = FakemidiStreamPause @267 -midiStreamPosition = FakemidiStreamPosition @268 -midiStreamProperty = FakemidiStreamProperty @269 -midiStreamRestart = FakemidiStreamRestart @270 -midiStreamStop = FakemidiStreamStop @271 -mixerClose = FakemixerClose @272 -mixerGetControlDetailsA = FakemixerGetControlDetailsA @273 -mixerGetControlDetailsW = FakemixerGetControlDetailsW @274 -mixerGetDevCapsA = FakemixerGetDevCapsA @275 -mixerGetDevCapsW = FakemixerGetDevCapsW @276 -mixerGetID = FakemixerGetID @277 -mixerGetLineControlsA = FakemixerGetLineControlsA @278 -mixerGetLineControlsW = FakemixerGetLineControlsW @279 -mixerGetLineInfoA = FakemixerGetLineInfoA @280 -mixerGetLineInfoW = FakemixerGetLineInfoW @281 -mixerGetNumDevs = FakemixerGetNumDevs @282 -mixerMessage = FakemixerMessage @283 -mixerOpen = FakemixerOpen @284 -mixerSetControlDetails = FakemixerSetControlDetails @285 -mmDrvInstall = FakemmDrvInstall @286 -mmGetCurrentTask = FakemmGetCurrentTask @287 -mmTaskBlock = FakemmTaskBlock @288 -mmTaskCreate = FakemmTaskCreate @289 -mmTaskSignal = FakemmTaskSignal @290 -mmTaskYield = FakemmTaskYield @291 -mmioAdvance = FakemmioAdvance @292 -mmioAscend = FakemmioAscend @293 -mmioClose = FakemmioClose @294 -mmioCreateChunk = FakemmioCreateChunk @295 -mmioDescend = FakemmioDescend @296 -mmioFlush = FakemmioFlush @297 -mmioGetInfo = FakemmioGetInfo @298 -mmioInstallIOProcA = FakemmioInstallIOProcA @299 -mmioInstallIOProcW = FakemmioInstallIOProcW @300 -mmioOpenA = FakemmioOpenA @301 -mmioOpenW = FakemmioOpenW @302 -mmioRead = FakemmioRead @303 -mmioRenameA = FakemmioRenameA @304 -mmioRenameW = FakemmioRenameW @305 -mmioSeek = FakemmioSeek @306 -mmioSendMessage = FakemmioSendMessage @307 -mmioSetBuffer = FakemmioSetBuffer @308 -mmioSetInfo = FakemmioSetInfo @309 -mmioStringToFOURCCA = FakemmioStringToFOURCCA @310 -mmioStringToFOURCCW = FakemmioStringToFOURCCW @311 -mmioWrite = FakemmioWrite @312 -mmsystemGetVersion = FakemmsystemGetVersion @313 -mod32Message = Fakemod32Message @314 -mxd32Message = Fakemxd32Message @315 -sndPlaySoundA = FakesndPlaySoundA @316 -sndPlaySoundW = FakesndPlaySoundW @317 -tid32Message = Faketid32Message @318 -timeBeginPeriod = FaketimeBeginPeriod @319 -timeEndPeriod = FaketimeEndPeriod @320 -timeGetDevCaps = FaketimeGetDevCaps @321 -timeGetSystemTime = FaketimeGetSystemTime @322 -timeGetTime = FaketimeGetTime @323 -timeKillEvent = FaketimeKillEvent @324 -timeSetEvent = FaketimeSetEvent @325 -waveInAddBuffer = FakewaveInAddBuffer @326 -waveInClose = FakewaveInClose @327 -waveInGetDevCapsA = FakewaveInGetDevCapsA @328 -waveInGetDevCapsW = FakewaveInGetDevCapsW @329 -waveInGetErrorTextA = FakewaveInGetErrorTextA @330 -waveInGetErrorTextW = FakewaveInGetErrorTextW @331 -waveInGetID = FakewaveInGetID @332 -waveInGetNumDevs = FakewaveInGetNumDevs @333 -waveInGetPosition = FakewaveInGetPosition @334 -waveInMessage = FakewaveInMessage @335 -waveInOpen = FakewaveInOpen @336 -waveInPrepareHeader = FakewaveInPrepareHeader @337 -waveInReset = FakewaveInReset @338 -waveInStart = FakewaveInStart @339 -waveInStop = FakewaveInStop @340 -waveInUnprepareHeader = FakewaveInUnprepareHeader @341 -waveOutBreakLoop = FakewaveOutBreakLoop @342 -waveOutClose = FakewaveOutClose @343 -waveOutGetDevCapsA = FakewaveOutGetDevCapsA @344 -waveOutGetDevCapsW = FakewaveOutGetDevCapsW @345 -waveOutGetErrorTextA = FakewaveOutGetErrorTextA @346 -waveOutGetErrorTextW = FakewaveOutGetErrorTextW @347 -waveOutGetID = FakewaveOutGetID @348 -waveOutGetNumDevs = FakewaveOutGetNumDevs @349 -waveOutGetPitch = FakewaveOutGetPitch @350 -waveOutGetPlaybackRate = FakewaveOutGetPlaybackRate @351 -waveOutGetPosition = FakewaveOutGetPosition @352 -waveOutGetVolume = FakewaveOutGetVolume @353 -waveOutMessage = FakewaveOutMessage @354 -waveOutOpen = FakewaveOutOpen @355 -waveOutPause = FakewaveOutPause @356 -waveOutPrepareHeader = FakewaveOutPrepareHeader @357 -waveOutReset = FakewaveOutReset @358 -waveOutRestart = FakewaveOutRestart @359 -waveOutSetPitch = FakewaveOutSetPitch @360 -waveOutSetPlaybackRate = FakewaveOutSetPlaybackRate @361 -waveOutSetVolume = FakewaveOutSetVolume @362 -waveOutUnprepareHeader = FakewaveOutUnprepareHeader @363 -waveOutWrite = FakewaveOutWrite @364 -wid32Message = Fakewid32Message @365 -winmmDbgOut = FakewinmmDbgOut @366 -winmmSetDebugLevel = FakewinmmSetDebugLevel @367 -wod32Message = Fakewod32Message @368 - - -; **** -;LIBRARY "winspool" -; **** -ADVANCEDSETUPDIALOG = FakeADVANCEDSETUPDIALOG @369 -AdvancedSetupDialog = FakeAdvancedSetupDialog @370 -ConvertAnsiDevModeToUnicodeDevmode = FakeConvertAnsiDevModeToUnicodeDevmode @371 -ConvertUnicodeDevModeToAnsiDevmode = FakeConvertUnicodeDevModeToAnsiDevmode @372 -DEVICEMODE = FakeDEVICEMODE @373 -DeviceMode = FakeDeviceMode @374 -DocumentEvent = FakeDocumentEvent @375 -PerfClose = FakePerfClose @376 -PerfCollect = FakePerfCollect @377 -PerfOpen = FakePerfOpen @378 -QueryColorProfile = FakeQueryColorProfile @379 -QueryRemoteFonts = FakeQueryRemoteFonts @380 -QuerySpoolMode = FakeQuerySpoolMode @381 -SpoolerDevQueryPrintW = FakeSpoolerDevQueryPrintW @382 -StartDocDlgW = FakeStartDocDlgW @383 -AbortPrinter = FakeAbortPrinter @384 -AddFormA = FakeAddFormA @385 -AddFormW = FakeAddFormW @386 -AddJobA = FakeAddJobA @387 -AddJobW = FakeAddJobW @388 -AddMonitorA = FakeAddMonitorA @389 -AddMonitorW = FakeAddMonitorW @390 -AddPortA = FakeAddPortA @391 -AddPortExA = FakeAddPortExA @392 -AddPortExW = FakeAddPortExW @393 -AddPortW = FakeAddPortW @394 -AddPrintProcessorA = FakeAddPrintProcessorA @395 -AddPrintProcessorW = FakeAddPrintProcessorW @396 -AddPrintProvidorA = FakeAddPrintProvidorA @397 -AddPrintProvidorW = FakeAddPrintProvidorW @398 -AddPrinterA = FakeAddPrinterA @399 -AddPrinterConnection2A = FakeAddPrinterConnection2A @400 -AddPrinterConnection2W = FakeAddPrinterConnection2W @401 -AddPrinterConnectionA = FakeAddPrinterConnectionA @402 -AddPrinterConnectionW = FakeAddPrinterConnectionW @403 -AddPrinterDriverA = FakeAddPrinterDriverA @404 -AddPrinterDriverExA = FakeAddPrinterDriverExA @405 -AddPrinterDriverExW = FakeAddPrinterDriverExW @406 -AddPrinterDriverW = FakeAddPrinterDriverW @407 -AddPrinterW = FakeAddPrinterW @408 -AdvancedDocumentPropertiesA = FakeAdvancedDocumentPropertiesA @409 -AdvancedDocumentPropertiesW = FakeAdvancedDocumentPropertiesW @410 -ClosePrinter = FakeClosePrinter @411 -CloseSpoolFileHandle = FakeCloseSpoolFileHandle @412 -CommitSpoolData = FakeCommitSpoolData @413 -ConfigurePortA = FakeConfigurePortA @414 -ConfigurePortW = FakeConfigurePortW @415 -ConnectToPrinterDlg = FakeConnectToPrinterDlg @416 -CorePrinterDriverInstalledA = FakeCorePrinterDriverInstalledA @417 -CorePrinterDriverInstalledW = FakeCorePrinterDriverInstalledW @418 -CreatePrintAsyncNotifyChannel = FakeCreatePrintAsyncNotifyChannel @419 -CreatePrinterIC = FakeCreatePrinterIC @420 -DEVICECAPABILITIES = FakeDEVICECAPABILITIES @421 -DeleteFormA = FakeDeleteFormA @422 -DeleteFormW = FakeDeleteFormW @423 -DeleteJobNamedProperty = FakeDeleteJobNamedProperty @424 -DeleteMonitorA = FakeDeleteMonitorA @425 -DeleteMonitorW = FakeDeleteMonitorW @426 -DeletePortA = FakeDeletePortA @427 -DeletePortW = FakeDeletePortW @428 -DeletePrintProcessorA = FakeDeletePrintProcessorA @429 -DeletePrintProcessorW = FakeDeletePrintProcessorW @430 -DeletePrintProvidorA = FakeDeletePrintProvidorA @431 -DeletePrintProvidorW = FakeDeletePrintProvidorW @432 -DeletePrinter = FakeDeletePrinter @433 -DeletePrinterConnectionA = FakeDeletePrinterConnectionA @434 -DeletePrinterConnectionW = FakeDeletePrinterConnectionW @435 -DeletePrinterDataA = FakeDeletePrinterDataA @436 -DeletePrinterDataExA = FakeDeletePrinterDataExA @437 -DeletePrinterDataExW = FakeDeletePrinterDataExW @438 -DeletePrinterDataW = FakeDeletePrinterDataW @439 -DeletePrinterDriverA = FakeDeletePrinterDriverA @440 -DeletePrinterDriverExA = FakeDeletePrinterDriverExA @441 -DeletePrinterDriverExW = FakeDeletePrinterDriverExW @442 -DeletePrinterDriverPackageA = FakeDeletePrinterDriverPackageA @443 -DeletePrinterDriverPackageW = FakeDeletePrinterDriverPackageW @444 -DeletePrinterDriverW = FakeDeletePrinterDriverW @445 -DeletePrinterIC = FakeDeletePrinterIC @446 -DeletePrinterKeyA = FakeDeletePrinterKeyA @447 -DeletePrinterKeyW = FakeDeletePrinterKeyW @448 -DevQueryPrint = FakeDevQueryPrint @449 -DevQueryPrintEx = FakeDevQueryPrintEx @450 -DeviceCapabilities = FakeDeviceCapabilities @451 -DeviceCapabilitiesA = FakeDeviceCapabilitiesA @452 -DeviceCapabilitiesW = FakeDeviceCapabilitiesW @453 -DevicePropertySheets = FakeDevicePropertySheets @454 -DocumentPropertiesA = FakeDocumentPropertiesA @455 -DocumentPropertiesW = FakeDocumentPropertiesW @456 -DocumentPropertySheets = FakeDocumentPropertySheets @457 -EXTDEVICEMODE = FakeEXTDEVICEMODE @458 -EndDocPrinter = FakeEndDocPrinter @459 -EndPagePrinter = FakeEndPagePrinter @460 -EnumFormsA = FakeEnumFormsA @461 -EnumFormsW = FakeEnumFormsW @462 -EnumJobNamedProperties = FakeEnumJobNamedProperties @463 -EnumJobsA = FakeEnumJobsA @464 -EnumJobsW = FakeEnumJobsW @465 -EnumMonitorsA = FakeEnumMonitorsA @466 -EnumMonitorsW = FakeEnumMonitorsW @467 -EnumPortsA = FakeEnumPortsA @468 -GetDefaultPrinterA = FakeGetDefaultPrinterA @469 -SetDefaultPrinterA = FakeSetDefaultPrinterA @470 -GetDefaultPrinterW = FakeGetDefaultPrinterW @471 -SetDefaultPrinterW = FakeSetDefaultPrinterW @472 -EnumPortsW = FakeEnumPortsW @473 -EnumPrintProcessorDatatypesA = FakeEnumPrintProcessorDatatypesA @474 -EnumPrintProcessorDatatypesW = FakeEnumPrintProcessorDatatypesW @475 -EnumPrintProcessorsA = FakeEnumPrintProcessorsA @476 -EnumPrintProcessorsW = FakeEnumPrintProcessorsW @477 -EnumPrinterDataA = FakeEnumPrinterDataA @478 -EnumPrinterDataExA = FakeEnumPrinterDataExA @479 -EnumPrinterDataExW = FakeEnumPrinterDataExW @480 -EnumPrinterDataW = FakeEnumPrinterDataW @481 -EnumPrinterDriversA = FakeEnumPrinterDriversA @482 -EnumPrinterDriversW = FakeEnumPrinterDriversW @483 -EnumPrinterKeyA = FakeEnumPrinterKeyA @484 -EnumPrinterKeyW = FakeEnumPrinterKeyW @485 -EnumPrintersA = FakeEnumPrintersA @486 -EnumPrintersW = FakeEnumPrintersW @487 -ExtDeviceMode = FakeExtDeviceMode @488 -FindClosePrinterChangeNotification = FakeFindClosePrinterChangeNotification @489 -FindFirstPrinterChangeNotification = FakeFindFirstPrinterChangeNotification @490 -FindNextPrinterChangeNotification = FakeFindNextPrinterChangeNotification @491 -FlushPrinter = FakeFlushPrinter @492 -FreePrintNamedPropertyArray = FakeFreePrintNamedPropertyArray @493 -FreePrintPropertyValue = FakeFreePrintPropertyValue @494 -FreePrinterNotifyInfo = FakeFreePrinterNotifyInfo @495 -GetCorePrinterDriversA = FakeGetCorePrinterDriversA @496 -GetCorePrinterDriversW = FakeGetCorePrinterDriversW @497 -GetFormA = FakeGetFormA @498 -GetFormW = FakeGetFormW @499 -GetJobA = FakeGetJobA @500 -GetJobNamedPropertyValue = FakeGetJobNamedPropertyValue @501 -GetJobW = FakeGetJobW @502 -GetPrintExecutionData = FakeGetPrintExecutionData @503 -GetPrintOutputInfo = FakeGetPrintOutputInfo @504 -GetPrintProcessorDirectoryA = FakeGetPrintProcessorDirectoryA @505 -GetPrintProcessorDirectoryW = FakeGetPrintProcessorDirectoryW @506 -GetPrinterA = FakeGetPrinterA @507 -GetPrinterDataA = FakeGetPrinterDataA @508 -GetPrinterDataExA = FakeGetPrinterDataExA @509 -GetPrinterDataExW = FakeGetPrinterDataExW @510 -GetPrinterDataW = FakeGetPrinterDataW @511 -GetPrinterDriver2A = FakeGetPrinterDriver2A @512 -GetPrinterDriver2W = FakeGetPrinterDriver2W @513 -GetPrinterDriverA = FakeGetPrinterDriverA @514 -GetPrinterDriverDirectoryA = FakeGetPrinterDriverDirectoryA @515 -GetPrinterDriverDirectoryW = FakeGetPrinterDriverDirectoryW @516 -GetPrinterDriverPackagePathA = FakeGetPrinterDriverPackagePathA @517 -GetPrinterDriverPackagePathW = FakeGetPrinterDriverPackagePathW @518 -GetPrinterDriverW = FakeGetPrinterDriverW @519 -GetPrinterW = FakeGetPrinterW @520 -GetSpoolFileHandle = FakeGetSpoolFileHandle @521 -InstallPrinterDriverFromPackageA = FakeInstallPrinterDriverFromPackageA @522 -InstallPrinterDriverFromPackageW = FakeInstallPrinterDriverFromPackageW @523 -IsValidDevmodeA = FakeIsValidDevmodeA @524 -IsValidDevmodeW = FakeIsValidDevmodeW @525 -OpenPrinter2A = FakeOpenPrinter2A @526 -OpenPrinter2W = FakeOpenPrinter2W @527 -OpenPrinterA = FakeOpenPrinterA @528 -OpenPrinterW = FakeOpenPrinterW @529 -PlayGdiScriptOnPrinterIC = FakePlayGdiScriptOnPrinterIC @530 -PrinterMessageBoxA = FakePrinterMessageBoxA @531 -PrinterMessageBoxW = FakePrinterMessageBoxW @532 -PrinterProperties = FakePrinterProperties @533 -ReadPrinter = FakeReadPrinter @534 -RegisterForPrintAsyncNotifications = FakeRegisterForPrintAsyncNotifications @535 -ReportJobProcessingProgress = FakeReportJobProcessingProgress @536 -ResetPrinterA = FakeResetPrinterA @537 -ResetPrinterW = FakeResetPrinterW @538 -ScheduleJob = FakeScheduleJob @539 -SeekPrinter = FakeSeekPrinter @540 -SetFormA = FakeSetFormA @541 -SetFormW = FakeSetFormW @542 -SetJobA = FakeSetJobA @543 -SetJobNamedProperty = FakeSetJobNamedProperty @544 -SetJobW = FakeSetJobW @545 -SetPortA = FakeSetPortA @546 -SetPortW = FakeSetPortW @547 -SetPrinterA = FakeSetPrinterA @548 -SetPrinterDataA = FakeSetPrinterDataA @549 -SetPrinterDataExA = FakeSetPrinterDataExA @550 -SetPrinterDataExW = FakeSetPrinterDataExW @551 -SetPrinterDataW = FakeSetPrinterDataW @552 -SetPrinterW = FakeSetPrinterW @553 -SplDriverUnloadComplete = FakeSplDriverUnloadComplete @554 -SpoolerPrinterEvent = FakeSpoolerPrinterEvent @555 -StartDocDlgA = FakeStartDocDlgA @556 -StartDocPrinterA = FakeStartDocPrinterA @557 -StartDocPrinterW = FakeStartDocPrinterW @558 -StartPagePrinter = FakeStartPagePrinter @559 -UnRegisterForPrintAsyncNotifications = FakeUnRegisterForPrintAsyncNotifications @560 -UploadPrinterDriverPackageA = FakeUploadPrinterDriverPackageA @561 -UploadPrinterDriverPackageW = FakeUploadPrinterDriverPackageW @562 -WaitForPrinterChange = FakeWaitForPrinterChange @563 -WritePrinter = FakeWritePrinter @564 -XcvDataW = FakeXcvDataW @565 - - -; **** -;LIBRARY "cryptsp" -; **** -CheckSignatureInFile = FakeCheckSignatureInFile @566 -CryptAcquireContextA = FakeCryptAcquireContextA @567 -CryptAcquireContextW = FakeCryptAcquireContextW @568 -CryptContextAddRef = FakeCryptContextAddRef @569 -CryptCreateHash = FakeCryptCreateHash @570 -CryptDecrypt = FakeCryptDecrypt @571 -CryptDeriveKey = FakeCryptDeriveKey @572 -CryptDestroyHash = FakeCryptDestroyHash @573 -CryptDestroyKey = FakeCryptDestroyKey @574 -CryptDuplicateHash = FakeCryptDuplicateHash @575 -CryptDuplicateKey = FakeCryptDuplicateKey @576 -CryptEncrypt = FakeCryptEncrypt @577 -CryptEnumProviderTypesA = FakeCryptEnumProviderTypesA @578 -CryptEnumProviderTypesW = FakeCryptEnumProviderTypesW @579 -CryptEnumProvidersA = FakeCryptEnumProvidersA @580 -CryptEnumProvidersW = FakeCryptEnumProvidersW @581 -CryptExportKey = FakeCryptExportKey @582 -CryptGenKey = FakeCryptGenKey @583 -CryptGenRandom = FakeCryptGenRandom @584 -CryptGetDefaultProviderA = FakeCryptGetDefaultProviderA @585 -CryptGetDefaultProviderW = FakeCryptGetDefaultProviderW @586 -CryptGetHashParam = FakeCryptGetHashParam @587 -CryptGetKeyParam = FakeCryptGetKeyParam @588 -CryptGetProvParam = FakeCryptGetProvParam @589 -CryptGetUserKey = FakeCryptGetUserKey @590 -CryptHashData = FakeCryptHashData @591 -CryptHashSessionKey = FakeCryptHashSessionKey @592 -CryptImportKey = FakeCryptImportKey @593 -CryptReleaseContext = FakeCryptReleaseContext @594 -CryptSetHashParam = FakeCryptSetHashParam @595 -CryptSetKeyParam = FakeCryptSetKeyParam @596 -CryptSetProvParam = FakeCryptSetProvParam @597 -CryptSetProviderA = FakeCryptSetProviderA @598 -CryptSetProviderExA = FakeCryptSetProviderExA @599 -CryptSetProviderExW = FakeCryptSetProviderExW @600 -CryptSetProviderW = FakeCryptSetProviderW @601 -CryptSignHashA = FakeCryptSignHashA @602 -CryptSignHashW = FakeCryptSignHashW @603 -CryptVerifySignatureA = FakeCryptVerifySignatureA @604 -CryptVerifySignatureW = FakeCryptVerifySignatureW @605 -SystemFunction006 = FakeSystemFunction006 @606 -SystemFunction007 = FakeSystemFunction007 @607 -SystemFunction008 = FakeSystemFunction008 @608 -SystemFunction009 = FakeSystemFunction009 @609 -SystemFunction010 = FakeSystemFunction010 @610 -SystemFunction011 = FakeSystemFunction011 @611 -SystemFunction012 = FakeSystemFunction012 @612 -SystemFunction013 = FakeSystemFunction013 @613 -SystemFunction014 = FakeSystemFunction014 @614 -SystemFunction015 = FakeSystemFunction015 @615 -SystemFunction016 = FakeSystemFunction016 @616 -SystemFunction018 = FakeSystemFunction018 @617 -SystemFunction020 = FakeSystemFunction020 @618 -SystemFunction021 = FakeSystemFunction021 @619 -SystemFunction022 = FakeSystemFunction022 @620 -SystemFunction023 = FakeSystemFunction023 @621 -SystemFunction024 = FakeSystemFunction024 @622 -SystemFunction025 = FakeSystemFunction025 @623 -SystemFunction026 = FakeSystemFunction026 @624 -SystemFunction027 = FakeSystemFunction027 @625 -SystemFunction030 = FakeSystemFunction030 @626 -SystemFunction031 = FakeSystemFunction031 @627 -SystemFunction032 = FakeSystemFunction032 @628 -SystemFunction033 = FakeSystemFunction033 @629 -SystemFunction035 = FakeSystemFunction035 @630 - - -; **** -;LIBRARY "dciman32" -; **** -DCIBeginAccess = FakeDCIBeginAccess @631 -DCICloseProvider = FakeDCICloseProvider @632 -DCICreateOffscreen = FakeDCICreateOffscreen @633 -DCICreateOverlay = FakeDCICreateOverlay @634 -DCICreatePrimary = FakeDCICreatePrimary @635 -DCIDestroy = FakeDCIDestroy @636 -DCIDraw = FakeDCIDraw @637 -DCIEndAccess = FakeDCIEndAccess @638 -DCIEnum = FakeDCIEnum @639 -DCIOpenProvider = FakeDCIOpenProvider @640 -DCISetClipList = FakeDCISetClipList @641 -DCISetDestination = FakeDCISetDestination @642 -DCISetSrcDestClip = FakeDCISetSrcDestClip @643 -GetDCRegionData = FakeGetDCRegionData @644 -GetWindowRegionData = FakeGetWindowRegionData @645 -WinWatchClose = FakeWinWatchClose @646 -WinWatchDidStatusChange = FakeWinWatchDidStatusChange @647 -WinWatchGetClipList = FakeWinWatchGetClipList @648 -WinWatchNotify = FakeWinWatchNotify @649 -WinWatchOpen = FakeWinWatchOpen @650 diff --git a/Dllmain/dxwrapper.h b/Dllmain/dxwrapper.h index 9a164efd..eccc95a6 100644 --- a/Dllmain/dxwrapper.h +++ b/Dllmain/dxwrapper.h @@ -15,12 +15,12 @@ #define APP_MAJOR 1 #define APP_MINOR 0 #define APP_BUILDNUMBER BUILD_NUMBER -#define APP_REVISION 19 +#define APP_REVISION 20 #define APP_COMPANYNAME "Sadrate Presents" -#define APP_DESCRPTION "Wraps or hooks DirectX files to fix compatibility issues in older games. Also allows code to be executed from inside the application. Wraps the following files: d3d8.dll, d3d9.dll, ddraw.dll, dplayx.dll, dsound.dll, dxgi.dll or winmm.dll" +#define APP_DESCRPTION "Wraps or hooks DirectX files to fix compatibility issues in older games. Also allows code to be executed from inside the application. Wraps the following files: bcrypt.dll, cryptsp.dll, d2d1.dll, d3d8.dll, d3d9.dll, d3d10.dll, d3d10core.dll, d3d11.dll, d3d12.dll, d3dim.dll, d3dim700.dll, dciman32.dll, ddraw.dll, dinput.dll, dinput8.dll, dplayx.dll, dsound.dll, dxgi.dll, msacm32.dll, msvfw32.dll, vorbisfile.dll, winmm.dll, winmmbase.dll, winspool.drv and xlive.dll" #define APP_COPYRIGHT "Copyright (C) 2017 Elisha Riedlinger" #define APP_ORIGINALVERSION "dxwrapper.dll" -#define APP_INTERNALNAME "dxwrapper" +#define APP_INTERNALNAME "DxWrapper" // Get APP_VERSION #define _TO_STRING_(x) #x diff --git a/Libraries/d3dx9.cpp b/Libraries/d3dx9.cpp index 3e4499c7..1b2a9a2e 100644 --- a/Libraries/d3dx9.cpp +++ b/Libraries/d3dx9.cpp @@ -15,6 +15,8 @@ */ #include "d3dx9.h" +#include "Settings\Settings.h" +#include "Utils\Utils.h" #include "Logging\Logging.h" typedef HRESULT(WINAPI *PFN_D3DXAssembleShader)(LPCSTR pSrcData, UINT SrcDataLen, const D3DXMACRO *pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, LPD3DXBUFFER *ppShader, LPD3DXBUFFER *ppErrorMsgs); @@ -41,19 +43,19 @@ void Loadd3dx9() static char d3dx9name[MAX_PATH]; if (!d3dx9Module) { + Logging::Log() << "Loading d3dx9_xx.dll"; // Declare d3dx9_xx.dll version for (int x = 99; x > 9 && d3dx9Module == nullptr; x--) { // Get dll name sprintf_s(d3dx9name, "d3dx9_%d.dll", x); // Load dll - d3dx9Module = LoadLibrary(d3dx9name); + d3dx9Module = Utils::LoadLibrary(d3dx9name, false); } } if (d3dx9Module) { - Logging::Log() << "Loaded " << d3dx9name << " library"; D3DXAssembleShaderPtr = reinterpret_cast(GetProcAddress(d3dx9Module, "D3DXAssembleShader")); D3DXDisassembleShaderPtr = reinterpret_cast(GetProcAddress(d3dx9Module, "D3DXDisassembleShader")); D3DXLoadSurfaceFromSurfacePtr = reinterpret_cast(GetProcAddress(d3dx9Module, "D3DXLoadSurfaceFromSurface")); @@ -76,14 +78,6 @@ void Loadd3dx9() } } -void UnLoadd3dx9() -{ - if (d3dx9Module) - { - FreeLibrary(d3dx9Module); - } -} - HRESULT D3DXAssembleShader(LPCSTR pSrcData, UINT SrcDataLen, const D3DXMACRO *pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, LPD3DXBUFFER *ppShader, LPD3DXBUFFER *ppErrorMsgs) { // Load module diff --git a/Libraries/d3dx9.h b/Libraries/d3dx9.h index 9986d51e..00e3c311 100644 --- a/Libraries/d3dx9.h +++ b/Libraries/d3dx9.h @@ -25,8 +25,6 @@ DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; }; -void UnLoadd3dx9(); - HRESULT D3DXAssembleShader(LPCSTR, UINT, const D3DXMACRO *, LPD3DXINCLUDE, DWORD, LPD3DXBUFFER *, LPD3DXBUFFER *); HRESULT D3DXDisassembleShader(const DWORD *, BOOL, LPCSTR, LPD3DXBUFFER *); HRESULT D3DXLoadSurfaceFromSurface(LPDIRECT3DSURFACE9, const PALETTEENTRY *, const RECT *, LPDIRECT3DSURFACE9, const PALETTEENTRY *, const RECT *, DWORD, D3DCOLOR); diff --git a/Libraries/dwmapi.cpp b/Libraries/dwmapi.cpp index e50dc090..4d72fb63 100644 --- a/Libraries/dwmapi.cpp +++ b/Libraries/dwmapi.cpp @@ -14,6 +14,8 @@ * 3. This notice may not be removed or altered from any source distribution. */ +#include "Settings\Settings.h" +#include "Utils\Utils.h" #include "Logging\Logging.h" typedef HRESULT(WINAPI *PFN_DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute); @@ -28,10 +30,9 @@ void Loaddwmapi() return; // Only load the dll once } IsLoaded = true; - dwmapiModule = LoadLibrary("dwmapi.dll"); + dwmapiModule = Utils::LoadLibrary("dwmapi.dll"); if (dwmapiModule) { - Logging::Log() << "Loaded dwmapi.dll library"; DwmSetWindowAttributePtr = reinterpret_cast(GetProcAddress(dwmapiModule, "DwmSetWindowAttribute")); if (!DwmSetWindowAttributePtr) { @@ -44,14 +45,6 @@ void Loaddwmapi() } } -void UnLoaddwmapi() -{ - if (dwmapiModule) - { - FreeLibrary(dwmapiModule); - } -} - HRESULT DwmSetWindowAttribute(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) { // Load module diff --git a/Libraries/dwmapi.h b/Libraries/dwmapi.h index e8eaadbb..d8908f24 100644 --- a/Libraries/dwmapi.h +++ b/Libraries/dwmapi.h @@ -33,6 +33,4 @@ enum DWMNCRENDERINGPOLICY DWMNCRP_LAST }; -void UnLoaddwmapi(); - HRESULT DwmSetWindowAttribute(HWND, DWORD, LPCVOID, DWORD); diff --git a/Libraries/uxtheme.cpp b/Libraries/uxtheme.cpp index 67c1274f..34d4769c 100644 --- a/Libraries/uxtheme.cpp +++ b/Libraries/uxtheme.cpp @@ -14,6 +14,8 @@ * 3. This notice may not be removed or altered from any source distribution. */ +#include "Settings\Settings.h" +#include "Utils\Utils.h" #include "Logging\Logging.h" typedef void(WINAPI *PFN_SetThemeAppProperties)(DWORD dwFlags); @@ -28,10 +30,9 @@ void LoadUxtheme() return; // Only load the dll once } IsLoaded = true; - UxThemeModule = LoadLibrary("uxtheme.dll"); + UxThemeModule = Utils::LoadLibrary("uxtheme.dll"); if (UxThemeModule) { - Logging::Log() << "Loaded uxtheme.dll library"; SetThemeAppPropertiesPtr = reinterpret_cast(GetProcAddress(UxThemeModule, "SetThemeAppProperties")); if (!SetThemeAppPropertiesPtr) { @@ -44,14 +45,6 @@ void LoadUxtheme() } } -void UnLoadUxtheme() -{ - if (UxThemeModule) - { - FreeLibrary(UxThemeModule); - } -} - void SetThemeAppProperties(DWORD dwFlags) { // Load module diff --git a/Libraries/uxtheme.h b/Libraries/uxtheme.h index bb1dcf46..7c3d8127 100644 --- a/Libraries/uxtheme.h +++ b/Libraries/uxtheme.h @@ -1,4 +1,3 @@ #pragma once -void UnLoadUxtheme(); void SetThemeAppProperties(DWORD); \ No newline at end of file diff --git a/Libraries/winmm.cpp b/Libraries/winmm.cpp index 2946afef..8d3a0f58 100644 --- a/Libraries/winmm.cpp +++ b/Libraries/winmm.cpp @@ -16,7 +16,7 @@ #include "winmm.h" #include "Settings\Settings.h" -#include "Wrappers\wrapper.h" +#include "Utils\Utils.h" #include "Logging\Logging.h" typedef MMRESULT(WINAPI *PFN_timeBeginPeriod)(UINT uPeriod); @@ -33,7 +33,7 @@ void Loadwinmm() return; // Only load the dll once } IsLoaded = true; - winmmModule = Wrapper::LoadDll(dtype.winmm); + winmmModule = Utils::LoadLibrary("winmm.dll"); if (winmmModule) { timeBeginPeriodPtr = reinterpret_cast(GetProcAddress(winmmModule, "timeBeginPeriod")); diff --git a/Logging/Logging.h b/Logging/Logging.h index ac283fcc..81dd0349 100644 --- a/Logging/Logging.h +++ b/Logging/Logging.h @@ -4,6 +4,7 @@ //#undef D3D8TO9NOLOG //#define DDRAWCOMPATLOG //#define FULLSCREENLOG +//#define SETTINGSLOG #ifndef DDRAWLOG_H #include "DDrawLog.h" diff --git a/MemoryModule/LICENSE.txt b/MemoryModule/LICENSE.txt new file mode 100644 index 00000000..14e2f777 --- /dev/null +++ b/MemoryModule/LICENSE.txt @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/MemoryModule/MemoryModule.c b/MemoryModule/MemoryModule.c new file mode 100644 index 00000000..d85735b8 --- /dev/null +++ b/MemoryModule/MemoryModule.c @@ -0,0 +1,1090 @@ +/* + * Memory DLL loading code + * Version 0.0.4 + * + * Copyright (c) 2004-2015 by Joachim Bauch / mail@joachim-bauch.de + * http://www.joachim-bauch.de + * + * The contents of this file are subject to the Mozilla Public License Version + * 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is MemoryModule.c + * + * The Initial Developer of the Original Code is Joachim Bauch. + * + * Portions created by Joachim Bauch are Copyright (C) 2004-2015 + * Joachim Bauch. All Rights Reserved. + * + */ + +#include +#include +#include +#include +#ifdef DEBUG_OUTPUT +#include +#endif + +#if _MSC_VER +// Disable warning about data -> function pointer conversion +#pragma warning(disable:4055) + // C4244: conversion from 'uintptr_t' to 'DWORD', possible loss of data. +#pragma warning(error: 4244) +// C4267: conversion from 'size_t' to 'int', possible loss of data. +#pragma warning(error: 4267) + +#define inline __inline +#endif + +#ifndef IMAGE_SIZEOF_BASE_RELOCATION +// Vista SDKs no longer define IMAGE_SIZEOF_BASE_RELOCATION!? +#define IMAGE_SIZEOF_BASE_RELOCATION (sizeof(IMAGE_BASE_RELOCATION)) +#endif + +#ifdef _WIN64 +#define HOST_MACHINE IMAGE_FILE_MACHINE_AMD64 +#else +#define HOST_MACHINE IMAGE_FILE_MACHINE_I386 +#endif + +#include "MemoryModule.h" + +typedef BOOL (WINAPI *DllEntryProc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); +typedef int (WINAPI *ExeEntryProc)(void); + +typedef struct { + PIMAGE_NT_HEADERS headers; + unsigned char *codeBase; + HCUSTOMMODULE *modules; + int numModules; + BOOL initialized; + BOOL isDLL; + BOOL isRelocated; + CustomAllocFunc alloc; + CustomFreeFunc free; + CustomLoadLibraryFunc loadLibrary; + CustomGetProcAddressFunc getProcAddress; + CustomFreeLibraryFunc freeLibrary; + void *userdata; + ExeEntryProc exeEntry; + DWORD pageSize; +} MEMORYMODULE, *PMEMORYMODULE; + +typedef struct { + LPVOID address; + LPVOID alignedAddress; + SIZE_T size; + DWORD characteristics; + BOOL last; +} SECTIONFINALIZEDATA, *PSECTIONFINALIZEDATA; + +#define GET_HEADER_DICTIONARY(module, idx) &(module)->headers->OptionalHeader.DataDirectory[idx] + +static inline uintptr_t +AlignValueDown(uintptr_t value, uintptr_t alignment) { + return value & ~(alignment - 1); +} + +static inline LPVOID +AlignAddressDown(LPVOID address, uintptr_t alignment) { + return (LPVOID) AlignValueDown((uintptr_t) address, alignment); +} + +static inline size_t +AlignValueUp(size_t value, size_t alignment) { + return (value + alignment - 1) & ~(alignment - 1); +} + +static inline void* +OffsetPointer(void* data, ptrdiff_t offset) { + return (void*) ((uintptr_t) data + offset); +} + +static inline void +OutputLastError(const char *msg) +{ +#ifndef DEBUG_OUTPUT + UNREFERENCED_PARAMETER(msg); +#else + LPVOID tmp; + char *tmpmsg; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&tmp, 0, NULL); + tmpmsg = (char *)LocalAlloc(LPTR, strlen(msg) + strlen(tmp) + 3); + sprintf(tmpmsg, "%s: %s", msg, tmp); + OutputDebugString(tmpmsg); + LocalFree(tmpmsg); + LocalFree(tmp); +#endif +} + +static BOOL +CheckSize(size_t size, size_t expected) { + if (size < expected) { + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } + + return TRUE; +} + +static BOOL +CopySections(const unsigned char *data, size_t size, PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module) +{ + int i, section_size; + unsigned char *codeBase = module->codeBase; + unsigned char *dest; + PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers); + for (i=0; iheaders->FileHeader.NumberOfSections; i++, section++) { + if (section->SizeOfRawData == 0) { + // section doesn't contain data in the dll itself, but may define + // uninitialized data + section_size = old_headers->OptionalHeader.SectionAlignment; + if (section_size > 0) { + dest = (unsigned char *)module->alloc(codeBase + section->VirtualAddress, + section_size, + MEM_COMMIT, + PAGE_READWRITE, + module->userdata); + if (dest == NULL) { + return FALSE; + } + + // Always use position from file to support alignments smaller + // than page size (allocation above will align to page size). + dest = codeBase + section->VirtualAddress; + // NOTE: On 64bit systems we truncate to 32bit here but expand + // again later when "PhysicalAddress" is used. + section->Misc.PhysicalAddress = (DWORD) ((uintptr_t) dest & 0xffffffff); + memset(dest, 0, section_size); + } + + // section is empty + continue; + } + + if (!CheckSize(size, section->PointerToRawData + section->SizeOfRawData)) { + return FALSE; + } + + // commit memory block and copy data from dll + dest = (unsigned char *)module->alloc(codeBase + section->VirtualAddress, + section->SizeOfRawData, + MEM_COMMIT, + PAGE_READWRITE, + module->userdata); + if (dest == NULL) { + return FALSE; + } + + // Always use position from file to support alignments smaller + // than page size (allocation above will align to page size). + dest = codeBase + section->VirtualAddress; + memcpy(dest, data + section->PointerToRawData, section->SizeOfRawData); + // NOTE: On 64bit systems we truncate to 32bit here but expand + // again later when "PhysicalAddress" is used. + section->Misc.PhysicalAddress = (DWORD) ((uintptr_t) dest & 0xffffffff); + } + + return TRUE; +} + +// Protection flags for memory pages (Executable, Readable, Writeable) +static int ProtectionFlags[2][2][2] = { + { + // not executable + {PAGE_NOACCESS, PAGE_WRITECOPY}, + {PAGE_READONLY, PAGE_READWRITE}, + }, { + // executable + {PAGE_EXECUTE, PAGE_EXECUTE_WRITECOPY}, + {PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE}, + }, +}; + +static SIZE_T +GetRealSectionSize(PMEMORYMODULE module, PIMAGE_SECTION_HEADER section) { + DWORD size = section->SizeOfRawData; + if (size == 0) { + if (section->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) { + size = module->headers->OptionalHeader.SizeOfInitializedData; + } else if (section->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) { + size = module->headers->OptionalHeader.SizeOfUninitializedData; + } + } + return (SIZE_T) size; +} + +static BOOL +FinalizeSection(PMEMORYMODULE module, PSECTIONFINALIZEDATA sectionData) { + DWORD protect, oldProtect; + BOOL executable; + BOOL readable; + BOOL writeable; + + if (sectionData->size == 0) { + return TRUE; + } + + if (sectionData->characteristics & IMAGE_SCN_MEM_DISCARDABLE) { + // section is not needed any more and can safely be freed + if (sectionData->address == sectionData->alignedAddress && + (sectionData->last || + module->headers->OptionalHeader.SectionAlignment == module->pageSize || + (sectionData->size % module->pageSize) == 0) + ) { + // Only allowed to decommit whole pages + module->free(sectionData->address, sectionData->size, MEM_DECOMMIT, module->userdata); + } + return TRUE; + } + + // determine protection flags based on characteristics + executable = (sectionData->characteristics & IMAGE_SCN_MEM_EXECUTE) != 0; + readable = (sectionData->characteristics & IMAGE_SCN_MEM_READ) != 0; + writeable = (sectionData->characteristics & IMAGE_SCN_MEM_WRITE) != 0; + protect = ProtectionFlags[executable][readable][writeable]; + if (sectionData->characteristics & IMAGE_SCN_MEM_NOT_CACHED) { + protect |= PAGE_NOCACHE; + } + + // change memory access flags + if (VirtualProtect(sectionData->address, sectionData->size, protect, &oldProtect) == 0) { + OutputLastError("Error protecting memory page"); + return FALSE; + } + + return TRUE; +} + +static BOOL +FinalizeSections(PMEMORYMODULE module) +{ + int i; + PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers); +#ifdef _WIN64 + // "PhysicalAddress" might have been truncated to 32bit above, expand to + // 64bits again. + uintptr_t imageOffset = ((uintptr_t) module->headers->OptionalHeader.ImageBase & 0xffffffff00000000); +#else + static const uintptr_t imageOffset = 0; +#endif + SECTIONFINALIZEDATA sectionData; + sectionData.address = (LPVOID)((uintptr_t)section->Misc.PhysicalAddress | imageOffset); + sectionData.alignedAddress = AlignAddressDown(sectionData.address, module->pageSize); + sectionData.size = GetRealSectionSize(module, section); + sectionData.characteristics = section->Characteristics; + sectionData.last = FALSE; + section++; + + // loop through all sections and change access flags + for (i=1; iheaders->FileHeader.NumberOfSections; i++, section++) { + LPVOID sectionAddress = (LPVOID)((uintptr_t)section->Misc.PhysicalAddress | imageOffset); + LPVOID alignedAddress = AlignAddressDown(sectionAddress, module->pageSize); + SIZE_T sectionSize = GetRealSectionSize(module, section); + // Combine access flags of all sections that share a page + // TODO(fancycode): We currently share flags of a trailing large section + // with the page of a first small section. This should be optimized. + if (sectionData.alignedAddress == alignedAddress || (uintptr_t) sectionData.address + sectionData.size > (uintptr_t) alignedAddress) { + // Section shares page with previous + if ((section->Characteristics & IMAGE_SCN_MEM_DISCARDABLE) == 0 || (sectionData.characteristics & IMAGE_SCN_MEM_DISCARDABLE) == 0) { + sectionData.characteristics = (sectionData.characteristics | section->Characteristics) & ~IMAGE_SCN_MEM_DISCARDABLE; + } else { + sectionData.characteristics |= section->Characteristics; + } + sectionData.size = (((uintptr_t)sectionAddress) + ((uintptr_t) sectionSize)) - (uintptr_t) sectionData.address; + continue; + } + + if (!FinalizeSection(module, §ionData)) { + return FALSE; + } + sectionData.address = sectionAddress; + sectionData.alignedAddress = alignedAddress; + sectionData.size = sectionSize; + sectionData.characteristics = section->Characteristics; + } + sectionData.last = TRUE; + if (!FinalizeSection(module, §ionData)) { + return FALSE; + } + return TRUE; +} + +static BOOL +ExecuteTLS(PMEMORYMODULE module) +{ + unsigned char *codeBase = module->codeBase; + PIMAGE_TLS_DIRECTORY tls; + PIMAGE_TLS_CALLBACK* callback; + + PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_TLS); + if (directory->VirtualAddress == 0) { + return TRUE; + } + + tls = (PIMAGE_TLS_DIRECTORY) (codeBase + directory->VirtualAddress); + callback = (PIMAGE_TLS_CALLBACK *) tls->AddressOfCallBacks; + if (callback) { + while (*callback) { + (*callback)((LPVOID) codeBase, DLL_PROCESS_ATTACH, NULL); + callback++; + } + } + return TRUE; +} + +static BOOL +PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta) +{ + unsigned char *codeBase = module->codeBase; + PIMAGE_BASE_RELOCATION relocation; + + PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_BASERELOC); + if (directory->Size == 0) { + return (delta == 0); + } + + relocation = (PIMAGE_BASE_RELOCATION) (codeBase + directory->VirtualAddress); + for (; relocation->VirtualAddress > 0; ) { + DWORD i; + unsigned char *dest = codeBase + relocation->VirtualAddress; + unsigned short *relInfo = (unsigned short*) OffsetPointer(relocation, IMAGE_SIZEOF_BASE_RELOCATION); + for (i=0; i<((relocation->SizeOfBlock-IMAGE_SIZEOF_BASE_RELOCATION) / 2); i++, relInfo++) { + // the upper 4 bits define the type of relocation + int type = *relInfo >> 12; + // the lower 12 bits define the offset + int offset = *relInfo & 0xfff; + + switch (type) + { + case IMAGE_REL_BASED_ABSOLUTE: + // skip relocation + break; + + case IMAGE_REL_BASED_HIGHLOW: + // change complete 32 bit address + { + DWORD *patchAddrHL = (DWORD *) (dest + offset); + *patchAddrHL += (DWORD) delta; + } + break; + +#ifdef _WIN64 + case IMAGE_REL_BASED_DIR64: + { + ULONGLONG *patchAddr64 = (ULONGLONG *) (dest + offset); + *patchAddr64 += (ULONGLONG) delta; + } + break; +#endif + + default: + //printf("Unknown relocation: %d\n", type); + break; + } + } + + // advance to next relocation block + relocation = (PIMAGE_BASE_RELOCATION) OffsetPointer(relocation, relocation->SizeOfBlock); + } + return TRUE; +} + +static BOOL +BuildImportTable(PMEMORYMODULE module) +{ + unsigned char *codeBase = module->codeBase; + PIMAGE_IMPORT_DESCRIPTOR importDesc; + BOOL result = TRUE; + + PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_IMPORT); + if (directory->Size == 0) { + return TRUE; + } + + importDesc = (PIMAGE_IMPORT_DESCRIPTOR) (codeBase + directory->VirtualAddress); + for (; !IsBadReadPtr(importDesc, sizeof(IMAGE_IMPORT_DESCRIPTOR)) && importDesc->Name; importDesc++) { + uintptr_t *thunkRef; + FARPROC *funcRef; + HCUSTOMMODULE *tmp; + HCUSTOMMODULE handle = module->loadLibrary((LPCSTR) (codeBase + importDesc->Name), module->userdata); + if (handle == NULL) { + SetLastError(ERROR_MOD_NOT_FOUND); + result = FALSE; + break; + } + + tmp = (HCUSTOMMODULE *) realloc(module->modules, (module->numModules+1)*(sizeof(HCUSTOMMODULE))); + if (tmp == NULL) { + module->freeLibrary(handle, module->userdata); + SetLastError(ERROR_OUTOFMEMORY); + result = FALSE; + break; + } + module->modules = tmp; + + module->modules[module->numModules++] = handle; + if (importDesc->OriginalFirstThunk) { + thunkRef = (uintptr_t *) (codeBase + importDesc->OriginalFirstThunk); + funcRef = (FARPROC *) (codeBase + importDesc->FirstThunk); + } else { + // no hint table + thunkRef = (uintptr_t *) (codeBase + importDesc->FirstThunk); + funcRef = (FARPROC *) (codeBase + importDesc->FirstThunk); + } + for (; *thunkRef; thunkRef++, funcRef++) { + if (IMAGE_SNAP_BY_ORDINAL(*thunkRef)) { + *funcRef = module->getProcAddress(handle, (LPCSTR)IMAGE_ORDINAL(*thunkRef), module->userdata); + } else { + PIMAGE_IMPORT_BY_NAME thunkData = (PIMAGE_IMPORT_BY_NAME) (codeBase + (*thunkRef)); + *funcRef = module->getProcAddress(handle, (LPCSTR)&thunkData->Name, module->userdata); + } + if (*funcRef == 0) { + result = FALSE; + break; + } + } + + if (!result) { + module->freeLibrary(handle, module->userdata); + SetLastError(ERROR_PROC_NOT_FOUND); + break; + } + } + + return result; +} + +LPVOID MemoryDefaultAlloc(LPVOID address, SIZE_T size, DWORD allocationType, DWORD protect, void* userdata) +{ + UNREFERENCED_PARAMETER(userdata); + return VirtualAlloc(address, size, allocationType, protect); +} + +BOOL MemoryDefaultFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType, void* userdata) +{ + UNREFERENCED_PARAMETER(userdata); + return VirtualFree(lpAddress, dwSize, dwFreeType); +} + +HCUSTOMMODULE MemoryDefaultLoadLibrary(LPCSTR filename, void *userdata) +{ + HMODULE result; + UNREFERENCED_PARAMETER(userdata); + result = LoadLibraryA(filename); + if (result == NULL) { + return NULL; + } + + return (HCUSTOMMODULE) result; +} + +FARPROC MemoryDefaultGetProcAddress(HCUSTOMMODULE module, LPCSTR name, void *userdata) +{ + UNREFERENCED_PARAMETER(userdata); + return (FARPROC) GetProcAddress((HMODULE) module, name); +} + +void MemoryDefaultFreeLibrary(HCUSTOMMODULE module, void *userdata) +{ + UNREFERENCED_PARAMETER(userdata); + FreeLibrary((HMODULE) module); +} + +HMEMORYMODULE MemoryLoadLibrary(const void *data, size_t size) +{ + return MemoryLoadLibraryEx(data, size, MemoryDefaultAlloc, MemoryDefaultFree, MemoryDefaultLoadLibrary, MemoryDefaultGetProcAddress, MemoryDefaultFreeLibrary, NULL); +} + +HMEMORYMODULE MemoryLoadLibraryEx(const void *data, size_t size, + CustomAllocFunc allocMemory, + CustomFreeFunc freeMemory, + CustomLoadLibraryFunc loadLibrary, + CustomGetProcAddressFunc getProcAddress, + CustomFreeLibraryFunc freeLibrary, + void *userdata) +{ + PMEMORYMODULE result = NULL; + PIMAGE_DOS_HEADER dos_header; + PIMAGE_NT_HEADERS old_header; + unsigned char *code, *headers; + ptrdiff_t locationDelta; + SYSTEM_INFO sysInfo; + PIMAGE_SECTION_HEADER section; + DWORD i; + size_t optionalSectionSize; + size_t lastSectionEnd = 0; + size_t alignedImageSize; + + if (!CheckSize(size, sizeof(IMAGE_DOS_HEADER))) { + return NULL; + } + dos_header = (PIMAGE_DOS_HEADER)data; + if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) { + SetLastError(ERROR_BAD_EXE_FORMAT); + return NULL; + } + + if (!CheckSize(size, dos_header->e_lfanew + sizeof(IMAGE_NT_HEADERS))) { + return NULL; + } + old_header = (PIMAGE_NT_HEADERS)&((const unsigned char *)(data))[dos_header->e_lfanew]; + if (old_header->Signature != IMAGE_NT_SIGNATURE) { + SetLastError(ERROR_BAD_EXE_FORMAT); + return NULL; + } + + if (old_header->FileHeader.Machine != HOST_MACHINE) { + SetLastError(ERROR_BAD_EXE_FORMAT); + return NULL; + } + + if (old_header->OptionalHeader.SectionAlignment & 1) { + // Only support section alignments that are a multiple of 2 + SetLastError(ERROR_BAD_EXE_FORMAT); + return NULL; + } + + section = IMAGE_FIRST_SECTION(old_header); + optionalSectionSize = old_header->OptionalHeader.SectionAlignment; + for (i=0; iFileHeader.NumberOfSections; i++, section++) { + size_t endOfSection; + if (section->SizeOfRawData == 0) { + // Section without data in the DLL + endOfSection = section->VirtualAddress + optionalSectionSize; + } else { + endOfSection = section->VirtualAddress + section->SizeOfRawData; + } + + if (endOfSection > lastSectionEnd) { + lastSectionEnd = endOfSection; + } + } + + GetNativeSystemInfo(&sysInfo); + alignedImageSize = AlignValueUp(old_header->OptionalHeader.SizeOfImage, sysInfo.dwPageSize); + if (alignedImageSize != AlignValueUp(lastSectionEnd, sysInfo.dwPageSize)) { + SetLastError(ERROR_BAD_EXE_FORMAT); + return NULL; + } + + // reserve memory for image of library + // XXX: is it correct to commit the complete memory region at once? + // calling DllEntry raises an exception if we don't... + code = (unsigned char *)allocMemory((LPVOID)(old_header->OptionalHeader.ImageBase), + alignedImageSize, + MEM_RESERVE | MEM_COMMIT, + PAGE_READWRITE, + userdata); + + if (code == NULL) { + // try to allocate memory at arbitrary position + code = (unsigned char *)allocMemory(NULL, + alignedImageSize, + MEM_RESERVE | MEM_COMMIT, + PAGE_READWRITE, + userdata); + if (code == NULL) { + SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + } + + result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MEMORYMODULE)); + if (result == NULL) { + freeMemory(code, 0, MEM_RELEASE, userdata); + SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + + result->codeBase = code; + result->isDLL = (old_header->FileHeader.Characteristics & IMAGE_FILE_DLL) != 0; + result->alloc = allocMemory; + result->free = freeMemory; + result->loadLibrary = loadLibrary; + result->getProcAddress = getProcAddress; + result->freeLibrary = freeLibrary; + result->userdata = userdata; + result->pageSize = sysInfo.dwPageSize; + + if (!CheckSize(size, old_header->OptionalHeader.SizeOfHeaders)) { + goto error; + } + + // commit memory for headers + headers = (unsigned char *)allocMemory(code, + old_header->OptionalHeader.SizeOfHeaders, + MEM_COMMIT, + PAGE_READWRITE, + userdata); + + // copy PE header to code + memcpy(headers, dos_header, old_header->OptionalHeader.SizeOfHeaders); + result->headers = (PIMAGE_NT_HEADERS)&((const unsigned char *)(headers))[dos_header->e_lfanew]; + + // update position + result->headers->OptionalHeader.ImageBase = (uintptr_t)code; + + // copy sections from DLL file block to new memory location + if (!CopySections((const unsigned char *) data, size, old_header, result)) { + goto error; + } + + // adjust base address of imported data + locationDelta = (ptrdiff_t)(result->headers->OptionalHeader.ImageBase - old_header->OptionalHeader.ImageBase); + if (locationDelta != 0) { + result->isRelocated = PerformBaseRelocation(result, locationDelta); + } else { + result->isRelocated = TRUE; + } + + // load required dlls and adjust function table of imports + if (!BuildImportTable(result)) { + goto error; + } + + // mark memory pages depending on section headers and release + // sections that are marked as "discardable" + if (!FinalizeSections(result)) { + goto error; + } + + // TLS callbacks are executed BEFORE the main loading + if (!ExecuteTLS(result)) { + goto error; + } + + // get entry point of loaded library + if (result->headers->OptionalHeader.AddressOfEntryPoint != 0) { + if (result->isDLL) { + DllEntryProc DllEntry = (DllEntryProc)(LPVOID)(code + result->headers->OptionalHeader.AddressOfEntryPoint); + // notify library about attaching to process + BOOL successfull = (*DllEntry)((HINSTANCE)code, DLL_PROCESS_ATTACH, 0); + if (!successfull) { + SetLastError(ERROR_DLL_INIT_FAILED); + goto error; + } + result->initialized = TRUE; + } else { + result->exeEntry = (ExeEntryProc)(LPVOID)(code + result->headers->OptionalHeader.AddressOfEntryPoint); + } + } else { + result->exeEntry = NULL; + } + + return (HMEMORYMODULE)result; + +error: + // cleanup + MemoryFreeLibrary(result); + return NULL; +} + +FARPROC MemoryGetProcAddress(HMEMORYMODULE module, LPCSTR name) +{ + unsigned char *codeBase = ((PMEMORYMODULE)module)->codeBase; + DWORD idx = 0; + PIMAGE_EXPORT_DIRECTORY exports; + PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((PMEMORYMODULE)module, IMAGE_DIRECTORY_ENTRY_EXPORT); + if (directory->Size == 0) { + // no export table found + SetLastError(ERROR_PROC_NOT_FOUND); + return NULL; + } + + exports = (PIMAGE_EXPORT_DIRECTORY) (codeBase + directory->VirtualAddress); + if (exports->NumberOfNames == 0 || exports->NumberOfFunctions == 0) { + // DLL doesn't export anything + SetLastError(ERROR_PROC_NOT_FOUND); + return NULL; + } + + if (HIWORD(name) == 0) { + // load function by ordinal value + if (LOWORD(name) < exports->Base) { + SetLastError(ERROR_PROC_NOT_FOUND); + return NULL; + } + + idx = LOWORD(name) - exports->Base; + } else { + // search function name in list of exported names + DWORD i; + DWORD *nameRef = (DWORD *) (codeBase + exports->AddressOfNames); + WORD *ordinal = (WORD *) (codeBase + exports->AddressOfNameOrdinals); + BOOL found = FALSE; + for (i=0; iNumberOfNames; i++, nameRef++, ordinal++) { + if (_stricmp(name, (const char *) (codeBase + (*nameRef))) == 0) { + idx = *ordinal; + found = TRUE; + break; + } + } + + if (!found) { + // exported symbol not found + SetLastError(ERROR_PROC_NOT_FOUND); + return NULL; + } + } + + if (idx > exports->NumberOfFunctions) { + // name <-> ordinal number don't match + SetLastError(ERROR_PROC_NOT_FOUND); + return NULL; + } + + // AddressOfFunctions contains the RVAs to the "real" functions + return (FARPROC)(LPVOID)(codeBase + (*(DWORD *) (codeBase + exports->AddressOfFunctions + (idx*4)))); +} + +void MemoryFreeLibrary(HMEMORYMODULE mod) +{ + PMEMORYMODULE module = (PMEMORYMODULE)mod; + + if (module == NULL) { + return; + } + if (module->initialized) { + // notify library about detaching from process + DllEntryProc DllEntry = (DllEntryProc)(LPVOID)(module->codeBase + module->headers->OptionalHeader.AddressOfEntryPoint); + (*DllEntry)((HINSTANCE)module->codeBase, DLL_PROCESS_DETACH, 0); + } + + if (module->modules != NULL) { + // free previously opened libraries + int i; + for (i=0; inumModules; i++) { + if (module->modules[i] != NULL) { + module->freeLibrary(module->modules[i], module->userdata); + } + } + + free(module->modules); + } + + if (module->codeBase != NULL) { + // release memory of library + module->free(module->codeBase, 0, MEM_RELEASE, module->userdata); + } + + HeapFree(GetProcessHeap(), 0, module); +} + +int MemoryCallEntryPoint(HMEMORYMODULE mod) +{ + PMEMORYMODULE module = (PMEMORYMODULE)mod; + + if (module == NULL || module->isDLL || module->exeEntry == NULL || !module->isRelocated) { + return -1; + } + + return module->exeEntry(); +} + +#define DEFAULT_LANGUAGE MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) + +HMEMORYRSRC MemoryFindResource(HMEMORYMODULE module, LPCTSTR name, LPCTSTR type) +{ + return MemoryFindResourceEx(module, name, type, DEFAULT_LANGUAGE); +} + +static PIMAGE_RESOURCE_DIRECTORY_ENTRY _MemorySearchResourceEntry( + void *root, + PIMAGE_RESOURCE_DIRECTORY resources, + LPCTSTR key) +{ + PIMAGE_RESOURCE_DIRECTORY_ENTRY entries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (resources + 1); + PIMAGE_RESOURCE_DIRECTORY_ENTRY result = NULL; + DWORD start; + DWORD end; + DWORD middle; + + if (!IS_INTRESOURCE(key) && key[0] == TEXT('#')) { + // special case: resource id given as string + TCHAR *endpos = NULL; + long int tmpkey = (WORD) _tcstol((TCHAR *) &key[1], &endpos, 10); + if (tmpkey <= 0xffff && lstrlen(endpos) == 0) { + key = MAKEINTRESOURCE(tmpkey); + } + } + + // entries are stored as ordered list of named entries, + // followed by an ordered list of id entries - we can do + // a binary search to find faster... + if (IS_INTRESOURCE(key)) { + WORD check = (WORD) (uintptr_t) key; + start = resources->NumberOfNamedEntries; + end = start + resources->NumberOfIdEntries; + + while (end > start) { + WORD entryName; + middle = (start + end) >> 1; + entryName = (WORD) entries[middle].Name; + if (check < entryName) { + end = (end != middle ? middle : middle-1); + } else if (check > entryName) { + start = (start != middle ? middle : middle+1); + } else { + result = &entries[middle]; + break; + } + } + } else { + LPCWSTR searchKey; + size_t searchKeyLen = _tcslen(key); +#if defined(UNICODE) + searchKey = key; +#else + // Resource names are always stored using 16bit characters, need to + // convert string we search for. +#define MAX_LOCAL_KEY_LENGTH 2048 + // In most cases resource names are short, so optimize for that by + // using a pre-allocated array. + wchar_t _searchKeySpace[MAX_LOCAL_KEY_LENGTH+1]; + LPWSTR _searchKey; + if (searchKeyLen > MAX_LOCAL_KEY_LENGTH) { + size_t _searchKeySize = (searchKeyLen + 1) * sizeof(wchar_t); + _searchKey = (LPWSTR) malloc(_searchKeySize); + if (_searchKey == NULL) { + SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + } else { + _searchKey = &_searchKeySpace[0]; + } + + mbstowcs(_searchKey, key, searchKeyLen); + _searchKey[searchKeyLen] = 0; + searchKey = _searchKey; +#endif + start = 0; + end = resources->NumberOfNamedEntries; + while (end > start) { + int cmp; + PIMAGE_RESOURCE_DIR_STRING_U resourceString; + middle = (start + end) >> 1; + resourceString = (PIMAGE_RESOURCE_DIR_STRING_U) OffsetPointer(root, entries[middle].Name & 0x7FFFFFFF); + cmp = _wcsnicmp(searchKey, resourceString->NameString, resourceString->Length); + if (cmp == 0) { + // Handle partial match + if (searchKeyLen > resourceString->Length) { + cmp = 1; + } else if (searchKeyLen < resourceString->Length) { + cmp = -1; + } + } + if (cmp < 0) { + end = (middle != end ? middle : middle-1); + } else if (cmp > 0) { + start = (middle != start ? middle : middle+1); + } else { + result = &entries[middle]; + break; + } + } +#if !defined(UNICODE) + if (searchKeyLen > MAX_LOCAL_KEY_LENGTH) { + free(_searchKey); + } +#undef MAX_LOCAL_KEY_LENGTH +#endif + } + + return result; +} + +HMEMORYRSRC MemoryFindResourceEx(HMEMORYMODULE module, LPCTSTR name, LPCTSTR type, WORD language) +{ + unsigned char *codeBase = ((PMEMORYMODULE) module)->codeBase; + PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((PMEMORYMODULE) module, IMAGE_DIRECTORY_ENTRY_RESOURCE); + PIMAGE_RESOURCE_DIRECTORY rootResources; + PIMAGE_RESOURCE_DIRECTORY nameResources; + PIMAGE_RESOURCE_DIRECTORY typeResources; + PIMAGE_RESOURCE_DIRECTORY_ENTRY foundType; + PIMAGE_RESOURCE_DIRECTORY_ENTRY foundName; + PIMAGE_RESOURCE_DIRECTORY_ENTRY foundLanguage; + if (directory->Size == 0) { + // no resource table found + SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); + return NULL; + } + + if (language == DEFAULT_LANGUAGE) { + // use language from current thread + language = LANGIDFROMLCID(GetThreadLocale()); + } + + // resources are stored as three-level tree + // - first node is the type + // - second node is the name + // - third node is the language + rootResources = (PIMAGE_RESOURCE_DIRECTORY) (codeBase + directory->VirtualAddress); + foundType = _MemorySearchResourceEntry(rootResources, rootResources, type); + if (foundType == NULL) { + SetLastError(ERROR_RESOURCE_TYPE_NOT_FOUND); + return NULL; + } + + typeResources = (PIMAGE_RESOURCE_DIRECTORY) (codeBase + directory->VirtualAddress + (foundType->OffsetToData & 0x7fffffff)); + foundName = _MemorySearchResourceEntry(rootResources, typeResources, name); + if (foundName == NULL) { + SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND); + return NULL; + } + + nameResources = (PIMAGE_RESOURCE_DIRECTORY) (codeBase + directory->VirtualAddress + (foundName->OffsetToData & 0x7fffffff)); + foundLanguage = _MemorySearchResourceEntry(rootResources, nameResources, (LPCTSTR) (uintptr_t) language); + if (foundLanguage == NULL) { + // requested language not found, use first available + if (nameResources->NumberOfIdEntries == 0) { + SetLastError(ERROR_RESOURCE_LANG_NOT_FOUND); + return NULL; + } + + foundLanguage = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (nameResources + 1); + } + + return (codeBase + directory->VirtualAddress + (foundLanguage->OffsetToData & 0x7fffffff)); +} + +DWORD MemorySizeofResource(HMEMORYMODULE module, HMEMORYRSRC resource) +{ + PIMAGE_RESOURCE_DATA_ENTRY entry; + UNREFERENCED_PARAMETER(module); + entry = (PIMAGE_RESOURCE_DATA_ENTRY) resource; + if (entry == NULL) { + return 0; + } + + return entry->Size; +} + +LPVOID MemoryLoadResource(HMEMORYMODULE module, HMEMORYRSRC resource) +{ + unsigned char *codeBase = ((PMEMORYMODULE) module)->codeBase; + PIMAGE_RESOURCE_DATA_ENTRY entry = (PIMAGE_RESOURCE_DATA_ENTRY) resource; + if (entry == NULL) { + return NULL; + } + + return codeBase + entry->OffsetToData; +} + +int +MemoryLoadString(HMEMORYMODULE module, UINT id, LPTSTR buffer, int maxsize) +{ + return MemoryLoadStringEx(module, id, buffer, maxsize, DEFAULT_LANGUAGE); +} + +int +MemoryLoadStringEx(HMEMORYMODULE module, UINT id, LPTSTR buffer, int maxsize, WORD language) +{ + HMEMORYRSRC resource; + PIMAGE_RESOURCE_DIR_STRING_U data; + DWORD size; + if (maxsize == 0) { + return 0; + } + + resource = MemoryFindResourceEx(module, MAKEINTRESOURCE((id >> 4) + 1), RT_STRING, language); + if (resource == NULL) { + buffer[0] = 0; + return 0; + } + + data = (PIMAGE_RESOURCE_DIR_STRING_U) MemoryLoadResource(module, resource); + id = id & 0x0f; + while (id--) { + data = (PIMAGE_RESOURCE_DIR_STRING_U) OffsetPointer(data, (data->Length + 1) * sizeof(WCHAR)); + } + if (data->Length == 0) { + SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND); + buffer[0] = 0; + return 0; + } + + size = data->Length; + if (size >= (DWORD) maxsize) { + size = maxsize; + } else { + buffer[size] = 0; + } +#if defined(UNICODE) + wcsncpy_s(buffer, size + sizeof *buffer, data->NameString, size); +#else + wcstombs(buffer, data->NameString, size); +#endif + return size; +} + +#ifdef TESTSUITE +#include + +#ifndef PRIxPTR +#ifdef _WIN64 +#define PRIxPTR "I64x" +#else +#define PRIxPTR "x" +#endif +#endif + +static const uintptr_t AlignValueDownTests[][3] = { + {16, 16, 16}, + {17, 16, 16}, + {32, 16, 32}, + {33, 16, 32}, +#ifdef _WIN64 + {0x12345678abcd1000, 0x1000, 0x12345678abcd1000}, + {0x12345678abcd101f, 0x1000, 0x12345678abcd1000}, +#endif + {0, 0, 0}, +}; + +static const uintptr_t AlignValueUpTests[][3] = { + {16, 16, 16}, + {17, 16, 32}, + {32, 16, 32}, + {33, 16, 48}, +#ifdef _WIN64 + {0x12345678abcd1000, 0x1000, 0x12345678abcd1000}, + {0x12345678abcd101f, 0x1000, 0x12345678abcd2000}, +#endif + {0, 0, 0}, +}; + +BOOL MemoryModuleTestsuite() { + BOOL success = TRUE; + size_t idx; + for (idx = 0; AlignValueDownTests[idx][0]; ++idx) { + const uintptr_t* tests = AlignValueDownTests[idx]; + uintptr_t value = AlignValueDown(tests[0], tests[1]); + if (value != tests[2]) { + printf("AlignValueDown failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n", + tests[0], tests[1], tests[2], value); + success = FALSE; + } + } + for (idx = 0; AlignValueDownTests[idx][0]; ++idx) { + const uintptr_t* tests = AlignValueUpTests[idx]; + uintptr_t value = AlignValueUp(tests[0], tests[1]); + if (value != tests[2]) { + printf("AlignValueUp failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n", + tests[0], tests[1], tests[2], value); + success = FALSE; + } + } + if (success) { + printf("OK\n"); + } + return success; +} +#endif diff --git a/MemoryModule/MemoryModule.h b/MemoryModule/MemoryModule.h new file mode 100644 index 00000000..a728f6b1 --- /dev/null +++ b/MemoryModule/MemoryModule.h @@ -0,0 +1,168 @@ +/* + * Memory DLL loading code + * Version 0.0.4 + * + * Copyright (c) 2004-2015 by Joachim Bauch / mail@joachim-bauch.de + * http://www.joachim-bauch.de + * + * The contents of this file are subject to the Mozilla Public License Version + * 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is MemoryModule.h + * + * The Initial Developer of the Original Code is Joachim Bauch. + * + * Portions created by Joachim Bauch are Copyright (C) 2004-2015 + * Joachim Bauch. All Rights Reserved. + * + */ + +#ifndef __MEMORY_MODULE_HEADER +#define __MEMORY_MODULE_HEADER + +#include + +typedef void *HMEMORYMODULE; + +typedef void *HMEMORYRSRC; + +typedef void *HCUSTOMMODULE; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef LPVOID (*CustomAllocFunc)(LPVOID, SIZE_T, DWORD, DWORD, void*); +typedef BOOL (*CustomFreeFunc)(LPVOID, SIZE_T, DWORD, void*); +typedef HCUSTOMMODULE (*CustomLoadLibraryFunc)(LPCSTR, void *); +typedef FARPROC (*CustomGetProcAddressFunc)(HCUSTOMMODULE, LPCSTR, void *); +typedef void (*CustomFreeLibraryFunc)(HCUSTOMMODULE, void *); + +/** + * Load EXE/DLL from memory location with the given size. + * + * All dependencies are resolved using default LoadLibrary/GetProcAddress + * calls through the Windows API. + */ +HMEMORYMODULE MemoryLoadLibrary(const void *, size_t); + +/** + * Load EXE/DLL from memory location with the given size using custom dependency + * resolvers. + * + * Dependencies will be resolved using passed callback methods. + */ +HMEMORYMODULE MemoryLoadLibraryEx(const void *, size_t, + CustomAllocFunc, + CustomFreeFunc, + CustomLoadLibraryFunc, + CustomGetProcAddressFunc, + CustomFreeLibraryFunc, + void *); + +/** + * Get address of exported method. Supports loading both by name and by + * ordinal value. + */ +FARPROC MemoryGetProcAddress(HMEMORYMODULE, LPCSTR); + +/** + * Free previously loaded EXE/DLL. + */ +void MemoryFreeLibrary(HMEMORYMODULE); + +/** + * Execute entry point (EXE only). The entry point can only be executed + * if the EXE has been loaded to the correct base address or it could + * be relocated (i.e. relocation information have not been stripped by + * the linker). + * + * Important: calling this function will not return, i.e. once the loaded + * EXE finished running, the process will terminate. + * + * Returns a negative value if the entry point could not be executed. + */ +int MemoryCallEntryPoint(HMEMORYMODULE); + +/** + * Find the location of a resource with the specified type and name. + */ +HMEMORYRSRC MemoryFindResource(HMEMORYMODULE, LPCTSTR, LPCTSTR); + +/** + * Find the location of a resource with the specified type, name and language. + */ +HMEMORYRSRC MemoryFindResourceEx(HMEMORYMODULE, LPCTSTR, LPCTSTR, WORD); + +/** + * Get the size of the resource in bytes. + */ +DWORD MemorySizeofResource(HMEMORYMODULE, HMEMORYRSRC); + +/** + * Get a pointer to the contents of the resource. + */ +LPVOID MemoryLoadResource(HMEMORYMODULE, HMEMORYRSRC); + +/** + * Load a string resource. + */ +int MemoryLoadString(HMEMORYMODULE, UINT, LPTSTR, int); + +/** + * Load a string resource with a given language. + */ +int MemoryLoadStringEx(HMEMORYMODULE, UINT, LPTSTR, int, WORD); + +/** +* Default implementation of CustomAllocFunc that calls VirtualAlloc +* internally to allocate memory for a library +* +* This is the default as used by MemoryLoadLibrary. +*/ +LPVOID MemoryDefaultAlloc(LPVOID, SIZE_T, DWORD, DWORD, void *); + +/** +* Default implementation of CustomFreeFunc that calls VirtualFree +* internally to free the memory used by a library +* +* This is the default as used by MemoryLoadLibrary. +*/ +BOOL MemoryDefaultFree(LPVOID, SIZE_T, DWORD, void *); + +/** + * Default implementation of CustomLoadLibraryFunc that calls LoadLibraryA + * internally to load an additional libary. + * + * This is the default as used by MemoryLoadLibrary. + */ +HCUSTOMMODULE MemoryDefaultLoadLibrary(LPCSTR, void *); + +/** + * Default implementation of CustomGetProcAddressFunc that calls GetProcAddress + * internally to get the address of an exported function. + * + * This is the default as used by MemoryLoadLibrary. + */ +FARPROC MemoryDefaultGetProcAddress(HCUSTOMMODULE, LPCSTR, void *); + +/** + * Default implementation of CustomFreeLibraryFunc that calls FreeLibrary + * internally to release an additional libary. + * + * This is the default as used by MemoryLoadLibrary. + */ +void MemoryDefaultFreeLibrary(HCUSTOMMODULE, void *); + +#ifdef __cplusplus +} +#endif + +#endif // __MEMORY_MODULE_HEADER diff --git a/README.md b/README.md index bf5299d0..adb37646 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DxWrapper ### Introduction -DxWrapper is a dll file designed to wrap or hook DirectX (or other) files to fix compatibility issues in older games. This project is primarily targeted to fixing compatibility issues with running games on Windows 10, ideally by simply dropping a dll file and ini file into the game folder. A secondary purpose for this is to offer a single tool (one stop shop, so to speak) by combining several other projects into one. So far this dll can wrap the following files: bcrypt.dll, cryptsp.dll, d3d8.dll, d3d9.dll, dciman32.dll, ddraw.dll, dinput.dll, dplayx.dll, dsound.dll, dxgi.dll, winmm.dll or winspool.drv +DxWrapper is a dll file designed to wrap or hook DirectX (or other) files to fix compatibility issues in older games. This project is primarily targeted to fixing compatibility issues with running games on Windows 10, ideally by simply dropping a dll file and ini file into the game folder. A secondary purpose for this is to offer a single tool (one stop shop, so to speak) by combining several other projects into one. ### Features DxWrapper has a number of features that it includes. Below is a list of features: @@ -41,6 +41,35 @@ Delete DxWrapper dll files and the ini files from the game's directory. You can To configure DxWrapper you just need to edit the ini file and enable the settings you want. See the [Configuration wiki](https://github.com/elishacloud/dxwrapper/wiki/Configuration) for more details. +### Supported DLLs + +DxWrapper can wrap the following dlls: + - bcrypt.dll + - cryptsp.dll + - d2d1.dll + - d3d8.dll + - d3d9.dll + - d3d10.dll + - d3d10core.dll + - d3d11.dll + - d3d12.dll + - d3dim.dll + - d3dim700.dll + - dciman32.dll + - ddraw.dll + - dinput.dll + - dinput8.dll + - dplayx.dll + - dsound.dll + - dxgi.dll + - msacm32.dll + - msvfw32.dll + - vorbisfile.dll + - winmm.dll + - winmmbase.dll + - winspool.drv + - xlive.dll + ### License Copyright (C) 2017 Elisha Riedlinger @@ -53,7 +82,7 @@ This software is provided 'as-is', without any express or implied warranty. In n DxWrapper uses code from several other projects. So to give credit where credit is due, below is a list of locations that source code was taken from: - [DDrawCompat](https://github.com/narzoul/DDrawCompat/): Includes the full DDrawCompat version 2.0b and 2.1. - - [DxWnd](https://sourceforge.net/projects/dxwnd/): Includes code from the proxy dll and exception handling. + - [DxWnd](https://sourceforge.net/projects/dxwnd/): Includes code from the proxy dll and exception handling. - [OllyDbg](http://www.ollydbg.de/): Includes the full cmdlist.c and disasm.c (disasm.dll) code used for exception handling. - [d3d8to9](https://github.com/crosire/d3d8to9): Includes the full Direct3D 8 to Direct3D 9 code. - [DSoundCtrl](https://github.com/nRaecheR/DirectSoundControl): Includes the full DirectSoundControl code. @@ -61,9 +90,10 @@ DxWrapper uses code from several other projects. So to give credit where credit - [Direct3D9 Wrapper DLL](https://gist.github.com/shaunlebron/3854bf4eec5bec297907): Includes the full wrapper code used for logging and manipulating Direct3D9 calls, such as enabling Anti-Aliasing. - [WineD3D d3d8.dll](https://github.com/alexhenrie/wine/tree/master/dlls/d3d8): Includes functions ValidatePixelShader and ValidateVertexShader. - [Ultimate ASI Loader](https://github.com/ThirteenAG/Ultimate-ASI-Loader): Includes code for loading ASI pluggins. + - [MemoryModule](https://github.com/fancycode/MemoryModule): Includes code for loading libraries from memory. - [Parsing PE export table](http://www.rohitab.com/discuss/topic/40594-parsing-pe-export-table/): Includes the full GetProcAddress. - [How do I programmatically get the version of a DLL or EXE file?](https://stackoverflow.com/questions/940707/how-do-i-programmatically-get-the-version-of-a-dll-or-exe-file): Includes code for getting the version of an EXE file. - - http://www.blitzbasic.com/Community/post.php?topic=99477&post=1202996: Used date here to create ability to set all 12 SetAppCompatData settings. + - hxxp://www.blitzbasic.com/Community/post.php?topic=99477&post=1202996 (site no longer exists): Used date here to create ability to set all 12 SetAppCompatData settings. ### Development DxWrapper is mostly written in C++ using Microsoft Visual Studio Community 2015. diff --git a/Settings/AllSettings.ini b/Settings/AllSettings.ini index be51df98..681544e4 100644 --- a/Settings/AllSettings.ini +++ b/Settings/AllSettings.ini @@ -6,14 +6,13 @@ ExcludeProcess = IncludeProcess = RunProcess = WaitForProcess = 0 -WrapperMode = 255 [Compatibility] AntiAliasing = 0 D3d8to9 = 0 DDrawCompat = 0 DDrawCompatDisableGDIHook = 0 -DisableHighDpiScaling = 0 +DisableHighDPIScaling = 0 DSoundCtrl = 0 DxWnd = 0 ForceTermination = 0 diff --git a/Settings/Settings.cpp b/Settings/Settings.cpp index a8335a0f..17aff20d 100644 --- a/Settings/Settings.cpp +++ b/Settings/Settings.cpp @@ -13,7 +13,7 @@ * being the original software. * 3. This notice may not be removed or altered from any source distribution. * -* Code in EraseCppComments, Parse, Read, ParseCallback and strippath functions taken from source code found in Aqrit's ddwrapper +* Code in EraseCppComments, Parse, Read and ParseCallback functions taken from source code found in Aqrit's ddwrapper * http://bitpatch.com/ddwrapper.html */ @@ -29,31 +29,53 @@ CONFIG Config; namespace Settings { // Declare varables - size_t AddressPointerCount = 0; // Count of addresses to hot patch - size_t BytesToWriteCount = 0; // Count of bytes to hot patch - std::vector szExclude; // List of excluded applications - std::vector szInclude; // List of included applications + size_t AddressPointerCount = 0; // Count of addresses to hot patch + size_t BytesToWriteCount = 0; // Count of bytes to hot patch // Function declarations void DeleteMemoryInfoVector(); void EraseCppComments(char*); void Parse(char*, NV); char* Read(char*); - void SetConfig(std::string&, char*); - void SetAddressPointerList(MEMORYINFO&, char*); - void SetBytesList(MEMORYINFO&, char*); bool IsValueEnabled(char*); - void LogSetting(char*, char*); + void ClearValue(void**); + void ClearValue(std::vector*); + void ClearValue(std::string*); + void ClearValue(DWORD*); + void ClearValue(bool*); + void SetValue(char*, char*, MEMORYINFO*); + void SetValue(char*, char*, void**); + void SetValue(char*, char*, std::string*); void SetValue(char*, char*, DWORD*); void SetValue(char*, char*, bool*); void __stdcall ParseCallback(char*, char*); - void strippath(char*); void ClearConfigSettings(); + void SetDefaultConfigSettings(); void GetWrapperMode(); } +#define SET_VALUE(functionName) \ + if (!_strcmpi(name, #functionName)) \ + { \ + SetValue(name, value, &Config.functionName); \ + return; \ + } + +#define SET_APPCOMPATDATA_VALUE(functionName) \ + if (!_strcmpi(name, #functionName)) \ + { \ + SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.functionName]); \ + return; \ + } + +#define CLEAR_VALUE(functionName) \ + ClearValue(&Config.functionName); + +#define CLEAR_APPCOMPATDATA_VALUE(functionName) \ + ClearValue(&Config.DXPrimaryEmulation[AppCompatDataType.functionName]); + // Checks if a string value exists in a string array -bool Settings::IfStringExistsInList(char* szValue, std::vector szList, bool CaseSensitive) +bool Settings::IfStringExistsInList(const char* szValue, std::vector szList, bool CaseSensitive) { for (UINT x = 0; x < szList.size(); ++x) { @@ -77,14 +99,24 @@ bool Settings::IfStringExistsInList(char* szValue, std::vector szLi // Deletes all BytesToWrite values from the BytesToWrite array void Settings::DeleteMemoryInfoVector() { + // Delete Verification memory bytes + if (Config.VerifyMemoryInfo.Bytes) + { + delete[] Config.VerifyMemoryInfo.Bytes; + Config.VerifyMemoryInfo.SizeOfBytes = 0; + } + + // Delete bytes to write while (Config.MemoryInfo.size() != 0) { if (Config.MemoryInfo.back().Bytes) { - delete [] Config.MemoryInfo.back().Bytes; + delete[] Config.MemoryInfo.back().Bytes; } Config.MemoryInfo.pop_back(); } + + // Set array size to zero AddressPointerCount = 0; BytesToWriteCount = 0; } @@ -208,41 +240,22 @@ char* Settings::Read(char* szFileName) return szCfg; } -// Set config from string (file) -void Settings::SetConfig(std::string& name, char* value) -{ - name.append(value); -} - -// Set config from string (file) -void Settings::SetConfigList(std::vector& name, char* value) -{ - std::string newString; - newString.append(value); - name.push_back(newString); -} - -// Set AddressPointer array from string (file) -void Settings::SetAddressPointerList(MEMORYINFO& MemoryInfo, char* value) +// Set booloean value from string (file) +bool Settings::IsValueEnabled(char* name) { - // Get address pointer - if (strtoul(value, nullptr, 16) > 0 && // Verify pointer has a value higher than 0 - value[0] == '0' && (char)tolower(value[1]) == 'x') // Check for leading "0x" to indicate hex number - { - MemoryInfo.AddressPointer = strtoul(value, nullptr, 16); - } - // Set to 0 if invalid address pointer - else - { - MemoryInfo.AddressPointer = 0; - } + return (atoi(name) > 0 || + _strcmpi("on", name) == 0 || + _strcmpi("yes", name) == 0 || + _strcmpi("true", name) == 0 || + _strcmpi("enabled", name) == 0); } -// Set BytesToWrite to memory from string (file) -void Settings::SetBytesList(MEMORYINFO& MemoryInfo, char* value) +// Set value for MEMORYINFO +void Settings::SetValue(char* name, char* value, MEMORYINFO* MemoryInfo) { // Declare vars char charTemp[] = { '0', 'x', '0' , '0' }; + char *charEnd = &charTemp[3]; DWORD len = strlen(value); // Check for valid bytes @@ -252,37 +265,69 @@ void Settings::SetBytesList(MEMORYINFO& MemoryInfo, char* value) { // Get bytes size DWORD size = (len / 2) - 1; - MemoryInfo.Bytes = new byte[size]; - MemoryInfo.SizeOfBytes = size; + MemoryInfo->Bytes = new byte[size]; + MemoryInfo->SizeOfBytes = size; // Get byte data for (DWORD x = 1; x <= size; x++) { charTemp[2] = value[x * 2]; charTemp[3] = value[(x * 2) + 1]; - MemoryInfo.Bytes[x - 1] = (byte)strtoul(charTemp, nullptr, 16); + MemoryInfo->Bytes[x - 1] = (byte)strtoul(charTemp, &charEnd, 16); } +#ifdef SETTINGSLOG + std::string buffer((size + 2) * 2, '\0'); + for (size_t j = 0; j < size; j++) + { + sprintf_s(&buffer[2 * j], 3, "%02X", MemoryInfo->Bytes[j]); + } + Logging::Log() << name << " set to '" << buffer.c_str() << "'"; +#else + UNREFERENCED_PARAMETER(name); +#endif } } -// Set booloean value from string (file) -bool Settings::IsValueEnabled(char* name) +// Set value for pointers +void Settings::SetValue(char* name, char* value, void** setting) { - return (atoi(name) > 0 || - _strcmpi("on", name) == 0 || - _strcmpi("yes", name) == 0 || - _strcmpi("true", name) == 0 || - _strcmpi("enabled", name) == 0); + // Set to zero + *setting = nullptr; + + // Get address pointer + if (strtoul(value, nullptr, 16) > 0 && // Verify pointer has a value higher than 0 + value[0] == '0' && (char)tolower(value[1]) == 'x') // Check for leading "0x" to indicate hex number + { + *setting = (void*)strtoul(value, nullptr, 16); + } +#ifdef SETTINGSLOG + Logging::Log() << name << " set to '" << *setting << "'"; +#else + UNREFERENCED_PARAMETER(name); +#endif } -// Log setting value for bool -void Settings::LogSetting(char* name, char* value) +// Set value for vector of strings +void Settings::SetValue(char* name, char* value, std::vector* setting) { -#ifdef _DEBUG - Logging::Log() << name << " set to '" << value << "'"; + std::string newString; + newString.assign(value); + setting->push_back(newString); +#ifdef SETTINGSLOG + Logging::Log() << name << " set to '" << setting->back().c_str() << "'"; +#else + UNREFERENCED_PARAMETER(name); +#endif +} + +// Set value for string +void Settings::SetValue(char* name, char* value, std::string* setting) +{ + setting->assign(value); +#ifdef SETTINGSLOG + Logging::Log() << name << " set to '" << setting->c_str() << "'"; #else UNREFERENCED_PARAMETER(name); - UNREFERENCED_PARAMETER(value); #endif } @@ -292,12 +337,12 @@ void Settings::SetValue(char* name, char* value, DWORD* setting) DWORD NewValue = atoi(value); if (*setting != NewValue) { -#ifdef _DEBUG - Logging::Log() << name << " set to '" << NewValue << "'"; + *setting = NewValue; +#ifdef SETTINGSLOG + Logging::Log() << name << " set to '" << *setting << "'"; #else UNREFERENCED_PARAMETER(name); #endif - *setting = NewValue; } } @@ -307,14 +352,14 @@ void Settings::SetValue(char* name, char* value, bool* setting) bool NewValue = IsValueEnabled(value); if (*setting != NewValue) { -#ifdef _DEBUG + *setting = NewValue; +#ifdef SETTINGSLOG char* NewValueText = "false"; - if (NewValue) NewValueText = "true"; + if (*setting) NewValueText = "true"; Logging::Log() << name << " set to '" << NewValueText << "'"; #else UNREFERENCED_PARAMETER(name); #endif - *setting = NewValue; } } @@ -333,300 +378,40 @@ void __stdcall Settings::ParseCallback(char* name, char* value) { return; } - // Boolean values + + // Check for the existance of certian values if (!_strcmpi(name, "SingleProcAffinity")) { - // Sets Affinity and AffinityNotSet flags - SetValue(name, value, &Config.Affinity); - Config.AffinityNotSet = false; - return; - } - if (!_strcmpi(name, "D3d8to9")) - { - SetValue(name, value, &Config.D3d8to9); - return; - } - if (!_strcmpi(name, "DDrawCompat")) - { - SetValue(name, value, &Config.DDrawCompat); - return; - } - if (!_strcmpi(name, "DDrawCompatDisableGDIHook")) - { - SetValue(name, value, &Config.DDrawCompatDisableGDIHook); - return; - } - if (!_strcmpi(name, "DisableHighDpiScaling")) - { - SetValue(name, value, &Config.DpiAware); - return; - } - if (!_strcmpi(name, "DSoundCtrl")) - { - SetValue(name, value, &Config.DSoundCtrl); - return; - } - if (!_strcmpi(name, "DxWnd")) - { - SetValue(name, value, &Config.DxWnd); - return; - } - if (!_strcmpi(name, "FullScreen")) - { - SetValue(name, value, &Config.FullScreen); - return; - } - if (!_strcmpi(name, "ForceTermination")) - { - SetValue(name, value, &Config.ForceTermination); - return; - } - if (!_strcmpi(name, "ForceWindowResize")) - { - SetValue(name, value, &Config.ForceWindowResize); - return; - } - if (!_strcmpi(name, "HandleExceptions")) - { - SetValue(name, value, &Config.HandleExceptions); - return; - } - if (!_strcmpi(name, "LoadPlugins")) - { - SetValue(name, value, &Config.LoadPlugins); - return; - } - if (!_strcmpi(name, "LoadFromScriptsOnly")) - { - SetValue(name, value, &Config.LoadFromScriptsOnly); - return; - } - if (!_strcmpi(name, "ResetScreenRes")) - { - SetValue(name, value, &Config.ResetScreenRes); - return; - } - if (!_strcmpi(name, "SendAltEnter")) - { - SetValue(name, value, &Config.SendAltEnter); - return; - } - if (!_strcmpi(name, "WaitForProcess")) - { - SetValue(name, value, &Config.WaitForProcess); - return; - } - if (!_strcmpi(name, "WaitForWindowChanges")) - { - SetValue(name, value, &Config.WaitForWindowChanges); - return; - } - // DSoundCtrl - if (!_strcmpi(name, "Num2DBuffers")) - { - SetValue(name, value, &Config.Num2DBuffers); - return; - } - if (!_strcmpi(name, "Num3DBuffers")) - { - SetValue(name, value, &Config.Num3DBuffers); - return; - } - if (!_strcmpi(name, "ForceCertification")) - { - SetValue(name, value, &Config.ForceCertification); - return; - } - if (!_strcmpi(name, "ForceExclusiveMode")) - { - SetValue(name, value, &Config.ForceExclusiveMode); - return; - } - if (!_strcmpi(name, "ForceSoftwareMixing")) - { - SetValue(name, value, &Config.ForceSoftwareMixing); - return; - } - if (!_strcmpi(name, "ForceHardwareMixing")) - { - SetValue(name, value, &Config.ForceHardwareMixing); - return; - } - if (!_strcmpi(name, "PreventSpeakerSetup")) - { - SetValue(name, value, &Config.PreventSpeakerSetup); - return; + Config.SingleProcAffinityNotSet = false; } - if (!_strcmpi(name, "ForceHQ3DSoftMixing")) - { - SetValue(name, value, &Config.ForceHQ3DSoftMixing); - return; - } - if (!_strcmpi(name, "ForceNonStaticBuffers")) - { - SetValue(name, value, &Config.ForceNonStaticBuffers); - return; - } - if (!_strcmpi(name, "ForceVoiceManagement")) - { - SetValue(name, value, &Config.ForceVoiceManagement); - return; - } - if (!_strcmpi(name, "ForcePrimaryBufferFormat")) - { - SetValue(name, value, &Config.ForcePrimaryBufferFormat); - return; - } - if (!_strcmpi(name, "PrimaryBufferBits")) - { - SetValue(name, value, &Config.PrimaryBufferBits); - return; - } - if (!_strcmpi(name, "PrimaryBufferSamples")) - { - SetValue(name, value, &Config.PrimaryBufferSamples); - return; - } - if (!_strcmpi(name, "PrimaryBufferChannels")) - { - SetValue(name, value, &Config.PrimaryBufferChannels); - return; - } - if (!_strcmpi(name, "ForceSpeakerConfig")) - { - SetValue(name, value, &Config.ForceSpeakerConfig); - return; - } - if (!_strcmpi(name, "SpeakerConfig")) - { - SetValue(name, value, &Config.SpeakerConfig); - return; - } - if (!_strcmpi(name, "StoppedDriverWorkaround")) - { - SetValue(name, value, &Config.StoppedDriverWorkaround); - return; - } - // AppCompatData - if (!_strcmpi(name, "LockEmulation")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.LockEmulation]); - return; - } - if (!_strcmpi(name, "BltEmulation")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.BltEmulation]); - return; - } - if (!_strcmpi(name, "ForceLockNoWindow")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.ForceLockNoWindow]); - return; - } - if (!_strcmpi(name, "ForceBltNoWindow")) + if (!_strcmpi(name, "DisableMaxWindowedMode")) { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.ForceBltNoWindow]); - return; + Config.DisableMaxWindowedModeNotSet = false; } + + // Set Value of normal config settings + VISIT_CONFIG_SETTINGS(SET_VALUE); + + // Set Value of AppCompatData LockColorkey setting if (!_strcmpi(name, "LockColorkey")) { - // Sets DXPrimaryEmulation and LockColorkey SetValue(name, value, &Config.LockColorkey); Config.DXPrimaryEmulation[AppCompatDataType.LockColorkey] = true; return; } - if (!_strcmpi(name, "FullscreenWithDWM")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.FullscreenWithDWM]); - return; - } - if (!_strcmpi(name, "DisableLockEmulation")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.DisableLockEmulation]); - return; - } - if (!_strcmpi(name, "EnableOverlays")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.EnableOverlays]); - return; - } - if (!_strcmpi(name, "DisableSurfaceLocks")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.DisableSurfaceLocks]); - return; - } - if (!_strcmpi(name, "RedirectPrimarySurfBlts")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.RedirectPrimarySurfBlts]); - return; - } - if (!_strcmpi(name, "StripBorderStyle")) - { - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.StripBorderStyle]); - return; - } - if (!_strcmpi(name, "DisableMaxWindowedMode")) - { - // Sets DisableMaxWindowedMode and DisableMaxWindowedModeNotSet flags - SetValue(name, value, &Config.DXPrimaryEmulation[AppCompatDataType.DisableMaxWindowedMode]); - Config.DisableMaxWindowedModeNotSet = false; - return; - } - // Numeric values - if (!_strcmpi(name, "LoopSleepTime")) - { - SetValue(name, value, &Config.LoopSleepTime); - return; - } - if (!_strcmpi(name, "ResetMemoryAfter")) - { - SetValue(name, value, &Config.ResetMemoryAfter); - return; - } - if (!_strcmpi(name, "WindowSleepTime")) - { - SetValue(name, value, &Config.WindowSleepTime); - return; - } - if (!_strcmpi(name, "SetFullScreenLayer")) - { - SetValue(name, value, &Config.SetFullScreenLayer); - return; - } - if (!_strcmpi(name, "AntiAliasing")) - { - SetValue(name, value, &Config.AntiAliasing); - return; - } - if (!_strcmpi(name, "WrapperMode")) - { - SetValue(name, value, &Config.WrapperMode); - return; - } - // String values - if (!_strcmpi(name, "RealDllPath")) - { - SetConfig(Config.szDllPath, value); - LogSetting(name, value); - return; - } - if (!_strcmpi(name, "RunProcess")) - { - SetConfig(Config.szShellPath, value); - LogSetting(name, value); - return; - } - // Memory Hack items + + // Set Value of AppCompatData config settings + VISIT_APPCOMPATDATA_SETTINGS(SET_APPCOMPATDATA_VALUE); + + // Set Value of Memory Hack config settings if (!_strcmpi(name, "VerificationAddress")) { - SetAddressPointerList(Config.VerifyMemoryInfo, value); - LogSetting(name, value); + SetValue(name, value, &Config.VerifyMemoryInfo.AddressPointer); return; } if (!_strcmpi(name, "VerificationBytes")) { - SetBytesList(Config.VerifyMemoryInfo, value); - LogSetting(name, value); + SetValue(name, value, &Config.VerifyMemoryInfo); return; } if (!_strcmpi(name, "AddressPointer")) @@ -636,8 +421,7 @@ void __stdcall Settings::ParseCallback(char* name, char* value) MEMORYINFO newMemoryInfo; Config.MemoryInfo.push_back(newMemoryInfo); } - SetAddressPointerList(Config.MemoryInfo[AddressPointerCount++], value); - LogSetting(name, value); + SetValue(name, value, &Config.MemoryInfo[AddressPointerCount++].AddressPointer); return; } if (!_strcmpi(name, "BytesToWrite")) @@ -647,147 +431,69 @@ void __stdcall Settings::ParseCallback(char* name, char* value) MEMORYINFO newMemoryInfo; Config.MemoryInfo.push_back(newMemoryInfo); } - SetBytesList(Config.MemoryInfo[BytesToWriteCount++], value); - LogSetting(name, value); - return; - } - // Lists of values - if (!_strcmpi(name, "LoadCustomDllPath")) - { - SetConfigList(Config.szCustomDllPath, value); - LogSetting(name, value); - return; - } - if (!_strcmpi(name, "SetNamedLayer")) - { - SetConfigList(Config.szSetNamedLayer, value); - LogSetting(name, value); - return; - } - if (!_strcmpi(name, "IgnoreWindowName")) - { - SetConfigList(Config.szIgnoreWindowName, value); - LogSetting(name, value); - return; - } - if (!_strcmpi(name, "ExcludeProcess")) - { - SetConfigList(szExclude, value); - LogSetting(name, value); - return; - } - if (!_strcmpi(name, "IncludeProcess")) - { - SetConfigList(szInclude, value); - LogSetting(name, value); + SetValue(name, value, &Config.MemoryInfo[BytesToWriteCount++]); return; } + // Logging Logging::Log() << "Warning. Config setting not recognized: " << name; } -// Strip path from a string -void Settings::strippath(char* str) +// Clear pointers +void Settings::ClearValue(void** setting) { - int ch = '\\'; - size_t len; - char* pdest; - char* inpfile = nullptr; + *setting = nullptr; +} - // Search backwards for last backslash in filepath - pdest = strrchr(str, ch); +// Clear vector of strings +void Settings::ClearValue(std::vector* setting) +{ + setting->clear(); +} - // if backslash not found in filepath - if (!pdest) - { - return; - } - else - { - pdest++; // Skip the backslash itself. - } +// Clear strings +void Settings::ClearValue(std::string* setting) +{ + setting->clear(); +} - // extract filename from file path - len = strlen(pdest) + 1; - inpfile = (char*)malloc(len); // Make space for the zero. - strcpy_s(inpfile, len, pdest); // Copy. - strcpy_s(str, len, inpfile); // Copy back. - free(inpfile); // Free memory after malloc. - return; +// Clear DWORD +void Settings::ClearValue(DWORD* setting) +{ + *setting = 0; } -// Set default values +// Clear bool +void Settings::ClearValue(bool* setting) +{ + *setting = false; +} + +// Clear all values void Settings::ClearConfigSettings() { // Cleanup memory (needs to be done first) Config.CleanUp(); - // Clear Config values - Config.Affinity = false; - Config.AffinityNotSet = true; // Default to 'true' until we know it is set - Config.D3d8to9 = false; - Config.DDrawCompat = false; - Config.DDrawCompatDisableGDIHook = false; - Config.DpiAware = false; - Config.DSoundCtrl = false; - Config.DxWnd = false; - Config.FullScreen = false; - Config.ForceTermination = false; - Config.ForceWindowResize = false; - Config.HandleExceptions = false; - Config.LoadPlugins = false; - Config.LoadFromScriptsOnly = false; - Config.ResetScreenRes = false; - Config.SendAltEnter = false; - Config.WaitForProcess = false; - Config.WaitForWindowChanges = false; - // Numeric values - Config.LoopSleepTime = 0; - Config.ResetMemoryAfter = 0; - Config.WindowSleepTime = 0; - Config.SetFullScreenLayer = 0; - Config.AntiAliasing = 0; - // DSoundCtrl - Config.Num2DBuffers = 0; - Config.Num3DBuffers = 0; - Config.ForceCertification = false; - Config.ForceExclusiveMode = false; - Config.ForceSoftwareMixing = false; - Config.ForceHardwareMixing = false; - Config.PreventSpeakerSetup = false; - Config.ForceHQ3DSoftMixing = false; - Config.ForceNonStaticBuffers = false; - Config.ForceVoiceManagement = false; - Config.ForcePrimaryBufferFormat = false; - Config.PrimaryBufferBits = 16; - Config.PrimaryBufferSamples = 44100; - Config.PrimaryBufferChannels = 2; - Config.ForceSpeakerConfig = false; - Config.SpeakerConfig = 6; - Config.StoppedDriverWorkaround = false; - // String of values - Config.szShellPath.clear(); - // AppCompatData - Config.DisableMaxWindowedModeNotSet = true; // Default to 'true' until we know it is set - for (UINT x = 0; x < 13; x++) - { - Config.DXPrimaryEmulation[x] = false; - } - Config.LockColorkey = 0; + + // Clear normal config settings + VISIT_CONFIG_SETTINGS(CLEAR_VALUE); + + // Set Value of AppCompatData config settings + VISIT_APPCOMPATDATA_SETTINGS(CLEAR_APPCOMPATDATA_VALUE); + + // Default to 'true' until we know it is set + Config.DisableMaxWindowedModeNotSet = true; + Config.SingleProcAffinityNotSet = true; } // Get wrapper mode based on dll name void Settings::GetWrapperMode() { - char buffer[MAX_PATH]; - Config.RealWrapperMode = dtype.Auto; - GetModuleFileNameA(hModule_dll, buffer, sizeof(buffer)); - strippath(buffer); - // Check each wrapper library for (UINT x = 0; x < dtypeArraySize; ++x) { // Check dll name - if (_strcmpi(buffer, dtypename[x]) == 0) + if (_strcmpi(Config.WrapperName.c_str(), dtypename[x]) == 0) { // Set RealWrapperMode Config.RealWrapperMode = x; @@ -796,18 +502,42 @@ void Settings::GetWrapperMode() } // Special for winmm.dll because sometimes it is changed to win32 or winnm or some other name - if (strlen(buffer) > 8) - { - buffer[3] = 'm'; - buffer[4] = 'm'; - } - if (_strcmpi(buffer, dtypename[dtype.winmm]) == 0) - { - // Set RealWrapperMode - Config.RealWrapperMode = dtype.winmm; + if (Config.WrapperName.size() > 8) + { + if (dtypename[dtype.winmm][0] == Config.WrapperName[0] && + dtypename[dtype.winmm][1] == Config.WrapperName[1] && + dtypename[dtype.winmm][2] == Config.WrapperName[2] && + dtypename[dtype.winmm][5] == Config.WrapperName[5] && + dtypename[dtype.winmm][6] == Config.WrapperName[6] && + dtypename[dtype.winmm][7] == Config.WrapperName[7] && + dtypename[dtype.winmm][8] == Config.WrapperName[8]) + { + // Set RealWrapperMode + Config.RealWrapperMode = dtype.winmm; + return; + } } } +// Set default values +void Settings::SetDefaultConfigSettings() +{ + // Set defaults + Config.DisableHighDPIScaling = true; + Config.DxWnd = true; + Config.HandleExceptions = true; + Config.LoopSleepTime = 120; + Config.WindowSleepTime = 500; + + // Set other default values + Config.PrimaryBufferBits = 16; + Config.PrimaryBufferSamples = 44100; + Config.PrimaryBufferChannels = 2; + Config.SpeakerConfig = 6; + SetValue("ExcludeProcess", "dxwnd.exe", &Config.ExcludeProcess); + SetValue("ExcludeProcess", "dgVoodooSetup.exe", &Config.ExcludeProcess); +} + void CONFIG::CleanUp() { using namespace Settings; @@ -821,35 +551,45 @@ void CONFIG::Init() // Reset all values ClearConfigSettings(); - // Get wrapper mode from dll name - GetWrapperMode(); - Config.WrapperMode = Config.RealWrapperMode; + // Get module handle + HMODULE hModule = NULL; + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)Settings::GetWrapperMode, &hModule); - // Set defaults - Config.DpiAware = true; - Config.DxWnd = true; - Config.HandleExceptions = true; - Config.LoopSleepTime = 120; - Config.WindowSleepTime = 500; - SetConfigList(szExclude, "dxwnd.exe"); - SetConfigList(szExclude, "dgVoodooSetup.exe"); + // Get module name + char wrappername[MAX_PATH]; + GetModuleFileName(hModule, wrappername, MAX_PATH); + char* p_wName = strrchr(wrappername, '\\') + 1; - // Get config file path - char path[MAX_PATH]; - GetModuleFileNameA(hModule_dll, path, sizeof(path)); - strcpy_s(strrchr(path, '.'), MAX_PATH - strlen(path), ".ini"); + // Set lower case + for (char* p = p_wName; *p != '\0'; p++) { *p = (char)tolower(*p); } + + // Get process name + char processname[MAX_PATH]; + GetModuleFileName(nullptr, processname, MAX_PATH); + char* p_pName = strrchr(processname, '\\') + 1; - // Get config file name for log - char* pdest = strrchr(path, '\\') + 1; - for (char* p = pdest; *p != '\0'; p++) + // Get module name and set RealWrapperMode + if (_strcmpi(p_wName, p_pName) == 0) { - *p = (char)tolower(*p); + WrapperName.assign("dxwrapper.dll"); + RealWrapperMode = dtype.dxwrapper; } - Logging::Log() << "Reading config file: " << pdest; + else + { + WrapperName.assign(p_wName); + GetWrapperMode(); + } + + // Set default settings + SetDefaultConfigSettings(); - // Read config file - char* szCfg; - szCfg = Read(path); + // Get config file path + strcpy_s(p_wName, MAX_PATH - strlen(wrappername), WrapperName.c_str()); + strcpy_s(strrchr(wrappername, '.'), MAX_PATH - strlen(wrappername), ".ini"); + + // Read defualt config file + char* szCfg = Read(wrappername); + Logging::Log() << "Reading config file: " << wrappername; // Parce config file if (szCfg) @@ -857,32 +597,22 @@ void CONFIG::Init() Parse(szCfg, ParseCallback); free(szCfg); } + + // If config file cannot be read else { Logging::Log() << "Could not load config file using defaults"; } // Verify sleep time to make sure it is not be set too low (can be perf issues if it is too low) - if (Config.LoopSleepTime < 30) Config.LoopSleepTime = 30; - - // Get porcess name - char szFileName[MAX_PATH]; - GetModuleFileName(nullptr, szFileName, MAX_PATH); - strippath(szFileName); + if (LoopSleepTime < 30) LoopSleepTime = 30; // Check if process should be excluded or not included // if so, then clear all settings (disable everything) - if ((szExclude.size() != 0 && IfStringExistsInList(szFileName, szExclude, false)) || - (szInclude.size() != 0 && !IfStringExistsInList(szFileName, szInclude, false))) + if ((ExcludeProcess.size() != 0 && IfStringExistsInList(p_pName, ExcludeProcess, false)) || + (IncludeProcess.size() != 0 && !IfStringExistsInList(p_pName, IncludeProcess, false))) { Logging::Log() << "Clearing config and disabling dxwrapper!"; ClearConfigSettings(); } - - // Update wrapper mode - if (Config.RealWrapperMode != dtype.Auto || - (Config.WrapperMode >= dtypeArraySize && Config.WrapperMode != dtype.Auto)) - { - Config.WrapperMode = Config.RealWrapperMode; - } } diff --git a/Settings/Settings.h b/Settings/Settings.h index 3681f4df..96ad0f96 100644 --- a/Settings/Settings.h +++ b/Settings/Settings.h @@ -5,53 +5,97 @@ #include #include -typedef unsigned char byte; +#define VISIT_CONFIG_SETTINGS(visit) \ + visit(AntiAliasing) \ + visit(D3d8to9) \ + visit(DDrawCompat) \ + visit(DDrawCompatDisableGDIHook) \ + visit(DisableHighDPIScaling) \ + visit(DSoundCtrl) \ + visit(DxWnd) \ + visit(ExcludeProcess) \ + visit(ForceCertification) \ + visit(ForceExclusiveMode) \ + visit(ForceHardwareMixing) \ + visit(ForceHQ3DSoftMixing) \ + visit(ForceNonStaticBuffers) \ + visit(ForcePrimaryBufferFormat) \ + visit(ForceSoftwareMixing) \ + visit(ForceSpeakerConfig) \ + visit(ForceTermination) \ + visit(ForceVoiceManagement) \ + visit(ForceWindowResize) \ + visit(FullScreen) \ + visit(HandleExceptions) \ + visit(IgnoreWindowName) \ + visit(IncludeProcess) \ + visit(LoadCustomDllPath) \ + visit(LoadFromScriptsOnly) \ + visit(LoadPlugins) \ + visit(LockColorkey) \ + visit(LoopSleepTime) \ + visit(Num2DBuffers) \ + visit(Num3DBuffers) \ + visit(PreventSpeakerSetup) \ + visit(PrimaryBufferBits) \ + visit(PrimaryBufferChannels) \ + visit(PrimaryBufferSamples) \ + visit(RealDllPath) \ + visit(ResetMemoryAfter) \ + visit(ResetScreenRes) \ + visit(RunProcess) \ + visit(SendAltEnter) \ + visit(SetFullScreenLayer) \ + visit(SetNamedLayer) \ + visit(SingleProcAffinity) \ + visit(SpeakerConfig) \ + visit(StoppedDriverWorkaround) \ + visit(WaitForProcess) \ + visit(WaitForWindowChanges) \ + visit(WindowSleepTime) -namespace Settings -{ - bool IfStringExistsInList(char*, std::vector, bool = true); - void SetConfigList(std::vector&, char*); -} +#define VISIT_APPCOMPATDATA_SETTINGS(visit) \ + visit(LockEmulation) \ + visit(BltEmulation) \ + visit(ForceLockNoWindow) \ + visit(ForceBltNoWindow) \ + visit(LockColorkey) \ + visit(FullscreenWithDWM) \ + visit(DisableLockEmulation) \ + visit(EnableOverlays) \ + visit(DisableSurfaceLocks) \ + visit(RedirectPrimarySurfBlts) \ + visit(StripBorderStyle) \ + visit(DisableMaxWindowedMode) + +typedef unsigned char byte; struct MEMORYINFO // Used for hot patching memory { - DWORD AddressPointer = 0; // Hot patch address + void* AddressPointer = nullptr; // Hot patch address byte* Bytes = nullptr; // Hot patch bytes size_t SizeOfBytes = 0; // Size of bytes to hot patch }; struct DLLTYPE { - const DWORD dciman32 = 0; + const DWORD dxwrapper = 0; const DWORD ddraw = 1; - const DWORD d3d9 = 2; - const DWORD d3d8 = 3; - const DWORD winmm = 4; - const DWORD dsound = 5; - const DWORD dxgi = 6; - const DWORD dplayx = 7; - const DWORD dinput = 8; - const DWORD bcrypt = 9; - const DWORD cryptsp = 10; - const DWORD winspool = 11; - const DWORD Auto = 255; + const DWORD d3d8 = 2; + const DWORD d3d9 = 3; + const DWORD dsound = 4; + const DWORD winmm = 5; }; static const DLLTYPE dtype; // Designated Initializer does not work in VS 2015 so must pay attention to the order static constexpr char* dtypename[] = { - "dciman32.dll", // 0 + "dxwrapper.dll",// 0 "ddraw.dll", // 1 - "d3d9.dll", // 2 - "d3d8.dll", // 3 - "winmm.dll", // 4 - "dsound.dll", // 5 - "dxgi.dll", // 6 - "dplayx.dll", // 7 - "dinput.dll", // 8 - "bcrypt.dll", // 9 - "cryptsp.dll", // 10 - "winspool.drv", // 11 + "d3d8.dll", // 2 + "d3d9.dll", // 3 + "dsound.dll", // 4 + "winmm.dll", // 5 }; static constexpr int dtypeArraySize = (sizeof(dtypename) / sizeof(*dtypename)); @@ -77,12 +121,12 @@ struct CONFIG { void Init(); // Initialize the config setting void CleanUp(); // Deletes all 'new' varables created by config - bool Affinity; // Sets the CPU affinity for this process and thread - bool AffinityNotSet; // If the CPU affinity option exists in the config file + bool SingleProcAffinity; // Sets the CPU affinity for this process and thread + bool SingleProcAffinityNotSet; // If the CPU affinity option exists in the config file bool D3d8to9; // Converts Direct3D8 (d3d8.dll) to Direct3D9 (d3d9.dll) https://github.com/crosire/d3d8to9 bool DDrawCompat; // Enables DDrawCompat functions https://github.com/narzoul/DDrawCompat/ bool DDrawCompatDisableGDIHook; // Disables DDrawCompat GDI hooks - bool DpiAware; // Disables display scaling on high DPI settings + bool DisableHighDPIScaling; // Disables display scaling on high DPI settings bool DSoundCtrl; // Enables DirectSoundControl https://github.com/nRaecheR/DirectSoundControl bool DxWnd; // Enables dXwnd https://sourceforge.net/projects/dxwnd/ bool FullScreen; // Sets the main window to fullscreen @@ -101,18 +145,21 @@ struct CONFIG DWORD SetFullScreenLayer; // The layer to be selected for fullscreen DWORD AntiAliasing; // Enable AntiAliasing for d3d9 CreateDevice DWORD RealWrapperMode; // Internal wrapper mode - DWORD WrapperMode; // 0 ... 254 = DLLTYPE - // 255 = Auto + MEMORYINFO VerifyMemoryInfo; // Memory used for verification before hot patching + std::vector MemoryInfo; // Addresses and memory used in hot patching + std::string WrapperName; // Name of dxwrapper + std::string RealDllPath; // Manually set Dll to wrap + std::string RunProcess; // Process to run on load + std::vector SetNamedLayer; // List of named layers to select for fullscreen + std::vector IgnoreWindowName; // List of window classes to ignore + std::vector LoadCustomDllPath; // List of custom dlls to load + std::vector ExcludeProcess; // List of excluded applications + std::vector IncludeProcess; // List of included applications + + // SetAppCompatData bool DXPrimaryEmulation[13]; // SetAppCompatData exported functions from ddraw.dll http://www.blitzbasic.com/Community/posts.php?topic=99477 DWORD LockColorkey; // DXPrimaryEmulation option that needs a second parameter bool DisableMaxWindowedModeNotSet; // If the DisableMaxWindowedMode option exists in the config file - MEMORYINFO VerifyMemoryInfo; // Memory used for verification before hot patching - std::vector MemoryInfo; // Addresses and memory used in hot patching - std::string szDllPath; // Manually set Dll to wrap - std::string szShellPath; // Process to run on load - std::vector szCustomDllPath; // List of custom dlls to load - std::vector szSetNamedLayer; // List of named layers to select for fullscreen - std::vector szIgnoreWindowName; // List of window classes to ignore // DSoundCtrl DWORD Num2DBuffers; @@ -134,3 +181,9 @@ struct CONFIG bool StoppedDriverWorkaround; }; extern CONFIG Config; + +namespace Settings +{ + bool IfStringExistsInList(const char*, std::vector, bool = true); + void SetValue(char*, char*, std::vector*); +} diff --git a/Stub/BuildNo.rc b/Stub/BuildNo.rc new file mode 100644 index 00000000..5811383c --- /dev/null +++ b/Stub/BuildNo.rc @@ -0,0 +1 @@ +#define BUILD_NUMBER 14 diff --git a/Stub/Dllmain.cpp b/Stub/Dllmain.cpp new file mode 100644 index 00000000..c782b2d2 --- /dev/null +++ b/Stub/Dllmain.cpp @@ -0,0 +1,92 @@ +/** +* Copyright (C) 2017 Elisha Riedlinger +* +* This software is provided 'as-is', without any express or implied warranty. In no event will the +* authors be held liable for any damages arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, including commercial +* applications, and to alter it and redistribute it freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the +* original software. If you use this software in a product, an acknowledgment in the product +* documentation would be appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as +* being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +#define WIN32_LEAN_AND_MEAN +#include +#include "..\MemoryModule\MemoryModule.h" +#include "..\Wrappers\wrapper.h" + +// Dll main function +bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + static HMEMORYMODULE wrapper_dll = nullptr; + static HMODULE proxy_dll = nullptr; + + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + { + // Start wrapper + proxy_dll = Wrapper::CreateWrapper(hModule); + + // Open file and get size + char path[MAX_PATH]; + std::ifstream myfile; + + // Get config file path + GetModuleFileNameA(hModule, path, sizeof(path)); + strcpy_s(strrchr(path, '\\'), MAX_PATH - strlen(path), "\\dxwrapper.dll"); + + // Get config file name for log + myfile.open(path, std::ios::binary | std::ios::in | std::ios::ate); + DWORD size = (DWORD)myfile.tellg(); + + // If size is greater than 0 + if (size && myfile.is_open()) + { + // Read file + myfile.seekg(0, std::ios::beg); + char * memblock; + memblock = new char[size]; + myfile.read(memblock, size); + + // Load library into memory + wrapper_dll = MemoryLoadLibrary(memblock, size); + + // Delete memory block from the loaded file + delete[] memblock; + } + + // Close the file + myfile.close(); + + // Check if DxWrapper is loaded + if (!wrapper_dll) + { + MessageBoxA(nullptr, "Could not find DxWrapper.dll functions will be disabled!", "DxWrapper Stub", MB_ICONWARNING | MB_TOPMOST | MB_SETFOREGROUND); + } + } + break; + case DLL_PROCESS_DETACH: + + // Unload wrapped dll + if (proxy_dll) + { + FreeLibrary(proxy_dll); + } + + // Unload dxwrapper dll from memory + if (wrapper_dll) + { + MemoryFreeLibrary(wrapper_dll); + } + break; + } + + return true; +} diff --git a/Stub/License.txt b/Stub/License.txt new file mode 100644 index 00000000..7554e31f --- /dev/null +++ b/Stub/License.txt @@ -0,0 +1,15 @@ +/** +* Copyright (C) 2017 Elisha Riedlinger +* +* This software is provided 'as-is', without any express or implied warranty. In no event will the +* authors be held liable for any damages arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, including commercial +* applications, and to alter it and redistribute it freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the +* original software. If you use this software in a product, an acknowledgment in the product +* documentation would be appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as +* being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ \ No newline at end of file diff --git a/Stub/stub.h b/Stub/stub.h new file mode 100644 index 00000000..e75309a8 --- /dev/null +++ b/Stub/stub.h @@ -0,0 +1,34 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by dxwrapper.rc + +#include "BuildNo.rc" + +// Main resource file details +#define APP_NAME "DxWrapper Stub" +#define APP_MAJOR 1 +#define APP_MINOR 0 +#define APP_BUILDNUMBER BUILD_NUMBER +#define APP_REVISION 0 +#define APP_COMPANYNAME "Sadrate Presents" +#define APP_DESCRPTION "Stub for DxWrapper. Supports following dlls: bcrypt.dll, cryptsp.dll, d2d1.dll, d3d8.dll, d3d9.dll, d3d10.dll, d3d10core.dll, d3d11.dll, d3d12.dll, d3dim.dll, d3dim700.dll, dciman32.dll, ddraw.dll, dinput.dll, dinput8.dll, dplayx.dll, dsound.dll, dxgi.dll, msacm32.dll, msvfw32.dll, vorbisfile.dll, winmm.dll, winmmbase.dll, winspool.drv and xlive.dll" +#define APP_COPYRIGHT "Copyright (C) 2017 Elisha Riedlinger" +#define APP_ORIGINALVERSION "stub.dll" +#define APP_INTERNALNAME "DxWrapper Stub" + +// Get APP_VERSION +#define _TO_STRING_(x) #x +#define _TO_STRING(x) _TO_STRING_(x) +#define APP_VERSION _TO_STRING(APP_MAJOR) "." _TO_STRING(APP_MINOR) "." _TO_STRING(APP_BUILDNUMBER) "." _TO_STRING(APP_REVISION) + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Stub/stub.rc b/Stub/stub.rc new file mode 100644 index 00000000..226eb1da --- /dev/null +++ b/Stub/stub.rc @@ -0,0 +1,103 @@ +// Microsoft Visual C++ generated resource script. +// +#include "stub.h" + +//Generated by Visual Studio +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION APP_MAJOR, APP_MINOR, APP_BUILDNUMBER, APP_REVISION + PRODUCTVERSION APP_MAJOR, APP_MINOR, APP_BUILDNUMBER, APP_REVISION + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", APP_COMPANYNAME + VALUE "FileDescription", APP_DESCRPTION + VALUE "FileVersion", APP_VERSION + VALUE "InternalName", APP_INTERNALNAME + VALUE "LegalCopyright", APP_COPYRIGHT + VALUE "OriginalFilename", APP_ORIGINALVERSION + VALUE "ProductName", APP_NAME + VALUE "ProductVersion", APP_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Stub/stub.vcxproj b/Stub/stub.vcxproj new file mode 100644 index 00000000..a56d8093 --- /dev/null +++ b/Stub/stub.vcxproj @@ -0,0 +1,160 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {E204DCB3-D122-4F2E-88A8-89AC22CE3274} + Win32Proj + stub + 10.0.14393.0 + + + + DynamicLibrary + true + MultiByte + v140 + + + DynamicLibrary + false + true + Unicode + v140 + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + + + Windows + true + ..\Wrappers\wrapper.def + + + IF NOT EXIST "$(TargetDir)Build" mkdir "$(TargetDir)Build" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\bcrypt.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\cryptsp.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d2d1.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d8.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d9.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d10.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d10core.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d11.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d12.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3dim.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3dim700.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dciman32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\ddraw.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dinput.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dinput8.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dplayx.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dsound.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dxgi.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\msacm32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\msvfw32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\vorbisfile.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winmm.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winmmbase.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winspool.drv" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\xlive.dll" >nul + + + + + Level3 + + + MaxSpeed + true + true + StreamingSIMDExtensions2 + + + Windows + true + true + ..\Wrappers\wrapper.def + + + cmd /c "@echo off && cd /D ""$(ProjectDir)"" && if not exist BuildNo.rc echo #define BUILD_NUMBER 0 >BuildNo.rc" +cmd /c "@echo off && cd /D ""$(ProjectDir)"" && FOR /F "tokens=3" %%i IN (BuildNo.rc) DO set /a var=%%i+1 >Build.txt" +cmd /c "@echo off && cd /D ""$(ProjectDir)"" && FOR /F %%i IN (Build.txt) DO echo #define BUILD_NUMBER %%i >BuildNo.rc" +cmd /c "@echo off && cd /D ""$(ProjectDir)"" && del Build.txt" +cmd /c "@echo off && cd /D ""$(ProjectDir)"" && type BuildNo.rc" + + + IF NOT EXIST "$(TargetDir)Build" mkdir "$(TargetDir)Build" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\bcrypt.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\cryptsp.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d2d1.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d8.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d9.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d10.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d10core.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d11.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d12.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3dim.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3dim700.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dciman32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\ddraw.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dinput.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dinput8.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dplayx.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dsound.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dxgi.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\msacm32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\msvfw32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\vorbisfile.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winmm.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winmmbase.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winspool.drv" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\xlive.dll" >nul + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Utils/Fullscreen.cpp b/Utils/Fullscreen.cpp index 384f870a..31e21855 100644 --- a/Utils/Fullscreen.cpp +++ b/Utils/Fullscreen.cpp @@ -344,7 +344,7 @@ BOOL CALLBACK Fullscreen::EnumWindowsCallback(HWND hwnd, LPARAM lParam) #endif // AutoDetect to search for main and fullscreen windows - if (data.AutoDetect || (Config.SetFullScreenLayer == 0 && Config.szSetNamedLayer.size() == 0)) + if (data.AutoDetect || (Config.SetFullScreenLayer == 0 && Config.SetNamedLayer.size() == 0)) { // Declare vars MONITORINFO mi = { sizeof(mi) }; @@ -371,8 +371,8 @@ BOOL CALLBACK Fullscreen::EnumWindowsCallback(HWND hwnd, LPARAM lParam) else { // Check other windows for a match - if ((Config.szSetNamedLayer.size() == 0 && ++data.LayerNumber == Config.SetFullScreenLayer) || // Check for specific window layer - Settings::IfStringExistsInList(class_name, Config.szSetNamedLayer)) // Check for specific window class name + if ((Config.SetNamedLayer.size() == 0 && ++data.LayerNumber == Config.SetFullScreenLayer) || // Check for specific window layer + Settings::IfStringExistsInList(class_name, Config.SetNamedLayer)) // Check for specific window class name { // Match found returning value data.best_handle = hwnd; @@ -797,7 +797,7 @@ void Fullscreen::MainFunc() // Change resolution if not fullscreen and ignore certian windows if (IsNotFullScreenFlag && // Check if it is already fullscreen - !(Config.szIgnoreWindowName.size() != 0 && Settings::IfStringExistsInList(class_name, Config.szIgnoreWindowName)) && // Ignore certian windows + !(Config.IgnoreWindowName.size() != 0 && Settings::IfStringExistsInList(class_name, Config.IgnoreWindowName)) && // Ignore certian windows IsWindow(CurrentLoop.hwnd)) // Check window handle { // Get the best screen resolution @@ -837,7 +837,7 @@ void Fullscreen::MainFunc() #endif // Add window to excluded list - Settings::SetConfigList(Config.szIgnoreWindowName, class_name); + Settings::SetValue("IgnoreWindowName", class_name, &Config.IgnoreWindowName); } } // Change resolution diff --git a/Utils/Utils.cpp b/Utils/Utils.cpp index ccddb123..7f057224 100644 --- a/Utils/Utils.cpp +++ b/Utils/Utils.cpp @@ -21,10 +21,12 @@ * * SetAppCompatData code created based on information from here: * http://www.blitzbasic.com/Community/post.php?topic=99477&post=1202996 +* +* ASI plugin loader taken from source code found in Ultimate ASI Loader +* https://github.com/ThirteenAG/Ultimate-ASI-Loader */ #include "Settings\Settings.h" -#include "Wrappers\wrapper.h" #include "Dllmain\Dllmain.h" extern "C" { @@ -39,11 +41,20 @@ typedef LPTOP_LEVEL_EXCEPTION_FILTER(WINAPI *PFN_SetUnhandledExceptionFilter)(LP namespace Utils { + // Strictures + struct type_dll + { + HMODULE dll; + std::string name; + }; + // Declare varables + std::vector custom_dll; // Used for custom dll's and asi plugins LPTOP_LEVEL_EXCEPTION_FILTER pOriginalSetUnhandledExceptionFilter = SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)EXCEPTION_CONTINUE_EXECUTION); PFN_SetUnhandledExceptionFilter pSetUnhandledExceptionFilter = reinterpret_cast(SetUnhandledExceptionFilter); // Function declarations + void FindFiles(WIN32_FIND_DATA*); LONG WINAPI myUnhandledExceptionFilter(LPEXCEPTION_POINTERS); LPTOP_LEVEL_EXCEPTION_FILTER WINAPI extSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER); } @@ -130,7 +141,7 @@ void Utils::SetAppCompat() // SetAppCompatData if (appCompatFlag) { - HMODULE module = Wrapper::LoadDll(dtype.ddraw); + HMODULE module = Utils::LoadLibrary("ddraw.dll"); FARPROC SetAppCompatDataPtr = (module != nullptr) ? GetProcAddress(module, "SetAppCompatData") : nullptr; if (module && SetAppCompatDataPtr) { @@ -247,3 +258,189 @@ void Utils::UnHookExceptionHandler(void) SetUnhandledExceptionFilter(pOriginalSetUnhandledExceptionFilter); Finishdisasm(); } + +// Add HMODULE to vector +void Utils::AddHandleToVector(HMODULE dll, const char *name) +{ + if (dll) + { + type_dll newCustom_dll; + newCustom_dll.dll = dll; + newCustom_dll.name.assign((strrchr(name, '\\')) ? strrchr(name, '\\') + 1 : name); + custom_dll.push_back(newCustom_dll); + } +} + +// Load real dll file that is being wrapped +HMODULE Utils::LoadLibrary(const char *dllname, bool EnableLogging) +{ + // Declare vars + HMODULE dll = nullptr; + const char *loadpath; + char path[MAX_PATH]; + bool isCurrentDll = (_strcmpi(Config.WrapperName.c_str(), dllname) == 0); + + // Get module name + const char *pdest = (strrchr(dllname, '\\')) ? strrchr(dllname, '\\') + 1 : dllname; + + // Check if dll is already loaded + for (size_t x = 0; x < custom_dll.size(); x++) + { + if (_strcmpi(custom_dll[x].name.c_str(), pdest) == 0) + { + return custom_dll[x].dll; + } + } + + // Logging + if (EnableLogging) + { + Logging::Log() << "Loading " << dllname; + } + + // Load dll from config + if (!Config.RealDllPath.empty() && isCurrentDll) + { + loadpath = Config.RealDllPath.c_str(); + dll = ::LoadLibrary(loadpath); + } + + // Load default dll + if (!dll && !isCurrentDll) + { + loadpath = dllname; + dll = ::LoadLibrary(loadpath); + } + + // Load system dll + if (!dll && !(strrchr(dllname, '\\'))) + { + //Load library + GetSystemDirectory(path, MAX_PATH); + strcat_s(path, MAX_PATH, "\\"); + strcat_s(path, MAX_PATH, dllname); + loadpath = path; + dll = ::LoadLibrary(loadpath); + } + + // Store handle and dll name + if (dll) + { + Logging::Log() << "Loaded " << loadpath << " library"; + AddHandleToVector(dll, pdest); + } + + // Return dll handle + return dll; +} + +// Load custom dll files +void Utils::LoadCustomDll() +{ + for (size_t x = 0; x < Config.LoadCustomDllPath.size(); ++x) + { + // Check if path is empty + if (!Config.LoadCustomDllPath[x].empty()) + { + Logging::Log() << "Loading custom " << Config.LoadCustomDllPath[x] << " library"; + // Load dll from ini + auto h = LoadLibrary(Config.LoadCustomDllPath[x].c_str(), false); + + // Cannot load dll + if (h) + { + AddHandleToVector(h, Config.LoadCustomDllPath[x].c_str()); + } + else + { + Logging::Log() << "Cannot load custom " << Config.LoadCustomDllPath[x] << " library"; + } + } + } +} + +// Find asi plugins to load +void Utils::FindFiles(WIN32_FIND_DATA* fd) +{ + char dir[MAX_PATH] = { 0 }; + GetCurrentDirectory(MAX_PATH, dir); + + HANDLE asiFile = FindFirstFile("*.asi", fd); + if (asiFile != INVALID_HANDLE_VALUE) + { + do { + if (!(fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + auto pos = strlen(fd->cFileName); + + if (fd->cFileName[pos - 4] == '.' && + (fd->cFileName[pos - 3] == 'a' || fd->cFileName[pos - 3] == 'A') && + (fd->cFileName[pos - 2] == 's' || fd->cFileName[pos - 2] == 'S') && + (fd->cFileName[pos - 1] == 'i' || fd->cFileName[pos - 1] == 'I')) + { + char path[MAX_PATH] = { 0 }; + sprintf_s(path, "%s\\%s", dir, fd->cFileName); + + Logging::Log() << "Loading Plugin: " << path; + auto h = LoadLibrary(path, false); + SetCurrentDirectory(dir); //in case asi switched it + + if (h) + { + AddHandleToVector(h, path); + } + else + { + Logging::LogFormat("Unable to load %s. Error: %d", fd->cFileName, GetLastError()); + } + } + } + } while (FindNextFile(asiFile, fd)); + FindClose(asiFile); + } +} + +// Load asi plugins +void Utils::LoadPlugins() +{ + Logging::Log() << "Loading ASI Plugins"; + + char oldDir[MAX_PATH]; // store the current directory + GetCurrentDirectory(MAX_PATH, oldDir); + + char selfPath[MAX_PATH]; + GetModuleFileName(hModule_dll, selfPath, MAX_PATH); + *strrchr(selfPath, '\\') = '\0'; + SetCurrentDirectory(selfPath); + + WIN32_FIND_DATA fd; + if (!Config.LoadFromScriptsOnly) + FindFiles(&fd); + + SetCurrentDirectory(selfPath); + + if (SetCurrentDirectory("scripts\\")) + FindFiles(&fd); + + SetCurrentDirectory(selfPath); + + if (SetCurrentDirectory("plugins\\")) + FindFiles(&fd); + + SetCurrentDirectory(oldDir); // Reset the current directory +} + +// Unload all dll files loaded by the wrapper +void Utils::UnloadAllDlls() +{ + // Logging + Logging::Log() << "Unloading libraries..."; + + // Unload custom libraries + while (custom_dll.size() != 0) + { + // Unload dll + FreeLibrary(custom_dll.back().dll); + custom_dll.pop_back(); + } +} diff --git a/Utils/Utils.h b/Utils/Utils.h index cbce9616..350e4f13 100644 --- a/Utils/Utils.h +++ b/Utils/Utils.h @@ -8,6 +8,11 @@ namespace Utils void SetAppCompat(); void HookExceptionHandler(); void UnHookExceptionHandler(); + void AddHandleToVector(HMODULE dll, const char *name); + HMODULE LoadLibrary(const char *dllname, bool EnableLogging = true); + void LoadCustomDll(); + void LoadPlugins(); + void UnloadAllDlls(); namespace WriteMemory { diff --git a/Utils/WriteMemory.cpp b/Utils/WriteMemory.cpp index 17322159..bec0cf93 100644 --- a/Utils/WriteMemory.cpp +++ b/Utils/WriteMemory.cpp @@ -45,11 +45,11 @@ void WriteMemory::WriteAllByteMemory() for (UINT x = 0; x < Config.MemoryInfo.size(); x++) { - if (Config.MemoryInfo[x].AddressPointer != 0 && Config.MemoryInfo[x].SizeOfBytes != 0) + if (Config.MemoryInfo[x].AddressPointer != nullptr && Config.MemoryInfo[x].SizeOfBytes != 0) { // Get current memory byte* lpBuffer = new byte[Config.MemoryInfo[x].SizeOfBytes]; - void* AddressPointer = (void*)Config.MemoryInfo[x].AddressPointer; + void* AddressPointer = Config.MemoryInfo[x].AddressPointer; if (ReadProcessMemory(hProcess, AddressPointer, lpBuffer, Config.MemoryInfo[x].SizeOfBytes, nullptr)) { // Make memory writeable @@ -70,12 +70,12 @@ void WriteMemory::WriteAllByteMemory() } else { - Logging::Log() << "Access Denied at memory address: 0x" << std::showbase << std::hex << Config.MemoryInfo[x].AddressPointer << std::dec << std::noshowbase; + Logging::Log() << "Access Denied at memory address: 0x" << Config.MemoryInfo[x].AddressPointer; } } else { - Logging::Log() << "Failed to read memory at address: 0x" << std::showbase << std::hex << Config.MemoryInfo[x].AddressPointer << std::dec << std::noshowbase; + Logging::Log() << "Failed to read memory at address: 0x" << Config.MemoryInfo[x].AddressPointer; } } } @@ -85,7 +85,7 @@ void WriteMemory::WriteAllByteMemory() bool WriteMemory::CheckVerificationMemory() { // Check Verification details - if (Config.VerifyMemoryInfo.SizeOfBytes == 0 || Config.VerifyMemoryInfo.AddressPointer == 0) + if (Config.VerifyMemoryInfo.SizeOfBytes == 0 || Config.VerifyMemoryInfo.AddressPointer == nullptr) { return false; } @@ -93,7 +93,7 @@ bool WriteMemory::CheckVerificationMemory() // Check current memory for (UINT x = 0; x < Config.VerifyMemoryInfo.SizeOfBytes; x++) { - if (*((byte*)(Config.VerifyMemoryInfo.AddressPointer + x)) != Config.VerifyMemoryInfo.Bytes[x]) + if (*((byte*)((DWORD)Config.VerifyMemoryInfo.AddressPointer + x)) != Config.VerifyMemoryInfo.Bytes[x]) { // Check failed return false; @@ -162,7 +162,7 @@ void WriteMemory::WriteMemory() } else { - if (Config.VerifyMemoryInfo.AddressPointer != 0) + if (Config.VerifyMemoryInfo.AddressPointer != nullptr) { Logging::Log() << "Failed verification for memory write!"; } diff --git a/Wrappers/bcrypt.h b/Wrappers/bcrypt.h index 6a63b246..a46eb308 100644 --- a/Wrappers/bcrypt.h +++ b/Wrappers/bcrypt.h @@ -1,6 +1,6 @@ #pragma once -#define VISIT_BCRYPT_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(BCryptAddContextFunction) \ visit(BCryptAddContextFunctionProvider) \ visit(BCryptCloseAlgorithmProvider) \ @@ -60,33 +60,6 @@ visit(BCryptUnregisterProvider) \ visit(BCryptVerifySignature) -namespace bcrypt -{ - class bcrypt_dll - { - public: - HMODULE dll = nullptr; - VISIT_BCRYPT_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(bcrypt, dll) - void Load() - { - if (Config.WrapperMode != dtype.bcrypt && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.bcrypt); - - // Load dll functions - if (dll) - { - VISIT_BCRYPT_PROCS(LOAD_ORIGINAL_PROC); - } - } - - void Unhook() {} - }; - - extern bcrypt_dll module; -}; +#undef VISIT_PROCS diff --git a/Wrappers/cryptsp.h b/Wrappers/cryptsp.h index d1205b2f..ae69445b 100644 --- a/Wrappers/cryptsp.h +++ b/Wrappers/cryptsp.h @@ -1,6 +1,6 @@ #pragma once -#define VISIT_CRYTPSP_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(CheckSignatureInFile) \ visit(CryptAcquireContextA) \ visit(CryptAcquireContextW) \ @@ -67,33 +67,6 @@ visit(SystemFunction033) \ visit(SystemFunction035) -namespace cryptsp -{ - class cryptsp_dll - { - public: - HMODULE dll = nullptr; - VISIT_CRYTPSP_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(cryptsp, dll) - void Load() - { - if (Config.WrapperMode != dtype.cryptsp && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.cryptsp); - - // Load dll functions - if (dll) - { - VISIT_CRYTPSP_PROCS(LOAD_ORIGINAL_PROC); - } - } - - void Unhook() {} - }; - - extern cryptsp_dll module; -}; +#undef VISIT_PROCS diff --git a/Wrappers/d2d1.h b/Wrappers/d2d1.h new file mode 100644 index 00000000..249ad891 --- /dev/null +++ b/Wrappers/d2d1.h @@ -0,0 +1,22 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(D2D1CreateFactory) \ + visit(D2D1MakeRotateMatrix) \ + visit(D2D1MakeSkewMatrix) \ + visit(D2D1IsMatrixInvertible) \ + visit(D2D1InvertMatrix) \ + visit(D2D1ConvertColorSpace) \ + visit(D2D1CreateDevice) \ + visit(D2D1CreateDeviceContext) \ + visit(D2D1SinCos) \ + visit(D2D1Tan) \ + visit(D2D1Vec3Length) \ + visit(D2D1ComputeMaximumScaleFactor) \ + visit(D2D1GetGradientMeshInteriorPointsFromCoonsPatch) \ + visit(D2DTkCreateOn12Device) \ + visit(D2DTkCreateAlgorithmFactory) + +PROC_CLASS(d2d1, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/d3d10.h b/Wrappers/d3d10.h new file mode 100644 index 00000000..c5e8b800 --- /dev/null +++ b/Wrappers/d3d10.h @@ -0,0 +1,37 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(RevertToOldImplementation) \ + visit(D3D10CompileEffectFromMemory) \ + visit(D3D10CompileShader) \ + visit(D3D10CreateBlob) \ + visit(D3D10CreateDevice) \ + visit(D3D10CreateDeviceAndSwapChain) \ + visit(D3D10CreateEffectFromMemory) \ + visit(D3D10CreateEffectPoolFromMemory) \ + visit(D3D10CreateStateBlock) \ + visit(D3D10DisassembleEffect) \ + visit(D3D10DisassembleShader) \ + visit(D3D10GetGeometryShaderProfile) \ + visit(D3D10GetInputAndOutputSignatureBlob) \ + visit(D3D10GetInputSignatureBlob) \ + visit(D3D10GetOutputSignatureBlob) \ + visit(D3D10GetPixelShaderProfile) \ + visit(D3D10GetShaderDebugInfo) \ + visit(D3D10GetVersion) \ + visit(D3D10GetVertexShaderProfile) \ + visit(D3D10PreprocessShader) \ + visit(D3D10ReflectShader) \ + visit(D3D10RegisterLayers) \ + visit(D3D10StateBlockMaskDifference) \ + visit(D3D10StateBlockMaskDisableAll) \ + visit(D3D10StateBlockMaskDisableCapture) \ + visit(D3D10StateBlockMaskEnableAll) \ + visit(D3D10StateBlockMaskEnableCapture) \ + visit(D3D10StateBlockMaskGetSetting) \ + visit(D3D10StateBlockMaskIntersect) \ + visit(D3D10StateBlockMaskUnion) + +PROC_CLASS(d3d10, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/d3d10core.h b/Wrappers/d3d10core.h new file mode 100644 index 00000000..4e5640ee --- /dev/null +++ b/Wrappers/d3d10core.h @@ -0,0 +1,11 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(D3D10CoreCreateDevice) \ + visit(D3D10CoreGetSupportedVersions) \ + visit(D3D10CoreGetVersion) \ + visit(D3D10CoreRegisterLayers) + +PROC_CLASS(d3d10core, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/d3d11.h b/Wrappers/d3d11.h new file mode 100644 index 00000000..b0396012 --- /dev/null +++ b/Wrappers/d3d11.h @@ -0,0 +1,22 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(D3D11CreateDeviceForD3D12) \ + visit(EnableFeatureLevelUpgrade) \ + visit(CreateDirect3D11DeviceFromDXGIDevice) \ + visit(CreateDirect3D11SurfaceFromDXGISurface) \ + visit(D3D11CoreCreateDevice) \ + visit(D3D11CoreCreateLayeredDevice) \ + visit(D3D11CoreGetLayeredDeviceSize) \ + visit(D3D11CoreRegisterLayers) \ + visit(D3D11CreateDevice) \ + visit(D3D11CreateDeviceAndSwapChain) \ + visit(D3D11On12CreateDevice) \ + visit(D3DPerformance_BeginEvent) \ + visit(D3DPerformance_EndEvent) \ + visit(D3DPerformance_GetStatus) \ + visit(D3DPerformance_SetMarker) + +PROC_CLASS(d3d11, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/d3d12.h b/Wrappers/d3d12.h new file mode 100644 index 00000000..7e9b4810 --- /dev/null +++ b/Wrappers/d3d12.h @@ -0,0 +1,18 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(GetBehaviorValue) \ + visit(D3D12CreateDevice) \ + visit(D3D12GetDebugInterface) \ + visit(D3D12CoreCreateLayeredDevice) \ + visit(D3D12CoreGetLayeredDeviceSize) \ + visit(D3D12CoreRegisterLayers) \ + visit(D3D12CreateRootSignatureDeserializer) \ + visit(D3D12CreateVersionedRootSignatureDeserializer) \ + visit(D3D12EnableExperimentalFeatures) \ + visit(D3D12SerializeRootSignature) \ + visit(D3D12SerializeVersionedRootSignature) + +PROC_CLASS(d3d12, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/d3d8.h b/Wrappers/d3d8.h index 3c2ddc46..a216069e 100644 --- a/Wrappers/d3d8.h +++ b/Wrappers/d3d8.h @@ -1,56 +1,11 @@ #pragma once -#define VISIT_D3D8_PROCS(visit) \ - visit(Direct3DCreate8) \ +#define VISIT_PROCS(visit) \ + visit(Direct3D8EnableMaximizedWindowedModeShim) \ visit(ValidateVertexShader) \ visit(ValidatePixelShader) \ - visit(DebugSetMute) + visit(Direct3DCreate8) -namespace d3d8 -{ - class d3d8_dll - { - public: - HMODULE dll = nullptr; - VISIT_D3D8_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(d3d8, dll) - void Load() - { - if (Config.WrapperMode != dtype.d3d8 && Config.WrapperMode != dtype.Auto && !Config.D3d8to9) - { - return; - } - - // Enable d3d8to9 conversion - if (Config.D3d8to9 && Config.RealWrapperMode == dtype.d3d8) - { - Direct3DCreate8 = D3d8to9::_Direct3DCreate8; - ValidateVertexShader = (FARPROC)*_ValidateVertexShader; - ValidatePixelShader = (FARPROC)*_ValidatePixelShader; - } - - // Load normal dll - else - { - // Load real dll - dll = LoadDll(dtype.d3d8); - - // Load dll functions - if (dll) - { - VISIT_D3D8_PROCS(LOAD_ORIGINAL_PROC); - - // Hook APIs for d3d8to9 conversion - if (Config.D3d8to9) - { - Logging::Log() << "Hooking d3d8.dll APIs..."; - // Direct3DCreate8 - Direct3DCreate8 = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.d3d8], Hook::GetProcAddress(dll, "Direct3DCreate8"), "Direct3DCreate8", D3d8to9::_Direct3DCreate8); - } - } - } - } - }; - - extern d3d8_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/d3d9.h b/Wrappers/d3d9.h index f2483408..37130808 100644 --- a/Wrappers/d3d9.h +++ b/Wrappers/d3d9.h @@ -1,6 +1,6 @@ #pragma once -#define VISIT_D3D9_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(Direct3DShaderValidatorCreate9) \ visit(PSGPError) \ visit(PSGPSampleTexture) \ @@ -14,60 +14,8 @@ visit(DebugSetLevel) \ visit(Direct3D9EnableMaximizedWindowedModeShim) \ visit(Direct3DCreate9) \ - visit(Direct3DCreate9Ex) \ - //visit(DebugSetMute) // <--- Shared with d3d8.dll + visit(Direct3DCreate9Ex) -namespace d3d9 -{ - class d3d9_dll - { - public: - HMODULE dll = nullptr; - VISIT_D3D9_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(d3d9, dll) - void Load() - { - bool D3d9Logging = false; -#ifdef D3D9LOGGING - D3d9Logging = true; -#endif // D3D9LOGGING - if (Config.WrapperMode != dtype.d3d9 && Config.WrapperMode != dtype.Auto && !Config.D3d8to9 && !D3d9Logging && Config.AntiAliasing == 0) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.d3d9); - - // Load dll functions - if (dll) - { - VISIT_D3D9_PROCS(LOAD_ORIGINAL_PROC); - d3d8::module.DebugSetMute = GetProcAddress(dll, "DebugSetMute", jmpaddr); // <--- Shared with d3d8.dll - - // Set d3d9 wrapper addresses - if (D3d9Logging || Config.AntiAliasing != 0) - { - d3d9_Wrapper::_Direct3DCreate9_RealProc = Direct3DCreate9; - Direct3DCreate9 = d3d9_Wrapper::_Direct3DCreate9_WrapperProc; - if (Config.RealWrapperMode != dtype.d3d9 && - (Config.RealWrapperMode != dtype.d3d8 && !Config.D3d8to9)) - { - Logging::Log() << "Hooking d3d9.dll APIs..."; - // Direct3DCreate9 - Direct3DCreate9 = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.d3d9], Hook::GetProcAddress(dll, "Direct3DCreate9"), "Direct3DCreate9", d3d9_Wrapper::_Direct3DCreate9_WrapperProc); - d3d9_Wrapper::_Direct3DCreate9_RealProc = Direct3DCreate9; - } - } - - // Set d3d8to9 addresses - if (Config.D3d8to9) - { - D3d8to9::_Direct3DCreate9 = (FARPROC)Direct3DCreate9; - } - } - } - }; - - extern d3d9_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/d3dim.h b/Wrappers/d3dim.h new file mode 100644 index 00000000..16b4ab7d --- /dev/null +++ b/Wrappers/d3dim.h @@ -0,0 +1,10 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(Direct3DCreateTexture) \ + visit(Direct3DGetSWRastZPixFmts) \ + visit(FlushD3DDevices2) + +PROC_CLASS(d3dim, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/d3dim700.h b/Wrappers/d3dim700.h new file mode 100644 index 00000000..8d2ae2c8 --- /dev/null +++ b/Wrappers/d3dim700.h @@ -0,0 +1,15 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(CreateTexture) \ + visit(D3DBreakVBLock) \ + visit(D3DTextureUpdate) \ + visit(DestroyTexture) \ + visit(GetLOD) \ + visit(GetPriority) \ + visit(SetLOD) \ + visit(SetPriority) + +PROC_CLASS(d3dim700, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/dciman32.h b/Wrappers/dciman32.h index 93d2ec7e..f3b43b5f 100644 --- a/Wrappers/dciman32.h +++ b/Wrappers/dciman32.h @@ -1,6 +1,6 @@ #pragma once -#define VISIT_DCIMAN32_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(DCIBeginAccess) \ visit(DCICloseProvider) \ visit(DCICreateOffscreen) \ @@ -22,33 +22,6 @@ visit(WinWatchNotify) \ visit(WinWatchOpen) -namespace dciman32 -{ - class dciman32_dll - { - public: - HMODULE dll = nullptr; - VISIT_DCIMAN32_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(dciman32, dll) - void Load() - { - if (Config.WrapperMode != dtype.dciman32 && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.dciman32); - - // Load dll functions - if (dll) - { - VISIT_DCIMAN32_PROCS(LOAD_ORIGINAL_PROC); - } - } - - void Unhook() {} - }; - - extern dciman32_dll module; -}; +#undef VISIT_PROCS diff --git a/Wrappers/ddraw.h b/Wrappers/ddraw.h index 1e9af3ab..fa9f4e3d 100644 --- a/Wrappers/ddraw.h +++ b/Wrappers/ddraw.h @@ -1,6 +1,8 @@ #pragma once -#define VISIT_DDRAW_PROCS(visit) \ +#include "wrapper.h" + +#define VISIT_PROCS(visit) \ visit(AcquireDDThreadLock) \ visit(CheckFullscreen) \ visit(CompleteCreateSysmemSurface) \ @@ -21,57 +23,8 @@ visit(GetSurfaceFromDC) \ visit(RegisterSpecialCase) \ visit(ReleaseDDThreadLock) \ - visit(SetAppCompatData) \ - //visit(DllCanUnloadNow) \ // <--- Shared with dsound.dll - //visit(DllGetClassObject) // <--- Shared with dsound.dll - -namespace ddraw -{ - class ddraw_dll - { - public: - HMODULE dll = nullptr; - VISIT_DDRAW_PROCS(ADD_FARPROC_MEMBER); - - void Load() - { - if (Config.WrapperMode != dtype.ddraw && Config.WrapperMode != dtype.Auto && !Config.DDrawCompat) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.ddraw); - - // Load dll functions - if (dll) - { - VISIT_DDRAW_PROCS(LOAD_ORIGINAL_PROC); - dsound::module.DllCanUnloadNow = GetProcAddress(dll, "DllCanUnloadNow", jmpaddr); // <--- Shared with dsound.dll - dsound::module.DllGetClassObject = GetProcAddress(dll, "DllGetClassObject", jmpaddr); // <--- Shared with dsound.dll - - // Enable DDrawCompat - if (Config.DDrawCompat && Config.RealWrapperMode == dtype.ddraw) - { - DirectDrawCreate = DDrawCompat::_DirectDrawCreate; - DirectDrawCreateEx = DDrawCompat::_DirectDrawCreateEx; - dsound::module.DllGetClassObject = DDrawCompat::_DllGetClassObject; - } + visit(SetAppCompatData) - // Hook ddraw APIs for DDrawCompat - else if (Config.DDrawCompat) - { - Logging::Log() << "Hooking ddraw.dll APIs..."; - // DirectDrawCreate - DirectDrawCreate = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.ddraw], Hook::GetProcAddress(dll, "DirectDrawCreate"), "DirectDrawCreate", DDrawCompat::_DirectDrawCreate); - // DirectDrawCreateEx - DirectDrawCreateEx = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.ddraw], Hook::GetProcAddress(dll, "DirectDrawCreateEx"), "DirectDrawCreateEx", DDrawCompat::_DirectDrawCreateEx); - // DllGetClassObject - dsound::module.DllGetClassObject = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.ddraw], Hook::GetProcAddress(dll, "DllGetClassObject"), "DllGetClassObject", DDrawCompat::_DllGetClassObject); - } - } - } - }; +PROC_CLASS(ddraw, dll) - extern ddraw_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/dinput.h b/Wrappers/dinput.h index cb8637c7..394dbb82 100644 --- a/Wrappers/dinput.h +++ b/Wrappers/dinput.h @@ -1,43 +1,10 @@ #pragma once -#define VISIT_DINPUT_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(DirectInputCreateA) \ visit(DirectInputCreateEx) \ - visit(DirectInputCreateW) \ - visit(DllRegisterServer) \ - visit(DllUnregisterServer) \ - //visit(DllCanUnloadNow) \ // <--- Shared with dsound.dll - //visit(DllGetClassObject) // <--- Shared with dsound.dll + visit(DirectInputCreateW) -namespace dinput -{ - class dinput_dll - { - public: - HMODULE dll = nullptr; - VISIT_DINPUT_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(dinput, dll) - void Load() - { - if (Config.WrapperMode != dtype.dinput && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.dinput); - - // Load dll functions - if (dll) - { - VISIT_DINPUT_PROCS(LOAD_ORIGINAL_PROC); - dsound::module.DllCanUnloadNow = GetProcAddress(dll, "DllCanUnloadNow", jmpaddr); // <--- Shared with dsound.dll - dsound::module.DllGetClassObject = GetProcAddress(dll, "DllGetClassObject", jmpaddr); // <--- Shared with dsound.dll - } - } - - void Unhook() {} - }; - - extern dinput_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/dinput8.h b/Wrappers/dinput8.h new file mode 100644 index 00000000..a777ceab --- /dev/null +++ b/Wrappers/dinput8.h @@ -0,0 +1,9 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(DirectInput8Create) \ + visit(GetdfDIJoystick) + +PROC_CLASS(dinput8, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/dplayx.h b/Wrappers/dplayx.h index d0ad379c..91b0f7a0 100644 --- a/Wrappers/dplayx.h +++ b/Wrappers/dplayx.h @@ -1,6 +1,6 @@ #pragma once -#define VISIT_DPLAYX_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(DirectPlayCreate) \ visit(DirectPlayEnumerate) \ visit(DirectPlayEnumerateA) \ @@ -8,33 +8,6 @@ visit(DirectPlayLobbyCreateA) \ visit(DirectPlayLobbyCreateW) -namespace dplayx -{ - class dplayx_dll - { - public: - HMODULE dll = nullptr; - VISIT_DPLAYX_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(dplayx, dll) - void Load() - { - if (Config.WrapperMode != dtype.dplayx && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.dplayx); - - // Load dll functions - if (dll) - { - VISIT_DPLAYX_PROCS(LOAD_ORIGINAL_PROC); - } - } - - void Unhook() {} - }; - - extern dplayx_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/dsound.h b/Wrappers/dsound.h index 20253074..4a5417e9 100644 --- a/Wrappers/dsound.h +++ b/Wrappers/dsound.h @@ -1,12 +1,9 @@ #pragma once -// All procs -#define VISIT_DSOUND_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(DirectSoundCreate) \ visit(DirectSoundEnumerateA) \ visit(DirectSoundEnumerateW) \ - visit(DllCanUnloadNow) \ - visit(DllGetClassObject) \ visit(DirectSoundCaptureCreate) \ visit(DirectSoundCaptureEnumerateA) \ visit(DirectSoundCaptureEnumerateW) \ @@ -15,71 +12,6 @@ visit(DirectSoundCreate8) \ visit(DirectSoundCaptureCreate8) -// DSoundCtrl procs -#define VISIT_DSOUNDCTR_PROCS(visit) \ - visit(DirectSoundCreate) \ - visit(DirectSoundEnumerateA) \ - visit(DirectSoundEnumerateW) \ - visit(DirectSoundCaptureCreate) \ - visit(DirectSoundCaptureEnumerateA) \ - visit(DirectSoundCaptureEnumerateW) \ - visit(GetDeviceID) \ - visit(DirectSoundFullDuplexCreate) \ - visit(DirectSoundCreate8) \ - visit(DirectSoundCaptureCreate8) - -#define HOOK_ALL_PROC(apiname) \ - apiname = (FARPROC)Hook::HookAPI(hModule_dll, dtypename[dtype.dsound], Hook::GetProcAddress(dll, #apiname), #apiname, DSoundCtrl::_ ## apiname); - -namespace dsound -{ - class dsound_dll - { - public: - HMODULE dll = nullptr; - VISIT_DSOUND_PROCS(ADD_FARPROC_MEMBER); - - void Load() - { - if (Config.WrapperMode != dtype.dsound && Config.WrapperMode != dtype.Auto && !Config.DSoundCtrl) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.dsound); - - // Load dll functions - if (dll) - { - VISIT_DSOUND_PROCS(LOAD_ORIGINAL_PROC); - - // Enable DSoundCtrl functions - if (Config.DSoundCtrl && Config.RealWrapperMode == dtype.dsound) - { - DirectSoundCreate = DSoundCtrl::_DirectSoundCreate; - DirectSoundEnumerateA = DSoundCtrl::_DirectSoundEnumerateA; - DirectSoundEnumerateW = DSoundCtrl::_DirectSoundEnumerateW; - DllCanUnloadNow = DSoundCtrl::_DllCanUnloadNow; - DllGetClassObject = DSoundCtrl::_DllGetClassObject; - DirectSoundCaptureCreate = DSoundCtrl::_DirectSoundCaptureCreate; - DirectSoundCaptureEnumerateA = DSoundCtrl::_DirectSoundCaptureEnumerateA; - DirectSoundCaptureEnumerateW = DSoundCtrl::_DirectSoundCaptureEnumerateW; - GetDeviceID = DSoundCtrl::_GetDeviceID; - DirectSoundFullDuplexCreate = DSoundCtrl::_DirectSoundFullDuplexCreate; - DirectSoundCreate8 = DSoundCtrl::_DirectSoundCreate8; - DirectSoundCaptureCreate8 = DSoundCtrl::_DirectSoundCaptureCreate8; - } - - // Hook APIs for DSoundCtrl functions - else if (Config.DSoundCtrl) - { - Logging::Log() << "Hooking dsound.dll APIs..."; - VISIT_DSOUNDCTR_PROCS(HOOK_ALL_PROC); - } - } - } - }; +PROC_CLASS(dsound, dll) - extern dsound_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/dxgi.h b/Wrappers/dxgi.h index ab868178..6721d365 100644 --- a/Wrappers/dxgi.h +++ b/Wrappers/dxgi.h @@ -1,6 +1,6 @@ #pragma once -#define VISIT_DXGI_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(ApplyCompatResolutionQuirking) \ visit(CompatString) \ visit(CompatValue) \ @@ -9,7 +9,6 @@ visit(PIXBeginCapture) \ visit(PIXEndCapture) \ visit(PIXGetCaptureState) \ - visit(SetAppCompatStringPointer) \ visit(CreateDXGIFactory1) \ visit(CreateDXGIFactory2) \ visit(CreateDXGIFactory) \ @@ -19,71 +18,8 @@ visit(DXGID3D10GetLayeredDeviceSize) \ visit(DXGID3D10RegisterLayers) \ visit(DXGIGetDebugInterface1) \ - visit(DXGIReportAdapterConfiguration) \ - visit(D3DKMTCloseAdapter) \ - visit(D3DKMTDestroyAllocation) \ - visit(D3DKMTDestroyContext) \ - visit(D3DKMTDestroyDevice) \ - visit(D3DKMTDestroySynchronizationObject) \ - visit(D3DKMTQueryAdapterInfo) \ - visit(D3DKMTSetDisplayPrivateDriverFormat) \ - visit(D3DKMTSignalSynchronizationObject) \ - visit(D3DKMTUnlock) \ - visit(OpenAdapter10) \ - visit(OpenAdapter10_2) \ - visit(D3DKMTCreateAllocation) \ - visit(D3DKMTCreateContext) \ - visit(D3DKMTCreateDevice) \ - visit(D3DKMTCreateSynchronizationObject) \ - visit(D3DKMTEscape) \ - visit(D3DKMTGetContextSchedulingPriority) \ - visit(D3DKMTGetDeviceState) \ - visit(D3DKMTGetDisplayModeList) \ - visit(D3DKMTGetMultisampleMethodList) \ - visit(D3DKMTGetRuntimeData) \ - visit(D3DKMTGetSharedPrimaryHandle) \ - visit(D3DKMTLock) \ - visit(D3DKMTOpenAdapterFromHdc) \ - visit(D3DKMTOpenResource) \ - visit(D3DKMTPresent) \ - visit(D3DKMTQueryAllocationResidency) \ - visit(D3DKMTQueryResourceInfo) \ - visit(D3DKMTRender) \ - visit(D3DKMTSetAllocationPriority) \ - visit(D3DKMTSetContextSchedulingPriority) \ - visit(D3DKMTSetDisplayMode) \ - visit(D3DKMTSetGammaRamp) \ - visit(D3DKMTSetVidPnSourceOwner) \ - visit(D3DKMTWaitForSynchronizationObject) \ - visit(D3DKMTWaitForVerticalBlankEvent) + visit(DXGIReportAdapterConfiguration) -namespace dxgi -{ - class dxgi_dll - { - public: - HMODULE dll = nullptr; - VISIT_DXGI_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(dxgi, dll) - void Load() - { - if (Config.WrapperMode != dtype.dxgi && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.dxgi); - - // Load dll functions - if (dll) - { - VISIT_DXGI_PROCS(LOAD_ORIGINAL_PROC); - } - } - - void Unhook() {} - }; - - extern dxgi_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/msacm32.h b/Wrappers/msacm32.h new file mode 100644 index 00000000..f7199474 --- /dev/null +++ b/Wrappers/msacm32.h @@ -0,0 +1,51 @@ +#pragma once + +#define VISIT_PROCS(visit) \ +visit(XRegThunkEntry) \ +visit(acmDriverAddA) \ +visit(acmDriverAddW) \ +visit(acmDriverClose) \ +visit(acmDriverDetailsA) \ +visit(acmDriverDetailsW) \ +visit(acmDriverEnum) \ +visit(acmDriverID) \ +visit(acmDriverMessage) \ +visit(acmDriverOpen) \ +visit(acmDriverPriority) \ +visit(acmDriverRemove) \ +visit(acmFilterChooseA) \ +visit(acmFilterChooseW) \ +visit(acmFilterDetailsA) \ +visit(acmFilterDetailsW) \ +visit(acmFilterEnumA) \ +visit(acmFilterEnumW) \ +visit(acmFilterTagDetailsA) \ +visit(acmFilterTagDetailsW) \ +visit(acmFilterTagEnumA) \ +visit(acmFilterTagEnumW) \ +visit(acmFormatChooseA) \ +visit(acmFormatChooseW) \ +visit(acmFormatDetailsA) \ +visit(acmFormatDetailsW) \ +visit(acmFormatEnumA) \ +visit(acmFormatEnumW) \ +visit(acmFormatSuggest) \ +visit(acmFormatTagDetailsA) \ +visit(acmFormatTagDetailsW) \ +visit(acmFormatTagEnumA) \ +visit(acmFormatTagEnumW) \ +visit(acmGetVersion) \ +visit(acmMessage32) \ +visit(acmMetrics) \ +visit(acmStreamClose) \ +visit(acmStreamConvert) \ +visit(acmStreamMessage) \ +visit(acmStreamOpen) \ +visit(acmStreamPrepareHeader) \ +visit(acmStreamReset) \ +visit(acmStreamSize) \ +visit(acmStreamUnprepareHeader) + +PROC_CLASS(msacm32, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/msvfw32.h b/Wrappers/msvfw32.h new file mode 100644 index 00000000..1d64cc5e --- /dev/null +++ b/Wrappers/msvfw32.h @@ -0,0 +1,54 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(VideoForWindowsVersion) \ + visit(DrawDibBegin) \ + visit(DrawDibChangePalette) \ + visit(DrawDibClose) \ + visit(DrawDibDraw) \ + visit(DrawDibEnd) \ + visit(DrawDibGetBuffer) \ + visit(DrawDibGetPalette) \ + visit(DrawDibOpen) \ + visit(DrawDibProfileDisplay) \ + visit(DrawDibRealize) \ + visit(DrawDibSetPalette) \ + visit(DrawDibStart) \ + visit(DrawDibStop) \ + visit(DrawDibTime) \ + visit(GetOpenFileNamePreview) \ + visit(GetOpenFileNamePreviewA) \ + visit(GetOpenFileNamePreviewW) \ + visit(GetSaveFileNamePreviewA) \ + visit(GetSaveFileNamePreviewW) \ + visit(ICClose) \ + visit(ICCompress) \ + visit(ICCompressorChoose) \ + visit(ICCompressorFree) \ + visit(ICDecompress) \ + visit(ICDraw) \ + visit(ICDrawBegin) \ + visit(ICGetDisplayFormat) \ + visit(ICGetInfo) \ + visit(ICImageCompress) \ + visit(ICImageDecompress) \ + visit(ICInfo) \ + visit(ICInstall) \ + visit(ICLocate) \ + visit(ICMThunk32) \ + visit(ICOpen) \ + visit(ICOpenFunction) \ + visit(ICRemove) \ + visit(ICSendMessage) \ + visit(ICSeqCompressFrame) \ + visit(ICSeqCompressFrameEnd) \ + visit(ICSeqCompressFrameStart) \ + visit(MCIWndCreate) \ + visit(MCIWndCreateA) \ + visit(MCIWndCreateW) \ + visit(MCIWndRegisterClass) \ + visit(StretchDIB) + +PROC_CLASS(msvfw32, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/shared.h b/Wrappers/shared.h new file mode 100644 index 00000000..93031dab --- /dev/null +++ b/Wrappers/shared.h @@ -0,0 +1,71 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(DllCanUnloadNow) \ + visit(DllGetClassObject) \ + visit(DllRegisterServer) \ + visit(DllUnregisterServer) \ + visit(DebugSetMute) \ + visit(SetAppCompatStringPointer) \ + visit(D3DFree) \ + visit(D3DMalloc) \ + visit(D3DRealloc) \ + visit(Direct3DCreateDevice) \ + visit(Direct3DCreate) \ + visit(Direct3D_HALCleanUp) \ + visit(FlushD3DDevices) \ + visit(PaletteAssociateNotify) \ + visit(PaletteUpdateNotify) \ + visit(SurfaceFlipNotify) \ + visit(D3DKMTCloseAdapter) \ + visit(D3DKMTDestroyAllocation) \ + visit(D3DKMTDestroyContext) \ + visit(D3DKMTDestroyDevice) \ + visit(D3DKMTDestroySynchronizationObject) \ + visit(D3DKMTPresent) \ + visit(D3DKMTQueryAdapterInfo) \ + visit(D3DKMTSetDisplayPrivateDriverFormat) \ + visit(D3DKMTSignalSynchronizationObject) \ + visit(D3DKMTUnlock) \ + visit(D3DKMTWaitForSynchronizationObject) \ + visit(D3DKMTCreateAllocation) \ + visit(D3DKMTCreateContext) \ + visit(D3DKMTCreateDevice) \ + visit(D3DKMTCreateSynchronizationObject) \ + visit(D3DKMTEscape) \ + visit(D3DKMTGetContextSchedulingPriority) \ + visit(D3DKMTGetDeviceState) \ + visit(D3DKMTGetDisplayModeList) \ + visit(D3DKMTGetMultisampleMethodList) \ + visit(D3DKMTGetRuntimeData) \ + visit(D3DKMTGetSharedPrimaryHandle) \ + visit(D3DKMTLock) \ + visit(D3DKMTOpenAdapterFromHdc) \ + visit(D3DKMTOpenResource) \ + visit(D3DKMTQueryAllocationResidency) \ + visit(D3DKMTQueryResourceInfo) \ + visit(D3DKMTRender) \ + visit(D3DKMTSetAllocationPriority) \ + visit(D3DKMTSetContextSchedulingPriority) \ + visit(D3DKMTSetDisplayMode) \ + visit(D3DKMTSetGammaRamp) \ + visit(D3DKMTSetVidPnSourceOwner) \ + visit(D3DKMTWaitForVerticalBlankEvent) \ + visit(OpenAdapter10) \ + visit(OpenAdapter10_2) + +namespace ShardProcs +{ + using namespace Wrapper; + VISIT_PROCS(ADD_FARPROC_MEMBER); + void Load(HMODULE dll) + { + if (dll) + { + VISIT_PROCS(LOAD_ORIGINAL_PROC); + } + } + VISIT_PROCS(CREATE_PROC_STUB) +} + +#undef VISIT_PROCS diff --git a/Wrappers/vorbisFile.h b/Wrappers/vorbisFile.h new file mode 100644 index 00000000..de447fba --- /dev/null +++ b/Wrappers/vorbisFile.h @@ -0,0 +1,42 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(ov_clear) \ + visit(ov_open) \ + visit(ov_open_callbacks) \ + visit(ov_bitrate) \ + visit(ov_bitrate_instant) \ + visit(ov_streams) \ + visit(ov_seekable) \ + visit(ov_serialnumber) \ + visit(ov_raw_total) \ + visit(ov_pcm_total) \ + visit(ov_time_total) \ + visit(ov_raw_seek) \ + visit(ov_pcm_seek) \ + visit(ov_pcm_seek_page) \ + visit(ov_time_seek) \ + visit(ov_time_seek_page) \ + visit(ov_raw_seek_lap) \ + visit(ov_pcm_seek_lap) \ + visit(ov_pcm_seek_page_lap) \ + visit(ov_time_seek_lap) \ + visit(ov_time_seek_page_lap) \ + visit(ov_raw_tell) \ + visit(ov_pcm_tell) \ + visit(ov_time_tell) \ + visit(ov_info) \ + visit(ov_comment) \ + visit(ov_read) \ + visit(ov_read_float) \ + visit(ov_test) \ + visit(ov_test_callbacks) \ + visit(ov_test_open) \ + visit(ov_crosslap) \ + visit(ov_halfrate) \ + visit(ov_halfrate_p) \ + visit(ov_fopen) + +PROC_CLASS(vorbisfile, dll) + +#undef VISIT_PROCS diff --git a/Wrappers/winmm.h b/Wrappers/winmm.h index 7dc203b5..0832e488 100644 --- a/Wrappers/winmm.h +++ b/Wrappers/winmm.h @@ -1,6 +1,6 @@ #pragma once -#define VISIT_WINMM_PROCS(visit) \ +#define VISIT_PROCS(visit) \ visit(CloseDriver) \ visit(DefDriverProc) \ visit(DriverCallback) \ @@ -194,35 +194,13 @@ visit(wid32Message) \ visit(winmmDbgOut) \ visit(winmmSetDebugLevel) \ - visit(wod32Message) + visit(wod32Message) \ + visit(sndOpenSound) \ + visit(winmmbaseFreeMMEHandles) \ + visit(winmmbaseGetWOWHandle) \ + visit(winmmbaseHandle32FromHandle16) \ + visit(winmmbaseSetWOWHandle) -namespace winmm -{ - class winmm_dll - { - public: - HMODULE dll = nullptr; - VISIT_WINMM_PROCS(ADD_FARPROC_MEMBER); +PROC_CLASS(winmm, dll) - void Load() - { - if (Config.WrapperMode != dtype.winmm && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.winmm); - - // Load dll functions - if (dll) - { - VISIT_WINMM_PROCS(LOAD_ORIGINAL_PROC); - } - } - - void Unhook() {} - }; - - extern winmm_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/winspool.h b/Wrappers/winspool.h index c4f7975f..b4da42e6 100644 --- a/Wrappers/winspool.h +++ b/Wrappers/winspool.h @@ -1,6 +1,8 @@ #pragma once -#define VISIT_WINSPOOL_PROCS(visit) \ +#undef DeviceCapabilities + +#define VISIT_PROCS(visit) \ visit(ADVANCEDSETUPDIALOG) \ visit(AdvancedSetupDialog) \ visit(ConvertAnsiDevModeToUnicodeDevmode) \ @@ -199,35 +201,6 @@ visit(WritePrinter) \ visit(XcvDataW) -#undef DeviceCapabilities - -namespace winspool -{ - class winspool_dll - { - public: - HMODULE dll = nullptr; - VISIT_WINSPOOL_PROCS(ADD_FARPROC_MEMBER); - - void Load() - { - if (Config.WrapperMode != dtype.winspool && Config.WrapperMode != dtype.Auto) - { - return; - } - - // Load real dll - dll = LoadDll(dtype.winspool); - - // Load dll functions - if (dll) - { - VISIT_WINSPOOL_PROCS(LOAD_ORIGINAL_PROC); - } - } - - void Unhook() {} - }; +PROC_CLASS(winspool, drv) - extern winspool_dll module; -} +#undef VISIT_PROCS diff --git a/Wrappers/wrapper.cpp b/Wrappers/wrapper.cpp index b4e521a9..5acf0dea 100644 --- a/Wrappers/wrapper.cpp +++ b/Wrappers/wrapper.cpp @@ -12,58 +12,105 @@ * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as * being the original software. * 3. This notice may not be removed or altered from any source distribution. -* -* ASI plugin loader taken from source code found in Ultimate ASI Loader -* https://github.com/ThirteenAG/Ultimate-ASI-Loader */ -// Default -#include "Settings\Settings.h" -#include "Dllmain\Dllmain.h" -#include "Hooking\Hook.h" -#include "Logging\Logging.h" +#define WIN32_LEAN_AND_MEAN +#include +#include #include "wrapper.h" -// Libraries -#include "d3dx9.h" -#include "dwmapi.h" -#include "uxtheme.h" -using namespace Wrapper; +#define ADD_FARPROC_MEMBER(procName) \ + FARPROC procName ## _var = jmpaddr; + +#define LOAD_ORIGINAL_PROC(procName) \ + procName ## _var = GetProcAddress(dll, #procName, jmpaddr); + +#define CREATE_PROC_STUB(procName) \ + extern "C" __declspec(naked) void __stdcall procName() \ + { \ + __asm mov edi, edi \ + __asm jmp procName ## _var \ + } + +#define PROC_CLASS(className, Extension) \ + namespace className \ + { \ + using namespace Wrapper; \ + char *Name = #className ## "." ## #Extension; \ + VISIT_PROCS(ADD_FARPROC_MEMBER); \ + HMODULE Load(char *strName) \ + { \ + char path[MAX_PATH]; \ + GetSystemDirectoryA(path, MAX_PATH); \ + strcat_s(path, MAX_PATH, "\\"); \ + if (strName) \ + { \ + strcat_s(path, MAX_PATH, strName); \ + } \ + else \ + { \ + strcat_s(path, MAX_PATH, Name); \ + } \ + HMODULE dll = LoadLibraryA(path); \ + if (dll) \ + { \ + VISIT_PROCS(LOAD_ORIGINAL_PROC); \ + ShardProcs::Load(dll); \ + } \ + return dll; \ + } \ + HMODULE Load() \ + { \ + return Load(nullptr); \ + } \ + VISIT_PROCS(CREATE_PROC_STUB) \ + } + +namespace Wrapper +{ + FARPROC GetProcAddress(HMODULE hModule, LPCSTR FunctionName, FARPROC SetReturnValue); + __declspec() HRESULT __stdcall _jmpaddr(); + constexpr FARPROC jmpaddr = (FARPROC)*_jmpaddr; +} + +// Shared procs +#include "shared.h" // Wrappers #include "bcrypt.h" #include "cryptsp.h" -#include "D3d8to9\d3d8.h" +#include "d2d1.h" #include "d3d8.h" #include "d3d9.h" -#include "dsound.h" +#include "d3d10.h" +#include "d3d10core.h" +#include "d3d11.h" +#include "d3d12.h" +#include "d3dim.h" +#include "d3dim700.h" +#include "dciman32.h" #include "ddraw.h" #include "dinput.h" +#include "dinput8.h" #include "dplayx.h" +#include "dsound.h" #include "dxgi.h" +#include "msacm32.h" +#include "msvfw32.h" +#include "vorbisfile.h" #include "winmm.h" #include "winspool.h" -#include "dciman32.h" +#include "xlive.h" -namespace Wrapper +__declspec(naked) HRESULT __stdcall Wrapper::_jmpaddr() { - // Declare varables - std::vector custom_dll; // Used for custom dll's and asi plugins - HMODULE dllhandle[dtypeArraySize] = { nullptr }; // Used for wrapper dll's - - // Function declarations - void LoadPlugins(); - void FindFiles(WIN32_FIND_DATA*); - void LoadCustomDll(); + __asm + { + mov eax, 0x80004001L // return E_NOTIMPL + retn 16 + } } -// Wrapper classes -VISIT_WRAPPERS(ADD_NAMESPACE_CLASS) - -// Proc functions -VISIT_WRAPPERS(CREATE_ALL_PROC_STUB) - -// Get pointer for funtion name use custom return value FARPROC Wrapper::GetProcAddress(HMODULE hModule, LPCSTR FunctionName, FARPROC SetReturnValue) { if (!FunctionName || !hModule) @@ -81,208 +128,60 @@ FARPROC Wrapper::GetProcAddress(HMODULE hModule, LPCSTR FunctionName, FARPROC Se return ProcAddress; } -// Load real dll file that is being wrapped -HMODULE Wrapper::LoadDll(DWORD dlltype) -{ - // Check for valid dlltype - if (dlltype == 0 || dlltype >= dtypeArraySize) - { - return nullptr; - } - - // Check if dll is already loaded - if (dllhandle[dlltype]) - { - return dllhandle[dlltype]; - } - - // Load dll from ini, if DllPath is not '0' - if (!Config.szDllPath.empty() && Config.WrapperMode == dlltype) - { - Logging::Log() << "Loading " << Config.szDllPath << " library"; - dllhandle[dlltype] = LoadLibrary(Config.szDllPath.c_str()); - if (!dllhandle[dlltype]) - { - Logging::Log() << "Cannot load " << Config.szDllPath << " library"; - } - } - - // Load current dll - if (!dllhandle[dlltype] && Config.WrapperMode != dlltype) - { - Logging::Log() << "Loading " << dtypename[dlltype] << " library"; - dllhandle[dlltype] = LoadLibrary(dtypename[dlltype]); - if (!dllhandle[dlltype]) - { - Logging::Log() << "Cannot load " << dtypename[dlltype] << " library"; - } - } - - // Load default system dll - if (!dllhandle[dlltype]) - { - char path[MAX_PATH]; - GetSystemDirectory(path, MAX_PATH); - strcat_s(path, MAX_PATH, "\\"); - strcat_s(path, MAX_PATH, dtypename[dlltype]); - Logging::Log() << "Loading " << path << " library"; - dllhandle[dlltype] = LoadLibrary(path); - } - - // Cannot load dll - if (!dllhandle[dlltype]) - { - Logging::Log() << "Cannot load " << dtypename[dlltype] << " library"; - if (Config.WrapperMode != dtype.Auto) - { - ExitProcess(0); - } - } - - // Return dll handle - return dllhandle[dlltype]; -} - -// Load custom dll files -void Wrapper::LoadCustomDll() +HMODULE Wrapper::CreateWrapper(HMODULE hModule) { - for (size_t x = 0; x < Config.szCustomDllPath.size(); ++x) - { - // Check if path is empty - if (!Config.szCustomDllPath[x].empty()) - { - Logging::Log() << "Loading custom " << Config.szCustomDllPath[x] << " library"; - // Load dll from ini - auto h = LoadLibrary(Config.szCustomDllPath[x].c_str()); + // Declare vars + HMODULE dll = nullptr; - // Cannot load dll - if (!h) - { - Logging::Log() << "Cannot load custom " << Config.szCustomDllPath[x] << " library"; - } - else - { - custom_dll.push_back(h); - } - } - } -} - -// Find asi plugins to load -void Wrapper::FindFiles(WIN32_FIND_DATA* fd) -{ - char dir[MAX_PATH] = { 0 }; - GetCurrentDirectory(MAX_PATH, dir); - - HANDLE asiFile = FindFirstFile("*.asi", fd); - if (asiFile != INVALID_HANDLE_VALUE) - { - do { - if (!(fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - auto pos = strlen(fd->cFileName); - - if (fd->cFileName[pos - 4] == '.' && - (fd->cFileName[pos - 3] == 'a' || fd->cFileName[pos - 3] == 'A') && - (fd->cFileName[pos - 2] == 's' || fd->cFileName[pos - 2] == 'S') && - (fd->cFileName[pos - 1] == 'i' || fd->cFileName[pos - 1] == 'I')) - { - char path[MAX_PATH] = { 0 }; - sprintf_s(path, "%s\\%s", dir, fd->cFileName); - - Logging::Log() << "Loading Plugin: " << path; - auto h = LoadLibrary(path); - SetCurrentDirectory(dir); //in case asi switched it - - if (!h) - { - Logging::LogFormat("Unable to load %s. Error: %d", fd->cFileName, GetLastError()); - } - else - { - custom_dll.push_back(h); - } - } - } - } while (FindNextFile(asiFile, fd)); - FindClose(asiFile); - } -} - -// Load asi plugins -void Wrapper::LoadPlugins() -{ - Logging::Log() << "Loading ASI Plugins"; + // Get module full path and name + char path[MAX_PATH]; + GetModuleFileNameA(hModule, path, sizeof(path)); - char oldDir[MAX_PATH]; // store the current directory - GetCurrentDirectory(MAX_PATH, oldDir); + // Search backwards for last backslash in filepath + char* pdest = strrchr(path, '\\'); - char selfPath[MAX_PATH]; - GetModuleFileName(hModule_dll, selfPath, MAX_PATH); - *strrchr(selfPath, '\\') = '\0'; - SetCurrentDirectory(selfPath); - - WIN32_FIND_DATA fd; - if (!Config.LoadFromScriptsOnly) - FindFiles(&fd); - - SetCurrentDirectory(selfPath); - - if (SetCurrentDirectory("scripts\\")) - FindFiles(&fd); - - SetCurrentDirectory(selfPath); - - if (SetCurrentDirectory("plugins\\")) - FindFiles(&fd); - - SetCurrentDirectory(oldDir); // Reset the current directory -} - -// Load wrapper dll files -void Wrapper::DllAttach() -{ - // Load wrappers - VISIT_WRAPPERS(LOAD_WRAPPER); - - // Load custom dlls - if (Config.szCustomDllPath.size() != 0) - { - LoadCustomDll(); - } - - // Load ASI plugins - if (Config.LoadPlugins) - { - LoadPlugins(); - } -} - -// Unload all dll files loaded by the wrapper -void Wrapper::DllDetach() -{ - // Unload custom libraries - while (Config.szCustomDllPath.size() != 0) + // If backslash not found in filepath + if (pdest) { - // Unload dll - FreeLibrary(custom_dll.back()); - custom_dll.pop_back(); + // Extract filename from file path + std::string input(pdest+1); + strcpy_s(path, MAX_PATH, input.c_str()); } - custom_dll.clear(); - // Unload wrapper libraries - for (int x = 1; x < dtypeArraySize; ++x) + // Check dll name and load correct wrapper + { using namespace bcrypt; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace cryptsp; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d2d1; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3d8; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3d9; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3d10; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3d10core; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3d11; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3d12; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3dim; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace d3dim700; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace dciman32; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace ddraw; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace dinput; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace dinput8; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace dplayx; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace dsound; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace dxgi; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace msacm32; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace msvfw32; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace vorbisfile; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace winmm; if (_strcmpi(path, "winmmbase.dll") == 0) dll = Load("winmmbase.dll"); } + { using namespace winspool; if (_strcmpi(path, Name) == 0) dll = Load(); } + { using namespace xlive; if (_strcmpi(path, Name) == 0) dll = Load(); } + + // Special for winmm.dll because sometimes it is changed to win32 or winnm or some other name + if (strlen(path) > 8) { - // If dll was loaded - if (dllhandle[x]) - { - // Unload dll - FreeLibrary(dllhandle[x]); - } + path[3] = 'm'; + path[4] = 'm'; } + { using namespace winmm; if (_strcmpi(path, Name) == 0) dll = Load(); } - // Unload dynmaic libraries - UnLoadd3dx9(); - UnLoaddwmapi(); - UnLoadUxtheme(); + // Exit and return handle + return dll; } diff --git a/Wrappers/wrapper.def b/Wrappers/wrapper.def new file mode 100644 index 00000000..2fab8cef --- /dev/null +++ b/Wrappers/wrapper.def @@ -0,0 +1,1374 @@ +LIBRARY +EXPORTS + + +; **** +;LIBRARY "dsound" <--- Needs to have the correct ordinals since some programs use the ordinal numbers for dsound APIs +; **** +DirectSoundCreate @1 +DirectSoundEnumerateA @2 +DirectSoundEnumerateW @3 +DllCanUnloadNow PRIVATE +DllGetClassObject PRIVATE +DirectSoundCaptureCreate @6 +DirectSoundCaptureEnumerateA @7 +DirectSoundCaptureEnumerateW @8 +GetDeviceID @9 +DirectSoundFullDuplexCreate @10 +DirectSoundCreate8 @11 +DirectSoundCaptureCreate8 @12 + + +; **** +;LIBRARY "bcrypt" +; **** +BCryptAddContextFunction +BCryptAddContextFunctionProvider +BCryptCloseAlgorithmProvider +BCryptConfigureContext +BCryptConfigureContextFunction +BCryptCreateContext +BCryptCreateHash +BCryptCreateMultiHash +BCryptDecrypt +BCryptDeleteContext +BCryptDeriveKey +BCryptDeriveKeyCapi +BCryptDeriveKeyPBKDF2 +BCryptDestroyHash +BCryptDestroyKey +BCryptDestroySecret +BCryptDuplicateHash +BCryptDuplicateKey +BCryptEncrypt +BCryptEnumAlgorithms +BCryptEnumContextFunctionProviders +BCryptEnumContextFunctions +BCryptEnumContexts +BCryptEnumProviders +BCryptEnumRegisteredProviders +BCryptExportKey +BCryptFinalizeKeyPair +BCryptFinishHash +BCryptFreeBuffer +BCryptGenRandom +BCryptGenerateKeyPair +BCryptGenerateSymmetricKey +BCryptGetFipsAlgorithmMode +BCryptGetProperty +BCryptHash +BCryptHashData +BCryptImportKey +BCryptImportKeyPair +BCryptKeyDerivation +BCryptOpenAlgorithmProvider +BCryptProcessMultiOperations +BCryptQueryContextConfiguration +BCryptQueryContextFunctionConfiguration +BCryptQueryContextFunctionProperty +BCryptQueryProviderRegistration +BCryptRegisterConfigChangeNotify +BCryptRegisterProvider +BCryptRemoveContextFunction +BCryptRemoveContextFunctionProvider +BCryptResolveProviders +BCryptSecretAgreement +BCryptSetAuditingInterface +BCryptSetContextFunctionProperty +BCryptSetProperty +BCryptSignHash +BCryptUnregisterConfigChangeNotify +BCryptUnregisterProvider +BCryptVerifySignature + + +; **** +;LIBRARY "cryptsp" +; **** +CheckSignatureInFile +CryptAcquireContextA +CryptAcquireContextW +CryptContextAddRef +CryptCreateHash +CryptDecrypt +CryptDeriveKey +CryptDestroyHash +CryptDestroyKey +CryptDuplicateHash +CryptDuplicateKey +CryptEncrypt +CryptEnumProviderTypesA +CryptEnumProviderTypesW +CryptEnumProvidersA +CryptEnumProvidersW +CryptExportKey +CryptGenKey +CryptGenRandom +CryptGetDefaultProviderA +CryptGetDefaultProviderW +CryptGetHashParam +CryptGetKeyParam +CryptGetProvParam +CryptGetUserKey +CryptHashData +CryptHashSessionKey +CryptImportKey +CryptReleaseContext +CryptSetHashParam +CryptSetKeyParam +CryptSetProvParam +CryptSetProviderA +CryptSetProviderExA +CryptSetProviderExW +CryptSetProviderW +CryptSignHashA +CryptSignHashW +CryptVerifySignatureA +CryptVerifySignatureW +SystemFunction006 +SystemFunction007 +SystemFunction008 +SystemFunction009 +SystemFunction010 +SystemFunction011 +SystemFunction012 +SystemFunction013 +SystemFunction014 +SystemFunction015 +SystemFunction016 +SystemFunction018 +SystemFunction020 +SystemFunction021 +SystemFunction022 +SystemFunction023 +SystemFunction024 +SystemFunction025 +SystemFunction026 +SystemFunction027 +SystemFunction030 +SystemFunction031 +SystemFunction032 +SystemFunction033 +SystemFunction035 + + +; **** +;LIBRARY "d2d1" +; **** +D2D1CreateFactory +D2D1MakeRotateMatrix +D2D1MakeSkewMatrix +D2D1IsMatrixInvertible +D2D1InvertMatrix +D2D1ConvertColorSpace +D2D1CreateDevice +D2D1CreateDeviceContext +D2D1SinCos +D2D1Tan +D2D1Vec3Length +D2D1ComputeMaximumScaleFactor +D2D1GetGradientMeshInteriorPointsFromCoonsPatch +D2DTkCreateOn12Device +D2DTkCreateAlgorithmFactory + + +; **** +;LIBRARY "d3d8" +; **** +Direct3D8EnableMaximizedWindowedModeShim +ValidatePixelShader +ValidateVertexShader +DebugSetMute +Direct3DCreate8 + + +; **** +;LIBRARY "d3d9" +; **** +Direct3DShaderValidatorCreate9 +PSGPError +PSGPSampleTexture +D3DPERF_BeginEvent +D3DPERF_EndEvent +D3DPERF_GetStatus +D3DPERF_QueryRepeatFrame +D3DPERF_SetMarker +D3DPERF_SetOptions +D3DPERF_SetRegion +DebugSetLevel +DebugSetMute +Direct3D9EnableMaximizedWindowedModeShim +Direct3DCreate9 +Direct3DCreate9Ex + + +; **** +;LIBRARY "d3d10" +; **** +RevertToOldImplementation +D3D10CompileEffectFromMemory +D3D10CompileShader +D3D10CreateBlob +D3D10CreateDevice +D3D10CreateDeviceAndSwapChain +D3D10CreateEffectFromMemory +D3D10CreateEffectPoolFromMemory +D3D10CreateStateBlock +D3D10DisassembleEffect +D3D10DisassembleShader +D3D10GetGeometryShaderProfile +D3D10GetInputAndOutputSignatureBlob +D3D10GetInputSignatureBlob +D3D10GetOutputSignatureBlob +D3D10GetPixelShaderProfile +D3D10GetShaderDebugInfo +D3D10GetVersion +D3D10GetVertexShaderProfile +D3D10PreprocessShader +D3D10ReflectShader +D3D10RegisterLayers +D3D10StateBlockMaskDifference +D3D10StateBlockMaskDisableAll +D3D10StateBlockMaskDisableCapture +D3D10StateBlockMaskEnableAll +D3D10StateBlockMaskEnableCapture +D3D10StateBlockMaskGetSetting +D3D10StateBlockMaskIntersect +D3D10StateBlockMaskUnion + + +; **** +;LIBRARY "d3d10core" +; **** +D3DKMTCloseAdapter +D3DKMTDestroyAllocation +D3DKMTDestroyContext +D3DKMTDestroyDevice +D3DKMTDestroySynchronizationObject +D3DKMTPresent +D3DKMTQueryAdapterInfo +D3DKMTSetDisplayPrivateDriverFormat +D3DKMTSignalSynchronizationObject +D3DKMTUnlock +D3DKMTWaitForSynchronizationObject +OpenAdapter10 +OpenAdapter10_2 +D3D10CoreCreateDevice +D3D10CoreGetSupportedVersions +D3D10CoreGetVersion +D3D10CoreRegisterLayers +D3DKMTCreateAllocation +D3DKMTCreateContext +D3DKMTCreateDevice +D3DKMTCreateSynchronizationObject +D3DKMTEscape +D3DKMTGetContextSchedulingPriority +D3DKMTGetDeviceState +D3DKMTGetDisplayModeList +D3DKMTGetMultisampleMethodList +D3DKMTGetRuntimeData +D3DKMTGetSharedPrimaryHandle +D3DKMTLock +D3DKMTOpenAdapterFromHdc +D3DKMTOpenResource +D3DKMTQueryAllocationResidency +D3DKMTQueryResourceInfo +D3DKMTRender +D3DKMTSetAllocationPriority +D3DKMTSetContextSchedulingPriority +D3DKMTSetDisplayMode +D3DKMTSetGammaRamp +D3DKMTSetVidPnSourceOwner +D3DKMTWaitForVerticalBlankEvent + + +; **** +;LIBRARY "d3d11" +; **** +D3D11CreateDeviceForD3D12 +D3DKMTCloseAdapter +D3DKMTDestroyAllocation +D3DKMTDestroyContext +D3DKMTDestroyDevice +D3DKMTDestroySynchronizationObject +D3DKMTPresent +D3DKMTQueryAdapterInfo +D3DKMTSetDisplayPrivateDriverFormat +D3DKMTSignalSynchronizationObject +D3DKMTUnlock +D3DKMTWaitForSynchronizationObject +EnableFeatureLevelUpgrade +OpenAdapter10 +OpenAdapter10_2 +CreateDirect3D11DeviceFromDXGIDevice +CreateDirect3D11SurfaceFromDXGISurface +D3D11CoreCreateDevice +D3D11CoreCreateLayeredDevice +D3D11CoreGetLayeredDeviceSize +D3D11CoreRegisterLayers +D3D11CreateDevice +D3D11CreateDeviceAndSwapChain +D3D11On12CreateDevice +D3DKMTCreateAllocation +D3DKMTCreateContext +D3DKMTCreateDevice +D3DKMTCreateSynchronizationObject +D3DKMTEscape +D3DKMTGetContextSchedulingPriority +D3DKMTGetDeviceState +D3DKMTGetDisplayModeList +D3DKMTGetMultisampleMethodList +D3DKMTGetRuntimeData +D3DKMTGetSharedPrimaryHandle +D3DKMTLock +D3DKMTOpenAdapterFromHdc +D3DKMTOpenResource +D3DKMTQueryAllocationResidency +D3DKMTQueryResourceInfo +D3DKMTRender +D3DKMTSetAllocationPriority +D3DKMTSetContextSchedulingPriority +D3DKMTSetDisplayMode +D3DKMTSetGammaRamp +D3DKMTSetVidPnSourceOwner +D3DKMTWaitForVerticalBlankEvent +D3DPerformance_BeginEvent +D3DPerformance_EndEvent +D3DPerformance_GetStatus +D3DPerformance_SetMarker + + +; **** +;LIBRARY "d3d12" +; **** +GetBehaviorValue +D3D12CreateDevice +D3D12GetDebugInterface +SetAppCompatStringPointer +D3D12CoreCreateLayeredDevice +D3D12CoreGetLayeredDeviceSize +D3D12CoreRegisterLayers +D3D12CreateRootSignatureDeserializer +D3D12CreateVersionedRootSignatureDeserializer +D3D12EnableExperimentalFeatures +D3D12SerializeRootSignature +D3D12SerializeVersionedRootSignature + + +; **** +;LIBRARY "d3dim" +; **** +D3DFree +D3DMalloc +D3DRealloc +Direct3DCreateDevice +Direct3DCreateTexture +Direct3DGetSWRastZPixFmts +Direct3DCreate +Direct3D_HALCleanUp +FlushD3DDevices2 +FlushD3DDevices +PaletteAssociateNotify +PaletteUpdateNotify +SurfaceFlipNotify + + +; **** +;LIBRARY "d3dim700" +; **** +D3DFree +D3DMalloc +D3DRealloc +Direct3DCreateDevice +CreateTexture +D3DBreakVBLock +D3DTextureUpdate +DestroyTexture +Direct3DCreate +Direct3D_HALCleanUp +FlushD3DDevices +GetLOD +GetPriority +PaletteAssociateNotify +PaletteUpdateNotify +SetLOD +SetPriority +SurfaceFlipNotify + + +; **** +;LIBRARY "dciman32" +; **** +DCIBeginAccess +DCICloseProvider +DCICreateOffscreen +DCICreateOverlay +DCICreatePrimary +DCIDestroy +DCIDraw +DCIEndAccess +DCIEnum +DCIOpenProvider +DCISetClipList +DCISetDestination +DCISetSrcDestClip +GetDCRegionData +GetWindowRegionData +WinWatchClose +WinWatchDidStatusChange +WinWatchGetClipList +WinWatchNotify +WinWatchOpen + + +; **** +;LIBRARY "ddraw" +; **** +AcquireDDThreadLock +CompleteCreateSysmemSurface +D3DParseUnknownCommand +DDGetAttachedSurfaceLcl +DDInternalLock +DDInternalUnlock +DSoundHelp +DirectDrawCreate +DirectDrawCreateClipper +DirectDrawCreateEx +DirectDrawEnumerateA +DirectDrawEnumerateExA +DirectDrawEnumerateExW +DirectDrawEnumerateW +DllCanUnloadNow PRIVATE +DllGetClassObject PRIVATE +GetDDSurfaceLocal +GetOLEThunkData +GetSurfaceFromDC +RegisterSpecialCase +ReleaseDDThreadLock +SetAppCompatData + + +; **** +;LIBRARY "dinput" +; **** +DirectInputCreateA +DirectInputCreateEx +DirectInputCreateW + + +; **** +;LIBRARY "dinput8" +; **** +DirectInput8Create +GetdfDIJoystick + + +; **** +;LIBRARY "dplayx" +; **** +DirectPlayCreate +DirectPlayEnumerate +DirectPlayEnumerateA +DirectPlayEnumerateW +DirectPlayLobbyCreateA +DirectPlayLobbyCreateW + + +; **** +;LIBRARY "dxgi" +; **** +ApplyCompatResolutionQuirking +CompatString +CompatValue +DXGIDumpJournal +DXGIRevertToSxS +PIXBeginCapture +PIXEndCapture +PIXGetCaptureState +SetAppCompatStringPointer +CreateDXGIFactory1 +CreateDXGIFactory2 +CreateDXGIFactory +DXGID3D10CreateDevice +DXGID3D10CreateLayeredDevice +DXGID3D10ETWRundown +DXGID3D10GetLayeredDeviceSize +DXGID3D10RegisterLayers +DXGIGetDebugInterface1 +DXGIReportAdapterConfiguration +D3DKMTCloseAdapter +D3DKMTDestroyAllocation +D3DKMTDestroyContext +D3DKMTDestroyDevice +D3DKMTDestroySynchronizationObject +D3DKMTQueryAdapterInfo +D3DKMTSetDisplayPrivateDriverFormat +D3DKMTSignalSynchronizationObject +D3DKMTUnlock +OpenAdapter10 +OpenAdapter10_2 +D3DKMTCreateAllocation +D3DKMTCreateContext +D3DKMTCreateDevice +D3DKMTCreateSynchronizationObject +D3DKMTEscape +D3DKMTGetContextSchedulingPriority +D3DKMTGetDeviceState +D3DKMTGetDisplayModeList +D3DKMTGetMultisampleMethodList +D3DKMTGetRuntimeData +D3DKMTGetSharedPrimaryHandle +D3DKMTLock +D3DKMTOpenAdapterFromHdc +D3DKMTOpenResource +D3DKMTPresent +D3DKMTQueryAllocationResidency +D3DKMTQueryResourceInfo +D3DKMTRender +D3DKMTSetAllocationPriority +D3DKMTSetContextSchedulingPriority +D3DKMTSetDisplayMode +D3DKMTSetGammaRamp +D3DKMTSetVidPnSourceOwner +D3DKMTWaitForSynchronizationObject +D3DKMTWaitForVerticalBlankEvent + + +; **** +;LIBRARY "msacm32" +; **** +XRegThunkEntry +acmDriverAddA +acmDriverAddW +acmDriverClose +acmDriverDetailsA +acmDriverDetailsW +acmDriverEnum +acmDriverID +acmDriverMessage +acmDriverOpen +acmDriverPriority +acmDriverRemove +acmFilterChooseA +acmFilterChooseW +acmFilterDetailsA +acmFilterDetailsW +acmFilterEnumA +acmFilterEnumW +acmFilterTagDetailsA +acmFilterTagDetailsW +acmFilterTagEnumA +acmFilterTagEnumW +acmFormatChooseA +acmFormatChooseW +acmFormatDetailsA +acmFormatDetailsW +acmFormatEnumA +acmFormatEnumW +acmFormatSuggest +acmFormatTagDetailsA +acmFormatTagDetailsW +acmFormatTagEnumA +acmFormatTagEnumW +acmGetVersion +acmMessage32 +acmMetrics +acmStreamClose +acmStreamConvert +acmStreamMessage +acmStreamOpen +acmStreamPrepareHeader +acmStreamReset +acmStreamSize +acmStreamUnprepareHeader + + +; **** +;LIBRARY "msvfw32" +; **** +VideoForWindowsVersion +DrawDibBegin +DrawDibChangePalette +DrawDibClose +DrawDibDraw +DrawDibEnd +DrawDibGetBuffer +DrawDibGetPalette +DrawDibOpen +DrawDibProfileDisplay +DrawDibRealize +DrawDibSetPalette +DrawDibStart +DrawDibStop +DrawDibTime +GetOpenFileNamePreview +GetOpenFileNamePreviewA +GetOpenFileNamePreviewW +GetSaveFileNamePreviewA +GetSaveFileNamePreviewW +ICClose +ICCompress +ICCompressorChoose +ICCompressorFree +ICDecompress +ICDraw +ICDrawBegin +ICGetDisplayFormat +ICGetInfo +ICImageCompress +ICImageDecompress +ICInfo +ICInstall +ICLocate +ICMThunk32 +ICOpen +ICOpenFunction +ICRemove +ICSendMessage +ICSeqCompressFrame +ICSeqCompressFrameEnd +ICSeqCompressFrameStart +MCIWndCreate +MCIWndCreateA +MCIWndCreateW +MCIWndRegisterClass +StretchDIB + + +; **** +;LIBRARY "vorbisfile" +; **** +ov_clear +ov_open +ov_open_callbacks +ov_bitrate +ov_bitrate_instant +ov_streams +ov_seekable +ov_serialnumber +ov_raw_total +ov_pcm_total +ov_time_total +ov_raw_seek +ov_pcm_seek +ov_pcm_seek_page +ov_time_seek +ov_time_seek_page +ov_raw_seek_lap +ov_pcm_seek_lap +ov_pcm_seek_page_lap +ov_time_seek_lap +ov_time_seek_page_lap +ov_raw_tell +ov_pcm_tell +ov_time_tell +ov_info +ov_comment +ov_read +ov_read_float +ov_test +ov_test_callbacks +ov_test_open +ov_crosslap +ov_halfrate +ov_halfrate_p +ov_fopen + + +; **** +;LIBRARY "winmm" +; **** +CloseDriver +DefDriverProc +DriverCallback +DrvGetModuleHandle +GetDriverModuleHandle +NotifyCallbackData +OpenDriver +PlaySound +PlaySoundA +PlaySoundW +SendDriverMessage +WOW32DriverCallback +WOW32ResolveMultiMediaHandle +WOWAppExit +aux32Message +auxGetDevCapsA +auxGetDevCapsW +auxGetNumDevs +auxGetVolume +auxOutMessage +auxSetVolume +joy32Message +joyConfigChanged +joyGetDevCapsA +joyGetDevCapsW +joyGetNumDevs +joyGetPos +joyGetPosEx +joyGetThreshold +joyReleaseCapture +joySetCapture +joySetThreshold +mci32Message +mciDriverNotify +mciDriverYield +mciExecute +mciFreeCommandResource +mciGetCreatorTask +mciGetDeviceIDA +mciGetDeviceIDFromElementIDA +mciGetDeviceIDFromElementIDW +mciGetDeviceIDW +mciGetDriverData +mciGetErrorStringA +mciGetErrorStringW +mciGetYieldProc +mciLoadCommandResource +mciSendCommandA +mciSendCommandW +mciSendStringA +mciSendStringW +mciSetDriverData +mciSetYieldProc +mid32Message +midiConnect +midiDisconnect +midiInAddBuffer +midiInClose +midiInGetDevCapsA +midiInGetDevCapsW +midiInGetErrorTextA +midiInGetErrorTextW +midiInGetID +midiInGetNumDevs +midiInMessage +midiInOpen +midiInPrepareHeader +midiInReset +midiInStart +midiInStop +midiInUnprepareHeader +midiOutCacheDrumPatches +midiOutCachePatches +midiOutClose +midiOutGetDevCapsA +midiOutGetDevCapsW +midiOutGetErrorTextA +midiOutGetErrorTextW +midiOutGetID +midiOutGetNumDevs +midiOutGetVolume +midiOutLongMsg +midiOutMessage +midiOutOpen +midiOutPrepareHeader +midiOutReset +midiOutSetVolume +midiOutShortMsg +midiOutUnprepareHeader +midiStreamClose +midiStreamOpen +midiStreamOut +midiStreamPause +midiStreamPosition +midiStreamProperty +midiStreamRestart +midiStreamStop +mixerClose +mixerGetControlDetailsA +mixerGetControlDetailsW +mixerGetDevCapsA +mixerGetDevCapsW +mixerGetID +mixerGetLineControlsA +mixerGetLineControlsW +mixerGetLineInfoA +mixerGetLineInfoW +mixerGetNumDevs +mixerMessage +mixerOpen +mixerSetControlDetails +mmDrvInstall +mmGetCurrentTask +mmTaskBlock +mmTaskCreate +mmTaskSignal +mmTaskYield +mmioAdvance +mmioAscend +mmioClose +mmioCreateChunk +mmioDescend +mmioFlush +mmioGetInfo +mmioInstallIOProcA +mmioInstallIOProcW +mmioOpenA +mmioOpenW +mmioRead +mmioRenameA +mmioRenameW +mmioSeek +mmioSendMessage +mmioSetBuffer +mmioSetInfo +mmioStringToFOURCCA +mmioStringToFOURCCW +mmioWrite +mmsystemGetVersion +mod32Message +mxd32Message +sndPlaySoundA +sndPlaySoundW +tid32Message +timeBeginPeriod +timeEndPeriod +timeGetDevCaps +timeGetSystemTime +timeGetTime +timeKillEvent +timeSetEvent +waveInAddBuffer +waveInClose +waveInGetDevCapsA +waveInGetDevCapsW +waveInGetErrorTextA +waveInGetErrorTextW +waveInGetID +waveInGetNumDevs +waveInGetPosition +waveInMessage +waveInOpen +waveInPrepareHeader +waveInReset +waveInStart +waveInStop +waveInUnprepareHeader +waveOutBreakLoop +waveOutClose +waveOutGetDevCapsA +waveOutGetDevCapsW +waveOutGetErrorTextA +waveOutGetErrorTextW +waveOutGetID +waveOutGetNumDevs +waveOutGetPitch +waveOutGetPlaybackRate +waveOutGetPosition +waveOutGetVolume +waveOutMessage +waveOutOpen +waveOutPause +waveOutPrepareHeader +waveOutReset +waveOutRestart +waveOutSetPitch +waveOutSetPlaybackRate +waveOutSetVolume +waveOutUnprepareHeader +waveOutWrite +wid32Message +winmmDbgOut +winmmSetDebugLevel +wod32Message + + +; **** +;LIBRARY "winmmbase" +; **** +CloseDriver +DefDriverProc +DriverCallback +DrvGetModuleHandle +GetDriverModuleHandle +OpenDriver +SendDriverMessage +auxGetDevCapsA +auxGetDevCapsW +auxGetNumDevs +auxGetVolume +auxOutMessage +auxSetVolume +joyConfigChanged +joyGetDevCapsA +joyGetDevCapsW +joyGetNumDevs +joyGetPos +joyGetPosEx +joyGetThreshold +joyReleaseCapture +joySetCapture +joySetThreshold +midiConnect +midiDisconnect +midiInAddBuffer +midiInClose +midiInGetDevCapsA +midiInGetDevCapsW +midiInGetErrorTextA +midiInGetErrorTextW +midiInGetID +midiInGetNumDevs +midiInMessage +midiInOpen +midiInPrepareHeader +midiInReset +midiInStart +midiInStop +midiInUnprepareHeader +midiOutCacheDrumPatches +midiOutCachePatches +midiOutClose +midiOutGetDevCapsA +midiOutGetDevCapsW +midiOutGetErrorTextA +midiOutGetErrorTextW +midiOutGetID +midiOutGetNumDevs +midiOutGetVolume +midiOutLongMsg +midiOutMessage +midiOutOpen +midiOutPrepareHeader +midiOutReset +midiOutSetVolume +midiOutShortMsg +midiOutUnprepareHeader +midiStreamClose +midiStreamOpen +midiStreamOut +midiStreamPause +midiStreamPosition +midiStreamProperty +midiStreamRestart +midiStreamStop +mixerClose +mixerGetControlDetailsA +mixerGetControlDetailsW +mixerGetDevCapsA +mixerGetDevCapsW +mixerGetID +mixerGetLineControlsA +mixerGetLineControlsW +mixerGetLineInfoA +mixerGetLineInfoW +mixerGetNumDevs +mixerMessage +mixerOpen +mixerSetControlDetails +mmDrvInstall +mmGetCurrentTask +mmTaskBlock +mmTaskCreate +mmTaskSignal +mmTaskYield +mmioAdvance +mmioAscend +mmioClose +mmioCreateChunk +mmioDescend +mmioFlush +mmioGetInfo +mmioInstallIOProcA +mmioInstallIOProcW +mmioOpenA +mmioOpenW +mmioRead +mmioRenameA +mmioRenameW +mmioSeek +mmioSendMessage +mmioSetBuffer +mmioSetInfo +mmioStringToFOURCCA +mmioStringToFOURCCW +mmioWrite +sndOpenSound +waveInAddBuffer +waveInClose +waveInGetDevCapsA +waveInGetDevCapsW +waveInGetErrorTextA +waveInGetErrorTextW +waveInGetID +waveInGetNumDevs +waveInGetPosition +waveInMessage +waveInOpen +waveInPrepareHeader +waveInReset +waveInStart +waveInStop +waveInUnprepareHeader +waveOutBreakLoop +waveOutClose +waveOutGetDevCapsA +waveOutGetDevCapsW +waveOutGetErrorTextA +waveOutGetErrorTextW +waveOutGetID +waveOutGetNumDevs +waveOutGetPitch +waveOutGetPlaybackRate +waveOutGetPosition +waveOutGetVolume +waveOutMessage +waveOutOpen +waveOutPause +waveOutPrepareHeader +waveOutReset +waveOutRestart +waveOutSetPitch +waveOutSetPlaybackRate +waveOutSetVolume +waveOutUnprepareHeader +waveOutWrite +winmmbaseFreeMMEHandles +winmmbaseGetWOWHandle +winmmbaseHandle32FromHandle16 +winmmbaseSetWOWHandle + + +; **** +;LIBRARY "winspool" +; **** +ADVANCEDSETUPDIALOG +AdvancedSetupDialog +ConvertAnsiDevModeToUnicodeDevmode +ConvertUnicodeDevModeToAnsiDevmode +DEVICEMODE +DeviceMode +DocumentEvent +PerfClose +PerfCollect +PerfOpen +QueryColorProfile +QueryRemoteFonts +QuerySpoolMode +SpoolerDevQueryPrintW +StartDocDlgW +AbortPrinter +AddFormA +AddFormW +AddJobA +AddJobW +AddMonitorA +AddMonitorW +AddPortA +AddPortExA +AddPortExW +AddPortW +AddPrintProcessorA +AddPrintProcessorW +AddPrintProvidorA +AddPrintProvidorW +AddPrinterA +AddPrinterConnection2A +AddPrinterConnection2W +AddPrinterConnectionA +AddPrinterConnectionW +AddPrinterDriverA +AddPrinterDriverExA +AddPrinterDriverExW +AddPrinterDriverW +AddPrinterW +AdvancedDocumentPropertiesA +AdvancedDocumentPropertiesW +ClosePrinter +CloseSpoolFileHandle +CommitSpoolData +ConfigurePortA +ConfigurePortW +ConnectToPrinterDlg +CorePrinterDriverInstalledA +CorePrinterDriverInstalledW +CreatePrintAsyncNotifyChannel +CreatePrinterIC +DEVICECAPABILITIES +DeleteFormA +DeleteFormW +DeleteJobNamedProperty +DeleteMonitorA +DeleteMonitorW +DeletePortA +DeletePortW +DeletePrintProcessorA +DeletePrintProcessorW +DeletePrintProvidorA +DeletePrintProvidorW +DeletePrinter +DeletePrinterConnectionA +DeletePrinterConnectionW +DeletePrinterDataA +DeletePrinterDataExA +DeletePrinterDataExW +DeletePrinterDataW +DeletePrinterDriverA +DeletePrinterDriverExA +DeletePrinterDriverExW +DeletePrinterDriverPackageA +DeletePrinterDriverPackageW +DeletePrinterDriverW +DeletePrinterIC +DeletePrinterKeyA +DeletePrinterKeyW +DevQueryPrint +DevQueryPrintEx +DeviceCapabilities +DeviceCapabilitiesA +DeviceCapabilitiesW +DevicePropertySheets +DocumentPropertiesA +DocumentPropertiesW +DocumentPropertySheets +EXTDEVICEMODE +EndDocPrinter +EndPagePrinter +EnumFormsA +EnumFormsW +EnumJobNamedProperties +EnumJobsA +EnumJobsW +EnumMonitorsA +EnumMonitorsW +EnumPortsA +GetDefaultPrinterA +SetDefaultPrinterA +GetDefaultPrinterW +SetDefaultPrinterW +EnumPortsW +EnumPrintProcessorDatatypesA +EnumPrintProcessorDatatypesW +EnumPrintProcessorsA +EnumPrintProcessorsW +EnumPrinterDataA +EnumPrinterDataExA +EnumPrinterDataExW +EnumPrinterDataW +EnumPrinterDriversA +EnumPrinterDriversW +EnumPrinterKeyA +EnumPrinterKeyW +EnumPrintersA +EnumPrintersW +ExtDeviceMode +FindClosePrinterChangeNotification +FindFirstPrinterChangeNotification +FindNextPrinterChangeNotification +FlushPrinter +FreePrintNamedPropertyArray +FreePrintPropertyValue +FreePrinterNotifyInfo +GetCorePrinterDriversA +GetCorePrinterDriversW +GetFormA +GetFormW +GetJobA +GetJobNamedPropertyValue +GetJobW +GetPrintExecutionData +GetPrintOutputInfo +GetPrintProcessorDirectoryA +GetPrintProcessorDirectoryW +GetPrinterA +GetPrinterDataA +GetPrinterDataExA +GetPrinterDataExW +GetPrinterDataW +GetPrinterDriver2A +GetPrinterDriver2W +GetPrinterDriverA +GetPrinterDriverDirectoryA +GetPrinterDriverDirectoryW +GetPrinterDriverPackagePathA +GetPrinterDriverPackagePathW +GetPrinterDriverW +GetPrinterW +GetSpoolFileHandle +InstallPrinterDriverFromPackageA +InstallPrinterDriverFromPackageW +IsValidDevmodeA +IsValidDevmodeW +OpenPrinter2A +OpenPrinter2W +OpenPrinterA +OpenPrinterW +PlayGdiScriptOnPrinterIC +PrinterMessageBoxA +PrinterMessageBoxW +PrinterProperties +ReadPrinter +RegisterForPrintAsyncNotifications +ReportJobProcessingProgress +ResetPrinterA +ResetPrinterW +ScheduleJob +SeekPrinter +SetFormA +SetFormW +SetJobA +SetJobNamedProperty +SetJobW +SetPortA +SetPortW +SetPrinterA +SetPrinterDataA +SetPrinterDataExA +SetPrinterDataExW +SetPrinterDataW +SetPrinterW +SplDriverUnloadComplete +SpoolerPrinterEvent +StartDocDlgA +StartDocPrinterA +StartDocPrinterW +StartPagePrinter +UnRegisterForPrintAsyncNotifications +UploadPrinterDriverPackageA +UploadPrinterDriverPackageW +WaitForPrinterChange +WritePrinter +XcvDataW + + +; **** +;LIBRARY "xlive" +; **** +_XWSAStartup +_XGetOverlappedExtendedError +_XGetOverlappedResult +_XSocketBind +_XSocketConnect +_XSocketListen +_XSocketAccept +_XSocketSelect +_XSocketRecv +_XWSACleanup +_XSocketRecvFrom +_XSocketSend +_XSocketSendTo +_XSocketInet_Addr +_XWSAGetLastError +_XCreateSocket +_XSocketNTOHS +_XSocketNTOHL +_XSockeClose +_XCustomGetLastActionPress +_XSocketShutdown +_XLiveInitialize +_XLiveInput +_XLiveRender +_XLiveUninitialize +_XLiveOnCreateDevice +_XLiveOnResetDevice +_XHVCreateEngine +_XLivePBufferAllocate +_XLivePBufferFree +_XLivePBufferGetByte +_XLivePBufferSetByte +_XLivePBufferGetDWORD +_XLivePBufferSetDWORD +_XLiveGetUpdateInformation +_XLiveUpdateSystem +_XLiveSetSponsorToken +_XLivePreTranslateMessage +_XLiveSetDebugLevel +_XLiveProtectData +_XLiveUnprotectData +_XLiveCreateProtectedDataContext +_XLiveQueryProtectedDataInformation +_XLiveCloseProtectedDataContext +_XNetStartup +_XNetCleanup +_XShowPlayerReviewUI +_XShowGuideUI +_XShowKeyboardUI +_XCloseHandle +_XShowGamerCardUI +_XCancelOverlapped +_XEnumerate +_XShowSigninUI +_XUserGetXUID +_XUserGetSigninState +_XUserGetName +_XUserAreUsersFriends +_XUserCheckPrivilege +_XUserGetSigninInfo +_XNotifyCreateListener +_XUserReadGamerpictureByKey +_XShowFriendsUI +_XUserSetProperty +_XUserSetContext +_XUserWriteAchievements +_XUserCreateAchievementEnumerator +_XUserReadStats +_XUserCreateStatsEnumeratorByRank +_XUserCreateStatsEnumeratorByXuid +_XUserSetContextEx +_XUserSetPropertyEx +_XLivePBufferGetByteArray +_XLivePBufferSetByteArray +_XLiveInitializeEx +_XSessionCreate +_XStringVerify +_XStorageUploadFromMemory +_XStorageEnumerate +_XOnlineStartup +_XOnlineCleanup +_XFriendsCreateEnumerator +_XUserMuteListQuery +_XInviteGetAcceptedInfo +_XInviteSend +_XSessionWriteStats +_XSessionStart +_XSessionSearchEx +_XSessionModify +_XSessionMigrateHost +_XOnlineGetNatType +_XSessionLeaveLocal +_XSessionJoinRemote +_XSessionJoinLocal +_XSessionGetDetails +_XSessionFlushStats +_XSessionDelete +_XUserReadProfileSettings +_XSessionEnd +_XSessionArbitrationRegister +_XTitleServerCreateEnumerator +_XSessionLeaveRemote +_XUserWriteProfileSettings +_XUserReadProfileSettingsByXuid +_XLiveCalculateSkill +_XStorageBuildServerPath +_XStorageDownloadToMemory +_XLiveProtectedVerifyFile +_XLiveContentCreateAccessHandle +_XLiveContentUninstall +_XLiveContentGetPath +_XLiveContentCreateEnumerator +_XLiveContentRetrieveOffersByDate +_XShowMarketplaceUI +_xlive_5367 +_xlive_5372 +_XNetCreateKey +_XNetRegisterKey +_XNetUnregisterKey +_XNetXnAddrToInAddr +_XNetServerToInAddr +_XSocketIOCTLSocket +_XNetInAddrToXnAddr +_XNetUnregisterInAddr +_XNetConnect +_XNotifyGetNext +_XNotifyPositionUI +_XNetGetConnectStatus +_XNetQosListen +_XSocketSetSockOpt +_XNetQosLookup +_XNetQosServiceLookup +_XNetQosRelease +_XNetGetTitleXnAddr +_XNetGetEthernetLinkStatus +_XNetSetSystemLinkPort +_XSocketGetSockName diff --git a/Wrappers/wrapper.h b/Wrappers/wrapper.h index e04b5a98..aa6ac7db 100644 --- a/Wrappers/wrapper.h +++ b/Wrappers/wrapper.h @@ -1,94 +1,26 @@ #pragma once -#define VISIT_WRAPPERS(visit) \ - visit(bcrypt, BCRYPT) \ - visit(cryptsp, CRYTPSP) \ - visit(d3d8, D3D8) \ - visit(d3d9, D3D9) \ - visit(ddraw, DDRAW) \ - visit(dinput, DINPUT) \ - visit(dplayx, DPLAYX) \ - visit(dsound, DSOUND) \ - visit(dxgi, DXGI) \ - visit(winmm, WINMM) \ - visit(winspool, WINSPOOL) \ - visit(dciman32, DCIMAN32) - -#define ADD_FARPROC_MEMBER(memberName) FARPROC memberName = jmpaddr; - -#define ADD_NAMESPACE_CLASS(className, Z) className::className ## _dll className::module; - -#define CREATE_ALL_PROC_STUB(module, MACRO) \ - namespace my ## module \ - { \ - using namespace module; \ - VISIT_ ## MACRO ## _PROCS(CREATE_PROC_STUB); \ - } - -#define CREATE_PROC_STUB(procName) \ - extern "C" __declspec(naked) void __stdcall Fake ## procName() \ - { \ - __asm jmp module.procName \ - } - -#define LOAD_ORIGINAL_PROC(procName) \ - procName = GetProcAddress(dll, #procName, jmpaddr); - -#define LOAD_WRAPPER(className, Z) \ - className::module.Load(); - -#define UNHOOK_WRAPPER(className, Z) \ - className::module.Unhook(); - +namespace ddraw +{ + extern FARPROC DirectDrawCreate_var; + extern FARPROC DirectDrawCreateEx_var; + HMODULE Load(); +} +namespace dsound +{ + extern FARPROC DirectSoundCreate_var; + extern FARPROC DirectSoundCreate8_var; + HMODULE Load(); +} +namespace d3d8 +{ + extern FARPROC Direct3DCreate8_var; +} +namespace ShardProcs +{ + extern FARPROC DllGetClassObject_var; +} namespace Wrapper { - __declspec(naked) static HRESULT __stdcall ReturnProc() - { - __asm { - mov eax, 0x80004001L // return E_NOTIMPL - retn 16 - } - } - - constexpr FARPROC jmpaddr = (FARPROC)*ReturnProc; - - HMODULE LoadDll(DWORD); - void DllAttach(); - void DllDetach(); - FARPROC GetProcAddress(HMODULE, LPCSTR, FARPROC); - - namespace d3d9_Wrapper - { - extern FARPROC _Direct3DCreate9_RealProc; - extern FARPROC _Direct3DCreate9_WrapperProc; - } - - namespace D3d8to9 - { - extern FARPROC _Direct3DCreate8; - extern FARPROC _Direct3DCreate9; - } - - namespace DDrawCompat - { - extern FARPROC _DirectDrawCreate; - extern FARPROC _DirectDrawCreateEx; - extern FARPROC _DllGetClassObject; - } - - namespace DSoundCtrl - { - extern FARPROC _DirectSoundCreate; - extern FARPROC _DirectSoundEnumerateA; - extern FARPROC _DirectSoundEnumerateW; - extern FARPROC _DllCanUnloadNow; - extern FARPROC _DllGetClassObject; - extern FARPROC _DirectSoundCaptureCreate; - extern FARPROC _DirectSoundCaptureEnumerateA; - extern FARPROC _DirectSoundCaptureEnumerateW; - extern FARPROC _GetDeviceID; - extern FARPROC _DirectSoundFullDuplexCreate; - extern FARPROC _DirectSoundCreate8; - extern FARPROC _DirectSoundCaptureCreate8; - } -}; + HMODULE CreateWrapper(HMODULE hModule); +} diff --git a/Wrappers/xlive.h b/Wrappers/xlive.h new file mode 100644 index 00000000..dc839217 --- /dev/null +++ b/Wrappers/xlive.h @@ -0,0 +1,144 @@ +#pragma once + +#define VISIT_PROCS(visit) \ + visit(_XWSAStartup) \ + visit(_XGetOverlappedExtendedError) \ + visit(_XGetOverlappedResult) \ + visit(_XSocketBind) \ + visit(_XSocketConnect) \ + visit(_XSocketListen) \ + visit(_XSocketAccept) \ + visit(_XSocketSelect) \ + visit(_XSocketRecv) \ + visit(_XWSACleanup) \ + visit(_XSocketRecvFrom) \ + visit(_XSocketSend) \ + visit(_XSocketSendTo) \ + visit(_XSocketInet_Addr) \ + visit(_XWSAGetLastError) \ + visit(_XCreateSocket) \ + visit(_XSocketNTOHS) \ + visit(_XSocketNTOHL) \ + visit(_XSockeClose) \ + visit(_XCustomGetLastActionPress) \ + visit(_XSocketShutdown) \ + visit(_XLiveInitialize) \ + visit(_XLiveInput) \ + visit(_XLiveRender) \ + visit(_XLiveUninitialize) \ + visit(_XLiveOnCreateDevice) \ + visit(_XLiveOnResetDevice) \ + visit(_XHVCreateEngine) \ + visit(_XLivePBufferAllocate) \ + visit(_XLivePBufferFree) \ + visit(_XLivePBufferGetByte) \ + visit(_XLivePBufferSetByte) \ + visit(_XLivePBufferGetDWORD) \ + visit(_XLivePBufferSetDWORD) \ + visit(_XLiveGetUpdateInformation) \ + visit(_XLiveUpdateSystem) \ + visit(_XLiveSetSponsorToken) \ + visit(_XLivePreTranslateMessage) \ + visit(_XLiveSetDebugLevel) \ + visit(_XLiveProtectData) \ + visit(_XLiveUnprotectData) \ + visit(_XLiveCreateProtectedDataContext) \ + visit(_XLiveQueryProtectedDataInformation) \ + visit(_XLiveCloseProtectedDataContext) \ + visit(_XNetStartup) \ + visit(_XNetCleanup) \ + visit(_XShowPlayerReviewUI) \ + visit(_XShowGuideUI) \ + visit(_XShowKeyboardUI) \ + visit(_XCloseHandle) \ + visit(_XShowGamerCardUI) \ + visit(_XCancelOverlapped) \ + visit(_XEnumerate) \ + visit(_XShowSigninUI) \ + visit(_XUserGetXUID) \ + visit(_XUserGetSigninState) \ + visit(_XUserGetName) \ + visit(_XUserAreUsersFriends) \ + visit(_XUserCheckPrivilege) \ + visit(_XUserGetSigninInfo) \ + visit(_XNotifyCreateListener) \ + visit(_XUserReadGamerpictureByKey) \ + visit(_XShowFriendsUI) \ + visit(_XUserSetProperty) \ + visit(_XUserSetContext) \ + visit(_XUserWriteAchievements) \ + visit(_XUserCreateAchievementEnumerator) \ + visit(_XUserReadStats) \ + visit(_XUserCreateStatsEnumeratorByRank) \ + visit(_XUserCreateStatsEnumeratorByXuid) \ + visit(_XUserSetContextEx) \ + visit(_XUserSetPropertyEx) \ + visit(_XLivePBufferGetByteArray) \ + visit(_XLivePBufferSetByteArray) \ + visit(_XLiveInitializeEx) \ + visit(_XSessionCreate) \ + visit(_XStringVerify) \ + visit(_XStorageUploadFromMemory) \ + visit(_XStorageEnumerate) \ + visit(_XOnlineStartup) \ + visit(_XOnlineCleanup) \ + visit(_XFriendsCreateEnumerator) \ + visit(_XUserMuteListQuery) \ + visit(_XInviteGetAcceptedInfo) \ + visit(_XInviteSend) \ + visit(_XSessionWriteStats) \ + visit(_XSessionStart) \ + visit(_XSessionSearchEx) \ + visit(_XSessionModify) \ + visit(_XSessionMigrateHost) \ + visit(_XOnlineGetNatType) \ + visit(_XSessionLeaveLocal) \ + visit(_XSessionJoinRemote) \ + visit(_XSessionJoinLocal) \ + visit(_XSessionGetDetails) \ + visit(_XSessionFlushStats) \ + visit(_XSessionDelete) \ + visit(_XUserReadProfileSettings) \ + visit(_XSessionEnd) \ + visit(_XSessionArbitrationRegister) \ + visit(_XTitleServerCreateEnumerator) \ + visit(_XSessionLeaveRemote) \ + visit(_XUserWriteProfileSettings) \ + visit(_XUserReadProfileSettingsByXuid) \ + visit(_XLiveCalculateSkill) \ + visit(_XStorageBuildServerPath) \ + visit(_XStorageDownloadToMemory) \ + visit(_XLiveProtectedVerifyFile) \ + visit(_XLiveContentCreateAccessHandle) \ + visit(_XLiveContentUninstall) \ + visit(_XLiveContentGetPath) \ + visit(_XLiveContentCreateEnumerator) \ + visit(_XLiveContentRetrieveOffersByDate) \ + visit(_XShowMarketplaceUI) \ + visit(_xlive_5367) \ + visit(_xlive_5372) \ + visit(_XNetCreateKey) \ + visit(_XNetRegisterKey) \ + visit(_XNetUnregisterKey) \ + visit(_XNetXnAddrToInAddr) \ + visit(_XNetServerToInAddr) \ + visit(_XSocketIOCTLSocket) \ + visit(_XNetInAddrToXnAddr) \ + visit(_XNetUnregisterInAddr) \ + visit(_XNetConnect) \ + visit(_XNotifyGetNext) \ + visit(_XNotifyPositionUI) \ + visit(_XNetGetConnectStatus) \ + visit(_XNetQosListen) \ + visit(_XSocketSetSockOpt) \ + visit(_XNetQosLookup) \ + visit(_XNetQosServiceLookup) \ + visit(_XNetQosRelease) \ + visit(_XNetGetTitleXnAddr) \ + visit(_XNetGetEthernetLinkStatus) \ + visit(_XNetSetSystemLinkPort) \ + visit(_XSocketGetSockName) + +PROC_CLASS(xlive, dll) + +#undef VISIT_PROCS diff --git a/dxwrapper.sln b/dxwrapper.sln index d73d5895..16584949 100644 --- a/dxwrapper.sln +++ b/dxwrapper.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwrapper", "dxwrapper.vcxproj", "{579E7FE7-2745-4100-A802-23511711FCDE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Stub", "Stub\stub.vcxproj", "{E204DCB3-D122-4F2E-88A8-89AC22CE3274}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -15,6 +17,10 @@ Global {579E7FE7-2745-4100-A802-23511711FCDE}.Debug|Win32.Build.0 = Debug|Win32 {579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.ActiveCfg = Release|Win32 {579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.Build.0 = Release|Win32 + {E204DCB3-D122-4F2E-88A8-89AC22CE3274}.Debug|Win32.ActiveCfg = Debug|Win32 + {E204DCB3-D122-4F2E-88A8-89AC22CE3274}.Debug|Win32.Build.0 = Debug|Win32 + {E204DCB3-D122-4F2E-88A8-89AC22CE3274}.Release|Win32.ActiveCfg = Release|Win32 + {E204DCB3-D122-4F2E-88A8-89AC22CE3274}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/dxwrapper.vcproj b/dxwrapper.vcproj index 427e6918..ac67ef4f 100644 --- a/dxwrapper.vcproj +++ b/dxwrapper.vcproj @@ -82,7 +82,7 @@ AdditionalLibraryDirectories="" IgnoreAllDefaultLibraries="false" IgnoreDefaultLibraryNames="" - ModuleDefinitionFile=".\dxwrapper.def" + ModuleDefinitionFile="Wrappers\wrapper.def" GenerateDebugInformation="true" RandomizedBaseAddress="1" DataExecutionPrevention="0" @@ -181,7 +181,7 @@ OutputFile="./Build/dxwrapper.dll" LinkIncremental="1" SuppressStartupBanner="true" - ModuleDefinitionFile=".\dxwrapper.def" + ModuleDefinitionFile="Wrappers\wrapper.def" ProgramDatabaseFile="" RandomizedBaseAddress="1" DataExecutionPrevention="0" @@ -261,10 +261,6 @@ RelativePath=".\dxwrapper.cpp" > - - diff --git a/dxwrapper.vcxproj b/dxwrapper.vcxproj index 475302e8..a3037052 100644 --- a/dxwrapper.vcxproj +++ b/dxwrapper.vcxproj @@ -94,12 +94,12 @@ true - .\Dllmain\dxwrapper.def + Wrappers\wrapper.def true false MachineX86 - UseLinkTimeCodeGeneration + Default false @@ -107,20 +107,9 @@ IF NOT EXIST "$(TargetDir)Build" mkdir "$(TargetDir)Build" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\ddraw.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d9.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d8.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winmm.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dsound.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dinput.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dxgi.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dplayx.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\bcrypt.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\cryptsp.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winspool.drv" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dciman32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\" >nul copy /Y "$(ProjectDir)Settings\AllSettings.ini" "$(TargetDir)Build\" >nul -copy /Y "$(ProjectDir)Settings\Settings.ini" "$(TargetDir)Build\" >nul +copy /Y "$(ProjectDir)Settings\Settings.ini" "$(TargetDir)Build\dxwrapper.ini" >nul @@ -168,7 +157,7 @@ copy /Y "$(ProjectDir)Settings\Settings.ini" "$(TargetDir)Build\" >nul $(OutDir)dxwrapper.dll true - .\Dllmain\dxwrapper.def + Wrappers\wrapper.def false @@ -187,21 +176,9 @@ copy /Y "$(ProjectDir)Settings\Settings.ini" "$(TargetDir)Build\" >nul IF NOT EXIST "$(TargetDir)Build" mkdir "$(TargetDir)Build" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\ddraw.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d9.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\d3d8.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winmm.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dsound.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dinput.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dxgi.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dplayx.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\bcrypt.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\cryptsp.dll" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\winspool.drv" >nul -copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\dciman32.dll" >nul +copy /Y "$(TargetDir)$(TargetName).dll" "$(TargetDir)Build\" >nul copy /Y "$(ProjectDir)Settings\AllSettings.ini" "$(TargetDir)Build\" >nul -copy /Y "$(ProjectDir)Settings\Settings.ini" "$(TargetDir)Build\" >nul - +copy /Y "$(ProjectDir)Settings\Settings.ini" "$(TargetDir)Build\dxwrapper.ini" >nul cmd /c "@echo off && cd /D ""$(ProjectDir)Dllmain\"" && if not exist BuildNo.rc echo #define BUILD_NUMBER 0 >BuildNo.rc" @@ -273,12 +250,12 @@ cmd /c "@echo off && cd /D ""$(ProjectDir)Dllmain\"" && type Bui - + - + @@ -286,6 +263,7 @@ cmd /c "@echo off && cd /D ""$(ProjectDir)Dllmain\"" && type Bui + @@ -340,19 +318,7 @@ cmd /c "@echo off && cd /D ""$(ProjectDir)Dllmain\"" && type Bui - - - - - - - - - - - - - + diff --git a/dxwrapper.vcxproj.filters b/dxwrapper.vcxproj.filters index 016320f9..7c231d9b 100644 --- a/dxwrapper.vcxproj.filters +++ b/dxwrapper.vcxproj.filters @@ -39,13 +39,10 @@ {dd986a8a-7ff1-403f-8a75-794ded77510d} - {58f67609-5b76-4ec4-8b6e-1c557d101b53} + {c922409a-b895-4ab0-a6e9-36287ac4f350} - - Wrappers - DSoundCtrl @@ -226,46 +223,25 @@ Utils + + Wrappers + D3d9 - - Dllmain - Settings Settings + + Wrappers + - - Wrappers - - - Wrappers - - - Wrappers - - - Wrappers - - - Wrappers - - - Wrappers - - - Wrappers - - - Wrappers - DSoundCtrl @@ -302,9 +278,6 @@ Libraries - - Wrappers - D3d8to9 @@ -329,15 +302,6 @@ Settings - - Wrappers - - - Wrappers - - - Wrappers - Libraries @@ -452,12 +416,15 @@ Hooking - + Wrappers D3d9 + + D3d9 +