GetASIModuleHandle to account for stupid people having their mods as DLL and not ASI

This commit is contained in:
Silent 2017-09-12 14:21:20 +02:00
parent 9cb66601f8
commit 43babcd405
5 changed files with 61 additions and 11 deletions

View 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

View File

@ -3,12 +3,14 @@
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "ASIModuleHandle.h"
int32_t (*FLAUtils::GetExtendedID8Func)(const uint8_t* ptr) = FLAUtils::GetExtendedID8_Stock;
int32_t (*FLAUtils::GetExtendedID16Func)(const uint16_t* ptr) = FLAUtils::GetExtendedID16_Stock;
void FLAUtils::Init()
{
const HMODULE hFLA = GetModuleHandle(TEXT("$fastman92limitAdjuster.asi"));
const HMODULE hFLA = GetASIModuleHandle(TEXT("$fastman92limitAdjuster"));
if ( hFLA != nullptr )
{
const auto function8 = reinterpret_cast<decltype(GetExtendedID8Func)>(GetProcAddress( hFLA, "GetExtendedIDfrom8bitBefore" ));

View File

@ -19,6 +19,7 @@
#include "Patterns.h"
#include "DelimStringReader.h"
#include "ASIModuleHandle.h"
#pragma warning(disable:4733)
@ -2288,9 +2289,9 @@ BOOL InjectDelayedPatches_10()
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
PathRenameExtensionW(wcModulePath, L".ini");
bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr;
bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr;
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr;
bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr;
ReadRotorFixExceptions(wcModulePath);
ReadDoubleRearWheels(wcModulePath);
@ -2467,7 +2468,7 @@ BOOL InjectDelayedPatches_10()
}
// SSE conflicts
if ( GetModuleHandleW(L"shadows.asi") == nullptr )
if ( GetASIModuleHandleW(L"shadows") == nullptr )
{
Patch<DWORD>(0x70665C, 0x52909090);
InjectHook(0x706662, &CShadowCamera::Update);
@ -2487,7 +2488,7 @@ BOOL InjectDelayedPatches_10()
// Adblocker
#if DISABLE_FLA_DONATION_WINDOW
if ( GetModuleHandleW(L"$fastman92limitAdjuster.asi") != nullptr )
if ( GetASIModuleHandleW(L"$fastman92limitAdjuster") != nullptr )
{
if ( *(DWORD*)0x748736 != 0xE8186A53 )
{
@ -2526,9 +2527,9 @@ BOOL InjectDelayedPatches_11()
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
PathRenameExtensionW(wcModulePath, L".ini");
bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr;
bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr;
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr;
bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr;
ReadRotorFixExceptions(wcModulePath);
@ -2713,7 +2714,7 @@ BOOL InjectDelayedPatches_11()
}
// SSE conflicts
if ( GetModuleHandleW(L"shadows.asi") == nullptr )
if ( GetASIModuleHandleW(L"shadows") == nullptr )
{
Patch<DWORD>(0x706E8C, 0x52909090);
InjectHook(0x706E92, &CShadowCamera::Update);
@ -2752,9 +2753,9 @@ BOOL InjectDelayedPatches_Steam()
GetModuleFileNameW(hDLLModule, wcModulePath, _countof(wcModulePath) - 3); // Minus max required space for extension
PathRenameExtensionW(wcModulePath, L".ini");
bool bHasImVehFt = GetModuleHandleW(L"ImVehFt.asi") != nullptr;
bool bHasImVehFt = GetASIModuleHandleW(L"ImVehFt") != nullptr;
bool bSAMP = GetModuleHandleW(L"samp") != nullptr;
bool bSARender = GetModuleHandleW(L"SARender.asi") != nullptr;
bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr;
ReadRotorFixExceptions(wcModulePath);
@ -2927,7 +2928,7 @@ BOOL InjectDelayedPatches_Steam()
}
// SSE conflicts
if ( GetModuleHandleW(L"shadows.asi") == nullptr )
if ( GetASIModuleHandleW(L"shadows") == nullptr )
{
Patch<DWORD>(0x74A864, 0x52909090);
InjectHook(0x74A86A, &CShadowCamera::Update);

View File

@ -235,6 +235,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
</FxCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\ASIModuleHandle.h" />
<ClInclude Include="..\SilentPatch\DelimStringReader.h" />
<ClInclude Include="..\SilentPatch\FLAC\callback.h" />
<ClInclude Include="..\SilentPatch\FLAC\export.h" />

View File

@ -152,6 +152,9 @@
<ClInclude Include="PoolsSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\ASIModuleHandle.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Shaders.rc">