added filesystemwarning hook, commented and not doing anything yet

This commit is contained in:
IcePixelx 2021-08-08 22:32:30 +02:00
parent 983172006b
commit 443d3fcc15
7 changed files with 56 additions and 0 deletions

View File

@ -356,4 +356,17 @@ enum SIGNONSTATE
SIGNONSTATE_FIRST_SNAP = 7, // ???
SIGNONSTATE_FULL = 8, // we are fully connected; first non-delta packet received
SIGNONSTATE_CHANGELEVEL = 9, // server is changing level; please wait
};
enum FileWarningLevel_t
{
FILESYSTEM_WARNING = -1,
FILESYSTEM_WARNING_QUIET = 0,
FILESYSTEM_WARNING_REPORTUNCLOSED,
FILESYSTEM_WARNING_REPORTUSAGE,
FILESYSTEM_WARNING_REPORTALLACCESSES,
FILESYSTEM_WARNING_REPORTALLACCESSES_READ,
FILESYSTEM_WARNING_REPORTALLACCESSES_READWRITE,
FILESYSTEM_WARNING_REPORTALLACCESSES_ASYNC
};

View File

@ -78,6 +78,13 @@ namespace Hooks
extern ShowCursorFn originalShowCursor;
#pragma endregion
#pragma region CBaseFileSystem
void FileSystemWarning(void* thisptr, FileWarningLevel_t level, const char* fmt, ...);
using FileSystemWarningFn = void(*)(void*, FileWarningLevel_t, const char*, ...);
extern FileSystemWarningFn originalFileSystemWarning;
#pragma endregion
#pragma region Other
int MSG_EngineError(char* fmt, va_list args);

View File

@ -51,6 +51,10 @@ namespace
FUNC_AT_ADDRESS(addr_CVEngineServer_IsPersistenceDataAvailable, bool(*)(__int64, int), r5_patterns.PatternSearch("3B 15 ?? ?? ?? ?? 7D 33").GetPtr());
#pragma endregion
#pragma region CBaseFileSystem
FUNC_AT_ADDRESS(addr_CBaseFileSystem_FileSystemWarning, void(*)(void*, FileWarningLevel_t, const char*, ...), r5_patterns.PatternSearch("E8 ? ? ? ? 33 C0 80 3B 2A").FollowNearCallSelf().GetPtr());
#pragma endregion
#pragma region Utility
/*0x140295600*/
FUNC_AT_ADDRESS(addr_MSG_EngineError, int(*)(char*, va_list), r5_patterns.PatternSearch("48 89 5C 24 08 48 89 74 24 10 57 48 81 EC 30 08 00 00 48 8B DA").GetPtr());
@ -72,6 +76,7 @@ namespace
PRINT_ADDRESS("NET_SendDatagram ", addr_NET_SendDatagram);
PRINT_ADDRESS("CHLClient::FrameStageNotify", addr_CHLClient_FrameStageNotify);
PRINT_ADDRESS("CVEngineServer::IsPersistenceDataAvailable", addr_CVEngineServer_IsPersistenceDataAvailable);
PRINT_ADDRESS("CBaseFileSystem::FileSystemWarning", addr_CBaseFileSystem_FileSystemWarning);
PRINT_ADDRESS("MSG_EngineError", addr_MSG_EngineError);
std::cout << "+--------------------------------------------------------+" << std::endl;
// TODO implement error handling when sigscan fails or result is 0

View File

@ -369,6 +369,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">pch.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\hooks\cbasefilesystem.cpp" />
<ClCompile Include="src\hooks\chlclient.cpp" />
<ClCompile Include="src\hooks\cvengineserver.cpp" />
<ClCompile Include="src\hooks\hooks.cpp" />

View File

@ -100,6 +100,9 @@
<Filter Include="gui\interface">
<UniqueIdentifier>{1979149f-6402-4985-b900-25a91f1168ac}</UniqueIdentifier>
</Filter>
<Filter Include="hooks\src\cbasefilesystem">
<UniqueIdentifier>{90ee1072-2d57-4d4e-aa1e-f19a81e6b27f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\dllmain.cpp">
@ -186,6 +189,9 @@
<ClCompile Include="src\gui_utility.cpp">
<Filter>gui</Filter>
</ClCompile>
<ClCompile Include="src\hooks\cbasefilesystem.cpp">
<Filter>hooks\src\cbasefilesystem</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\external\imgui\include\imgui_impl_win32.h">

View File

@ -0,0 +1,12 @@
#include "pch.h"
#include "hooks.h"
namespace Hooks
{
FileSystemWarningFn originalFileSystemWarning = nullptr;
}
void Hooks::FileSystemWarning(void* thisptr, FileWarningLevel_t level, const char* fmt, ...)
{
// How you call original functions, you dont need it here.
// originalFileSystemWarning(thisptr, level, fmt, ...);
}

View File

@ -37,6 +37,10 @@ void Hooks::InstallHooks()
MH_CreateHook(addr_ConVar_IsFlagSet, &Hooks::ConVar_IsFlagSet, NULL);
MH_CreateHook(addr_ConCommand_IsFlagSet, &Hooks::ConCommand_IsFlagSet, NULL);
///////////////////////////////////////////////////////////////////////////////
// Hooks CBaseFileSystem functions.
//MH_CreateHook(addr_CBaseFileSystem_FileSystemWarning, &Hooks::FileSystemWarning, reinterpret_cast<void**>(&originalFileSystemWarning);
///////////////////////////////////////////////////////////////////////////////
// Hook Utility functions
MH_CreateHook(addr_MSG_EngineError, &Hooks::MSG_EngineError, reinterpret_cast<void**>(&originalMSG_EngineError));
@ -85,6 +89,10 @@ void Hooks::InstallHooks()
MH_EnableHook(addr_ConVar_IsFlagSet);
MH_EnableHook(addr_ConCommand_IsFlagSet);
///////////////////////////////////////////////////////////////////////////////
// Enable CBaseFileSystem hooks
//MH_EnableHook(addr_CBaseFileSystem_FileSystemWarning);
///////////////////////////////////////////////////////////////////////////////
// Enabled Utility hooks
MH_EnableHook(addr_MSG_EngineError);
@ -135,6 +143,10 @@ void Hooks::RemoveHooks()
// Unhook Utility functions
MH_RemoveHook(addr_MSG_EngineError);
///////////////////////////////////////////////////////////////////////////////
// Unhook CBaseFileSystem functions.
//MH_RemoveHook(addr_CBaseFileSystem_FileSystemWarning);
///////////////////////////////////////////////////////////////////////////////
// Reset Minhook
MH_Uninitialize();