NoteZ icon indicating copy to clipboard operation
NoteZ copied to clipboard

How to use Bochs Debug MBR

Open jmpews opened this issue 7 years ago • 0 comments

Prologue

记录在使用 Bochs 调试的心得

建议安装 cmder, 避免复杂安装 dd 等.

References

http://bochs.sourceforge.net/
http://thestarman.pcministry.com/asm/bochs/bochsdbg.html
http://bochs.sourceforge.net/doc/docbook/user/index.html
https://www.hex-rays.com/products/ida/support/tutorials/debugging_bochs.pdf

Smnoliquy

需要先 bximage.exe 创建一个 img.

image

创建一个 bochs 的配置文件, 样例文件可以参考, 安装目录下的 bochsrc-sample.txt 或者 dlxlinux demo 下的配置文件.

template demo 的配置文件如下, 这里按理说应该配置 $BXSHARE 会更好一些. 注意: 如果使用 IDA 的 Bochs Debugger 请不要设置 display_library.

#
# template.bxrc
#

# how much memory the emulated machine will have
megs: 32

# filename of ROM images
romimage: file=D:\TechnicalProgramFiles\Bochs-2.6.9\BIOS-bochs-latest
vgaromimage: file=D:\TechnicalProgramFiles\Bochs-2.6.9\VGABIOS-lgpl-latest

# hard disk
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, path="c.img", mode=flat

# choose the boot disk.
boot: disk

#display_library: x
# other choices: win32 sdl wx carbon amigaos beos macintosh nogui rfb term svga
# display_library: win32, options="gui_debug"

# where do we send log messages?
log: bochsout.txt

# disable the mouse, since DLX is text only
mouse: enabled=0

# enable key mapping, using US layout as default.
keyboard: type=mf, serial_delay=200, paste_delay=100000
keyboard: keymap=D:\TechnicalProgramFiles\Bochs-2.6.9\keymaps\x11-pc-us.map
keyboard: user_shortcut=ctrl-alt-del

如果需要使用 IDA 调试直接在 Debugger 选择 Bochs, 之后执行 Application 为 template.bxrc, IDA 会自动识别.

Mac 下 Bochs 的配置

brew install sdl

./configure --enable-ne2000 \
--enable-all-optimizations \
--enable-cpu-level=6 \
--enable-x86_64 \
--enable-vmx=2 \
--enable-pci \
--enable-usb \
--enable-usb-ohci \
--enable-e1000 \
--enable-debugger \
--enable-disasm \
--disable-debugger-gui \
--with-sdl \
--prefix=$HOME/opt/bochs

jmpews avatar Jan 13 '18 16:01 jmpews