Skip to content

Commit

Permalink
Merge branch 'master' into reverse_xyzrhw_new
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud authored Mar 2, 2024
2 parents 80dfe72 + 289e652 commit 11e1db3
Show file tree
Hide file tree
Showing 110 changed files with 1,272 additions and 1,049 deletions.
12 changes: 6 additions & 6 deletions DDrawCompat/DDrawCompatExternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "v0.2.1\DllMain.h"
#include "v0.3.1\Dll\DllMain.h"

#define DDrawCompatDefault Compat31
#define DDrawCompatForDd7to9 Compat31
#define DDrawCompatDefault Compat32
#define DDrawCompatForDd7to9 Compat32

#define INITIALIZE_WRAPPED_PROC(procName) \
volatile FARPROC procName ## _in = nullptr; \
Expand Down Expand Up @@ -38,7 +38,7 @@ namespace DDrawCompat
{
// DDrawCompat v0.3.1
#ifdef DDRAWCOMPAT_31
PREPARE_DDRAWCOMPAT(Compat31);
PREPARE_DDRAWCOMPAT(Compat32);
#endif

// DDrawCompat v0.2.1
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace DDrawCompat

// DDrawCompat v0.3.1
#ifdef DDRAWCOMPAT_31
START_DDRAWCOMPAT(Compat31);
START_DDRAWCOMPAT(Compat32);
#endif

// DDrawCompat v0.2.1
Expand Down Expand Up @@ -97,9 +97,9 @@ namespace DDrawCompat
}

// Used for hooking with dd7to9
void InstallHooks()
void InstallDd7to9Hooks()
{
// Dd7to9 DDrawCompat version
return DDrawCompatForDd7to9::InstallHooks();
return DDrawCompatForDd7to9::InstallDd7to9Hooks();
}
}
2 changes: 1 addition & 1 deletion DDrawCompat/DDrawCompatExternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ namespace DDrawCompat
void Prepare();
void Start(HINSTANCE, DWORD);
bool IsEnabled();
void InstallHooks();
void InstallDd7to9Hooks();
}
2 changes: 1 addition & 1 deletion DDrawCompat/DDrawLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace Compat21
}
}

namespace Compat31
namespace Compat32
{
using namespace Logging;
}
6 changes: 3 additions & 3 deletions DDrawCompat/v0.3.1/Common/CompatPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CompatPtr : public CompatWeakPtr<Intf>
template <typename OtherIntf>
static CompatPtr from(OtherIntf* other)
{
return CompatPtr(Compat31::queryInterface<Intf>(other));
return CompatPtr(Compat32::queryInterface<Intf>(other));
}

CompatPtr(std::nullptr_t = nullptr)
Expand All @@ -25,13 +25,13 @@ class CompatPtr : public CompatWeakPtr<Intf>

CompatPtr(const CompatPtr& other)
{
m_intf = Compat31::queryInterface<Intf>(other.get());
m_intf = Compat32::queryInterface<Intf>(other.get());
}

template <typename OtherIntf>
CompatPtr(const CompatPtr<OtherIntf>& other)
{
m_intf = Compat31::queryInterface<Intf>(other.get());
m_intf = Compat32::queryInterface<Intf>(other.get());
}

~CompatPtr()
Expand Down
2 changes: 1 addition & 1 deletion DDrawCompat/v0.3.1/Common/CompatQueryInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <DDrawCompat/v0.3.1/Common/CompatVtable.h>

namespace Compat31
namespace Compat32
{
template <typename Intf>
struct GetBaseIntf
Expand Down
40 changes: 20 additions & 20 deletions DDrawCompat/v0.3.1/Common/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ namespace
HRESULT result = g_debugDataSpaces->WriteVirtual(g_debugBase, instruction, MAX_INSTRUCTION_SIZE, nullptr);
if (FAILED(result))
{
LOG_ONCE("ERROR: DbgEng: WriteVirtual failed: " << Compat31::hex(result));
LOG_ONCE("ERROR: DbgEng: WriteVirtual failed: " << Compat32::hex(result));
return 0;
}

ULONG64 endOffset = 0;
result = g_debugControl->Disassemble(g_debugBase, 0, nullptr, 0, nullptr, &endOffset);
if (FAILED(result))
{
LOG_ONCE("ERROR: DbgEng: Disassemble failed: " << Compat31::hex(result) << " "
<< Compat31::hexDump(instruction, MAX_INSTRUCTION_SIZE));
LOG_ONCE("ERROR: DbgEng: Disassemble failed: " << Compat32::hex(result) << " "
<< Compat32::hexDump(instruction, MAX_INSTRUCTION_SIZE));
return 0;
}

Expand All @@ -135,7 +135,7 @@ namespace

std::ostringstream oss;
#ifdef DEBUGLOGS
oss << Compat31::funcPtrToStr(targetFunc) << ' ';
oss << Compat32::funcPtrToStr(targetFunc) << ' ';

char origFuncPtrStr[20] = {};
if (!funcName)
Expand Down Expand Up @@ -164,7 +164,7 @@ namespace
{
instructionSize = 6;
auto candidateTargetFunc = **reinterpret_cast<BYTE***>(targetFunc + 2);
if (Compat31::getModuleHandleFromAddress(candidateTargetFunc) == Compat31::getModuleHandleFromAddress(targetFunc))
if (Compat32::getModuleHandleFromAddress(candidateTargetFunc) == Compat32::getModuleHandleFromAddress(targetFunc))
{
break;
}
Expand All @@ -175,14 +175,14 @@ namespace
break;
}
#ifdef DEBUGLOGS
oss << Compat31::hexDump(prevTargetFunc, instructionSize) << " -> " << Compat31::funcPtrToStr(targetFunc) << ' ';
oss << Compat32::hexDump(prevTargetFunc, instructionSize) << " -> " << Compat32::funcPtrToStr(targetFunc) << ' ';
prevTargetFunc = targetFunc;
#endif
}

if (Compat31::getModuleHandleFromAddress(targetFunc) == Dll::g_currentModule)
if (Compat32::getModuleHandleFromAddress(targetFunc) == Dll::g_currentModule)
{
Compat31::Log() << "ERROR: Target function is already hooked: " << funcName;
Compat32::Log() << "ERROR: Target function is already hooked: " << funcName;
return;
}

Expand All @@ -203,7 +203,7 @@ namespace
}

LOG_DEBUG << "Hooking function: " << funcName
<< " (" << oss.str() << Compat31::hexDump(targetFunc, totalInstructionSize) << ')';
<< " (" << oss.str() << Compat32::hexDump(targetFunc, totalInstructionSize) << ')';

BYTE* trampoline = static_cast<BYTE*>(
VirtualAlloc(nullptr, totalInstructionSize + 5, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE));
Expand Down Expand Up @@ -266,15 +266,15 @@ namespace
// Hook function and get process address
if (dll && GetProcAddress(dll, "DebugCreate"))
{
Compat31::hookIatFunction(dll, "GetProcAddress", dbgEngGetProcAddress);
Compat32::hookIatFunction(dll, "GetProcAddress", dbgEngGetProcAddress);

pDebugCreate = (PFN_DebugCreate)GetProcAddress(dll, "DebugCreate");
}
RunOnce = false;
}
if (!pDebugCreate)
{
Compat31::Log() << "ERROR: DbgEng: failed to get proc address!";
Compat32::Log() << "ERROR: DbgEng: failed to get proc address!";
return false;
}
//********** End Edit ***************
Expand All @@ -285,46 +285,46 @@ namespace
FAILED(result = g_debugClient->QueryInterface(IID_IDebugSymbols, reinterpret_cast<void**>(&g_debugSymbols))) ||
FAILED(result = g_debugClient->QueryInterface(IID_IDebugDataSpaces4, reinterpret_cast<void**>(&g_debugDataSpaces))))
{
Compat31::Log() << "ERROR: DbgEng: object creation failed: " << Compat31::hex(result);
Compat32::Log() << "ERROR: DbgEng: object creation failed: " << Compat32::hex(result);
return false;
}

result = g_debugClient->OpenDumpFileWide(Compat31::getModulePath(Dll::g_currentModule).c_str(), 0);
result = g_debugClient->OpenDumpFileWide(Compat32::getModulePath(Dll::g_currentModule).c_str(), 0);
if (FAILED(result))
{
Compat31::Log() << "ERROR: DbgEng: OpenDumpFile failed: " << Compat31::hex(result);
Compat32::Log() << "ERROR: DbgEng: OpenDumpFile failed: " << Compat32::hex(result);
return false;
}

g_debugControl->SetEngineOptions(DEBUG_ENGOPT_DISABLE_MODULE_SYMBOL_LOAD);
result = g_debugControl->WaitForEvent(0, INFINITE);
if (FAILED(result))
{
Compat31::Log() << "ERROR: DbgEng: WaitForEvent failed: " << Compat31::hex(result);
Compat32::Log() << "ERROR: DbgEng: WaitForEvent failed: " << Compat32::hex(result);
return false;
}

DEBUG_MODULE_PARAMETERS dmp = {};
result = g_debugSymbols->GetModuleParameters(1, 0, 0, &dmp);
if (FAILED(result))
{
Compat31::Log() << "ERROR: DbgEng: GetModuleParameters failed: " << Compat31::hex(result);
Compat32::Log() << "ERROR: DbgEng: GetModuleParameters failed: " << Compat32::hex(result);
return false;
}

ULONG size = 0;
result = g_debugDataSpaces->GetValidRegionVirtual(dmp.Base, dmp.Size, &g_debugBase, &size);
if (FAILED(result) || 0 == g_debugBase)
{
Compat31::Log() << "ERROR: DbgEng: GetValidRegionVirtual failed: " << Compat31::hex(result);
Compat32::Log() << "ERROR: DbgEng: GetValidRegionVirtual failed: " << Compat32::hex(result);
return false;
}

return true;
}
}

namespace Compat31
namespace Compat32
{
void closeDbgEng()
{
Expand Down Expand Up @@ -360,10 +360,10 @@ namespace Compat31
std::string funcPtrToStr(void* funcPtr)
{
std::ostringstream oss;
HMODULE module = Compat31::getModuleHandleFromAddress(funcPtr);
HMODULE module = Compat32::getModuleHandleFromAddress(funcPtr);
if (module)
{
oss << Compat31::getModulePath(module).u8string() << "+0x" << std::hex <<
oss << Compat32::getModulePath(module).u8string() << "+0x" << std::hex <<
reinterpret_cast<DWORD>(funcPtr) - reinterpret_cast<DWORD>(module);
}
else
Expand Down
8 changes: 4 additions & 4 deletions DDrawCompat/v0.3.1/Common/Hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#include <Windows.h>

#define CALL_ORIG_FUNC(func) Compat31::g_origFuncPtr<&func>
#define CALL_ORIG_FUNC(func) Compat32::g_origFuncPtr<&func>

#define HOOK_FUNCTION(module, func, newFunc) \
Compat31::hookFunction<&func>(#module, #func, &newFunc)
Compat32::hookFunction<&func>(#module, #func, &newFunc)
#define HOOK_SHIM_FUNCTION(func, newFunc) \
Compat31::hookFunction(reinterpret_cast<void*&>(Compat31::g_origFuncPtr<&func>), newFunc, #func)
Compat32::hookFunction(reinterpret_cast<void*&>(Compat32::g_origFuncPtr<&func>), newFunc, #func)

namespace Compat31
namespace Compat32
{
void closeDbgEng();
std::string funcPtrToStr(void* funcPtr);
Expand Down
2 changes: 1 addition & 1 deletion DDrawCompat/v0.3.1/Common/Path.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <DDrawCompat/v0.3.1/Common/Path.h>

namespace Compat31
namespace Compat32
{
std::filesystem::path getModulePath(HMODULE module)
{
Expand Down
2 changes: 1 addition & 1 deletion DDrawCompat/v0.3.1/Common/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <Windows.h>

namespace Compat31
namespace Compat32
{
std::filesystem::path getModulePath(HMODULE module);
std::filesystem::path getSystemPath();
Expand Down
2 changes: 1 addition & 1 deletion DDrawCompat/v0.3.1/Common/ScopedCriticalSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <Windows.h>

namespace Compat31
namespace Compat32
{
class CriticalSection : public CRITICAL_SECTION
{
Expand Down
2 changes: 1 addition & 1 deletion DDrawCompat/v0.3.1/Common/ScopedSrwLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <Windows.h>

namespace Compat31
namespace Compat32
{
class SrwLock : public SRWLOCK
{
Expand Down
4 changes: 2 additions & 2 deletions DDrawCompat/v0.3.1/Common/VtableHookVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class VtableHookVisitor
{
#ifdef DEBUGLOGS
s_funcName<memberPtr> = s_vtableTypeName + "::" + funcName;
Compat31::Log() << "Hooking function: " << s_funcName<memberPtr>
<< " (" << Compat31::funcPtrToStr(m_vtable.*memberPtr) << ')';
Compat32::Log() << "Hooking function: " << s_funcName<memberPtr>
<< " (" << Compat32::funcPtrToStr(m_vtable.*memberPtr) << ')';
#endif
m_vtable.*memberPtr = &hookFunc<memberPtr>;
}
Expand Down
2 changes: 1 addition & 1 deletion DDrawCompat/v0.3.1/D3dDdi/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace
oss << "Checking source color key support: failed (" << reason;
if (resultCode)
{
oss << ": " << Compat31::hex(resultCode);
oss << ": " << Compat32::hex(resultCode);
}
oss << ')';

Expand Down
2 changes: 1 addition & 1 deletion DDrawCompat/v0.3.1/D3dDdi/DeviceState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace D3dDdi
D3DDDIARG_CREATEVERTEXSHADERDECL* data,
const D3DDDIVERTEXELEMENT* vertexElements)
{
LOG_DEBUG << Compat31::array(vertexElements, data->NumVertexElements);
LOG_DEBUG << Compat32::array(vertexElements, data->NumVertexElements);
HRESULT result = m_device.getOrigVtable().pfnCreateVertexShaderDecl(m_device, data, vertexElements);
if (SUCCEEDED(result))
{
Expand Down
8 changes: 4 additions & 4 deletions DDrawCompat/v0.3.1/D3dDdi/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

std::ostream& operator<<(std::ostream& os, const D3DDDIARG_OPENADAPTER& data)
{
return Compat31::LogStruct(os)
return Compat32::LogStruct(os)
<< data.hAdapter
<< data.Interface
<< data.Version
<< data.pAdapterCallbacks
<< Compat31::out(data.pAdapterFuncs)
<< Compat32::out(data.pAdapterFuncs)
<< data.DriverVersion;
}

Expand All @@ -41,7 +41,7 @@ namespace
static std::set<HMODULE> hookedModules;
if (hookedModules.find(hModule) == hookedModules.end())
{
Compat31::Log() << "Hooking user mode display driver: " << Compat31::funcPtrToStr(g_origOpenAdapter);
Compat32::Log() << "Hooking user mode display driver: " << Compat32::funcPtrToStr(g_origOpenAdapter);
Dll::pinModule(hModule);
hookedModules.insert(hModule);
}
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace D3dDdi
{
void installHooks()
{
Compat31::hookIatFunction(Dll::g_origDDrawModule, "GetProcAddress", getProcAddress);
Compat32::hookIatFunction(Dll::g_origDDrawModule, "GetProcAddress", getProcAddress);

KernelModeThunks::installHooks();
}
Expand Down
Loading

0 comments on commit 11e1db3

Please sign in to comment.