Example #1
0
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    # register our own event callbacks
    mask = DbgEng.DEBUG_EVENT_BREAKPOINT
    event_callback = MyDebugEventCallbacks(mask)

    # initialize the debugger
    dbgx = PyDbgX(event_cb=event_callback)

    # bind PyDbgX instance to the event callbakcs
    event_callback.bind_pydbgx(dbgx)

    # create target process: notepad.exe
    # note: can not debug x64 executable with 32 bit python
    dbgx.create_process('notepad.exe')

    # active the process so that we can set breakpoints on it
    dbgx.active_process()

    # set a breakpoint on API CreateFileW
    BpId = dbgx.set_software_breakpoint_exp('Kernel32!CreateFileW')

    # set the effective processor to x86 if the target is a x86 application
    dbgx.set_effective_processor('x86')

    # wait for debug event
    dbgx.wait_for_event_ex()