コード例 #1
0
ファイル: main.cpp プロジェクト: europop/morrgraphext
BOOL IsMorrowind () {
	if (ItsMorrowind) return false;
	BOOL status = false;
	HINSTANCE hInstance = GetModuleHandleA (NULL);

	char *origFilename = new char[MAX_PATH];
	MWVersion = GetModuleNameAndVersion(hInstance, origFilename, MAX_PATH);
	if (!_stricmp (origFilename, "Morrowind.exe")) {
		LOG::open ("mwse-mge log.txt");
		LOG::log (WelcomeMessage);
		LOG::log ("DLL injected\r\n");
		if (!MWVersion) {
			ERRORMSG ("Unable to get Morrowind's version number.");
		}
		ItsMorrowind = status = true;
	}
	if (!PatchDisabled) lpPatchTree = PatchTree::BuildPatchTree();
	if (ItsMorrowind) ForceTextDll(GetModuleHandle(TEXT_DLL_NAME));
	if (strstr(origFilename, ".") == NULL) strcat_s(origFilename, MAX_PATH, ".exe");
	if (!IntegrationDisabled) Integration(hInstance, origFilename, MWVersion, ItsMorrowind);
	if (!PatchDisabled) PatchProcessMemory(hInstance, origFilename, MWVersion, ItsMorrowind);
	delete [] origFilename;

	return status;
}
コード例 #2
0
void PatchModuleMemory(HINSTANCE hModule, LPSTR lpFilename, bool isMorrowind) {
	if(!lpPatchTree || !hModule || !lpFilename) return;
	PatchTree *file = lpPatchTree;
	do {
		if((_stricmp(lpFilename, file->Section)==0)&&(file->Removed?!(*file->Removed):true)&&(file->Checked?(*file->Checked):true)&&file->Child) {
			if(ApplyPatch(file->Child, true, NULL, GetModuleNameAndVersion(hModule,NULL,NULL), isMorrowind, DWORD(hModule)-DEFAULT_INSTANCE_DLL)) {
				if(isMorrowind) _LogLine("Patch has been applied to %s successfully", file->Section);
			}
			break;
		}
	}while(file = file->Next);
	return;
}
コード例 #3
0
void PatchProcessMemory(HINSTANCE hModule, LPSTR origFilename, DWORD dwVersionLS, bool isMorrowind) {
	HINSTANCE hInstance = hModule;//GetModuleHandleA(NULL);
	if(lpPatchTree && hInstance && hModule && origFilename) {} else return;
	PatchTree *file = lpPatchTree;
	do {
		HINSTANCE hModuleInstance = _stricmp(origFilename, file->Section)==0 ? hModule : GetModuleHandleA(file->Section);
		if(hModule == hInstance && (_stricmp(TEXT_DLL_NAME, file->Section)==0 || _stricmp(MWE_DLL_NAME, file->Section)==0)) continue;
		if(hModuleInstance && (file->Removed?!(*file->Removed):true) && (file->Checked?(*file->Checked):true) && file->Child) {
			if(ApplyPatch(file->Child, true, NULL, 
				hModuleInstance == hInstance ? dwVersionLS : GetModuleNameAndVersion(hModuleInstance, NULL, NULL), isMorrowind,
				DWORD(hModuleInstance) - (hModuleInstance == hInstance ? DEFAULT_INSTANCE_EXE : DEFAULT_INSTANCE_DLL ))) {
				if(isMorrowind) _LogLine("Patch has been applied to %s successfully", file->Section);
			}
		}
	}while(file = file->Next);
	return;
}