All pastes #98667 Raw Edit

Mine

public text v1 · immutable
#98667 ·published 2006-07-24 18:32 UTC
rendered paste body
//create a stub which emulates the first instruction then jumps passed it so we can avoid
//the breakpoint
byte __cdecl *CreateBreakpointStub( byte *address, uint instruction_size ) {
    byte *pstub = VirtualAlloc( 0, instruction_size+5, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );

    //copy the original instruction
    memcpy( pstub, address, instruction_size );
   
    *(byte  *)( pstub+instruction_size   ) = 0xE9;
    *(dword *)( pstub+instruction_size+1 ) = ( ( address-pstub )-5 );

    return pstub;
}
//---