aboutsummaryrefslogtreecommitdiff
path: root/TestDLL
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2019-09-30 22:29:18 +0200
committerToni Uhlig <matzeton@googlemail.com>2019-09-30 22:29:18 +0200
commit3da2303b0828532c96c68a08e4d6d0f5725857dc (patch)
treed84402e734e4e1fa8a2e734d52611920d14eceb3 /TestDLL
parent041e2d5781133fd06e150a9a9fe93ac63decb23b (diff)
added some more HUNT classes and post DLL injection checks
Diffstat (limited to 'TestDLL')
-rw-r--r--TestDLL/HuntClasses.h265
-rw-r--r--TestDLL/dllmain.cpp37
2 files changed, 212 insertions, 90 deletions
diff --git a/TestDLL/HuntClasses.h b/TestDLL/HuntClasses.h
index 6fb8e5c..40d45e1 100644
--- a/TestDLL/HuntClasses.h
+++ b/TestDLL/HuntClasses.h
@@ -6,87 +6,7 @@
#include <stdarg.h>
#include <string.h>
-
-struct SSystemGlobalEnvironment {
- UINT64 pDialogSystem;
- UINT64 p3DEngine;
- UINT64 pNetwork;
- UINT64 pNetContext;
- UINT64 pLobby;
- UINT64 pScriptSystem;
- UINT64 pPhysicalWorld;
- UINT64 pFlowSystem;
- UINT64 pInput;
- UINT64 pStatoscope;
- UINT64 pCryPak;
- UINT64 pFileChangeMonitor;
- UINT64 pParticleManager;
- UINT64 pOpticsManager;
- UINT64 pTimer;
- UINT64 pCryFont;
- UINT64 pGameFramework;
- UINT64 pLocalMemoryUsage;
- UINT64 pEntitySystem;
- UINT64 pConsole;
- UINT64 pAudioSystem;
- UINT64 pSystem;
- UINT64 pCharacterManager;
- UINT64 pAISystem;
- UINT64 pLog;
- UINT64 pCodeCheckpointMgr;
- UINT64 pMovieSystem;
- UINT64 pNameTable;
- UINT64 pRenderer;
- UINT64 pAuxGeomRenderer;
- UINT64 pHardwareMouse;
- UINT64 pMaterialEffects;
- UINT64 pJobManager;
- UINT64 pOverloadSceneManager;
- UINT64 pFlashUI;
- UINT64 pUIFramework;
- UINT64 pServiceNetwork;
- UINT64 pRemoteCommandManager;
- UINT64 pDynamicResponseSystem;
- UINT64 pThreadManager;
- UINT64 pScaleformHelper;
- UINT64 pSchematyc;
- UINT64 pSchematyc2;
- UINT64 pReflection;
- UINT64 pScriptCoreEnv;
- UINT64 pScriptCoreRegistry;
- UINT64 pUDR;
- UINT64 pLiveCreateManager;
- UINT64 pLiveCreateHost;
- UINT64 pMonoRuntime;
- UINT32 mMainThreadId;
- UINT32 nMainFrameID;
- UINT64 szCmdLine;
- CHAR szDebugStatus[128];
- BOOL bServer;
- BOOL bMultiplayer;
- BOOL bHostMigrating;
- UCHAR padding_00;
- UINT64 startProfilingSection;
- UINT64 endProfilingSection;
- UINT64 recordProfilingMarker;
- BOOL bUnattendedMode;
- BOOL bTesting;
- BOOL bNoRandomSeed;
- UCHAR padding_01;
- UINT32 assertSettings;
- UCHAR platformInfo[286];
- UCHAR protectedFunctions[80];
- BOOL bIsOutOfMemory;
- BOOL bIsOutOfVideoMemory;
- BOOL bDedicatedArbitrator;
- BOOL bEditor;
- BOOL bEditorGameMode;
- BOOL bEditorSimulationMode;
- BOOL bDedicated;
- BOOL bClient;
- BOOL m_isFMVPlaying;
- BOOL m_isCutscenePlaying;
-};
+struct ISystem;
struct IEntitySystem
{
@@ -134,7 +54,7 @@ struct IEntitySystem
virtual void PauseTimers(bool bPause, bool bResume = false) = 0;
virtual bool IsIDUsed(int) const = 0;
virtual void GetMemoryStatistics(PVOID) const = 0;
- virtual PVOID GetSystem() const = 0;
+ virtual ISystem* GetSystem() const = 0;
virtual bool ExtractArcheTypeLoadParams(void) const = 0;
virtual bool ExtractEntityLoadParams(void) const = 0;
virtual void BeginCreateEntities(int amtToCreate) = 0;
@@ -342,4 +262,183 @@ public:
RenderText(pos, ti, format, args);
}
-}; \ No newline at end of file
+};
+
+struct SSystemGlobalEnvironment {
+ UINT64 pDialogSystem;
+ UINT64 p3DEngine;
+ UINT64 pNetwork;
+ UINT64 pNetContext;
+ UINT64 pLobby;
+ UINT64 pScriptSystem;
+ UINT64 pPhysicalWorld;
+ UINT64 pFlowSystem;
+ UINT64 pInput;
+ UINT64 pStatoscope;
+ UINT64 pCryPak;
+ UINT64 pFileChangeMonitor;
+ UINT64 pParticleManager;
+ UINT64 pOpticsManager;
+ UINT64 pTimer;
+ UINT64 pCryFont;
+ UINT64 pGameFramework;
+ UINT64 pLocalMemoryUsage;
+ IEntitySystem* pEntitySystem;
+ UINT64 pConsole;
+ UINT64 pAudioSystem;
+ ISystem* pSystem;
+ UINT64 pCharacterManager;
+ UINT64 pAISystem;
+ UINT64 pLog;
+ UINT64 pCodeCheckpointMgr;
+ UINT64 pMovieSystem;
+ UINT64 pNameTable;
+ UINT64 pRenderer;
+ UINT64 pAuxGeomRenderer;
+ UINT64 pHardwareMouse;
+ UINT64 pMaterialEffects;
+ UINT64 pJobManager;
+ UINT64 pOverloadSceneManager;
+ UINT64 pFlashUI;
+ UINT64 pUIFramework;
+ UINT64 pServiceNetwork;
+ UINT64 pRemoteCommandManager;
+ UINT64 pDynamicResponseSystem;
+ UINT64 pThreadManager;
+ UINT64 pScaleformHelper;
+ UINT64 pSchematyc;
+ UINT64 pSchematyc2;
+ UINT64 pReflection;
+ UINT64 pScriptCoreEnv;
+ UINT64 pScriptCoreRegistry;
+ UINT64 pUDR;
+ UINT64 pLiveCreateManager;
+ UINT64 pLiveCreateHost;
+ UINT64 pMonoRuntime;
+ UINT32 mMainThreadId;
+ UINT32 nMainFrameID;
+ UINT64 szCmdLine;
+ CHAR szDebugStatus[128];
+ BOOL bServer;
+ BOOL bMultiplayer;
+ BOOL bHostMigrating;
+ UCHAR padding_00;
+ UINT64 startProfilingSection;
+ UINT64 endProfilingSection;
+ UINT64 recordProfilingMarker;
+ BOOL bUnattendedMode;
+ BOOL bTesting;
+ BOOL bNoRandomSeed;
+ UCHAR padding_01;
+ UINT32 assertSettings;
+ UCHAR platformInfo[286];
+ UCHAR protectedFunctions[80];
+ BOOL bIsOutOfMemory;
+ BOOL bIsOutOfVideoMemory;
+ BOOL bDedicatedArbitrator;
+ BOOL bEditor;
+ BOOL bEditorGameMode;
+ BOOL bEditorSimulationMode;
+ BOOL bDedicated;
+ BOOL bClient;
+ BOOL m_isFMVPlaying;
+ BOOL m_isCutscenePlaying;
+};
+
+struct ISystem
+{
+ struct ILoadingProgressListener
+ {
+ virtual ~ILoadingProgressListener() {}
+ virtual void OnLoadingProgress(int steps) = 0;
+ };
+
+ virtual ~ISystem() {}
+ virtual PVOID GetCVarsWhiteListConfigSink() const = 0;
+ virtual SSystemGlobalEnvironment* GetGlobalEnvironment() = 0;
+ virtual PVOID GetUserCallback() const = 0;
+ virtual const char* GetRootFolder() const = 0;
+ virtual bool DoFrame(void) = 0;
+ virtual void RenderBegin(void) = 0;
+ virtual void RenderEnd(bool bRenderStats = true) = 0;
+ virtual bool Update(int updateFlags, int nPauseMode = 0) = 0;
+ virtual void RenderPhysicsHelpers() = 0;
+ virtual PVOID GetManualFrameStepController() const = 0;
+ virtual bool UpdateLoadtime() = 0;
+ virtual void SynchronousLoadingTick(const char* pFunc, int line) = 0;
+ virtual void RenderStatistics() = 0;
+ virtual void RenderPhysicsStatistics(PVOID pWorld) = 0;
+ virtual UINT32 GetUsedMemory() = 0;
+ virtual const char* GetUserName() = 0;
+ virtual UINT32 GetCPUFlags() = 0;
+ virtual int GetLogicalCPUCount() = 0;
+ virtual void DumpMemoryUsageStatistics(bool bUseKB = false) = 0;
+ virtual void Quit() = 0;
+ virtual void Relaunch(bool bRelaunch) = 0;
+ virtual bool IsQuitting() const = 0;
+ virtual bool IsShaderCacheGenMode() const = 0;
+ virtual void SerializingFile(int mode) = 0;
+ virtual int IsSerializingFile() const = 0;
+ virtual bool IsRelaunch() const = 0;
+ virtual void DisplayErrorMessage(const char* acMessage, float fTime, const float* pfColor = 0, bool bHardError = true) = 0;
+ virtual void FatalError(const char* sFormat, ...) = 0;
+ virtual void ReportBug(const char* sFormat, ...) = 0;
+ virtual void WarningV(int module, int severity, int flags, const char* file, const char* format, va_list args) = 0;
+ virtual void Warning(int module, int severity, int flags, const char* file, const char* format, ...) = 0;
+ virtual void WarningOnce(int module, int severity, int flags, const char* file, const char* format, ...) = 0;
+ virtual bool CheckLogVerbosity(int verbosity) = 0;
+ virtual bool IsUIFrameworkMode() { return false; }
+ virtual void FillRandomMT(UINT32* pOutWords, UINT32 numWords) = 0;
+ virtual PVOID GetRandomGenerator() = 0;
+ virtual PVOID GetIZLibCompressor() = 0;
+ virtual PVOID GetIZLibDecompressor() = 0;
+ virtual PVOID GetLZ4Decompressor() = 0;
+ virtual PVOID GetPerfHUD() = 0;
+ virtual PVOID GetMiniGUI() = 0;
+ virtual PVOID GetPlatformOS() = 0;
+ virtual PVOID GetINotificationNetwork() = 0;
+ virtual PVOID GetIHardwareMouse() = 0;
+ virtual PVOID GetIDialogSystem() = 0;
+ virtual PVOID GetIFlowSystem() = 0;
+ virtual PVOID GetIBudgetingSystem() = 0;
+ virtual PVOID GetINameTable() = 0;
+ virtual PVOID GetIDiskProfiler() = 0;
+ virtual PVOID GetProfilingSystem() = 0;
+ virtual PVOID GetLegacyProfilerInterface() = 0;
+ virtual PVOID GetIValidator() = 0;
+ virtual PVOID GetIPhysicsDebugRenderer() = 0;
+ virtual PVOID GetIPhysRenderer() = 0;
+ virtual PVOID GetIAnimationSystem() = 0;
+ virtual PVOID GetStreamEngine() = 0;
+ virtual PVOID GetICmdLine() = 0;
+ virtual PVOID GetILog() = 0;
+ virtual PVOID GetIPak() = 0;
+ virtual PVOID GetICryFont() = 0;
+ virtual IEntitySystem* GetIEntitySystem() = 0;
+ virtual PVOID GetIMemoryManager() = 0;
+ virtual PVOID GetAISystem() = 0;
+ virtual PVOID GetIMovieSystem() = 0;
+ virtual PVOID GetIPhysicalWorld() = 0;
+ virtual PVOID GetIAudioSystem() = 0;
+ virtual PVOID GetI3DEngine() = 0;
+ virtual PVOID GetIScriptSystem() = 0;
+ virtual PVOID GetIConsole() = 0;
+ virtual PVOID GetIRemoteConsole() = 0;
+ virtual PVOID GetIUserAnalyticsSystem() = 0;
+ virtual PVOID GetIPluginManager() = 0;
+ virtual PVOID GetIProjectManager() = 0;
+ virtual PVOID GetIUDR() = 0;
+ virtual PVOID GetIResourceManager() = 0;
+ virtual PVOID GetISystemEventDispatcher() = 0;
+ virtual PVOID GetIFileChangeMonitor() = 0;
+ virtual PVOID GetHWND() = 0;
+ virtual PVOID GetActiveHWND() = 0;
+ virtual PVOID GetINetwork() = 0;
+ virtual PVOID GetIRenderer() = 0;
+ virtual PVOID GetIInput() = 0;
+ virtual PVOID GetITimer() = 0;
+ virtual PVOID GetIThreadManager() = 0;
+ virtual PVOID GetIMonoEngineModule() = 0;
+
+ /* some more virtual functions */
+};
diff --git a/TestDLL/dllmain.cpp b/TestDLL/dllmain.cpp
index 0124c65..63458ff 100644
--- a/TestDLL/dllmain.cpp
+++ b/TestDLL/dllmain.cpp
@@ -205,16 +205,39 @@ void APIENTRY LibEntry(PVOID user_ptr)
"TestDLL Notification",
MB_OK | MB_ICONINFORMATION);
- UINT64 pEntSys = (UINT64)user_ptr;
- pEntSys = *(UINT64*)pEntSys;
-
+ UINT64 pEntSys = *(UINT64*)user_ptr;
IEntitySystem * iEnt = *(IEntitySystem **)user_ptr;
+#define PENTITYSYSTEM_ISYSTEM_OFFSET 104
+ if ((PVOID)(*(UINT64*)(pEntSys + PENTITYSYSTEM_ISYSTEM_OFFSET)) != iEnt->GetSystem()) {
+ char errbuf[128];
+ snprintf(errbuf, sizeof errbuf,
+ "WARNING: ISystem interface instance not equal: MEMBER[%p] != GETSYSTEM[%p]\n",
+ (PVOID)(*(UINT64*)(pEntSys + PENTITYSYSTEM_ISYSTEM_OFFSET)), iEnt->GetSystem());
+ MessageBoxA(NULL,
+ errbuf,
+ "Hunted WARNING",
+ MB_OK | MB_ICONINFORMATION);
+ return;
+ }
+
+ if ((PVOID)pEntSys != iEnt->GetSystem()->GetIEntitySystem()) {
+ char errbuf[128];
+ snprintf(errbuf, sizeof errbuf,
+ "WARNING: IEntitySystem interface instance not equal: GLOBAL[%p] != GETENTITYSYSTEM[%p]\n",
+ (PVOID)pEntSys, iEnt->GetSystem()->GetIEntitySystem());
+ MessageBoxA(NULL,
+ errbuf,
+ "Hunted WARNING",
+ MB_OK | MB_ICONINFORMATION);
+ return;
+ }
+
char buf[128];
- snprintf(buf, sizeof buf, "gEnv: %p | %p | %u | %u | %p | %p\n", user_ptr,
- (PVOID)(*(UINT64*)(pEntSys + 104)), *(BOOL*)(pEntSys + 786974),
- *(UINT32*)(pEntSys + 786970), (PVOID)(*(UINT64*)(pEntSys + 786962)),
- iEnt->GetSystem());
+ snprintf(buf, sizeof buf, "---%p---%p---%p---%u------\n",
+ iEnt->GetSystem()->GetGlobalEnvironment(), (PVOID)pEntSys,
+ iEnt->GetSystem()->GetIEntitySystem(),
+ iEnt->GetSystem()->GetUsedMemory());
MessageBoxA(NULL,
buf,
"TestDLL Notification",