bool EnforceFilter( bool bEnforce ) { DWORD ErrCode = 0; // Obtain the address of SetUnhandledExceptionFilter HMODULE hLib = GetModuleHandle( _T("kernel32.dll") ); if( hLib == NULL ) { ErrCode = GetLastError(); _ASSERTE( !_T("GetModuleHandle(kernel32.dll) failed.") ); return false; } BYTE* pTarget = (BYTE*)GetProcAddress( hLib, "SetUnhandledExceptionFilter" ); if( pTarget == 0 ) { ErrCode = GetLastError(); _ASSERTE( !_T("GetProcAddress(SetUnhandledExceptionFilter) failed.") ); return false; } if( IsBadReadPtr( pTarget, sizeof(OriginalBytes) ) ) { _ASSERTE( !_T("Target is unreadable.") ); return false; } if( bEnforce ) { // Save the original contents of SetUnhandledExceptionFilter memcpy( OriginalBytes, pTarget, sizeof(OriginalBytes) ); // Patch SetUnhandledExceptionFilter if( !WriteMemory( pTarget, PatchBytes, sizeof(PatchBytes) ) ) return false; } else { // Restore the original behavior of SetUnhandledExceptionFilter if( !WriteMemory( pTarget, OriginalBytes, sizeof(OriginalBytes) ) ) return false; } // Success return true; }
void NoDamageText(bool toggle) { if (toggle) { WriteMemory(NoDamageText_Addy, 7, 0xC2, 0x58, 0x00, 0x90, 0x90, 0x90, 0x90); } else { WriteMemory(NoDamageText_Addy, 7, 0x6A, 0xFF, 0x68, 0x08, 0x95, 0x68, 0x01); } }
// CPU Hacks void NoBackground(bool toggle) { if (toggle) { WriteMemory(NoBackground_Addy, 5, 0x90, 0x90, 0x90, 0x90, 0x90); } else { WriteMemory(NoBackground_Addy, 5, 0x8B, 0x75, 0x04, 0x3B, 0xF7); } }
// Char Hacks void StanceHack(bool toggle) { if (toggle) { WriteMemory(StanceHack_Addy, 1, 0x00); } else { WriteMemory(StanceHack_Addy, 1, 0x01); } }
VOID SetDepthLookaside ( IN ULONG Address, IN PUCHAR Name, IN ULONG Depth ) /*++ Routine Description: Set the depth of a specific lookaside list. Arguments: Address - Gives the address of the lookaside list to reset Name - Gives an optional name of to print in case of errors Depth - Supplies the depth to set the lookaside list to Return Value: None --*/ { NPAGED_LOOKASIDE_LIST Lookaside; ULONG Results; // // Read the lookaside list from memory // if (!ReadMemory( (ULONG)Address, &Lookaside, sizeof(NPAGED_LOOKASIDE_LIST), &Results ) || (Results < sizeof(NPAGED_LOOKASIDE_LIST))) { dprintf("Can't read lookaside \"%s\" at 0x%08lx\n", Name, Address); } // // Set the depth // Lookaside.L.Depth = (USHORT)Depth; // // Write it back out // if (!WriteMemory( (ULONG)Address, &Lookaside, sizeof(NPAGED_LOOKASIDE_LIST), &Results ) || (Results < sizeof(NPAGED_LOOKASIDE_LIST))) { dprintf("Can't write lookaside \"%s\" at 0x%08lx\n", Name, Address); } return; }
void FifoPlayer::WriteFramePart(u32 dataStart, u32 dataEnd, u32 &nextMemUpdate, const FifoFrameInfo &frame, const AnalyzedFrameInfo &info) { u8 *data = frame.fifoData; while (nextMemUpdate < frame.memoryUpdates.size() && dataStart < dataEnd) { const MemoryUpdate &memUpdate = info.memoryUpdates[nextMemUpdate]; if (memUpdate.fifoPosition < dataEnd) { if (dataStart < memUpdate.fifoPosition) { WriteFifo(data, dataStart, memUpdate.fifoPosition); dataStart = memUpdate.fifoPosition; } WriteMemory(memUpdate); ++nextMemUpdate; } else { WriteFifo(data, dataStart, dataEnd); dataStart = dataEnd; } } if (dataStart < dataEnd) WriteFifo(data, dataStart, dataEnd); }
DWORD TraceBpHandler( PPROCESS_INFO ThisProcess, PTHREAD_INFO ThisThread, PEXCEPTION_RECORD ExceptionRecord, PBREAKPOINT_INFO BreakpointInfo ) { CONTEXT Context; #ifdef _M_IX86 if (BreakpointInfo->Flags & BPF_TRACE) { CurrContext.EFlags &= ~0x100; SetRegContext( ThisThread->hThread, &CurrContext ); } #endif if (BreakpointInfo->LastBp) { WriteMemory( ThisProcess->hProcess, (PVOID) BreakpointInfo->LastBp->Address, &BpInstr, BpSize ); BreakpointInfo->LastBp = NULL; } // // clear the trace breakpoint // ClearBreakpoint( ThisProcess, BreakpointInfo ); // // print the registers // if (PrintRegistersFlag) { PrintRegisters(); } // // print the code // PrintOneInstruction( ThisProcess->hProcess, (ULONG)ExceptionRecord->ExceptionAddress ); // // enter the debugger // ULONG ContinueStatus = ConsoleDebugger( ThisThread->hProcess, ThisThread->hThread, ExceptionRecord, FALSE, BreakpointInfo->Command ); // // continue the debuggee // return ContinueStatus; }
int RedirectFunc(const char *name1, T* name2) { map <string, void *> :: iterator it = IATAddress.find(name1); if (it == IATAddress.end()) return 0; int org = *(int *)IATAddress[name1]; WriteMemory(it->second, &name2, sizeof(name2)); return org; }
DWORD SetRange(const LPVOID dwAddress, const USHORT wCount, const BYTE btValue) { BYTE * lpBuf = new BYTE[wCount]; // ---- memset(lpBuf, btValue, wCount); // ---- return WriteMemory( dwAddress, (LPVOID) lpBuf, wCount); }
void CAttributeItem::SetSelect(const int index) { m_lstCandidata.SetSelect(index); // 写入内存中 WriteMemory(); m_bChanged = true; }
DWORD SetOp(const LPVOID dwEnterFunction, const LPVOID dwJMPAddress, const BYTE cmd) { BYTE btBuf[5]; DWORD dwShift = (ULONG_PTR)dwJMPAddress - (ULONG_PTR)dwEnterFunction - 5; // ---- btBuf[0] = cmd; memcpy( (LPVOID) & btBuf[1], (LPVOID) & dwShift, sizeof(ULONG_PTR)); // ---- return WriteMemory(dwEnterFunction, (LPVOID) btBuf, sizeof(btBuf)); }
bool restore_cpp_handler() { if(!saved_handler_instructions) return false; else { void *loc = __CxxFrameHandler; return WriteMemory(loc, cpp_handler_instructions, sizeof(cpp_handler_instructions)); } }
trap_retval ReqWrite_mem( void ) { write_mem_req *acc; write_mem_ret *ret; _DBG1(( "WriteMem" )); acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); ret->len = WriteMemory( &acc->mem_addr, GetInPtr( sizeof(*acc) ), GetTotalSize() - sizeof(*acc) ); return( sizeof( *ret ) ); }
DWORD SetJa(const LPVOID dwEnterFunction, const LPVOID dwJMPAddress) { BYTE btBuf[6]; DWORD dwShift = (ULONG_PTR)dwJMPAddress - (ULONG_PTR)dwEnterFunction - 6; // ---- btBuf[0] = 0x0F; btBuf[1] = 0x87; memcpy( (LPVOID) & btBuf[2], (LPVOID) & dwShift, sizeof(ULONG_PTR)); // ---- return WriteMemory(dwEnterFunction, (LPVOID) btBuf, sizeof(btBuf)); }
unsigned ReqWrite_mem( void ) /***************************/ { write_mem_req *acc; write_mem_ret *ret; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); ret->len = WriteMemory( &acc->mem_addr, GetInPtr( sizeof( *acc ) ), GetTotalSize() - sizeof( *acc ) ); return( sizeof( *ret ) ); }
trap_retval ReqClear_break( void ) { clear_break_req *acc; opcode_type brk_opcode; acc = GetInPtr( 0 ); brk_opcode = acc->old; WriteMemory( &acc->break_addr, &brk_opcode, sizeof( brk_opcode ) ); _DBG1(( "AccRestoreBreak" )); return( 0 ); }
void CFPSOverrider::OnBnClickedcmdsetfps() { // When cmdsetfps is clicked do this: CWnd* txtsetfps = GetDlgItem(txtSetFPS); txtsetfps->GetWindowText(strFPSValue); //Get value from the text file intFPSValue = atoi(strFPSValue); //Convert Value from String to Int FPSValue = CheckFPSRange(intFPSValue); //Check if its between 30 and 120 if(FPSValue != 0){ WriteMemory( "SWGANH.exe" ); //Write memory to .exe } }
void CChildView::OnButtonZero() { CMemory mem; for (UINT i = 0; i < Selected.size(); i++) { DWORD s = Selected[i].object->GetMemorySize(); DWORD_PTR a = Selected[i].Address; mem.SetSize(s); ZeroMemory(mem.pMemory, s); WriteMemory((LPVOID)a, mem.pMemory, s); } }
DWORD SetHook(const LPVOID dwMyFuncOffset, const LPVOID dwJmpOffset, const BYTE cmd) { BYTE btBuf[5]; // ---- DWORD dwShift = (ULONG_PTR)dwMyFuncOffset - ( (ULONG_PTR)dwJmpOffset + 5 ); // ---- btBuf[0] = cmd; // ---- memcpy( (LPVOID) & btBuf[1], (LPVOID) & dwShift, sizeof(ULONG_PTR)); // ---- return WriteMemory(dwJmpOffset, (LPVOID) btBuf, sizeof(btBuf)); }
unsigned ReqClear_break( void ) /*****************************/ { byte ch; clear_break_req *acc; _DBG( "AccClearBreak\r\n" ); acc = GetInPtr( 0 ); ch = acc->old; WriteMemory( &acc->break_addr, &ch, 1 ); return( 0 ); }
int r2k__write(RIO *io, RIODesc *fd, const ut8 *buf, int count) { #if __WINDOWS__ //eprintf("writing to: 0x%"PFMT64x" len: %x\n",io->off, count); return WriteKernelMemory (io->off, buf, count); #elif defined (__linux__) && !defined (__GNU__) switch (r2k_struct.beid) { case 0: return WriteMemory (io, fd, IOCTL_WRITE_KERNEL_MEMORY, r2k_struct.pid, io->off, buf, count); case 1: return WriteMemory (io, fd, IOCTL_WRITE_PROCESS_ADDR, r2k_struct.pid, io->off, buf, count); case 2: return WriteMemory (io, fd, IOCTL_WRITE_PHYSICAL_ADDR, r2k_struct.pid, io->off, buf, count); default: io->cb_printf ("ERROR: Undefined beid in r2k__write.\n"); return -1; } #else io->cb_printf ("TODO: r2k not implemented for this plataform.\n"); return -1; #endif }
trap_retval ReqClear_break( void ) /*****************************/ { opcode_type brk_opcode; clear_break_req *acc; _DBG( "AccClearBreak\r\n" ); acc = GetInPtr( 0 ); brk_opcode = acc->old; WriteMemory( &acc->break_addr, &brk_opcode, sizeof( brk_opcode ) ); return( 0 ); }
void FifoPlayer::WriteAllMemoryUpdates() { _assert_(m_File); for (int frameNum = 0; frameNum < m_File->GetFrameCount(); ++frameNum) { const FifoFrameInfo &frame = m_File->GetFrame(frameNum); for (unsigned int i = 0; i < frame.memoryUpdates.size(); ++i) { WriteMemory(frame.memoryUpdates[i]); } } }
void FifoPlayer::WriteAllMemoryUpdates() { _assert_(m_File); for (u32 frameNum = 0; frameNum < m_File->GetFrameCount(); ++frameNum) { const FifoFrameInfo &frame = m_File->GetFrame(frameNum); for (auto& update : frame.memoryUpdates) { WriteMemory(update); } } }
unsigned ReqWrite_mem() { write_mem_req *acc; write_mem_ret *ret; _DBG1(( "WriteMem\n" )); acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); ret->len = WriteMemory( (addr48_ptr *)&acc->mem_addr, GetInPtr( sizeof(*acc) ), GetTotalSize() - sizeof(*acc) ); return( sizeof( *ret ) ); }
void DllHook::UpdateThunk(IMAGE_THUNK_DATA*pThunk,bool bInstall) const { if (hModule) { const dword_map& mpLookup = (bInstall?mpModuleToRedirect:mpRedirectToModule); while (pThunk->u1.Function) { dword_map::const_iterator it = mpLookup.find(pThunk->u1.Function); if (it != mpLookup.end()) WriteMemory(&(pThunk->u1.Function),it->second); ++pThunk; } } }
unsigned ReqSet_break( void ) /***************************/ { byte ch; set_break_req *acc; set_break_ret *ret; _DBG( "AccSetBreak\r\n" ); acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); ReadMemory( &acc->break_addr, &ch, 1 ); ret->old = ch; ch = 0xCC; WriteMemory( &acc->break_addr, &ch, 1 ); return( sizeof( *ret ) ); }
void CChildView::OnButtonSwap() { CMemory mem; for (UINT i = 0; i < Selected.size(); i++) { DWORD s = Selected[i].object->GetMemorySize(); DWORD_PTR a = Selected[i].Address; mem.SetSize(s); ReadMemory((LPVOID)a, mem.pMemory, s); std::reverse(mem.pMemory, mem.pMemory + s); WriteMemory((LPVOID)a, mem.pMemory, s); } }
trap_retval ReqSet_break( void ) /******************************/ { opcode_type brk_opcode; set_break_req *acc; set_break_ret *ret; _DBG( "AccSetBreak\r\n" ); acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); ReadMemory( &acc->break_addr, &brk_opcode, sizeof( brk_opcode ) ); ret->old = brk_opcode; brk_opcode = BRKPOINT; WriteMemory( &acc->break_addr, &brk_opcode, sizeof( brk_opcode ) ); return( sizeof( *ret ) ); }
void CChildView::OnButtonRandom() { CMemory mem; srand(GetTickCount()); for (UINT i = 0; i < Selected.size(); i++) { DWORD s = Selected[i].object->GetMemorySize(); DWORD_PTR a = Selected[i].Address; mem.SetSize(s); for (UINT r = 0; r < s; r++) mem.pMemory[r] = rand(); WriteMemory((LPVOID)a, mem.pMemory, s); } }