Skip to content

Instantly share code, notes, and snippets.

@valda
Created January 26, 2009 17:56
Show Gist options
  • Save valda/52887 to your computer and use it in GitHub Desktop.
Save valda/52887 to your computer and use it in GitHub Desktop.
fose中華exe対応patch
--- 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