mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-31 06:57:28 +05:00
GetASIModuleHandle to account for stupid people having their mods as DLL and not ASI
This commit is contained in:
parent
9cb66601f8
commit
43babcd405
5 changed files with 61 additions and 11 deletions
43
SilentPatch/ASIModuleHandle.h
Normal file
43
SilentPatch/ASIModuleHandle.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
inline HMODULE GetASIModuleHandleA( const char(&lpModuleName)[N] )
|
||||||
|
{
|
||||||
|
HMODULE asi = GetModuleHandleA( lpModuleName );
|
||||||
|
if ( asi == nullptr )
|
||||||
|
{
|
||||||
|
char nameWithSuffix[ N + 4 ];
|
||||||
|
memcpy( nameWithSuffix, lpModuleName, sizeof(lpModuleName) - sizeof(lpModuleName[0]) );
|
||||||
|
nameWithSuffix[N - 1] = '.';
|
||||||
|
nameWithSuffix[N + 0] = 'a';
|
||||||
|
nameWithSuffix[N + 1] = 's';
|
||||||
|
nameWithSuffix[N + 2] = 'i';
|
||||||
|
nameWithSuffix[N + 3] = '\0';
|
||||||
|
asi = GetModuleHandleA( nameWithSuffix );
|
||||||
|
}
|
||||||
|
return asi;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
inline HMODULE GetASIModuleHandleW( const wchar_t(&lpModuleName)[N] )
|
||||||
|
{
|
||||||
|
HMODULE asi = GetModuleHandleW( lpModuleName );
|
||||||
|
if ( asi == nullptr )
|
||||||
|
{
|
||||||
|
wchar_t nameWithSuffix[ N + 4 ];
|
||||||
|
memcpy( nameWithSuffix, lpModuleName, sizeof(lpModuleName) - sizeof(lpModuleName[0]) );
|
||||||
|
nameWithSuffix[N - 1] = L'.';
|
||||||
|
nameWithSuffix[N + 0] = L'a';
|
||||||
|
nameWithSuffix[N + 1] = L's';
|
||||||
|
nameWithSuffix[N + 2] = L'i';
|
||||||
|
nameWithSuffix[N + 3] = L'\0';
|
||||||
|
asi = GetModuleHandleW( nameWithSuffix );
|
||||||
|
}
|
||||||
|
return asi;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
#define GetASIModuleHandle GetASIModuleHandleW
|
||||||
|
#else
|
||||||
|
#define GetASIModuleHandle GetASIModuleHandleA
|
||||||
|
#endif
|
|
@ -3,12 +3,14 @@
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#include "ASIModuleHandle.h"
|
||||||
|
|
||||||
int32_t (*FLAUtils::GetExtendedID8Func)(const uint8_t* ptr) = FLAUtils::GetExtendedID8_Stock;
|
int32_t (*FLAUtils::GetExtendedID8Func)(const uint8_t* ptr) = FLAUtils::GetExtendedID8_Stock;
|
||||||
int32_t (*FLAUtils::GetExtendedID16Func)(const uint16_t* ptr) = FLAUtils::GetExtendedID16_Stock;
|
int32_t (*FLAUtils::GetExtendedID16Func)(const uint16_t* ptr) = FLAUtils::GetExtendedID16_Stock;
|
||||||
|
|
||||||
void FLAUtils::Init()
|
void FLAUtils::Init()
|
||||||
{
|
{
|
||||||
const HMODULE hFLA = GetModuleHandle(TEXT("$fastman92limitAdjuster.asi"));
|
const HMODULE hFLA = GetASIModuleHandle(TEXT("$fastman92limitAdjuster"));
|
||||||
if ( hFLA != nullptr )
|
if ( hFLA != nullptr )
|
||||||
{
|
{
|
||||||
const auto function8 = reinterpret_cast<decltype(GetExtendedID8Func)>(GetProcAddress( hFLA, "GetExtendedIDfrom8bitBefore" ));
|
const auto function8 = reinterpret_cast<decltype(GetExtendedID8Func)>(GetProcAddress( hFLA, "GetExtendedIDfrom8bitBefore" ));
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "Patterns.h"
|
#include "Patterns.h"
|
||||||
#include "DelimStringReader.h"
|
#include "DelimStringReader.h"
|
||||||
|
#include "ASIModuleHandle.h"
|
||||||
|
|
||||||
#pragma warning(disable:4733)
|
#pragma warning(disable:4733)
|
||||||
|
|
||||||
|
@ -2288,9 +2289,9 @@ BOOL InjectDelayedPatches_10()
|
||||||
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
|
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
|
||||||
PathRenameExtensionW(wcModulePath, L".ini");
|
PathRenameExtensionW(wcModulePath, L".ini");
|
||||||
|
|
||||||
bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr;
|
bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr;
|
||||||
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
|
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
|
||||||
bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr;
|
bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr;
|
||||||
|
|
||||||
ReadRotorFixExceptions(wcModulePath);
|
ReadRotorFixExceptions(wcModulePath);
|
||||||
ReadDoubleRearWheels(wcModulePath);
|
ReadDoubleRearWheels(wcModulePath);
|
||||||
|
@ -2467,7 +2468,7 @@ BOOL InjectDelayedPatches_10()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSE conflicts
|
// SSE conflicts
|
||||||
if ( GetModuleHandleW(L"shadows.asi") == nullptr )
|
if ( GetASIModuleHandleW(L"shadows") == nullptr )
|
||||||
{
|
{
|
||||||
Patch<DWORD>(0x70665C, 0x52909090);
|
Patch<DWORD>(0x70665C, 0x52909090);
|
||||||
InjectHook(0x706662, &CShadowCamera::Update);
|
InjectHook(0x706662, &CShadowCamera::Update);
|
||||||
|
@ -2487,7 +2488,7 @@ BOOL InjectDelayedPatches_10()
|
||||||
|
|
||||||
// Adblocker
|
// Adblocker
|
||||||
#if DISABLE_FLA_DONATION_WINDOW
|
#if DISABLE_FLA_DONATION_WINDOW
|
||||||
if ( GetModuleHandleW(L"$fastman92limitAdjuster.asi") != nullptr )
|
if ( GetASIModuleHandleW(L"$fastman92limitAdjuster") != nullptr )
|
||||||
{
|
{
|
||||||
if ( *(DWORD*)0x748736 != 0xE8186A53 )
|
if ( *(DWORD*)0x748736 != 0xE8186A53 )
|
||||||
{
|
{
|
||||||
|
@ -2526,9 +2527,9 @@ BOOL InjectDelayedPatches_11()
|
||||||
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
|
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
|
||||||
PathRenameExtensionW(wcModulePath, L".ini");
|
PathRenameExtensionW(wcModulePath, L".ini");
|
||||||
|
|
||||||
bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr;
|
bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr;
|
||||||
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
|
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
|
||||||
bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr;
|
bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr;
|
||||||
|
|
||||||
ReadRotorFixExceptions(wcModulePath);
|
ReadRotorFixExceptions(wcModulePath);
|
||||||
|
|
||||||
|
@ -2713,7 +2714,7 @@ BOOL InjectDelayedPatches_11()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSE conflicts
|
// SSE conflicts
|
||||||
if ( GetModuleHandleW(L"shadows.asi") == nullptr )
|
if ( GetASIModuleHandleW(L"shadows") == nullptr )
|
||||||
{
|
{
|
||||||
Patch<DWORD>(0x706E8C, 0x52909090);
|
Patch<DWORD>(0x706E8C, 0x52909090);
|
||||||
InjectHook(0x706E92, &CShadowCamera::Update);
|
InjectHook(0x706E92, &CShadowCamera::Update);
|
||||||
|
@ -2752,9 +2753,9 @@ BOOL InjectDelayedPatches_Steam()
|
||||||
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
|
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
|
||||||
PathRenameExtensionW(wcModulePath, L".ini");
|
PathRenameExtensionW(wcModulePath, L".ini");
|
||||||
|
|
||||||
bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr;
|
bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr;
|
||||||
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
|
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
|
||||||
bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr;
|
bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr;
|
||||||
|
|
||||||
ReadRotorFixExceptions(wcModulePath);
|
ReadRotorFixExceptions(wcModulePath);
|
||||||
|
|
||||||
|
@ -2927,7 +2928,7 @@ BOOL InjectDelayedPatches_Steam()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSE conflicts
|
// SSE conflicts
|
||||||
if ( GetModuleHandleW(L"shadows.asi") == nullptr )
|
if ( GetASIModuleHandleW(L"shadows") == nullptr )
|
||||||
{
|
{
|
||||||
Patch<DWORD>(0x74A864, 0x52909090);
|
Patch<DWORD>(0x74A864, 0x52909090);
|
||||||
InjectHook(0x74A86A, &CShadowCamera::Update);
|
InjectHook(0x74A86A, &CShadowCamera::Update);
|
||||||
|
|
|
@ -235,6 +235,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\SilentPatch\ASIModuleHandle.h" />
|
||||||
<ClInclude Include="..\SilentPatch\DelimStringReader.h" />
|
<ClInclude Include="..\SilentPatch\DelimStringReader.h" />
|
||||||
<ClInclude Include="..\SilentPatch\FLAC\callback.h" />
|
<ClInclude Include="..\SilentPatch\FLAC\callback.h" />
|
||||||
<ClInclude Include="..\SilentPatch\FLAC\export.h" />
|
<ClInclude Include="..\SilentPatch\FLAC\export.h" />
|
||||||
|
|
|
@ -152,6 +152,9 @@
|
||||||
<ClInclude Include="PoolsSA.h">
|
<ClInclude Include="PoolsSA.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\SilentPatch\ASIModuleHandle.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="Shaders.rc">
|
<ResourceCompile Include="Shaders.rc">
|
||||||
|
|
Loading…
Reference in a new issue