bool gmCodeGenPrivate::GenStmtFor(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode) { GM_ASSERT(a_node->m_type == CTNT_STATEMENT && a_node->m_subType == CTNST_FOR); unsigned int loc1, loc2 = 0, continueAddress; // Initialisers if(!Generate(a_node->m_children[0], a_byteCode)) return false; PushLoop(); loc1 = a_byteCode->Tell(); // Condition expression if(!Generate(a_node->m_children[1], a_byteCode)) { PopLoop(); return false; } if(a_node->m_children[1] != NULL) // no branch for no test. { loc2 = a_byteCode->Skip(SIZEOF_BC_BRA); } // Body if(!Generate(a_node->m_children[3], a_byteCode)) { PopLoop(); return false; } // Continue patch continueAddress = a_byteCode->Tell(); // Loop Expression if(!Generate(a_node->m_children[2], a_byteCode)) { PopLoop(); return false; } a_byteCode->EmitPtr(BC_BRA, loc1); loc1 = a_byteCode->Tell(); if(a_node->m_children[1] != NULL) { a_byteCode->Seek(loc2); a_byteCode->EmitPtr(BC_BRZ, loc1); a_byteCode->Seek(loc1); } ApplyPatches(m_loopStack[m_currentLoop].m_breaks, a_byteCode, loc1); ApplyPatches(m_loopStack[m_currentLoop].m_continues, a_byteCode, continueAddress); PopLoop(); return true; }
bool gmCodeGenPrivate::GenStmtForEach(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode) { unsigned int breakAddress, continueAddress, loc1, loc2; // Generate table if(!Generate(a_node->m_children[0], a_byteCode)) { return false; } PushLoop(); // Push the first iterator a_byteCode->Emit(BC_PUSHINT, (gmuint32) -2); // first iterator value. continueAddress = a_byteCode->Tell(); // Generate call const char * keyVar = s_tempVarName1; if(a_node->m_children[2]) keyVar = a_node->m_children[2]->m_data.m_string; const char * valueVar = a_node->m_children[1]->m_data.m_string; gmuint16 keyOffset = (gmuint16) m_currentFunction->SetVariableType(keyVar, CTVT_LOCAL); gmuint16 valueOffset = (gmuint16) m_currentFunction->SetVariableType(valueVar, CTVT_LOCAL); gmuint32 opcode = (keyOffset << 16) | (valueOffset & 0xffff); loc1 = a_byteCode->Tell(); a_byteCode->Emit(BC_FOREACH, opcode); // Skip space for jump loc2 = a_byteCode->Skip(SIZEOF_BC_BRA); // Generate body if(!Generate(a_node->m_children[3], a_byteCode)) { PopLoop(); return false; } a_byteCode->EmitPtr(BC_BRA, (gmuint32) loc1); breakAddress = a_byteCode->Seek(loc2); a_byteCode->EmitPtr(BC_BRZ, breakAddress); a_byteCode->Seek(breakAddress); // pop table and iterator a_byteCode->Emit(BC_POP2); ApplyPatches(m_loopStack[m_currentLoop].m_breaks, a_byteCode, breakAddress); ApplyPatches(m_loopStack[m_currentLoop].m_continues, a_byteCode, continueAddress); PopLoop(); return true; }
//Generates code.if user_data is non zero , user_data_size bytes are allocated after the executable code //and user_data is set to the first byte of em.Allways 16 byte alligned void* ppc_block::Generate() { if (do_realloc) { u8* final_buffer=0; final_buffer=(u8*)allocfin(ppc_buff,ppc_size,ppc_indx); if (final_buffer==0) return 0; ppc_buff=final_buffer; } ApplyPatches(ppc_buff); memicbi(ppc_buff,ppc_indx); bool force=false; // force=true; // force=(u32)ppc_buff>=0x8054f510; if(do_disasm || force) printf("Gen %p %04x %04x\n",ppc_buff,ppc_size,ppc_indx); if (do_disasm || force) for(u32 i=0;i<ppc_indx;i+=4) disassemble((u32)&ppc_buff[i],*(u32*)&ppc_buff[i]); do_disasm=false; return &ppc_buff[0]; }
void ApplyFramePatches() { ApplyPatches(onFrame); // Run the Gecko code handler Gecko::RunCodeHandler(); }
bool gmCodeGenPrivate::GenStmtWhile(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode) { GM_ASSERT(a_node->m_type == CTNT_STATEMENT && a_node->m_subType == CTNST_WHILE); unsigned int loc1, loc2, continueAddress; PushLoop(); // Continue address loc1 = continueAddress = a_byteCode->Tell(); // Condition expression if(!Generate(a_node->m_children[0], a_byteCode)) { PopLoop(); return false; } loc2 = a_byteCode->Skip(SIZEOF_BC_BRA); // Loop body if(!Generate(a_node->m_children[1], a_byteCode)) { PopLoop(); return false; } a_byteCode->EmitPtr(BC_BRA, loc1); loc1 = a_byteCode->Seek(loc2); a_byteCode->EmitPtr(BC_BRZ, loc1); a_byteCode->Seek(loc1); ApplyPatches(m_loopStack[m_currentLoop].m_breaks, a_byteCode, loc1); ApplyPatches(m_loopStack[m_currentLoop].m_continues, a_byteCode, continueAddress); PopLoop(); return true; }
// Rellocate all pointers to have size elements void RellocArray(size_t size) { // Reallocate the array and relloc the pointers our_array.resize(size); ApplyPatches(); // Move the contents of the previous array to the new array if it's the first time we're rellocating // Not necessary the second time because std::vector handles that for us if(has_relloc == false) { ptrs.ApplyReflection(&our_array[0], default_ptr, sizeof(T), size, default_size); } has_relloc = true; }
//Generates code.if user_data is non zero , user_data_size bytes are allocated after the executable code //and user_data is set to the first byte of em.Allways 16 byte aligned void* x86_block::Generate() { if (do_realloc) { u8* final_buffer=0; final_buffer=(u8*)allocfin(x86_buff,x86_size,x86_indx); if (final_buffer==0) return 0; x86_buff=final_buffer; } ApplyPatches(x86_buff); return &x86_buff[0]; }
bool ApplyFramePatches() { // Because we're using the VI Interrupt to time this instead of patching the game with a // callback hook we can end up catching the game in an exception vector. // We deal with this by returning false so that SystemTimers will reschedule us in a few cycles // where we can try again after the CPU hopefully returns back to the normal instruction flow. if (!MSR.DR || !MSR.IR || !IsStackSane()) { DEBUG_LOG( ACTIONREPLAY, "Need to retry later. CPU configuration is currently incorrect. PC = 0x%08X, MSR = 0x%08X", PC, MSR.Hex); return false; } ApplyPatches(s_on_frame); // Run the Gecko code handler Gecko::RunCodeHandler(); ActionReplay::RunAllActive(); return true; }
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { ExceptionDebuggerThing(); Log::Init(hModule); //DEBUGOUT("m0d-s0beit-v loaded"); if (!GetModuleInformation(GetCurrentProcess(), GetModuleHandle(0), &g_MainModuleInfo, sizeof(g_MainModuleInfo))) { Log::Fatal("Unable to get MODULEINFO from GTA5.exe"); } DEBUGOUT("GTA5 [0x%I64X][0x%X]", g_MainModuleInfo.lpBaseOfDll, g_MainModuleInfo.SizeOfImage); //DisableLegalMessagesCompletely(); //NoIntro(); ApplyPatches(); //Apply patches, disable loading screens, etc this was on before (Memory writes) SpawnScriptHook(); //Hook that. //BypassOnlineModelRequestBlock(); //This allows us to spawn models on the LE XD INTERNET } return TRUE; }
int GitPatch::Init(const CString& patchfile, const CString& targetpath, CSysProgressDlg *pPprogDlg) { CTGitPath target = CTGitPath(targetpath); if (patchfile.IsEmpty() || targetpath.IsEmpty()) { m_errorStr.LoadString(IDS_ERR_PATCHPATHS); return 0; } m_errorStr.Empty(); m_patchfile = patchfile; m_targetpath = targetpath; m_testPath.Empty(); m_patchfile.Replace('\\', '/'); m_targetpath.Replace('\\', '/'); if (pPprogDlg) { pPprogDlg->SetTitle(IDS_APPNAME); pPprogDlg->FormatNonPathLine(1, IDS_PATCH_PROGTITLE); pPprogDlg->SetShowProgressBar(false); pPprogDlg->ShowModeless(AfxGetMainWnd()); m_pProgDlg = pPprogDlg; } m_filePaths.clear(); m_nRejected = 0; m_nStrip = 0; // Read and try to apply patch if (m_patch.OpenUnifiedDiffFile(m_patchfile) == FALSE) { m_errorStr = m_patch.GetErrorMessage(); m_filePaths.clear(); return 0; } if (!ApplyPatches()) { m_filePaths.clear(); return 0; } m_pProgDlg = NULL; if ((m_nRejected > ((int)m_filePaths.size() / 3)) && !m_testPath.IsEmpty()) { ++m_nStrip; bool found = false; for (m_nStrip = 0; m_nStrip < STRIP_LIMIT; ++m_nStrip) { for (const auto& filepath : m_filePaths) { if (Strip(filepath.path).IsEmpty()) { found = true; m_nStrip--; break; } } if (found) break; } } if (m_nStrip == STRIP_LIMIT) m_filePaths.clear(); else if (m_nStrip > 0) { m_filePaths.clear(); m_nRejected = 0; if (!ApplyPatches()) { m_filePaths.clear(); } } return (int)m_filePaths.size(); }
void sPATCHDialog::OnBitmapButton_UpdateClick(wxCommandEvent& event) { if(aVersions.Count()>0 && wxAtoi(cVersion)<wxAtoi(aVersions[aVersions.Count()-1])) { Timer_Progress.Start(); BitmapButton_Close->Enable(false); BitmapButton_Update->Enable(false); BitmapButton_Play->Enable(false); try { //###################################################################### //##### DOWNLOAD PATCHES ############################################### //###################################################################### if(wxDirExists(wxT("PATCHES"))) { wxDeldir(wxT("PATCHES")); } wxMkdir(wxT("PATCHES")); int version = wxAtoi(cVersion); for(int i=0; i<(int)aVersions.Count(); i++) { if(version < wxAtoi(aVersions[i].BeforeFirst(L'='))) { Status = wxT("Downloading (") + aVersions[i].AfterFirst(L'=') + wxT(") ..."); this->Refresh(); wxProcess::Open(wxT("tools\\wget.exe -q -O \"PATCHES\\") + wxString::Format(wxT("%08i"), i) + wxT(".xup\" \"") + PatchServer + aVersions[i].AfterFirst('=') + wxT("\""), wxEXEC_SYNC | wxEXEC_NODISABLE); } } //###################################################################### //##### APPLY UPDATE ################################################### //###################################################################### ApplyPatches(); //###################################################################### //##### FINISHING UPDATE ############################################### //###################################################################### cVersion = aVersions[aVersions.Count()-1].BeforeFirst(L'='); wxTextFile f; f.Open(wxT("version.sw")); f.Clear(); f.AddLine(cVersion); f.Write(wxTextFileType_None); f.Close(); Status = wxT("Update Complete!"); } catch(...) { Status = wxT("Update Failed!"); BitmapButton_Update->Enable(true); } BitmapButton_Close->Enable(true); BitmapButton_Play->Enable(true); Timer_Progress.Stop(); Gauge_Progress->SetValue(100); this->Refresh(); } }
/* Entry point */ extern "C" int Menu_Main(void) { //!******************************************************************* //! Initialize function pointers * //!******************************************************************* //! do OS (for acquire) and sockets first so we got logging InitOSFunctionPointers(); InitSocketFunctionPointers(); log_init(LOADIINE_LOGGER_IP); log_print("Starting Loadiine GX2 " LOADIINE_VERSION "\n"); InitFSFunctionPointers(); InitGX2FunctionPointers(); InitSysFunctionPointers(); InitVPadFunctionPointers(); InitPadScoreFunctionPointers(); InitAXFunctionPointers(); InitCurlFunctionPointers(); InitAocFunctionPointers(); InitACPFunctionPointers(); log_printf("Function exports loaded\n"); //!******************************************************************* //! Initialize our kernel variables * //!******************************************************************* log_printf("Setup kernel variables\n"); SetupKernelCallback(); //!******************************************************************* //! Initialize heap memory * //!******************************************************************* log_print("Initialize memory management\n"); memoryInitialize(); //!******************************************************************* //! Initialize FS * //!******************************************************************* log_printf("Mount SD partition\n"); mount_sd_fat("sd"); //!******************************************************************* //! Read Configs for HID support * //!******************************************************************* if(gConfig_done == HID_INIT_DONE) { log_print("Reading config files from SD Card\n"); ConfigReader::getInstance(); //doing the magic automatically ConfigReader::destroyInstance(); log_print("Done with reading config files from SD Card\n"); gConfig_done = HID_SDCARD_READ; } //!******************************************************************* //! Patch Functions * //!******************************************************************* log_printf("Patch FS and loader functions\n"); ApplyPatches(); PatchSDK(); //!******************************************************************* //! Setup exception handler * //!******************************************************************* log_printf("Setup exception handler\n"); setup_os_exceptions(); //!******************************************************************* //! Enter main application * //!******************************************************************* log_printf("Start main application\n"); Application::instance()->exec(); log_printf("Main application stopped\n"); Application::destroyInstance(); log_printf("Unmount SD\n"); unmount_sd_fat("sd"); log_printf("Release memory\n"); memoryRelease(); log_printf("Loadiine peace out...\n"); //log_deinit(); return 0; }
void ApplyFramePatches() { ApplyPatches(onFrame); }