Created
January 26, 2009 17:56
-
-
Save valda/52887 to your computer and use it in GitHub Desktop.
fose中華exe対応patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- main.cpp.orig 2009-01-17 07:56:08.000000000 +0900 | |
+++ main.cpp 2009-01-26 16:31:22.654000000 +0900 | |
@@ -20,6 +20,7 @@ | |
static bool DoInjectDLL(PROCESS_INFORMATION * info, const char * dllPath, ProcHookInfo * hookInfo); | |
static bool TestChecksum(const char * procName, std::string * dllSuffix, ProcHookInfo * hookInfo); | |
static void PrintError(const char * fmt, ...); | |
+static bool Inject3DMDLL(HANDLE hprocess); | |
int main(int argc, char ** argv) | |
{ | |
@@ -144,6 +145,9 @@ | |
if(result) | |
{ | |
+ if (Inject3DMDLL(procInfo.hProcess)) { | |
+ _MESSAGE("fallout3_cn.3dm was injected."); | |
+ } | |
_MESSAGE("launching"); | |
// start the process | |
@@ -570,3 +574,33 @@ | |
va_end(args); | |
} | |
+ | |
+static bool Inject3DMDLL(HANDLE hprocess) | |
+{ | |
+ char currentWorkingDirectory[4096]; | |
+ ASSERT(_getcwd(currentWorkingDirectory, sizeof(currentWorkingDirectory))); | |
+ std::string procPath = std::string(currentWorkingDirectory) + "\\fallout3_cn.3dm"; | |
+ { | |
+ IFileStream tempFile; | |
+ if(!tempFile.Open(procPath.c_str())) { | |
+ return false; | |
+ } | |
+ } | |
+ LPVOID args = VirtualAllocEx(hprocess, NULL, procPath.size()+1, MEM_COMMIT, PAGE_READWRITE); | |
+ if (NULL == args) { | |
+ return false; | |
+ } | |
+ if (0 == WriteProcessMemory(hprocess, args, (PVOID)procPath.c_str(), procPath.size()+1, NULL)) { | |
+ return false; | |
+ } | |
+ PTHREAD_START_ROUTINE pfn = (PTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA"); | |
+ if (pfn == NULL) { | |
+ return false; | |
+ } | |
+ HANDLE hthread = CreateRemoteThread(hprocess, NULL, 0, pfn, args, 0, NULL); | |
+ if (hthread == NULL) { | |
+ return false; | |
+ } | |
+ Sleep(1000); | |
+ return true; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment