MCPcopy Create free account
hub / github.com/beefytech/Beef / PhysSetBreakpoint

Method PhysSetBreakpoint

IDEHelper/WinDebugger.cpp:687–718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

685}
686
687void WinDebugger::PhysSetBreakpoint(addr_target address)
688{
689 BfLogDbg("PhysSetBreakpoint %p\n", address);
690
691 uint8 newData = 0xCC;
692
693 // This ensure that we have the orig image data cached
694 DbgMemoryFlags flags = mDebugTarget->ReadOrigImageData(address, NULL, 1);
695 if ((flags & DbgMemoryFlags_Execute) == 0)
696 {
697 BfLogDbg("Breakpoint ignored - execute flag NOT set in breakpoint address\n", address);
698
699 BfLogDbg("Memory Flags = %d\n", gDebugger->GetMemoryFlags(address));
700
701 return;
702 }
703
704 // Replace it with Breakpoint
705 SIZE_T dwReadBytes;
706 BOOL worked = ::WriteProcessMemory(mProcessInfo.hProcess, (void*)(intptr)address, &newData, 1, &dwReadBytes);
707 if (!worked)
708 {
709 int err = GetLastError();
710 BfLogDbg("SetBreakpoint FAILED %p\n", address);
711 }
712 FlushInstructionCache(mProcessInfo.hProcess, (void*)(intptr)address, 1);
713
714 {
715 uint8 mem = ReadMemory<uint8>(address);
716 BfLogDbg("Breakpoint byte %X\n", mem);
717 }
718}
719
720void WinDebugger::SetBreakpoint(addr_target address, bool fromRehup)
721{

Callers 1

HotReplaceMethodsMethod · 0.80

Calls 2

ReadOrigImageDataMethod · 0.80
GetMemoryFlagsMethod · 0.45

Tested by

no test coverage detected