diff --git a/SilentPatch/RWGTA.cpp b/SilentPatch/RWGTA.cpp new file mode 100644 index 0000000..922a1a9 --- /dev/null +++ b/SilentPatch/RWGTA.cpp @@ -0,0 +1,36 @@ +#include "RWGTA.h" + +#include "Utils/MemoryMgr.h" +#include "Utils/Patterns.h" + +#include + +// GTA versions of RenderWare functions/macros for GTA III/Vice City +// since we cannot use RwEngineInstance directly + +// Anything originally using RwEngineInstance shall be redefined here +// Functions which RW 3.6 inlined can also easily be defined here + +void** GTARwEngineInstance = []() -> void** { + // Thanks Steam III... + + // Locate RwRenderStateSet + auto renderStateSetPtr = hook::get_pattern( "D1 7C 24 2C", 4 ); + auto renderStateSet = reinterpret_cast(Memory::ReadCallFrom( renderStateSetPtr )); + + // Test III 1.0/1.1/VC + if ( *reinterpret_cast(renderStateSet) == 0xA1 ) + { + return *reinterpret_cast(renderStateSet + 1); + } + + // Test III Steam + renderStateSet += 3; + if ( *reinterpret_cast(renderStateSet) == 0xA1 ) + { + return *reinterpret_cast(renderStateSet + 1); + } + + assert(!"Could not locate RwEngineInstance!"); + return nullptr; +}(); diff --git a/SilentPatch/RWGTA.h b/SilentPatch/RWGTA.h new file mode 100644 index 0000000..33eb4e1 --- /dev/null +++ b/SilentPatch/RWGTA.h @@ -0,0 +1,12 @@ +#pragma once + +// GTA versions of RenderWare functions/macros for GTA III/Vice City +// since we cannot use RwEngineInstance directly + +// Anything originally using RwEngineInstance shall be redefined here + +extern void** GTARwEngineInstance; + +/* macro used to access global data structure (the root type is RwGlobals) */ +#define GTARWSRCGLOBAL(variable) \ + (((RwGlobals *)(*GTARwEngineInstance))->variable) \ No newline at end of file diff --git a/SilentPatchIII/SilentPatchIII.vcxproj b/SilentPatchIII/SilentPatchIII.vcxproj index 139345b..86a2ed3 100644 --- a/SilentPatchIII/SilentPatchIII.vcxproj +++ b/SilentPatchIII/SilentPatchIII.vcxproj @@ -25,6 +25,11 @@ NotUsing NotUsing + + NotUsing + NotUsing + NotUsing + @@ -44,6 +49,7 @@ + diff --git a/SilentPatchIII/SilentPatchIII.vcxproj.filters b/SilentPatchIII/SilentPatchIII.vcxproj.filters index 3f02ae8..49254c6 100644 --- a/SilentPatchIII/SilentPatchIII.vcxproj.filters +++ b/SilentPatchIII/SilentPatchIII.vcxproj.filters @@ -42,6 +42,9 @@ Source Files\Utils + + Source Files + @@ -77,6 +80,9 @@ Header Files + + Header Files + diff --git a/SilentPatchVC/SilentPatchVC.vcxproj b/SilentPatchVC/SilentPatchVC.vcxproj index d4ee378..d773a7a 100644 --- a/SilentPatchVC/SilentPatchVC.vcxproj +++ b/SilentPatchVC/SilentPatchVC.vcxproj @@ -174,6 +174,7 @@ + @@ -194,6 +195,11 @@ NotUsing NotUsing + + NotUsing + NotUsing + NotUsing + diff --git a/SilentPatchVC/SilentPatchVC.vcxproj.filters b/SilentPatchVC/SilentPatchVC.vcxproj.filters index 70466a5..1b1557e 100644 --- a/SilentPatchVC/SilentPatchVC.vcxproj.filters +++ b/SilentPatchVC/SilentPatchVC.vcxproj.filters @@ -54,6 +54,9 @@ Header Files + + Header Files + @@ -80,6 +83,9 @@ Source Files\Utils + + Source Files +