From 3106081c43439d790b6a2d6a95819db02c5eda8b Mon Sep 17 00:00:00 2001 From: Silent Date: Wed, 22 Apr 2015 01:00:36 +0200 Subject: [PATCH] New TEST User Files obtaining code for VC 1.0 --- ResSock/dllmain.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/ResSock/dllmain.cpp b/ResSock/dllmain.cpp index 99263d1..2146b0f 100644 --- a/ResSock/dllmain.cpp +++ b/ResSock/dllmain.cpp @@ -1,9 +1,12 @@ #define WIN32_LEAN_AND_MEAN #define _CRT_SECURE_NO_WARNINGS +#define WINVER 0x0501 +#define _WIN32_WINNT 0x0501 #include #include #include +#include #include #include "MemoryMgr.h" @@ -142,11 +145,68 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, R return pDirectDrawCreateEx(lpGUID, lplpDD, iid, pUnkOuter); } +char** ppUserFilesDir; + +char* GetMyDocumentsPath() +{ + static char cUserFilesPath[MAX_PATH]; + + if ( cUserFilesPath[0] == '\0' ) + { + SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath); + PathAppend(cUserFilesPath, *ppUserFilesDir); + CreateDirectory(cUserFilesPath, nullptr); + } + return cUserFilesPath; +} + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { UNREFERENCED_PARAMETER(hinstDLL); - UNREFERENCED_PARAMETER(fdwReason); UNREFERENCED_PARAMETER(lpvReserved); + if ( fdwReason == DLL_PROCESS_ATTACH ) + { + using namespace MemoryVP; + DisableThreadLibraryCalls(hinstDLL); + + // TODO: Offset by a byte, or 5 + if (*(DWORD*)0x5C1E70 == 0x53E58955) + { + // III 1.0 + + } + else if (*(DWORD*)0x5C2130 == 0x53E58955) + { + // III 1.1 + + } + else if (*(DWORD*)0x5C6FD0 == 0x53E58955) + { + // III Steam + + } + + else if (*(DWORD*)0x667BF5 == 0xB85548EC) + { + // VC 1.0 + ppUserFilesDir = (char**)0x6022AA; + InjectHook(0x602240, GetMyDocumentsPath, PATCH_JUMP); + + InjectHook(0x601A40, GetMyDocumentsPath, PATCH_CALL); + InjectHook(0x601A45, 0x601B2F, PATCH_JUMP); + } + else if (*(DWORD*)0x667C40 == 0x53E58955) + { + // VC 1.1 + + } + else if (*(DWORD*)0x666BA0 == 0x53E58955) + { + // VC Steam + + } + } + return TRUE; } \ No newline at end of file