通过vmware虚拟机安装和调试编译好的 ReactOS

  1. 首先创建 VMware 虚拟机配置脚本 `setup_vmware.bat`:

```batch

@echo off

:: setup_vmware.bat

:: 设置路径

set "REACTOS_BUILD=E:\Reactos_WinDriver\reactos-master\build"

set "VM_PATH=E:\VMs\ReactOS_Debug"

set "VMWARE_PATH=C:\Program Files (x86)\VMware\VMware Workstation"

:: 创建虚拟机目录

if not exist "%VM_PATH%" mkdir "%VM_PATH%"

:: 创建 VMware 虚拟机配置文件

echo Creating VMware configuration file...

(

echo .encoding = "windows-1252"

echo config.version = "8"

echo virtualHW.version = "16"

echo memsize = "2048"

echo numvcpus = "2"

echo displayName = "ReactOS_Debug"

echo guestOS = "other"

echo serial0.present = "TRUE"

echo serial0.fileType = "pipe"

echo serial0.fileName = "\\.\pipe\ReactOS_Debug"

echo serial0.pipe.endPoint = "server"

echo serial0.tryNoRxLoss = "FALSE"

echo debugStub.listen.guest32 = "TRUE"

echo debugStub.hideBreakpoints = "TRUE"

echo isolation.tools.hgfs.disable = "TRUE"

echo isolation.tools.dnd.disable = "TRUE"

echo isolation.tools.copy.enable = "TRUE"

echo isolation.tools.paste.enable = "TRUE"

echo scsi0.present = "TRUE"

echo scsi0.virtualDev = "lsilogic"

echo scsi0:0.present = "TRUE"

echo scsi0:0.fileName = "ReactOS.vmdk"

echo scsi0:0.deviceType = "scsi-hardDisk"

echo ide1:0.present = "TRUE"

echo ide1:0.fileName = "auto detect"

echo ide1:0.deviceType = "cdrom-raw"

echo ethernet0.present = "TRUE"

echo ethernet0.connectionType = "nat"

echo ethernet0.virtualDev = "e1000"

echo ethernet0.wakeOnPcktRcv = "FALSE"

echo ethernet0.addressType = "generated"

echo sound.present = "TRUE"

echo sound.virtualDev = "hdaudio"

echo pciBridge0.present = "TRUE"

echo pciBridge4.present = "TRUE"

echo pciBridge4.virtualDev = "pcieRootPort"

echo pciBridge4.functions = "8"

echo pciBridge5.present = "TRUE"

echo pciBridge5.virtualDev = "pcieRootPort"

echo pciBridge5.functions = "8"

echo pciBridge6.present = "TRUE"

echo pciBridge6.virtualDev = "pcieRootPort"

echo pciBridge6.functions = "8"

echo pciBridge7.present = "TRUE"

echo pciBridge7.virtualDev = "pcieRootPort"

echo pciBridge7.functions = "8"

) > "%VM_PATH%\ReactOS_Debug.vmx"

:: 创建虚拟硬盘

"%VMWARE_PATH%\vmware-vdiskmanager.exe" -c -s 20GB -t 0 -a lsilogic "%VM_PATH%\ReactOS.vmdk"

echo VMware virtual machine setup completed!

```

  1. 创建启动调试脚本 `start_vmware_debug.bat`:

```batch

@echo off

:: start_vmware_debug.bat

:: 设置路径

set "REACTOS_BUILD=E:\Reactos_WinDriver\reactos-master\build"

set "VM_PATH=E:\VMs\ReactOS_Debug"

set "VMWARE_PATH=C:\Program Files (x86)\VMware\VMware Workstation"

:: 确保调试管道不存在

if exist \\.\pipe\ReactOS_Debug (

echo Cleaning up existing debug pipe...

timeout /t 2 /nobreak > nul

)

:: 启动虚拟机

start "ReactOS VM" "%VMWARE_PATH%\vmware.exe" -x "%VM_PATH%\ReactOS_Debug.vmx"

:: 等待虚拟机启动

timeout /t 5 /nobreak

:: 启动调试器

start "WinDbg" "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\windbg.exe" -k com:pipe,port=\\.\pipe\ReactOS_Debug,resets=0,reconnect

echo Debug environment started!

```

  1. 创建 VMware 工具检查脚本 `check_vmware_tools.bat`:

```batch

@echo off

:: check_vmware_tools.bat

:: 检查 VMware 安装

if not exist "C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe" (

echo VMware Workstation not found!

echo Please install VMware Workstation first.

exit /b 1

)

:: 检查必要工具

where windbg >nul 2>&1

if %ERRORLEVEL% NEQ 0 (

echo WinDbg not found!

echo Please install Windows SDK or WDK.

exit /b 1

)

echo All required tools are available!

```

  1. 创建 VMware 专用的调试环境配置文件 `vmware_debug.conf`:

```ini

VMware Debug Configuration

[Virtual Machine]

Name=ReactOS_Debug

Memory=2048

Processors=2

HDD_Size=20GB

ISO_Path=E:\Reactos_WinDriver\reactos-master\build\bootcd.iso

[Debug]

Pipe_Name=\\.\pipe\ReactOS_Debug

Baud_Rate=115200

Debug_Port=COM1

[Symbols]

Path=E:\Reactos_WinDriver\reactos-master\build\symbols

Source_Path=E:\Reactos_WinDriver\reactos-master

```

  1. 创建完整的 VMware 调试环境启动脚本 `start_vmware_environment.bat`:

```batch

@echo off

:: start_vmware_environment.bat

setlocal enabledelayedexpansion

:: 检查环境

call check_vmware_tools.bat

if %ERRORLEVEL% NEQ 0 goto :error

:: 设置路径

set "REACTOS_BUILD=E:\Reactos_WinDriver\reactos-master\build"

set "VM_PATH=E:\VMs\ReactOS_Debug"

set "ISO_PATH=%REACTOS_BUILD%\bootcd.iso"

:: 检查 ISO 文件

if not exist "%ISO_PATH%" (

echo ReactOS ISO not found at: %ISO_PATH%

goto :error

)

:: 配置虚拟机

if not exist "%VM_PATH%\ReactOS_Debug.vmx" (

echo Setting up new VMware virtual machine...

call setup_vmware.bat

if %ERRORLEVEL% NEQ 0 goto :error

)

:: 更新 CD-ROM 配置

echo Updating CD-ROM configuration...

(

echo ide1:0.fileName = "%ISO_PATH%"

echo ide1:0.present = "TRUE"

echo ide1:0.deviceType = "cdrom-image"

) >> "%VM_PATH%\ReactOS_Debug.vmx"

:: 启动调试环境

call start_vmware_debug.bat

if %ERRORLEVEL% NEQ 0 goto :error

echo VMware debug environment started successfully!

goto :end

:error

echo Failed to start VMware debug environment!

exit /b 1

:end

endlocal

```

  1. 创建调试命令文件 `debug_commands.dbg`:

```

; debug_commands.dbg

; 加载符号

.sympath+ E:\Reactos_WinDriver\reactos-master\build\symbols

.reload

; 设置源码路径

.srcpath+ E:\Reactos_WinDriver\reactos-master

; 常用断点

bp ntoskrnl!KiSystemStartup "g"

bp ntoskrnl!IoInitSystem "g"

; 显示调试信息

!vm

!process 0 0

!drvobj

; 继续执行

g

```

使用说明:

  1. 准备工作:

```batch

:: 检查环境

call check_vmware_tools.bat

:: 设置虚拟机

call setup_vmware.bat

```

  1. 启动调试环境:

```batch

call start_vmware_environment.bat

```

  1. 在 WinDbg 中:

```

; 加载调试命令

\>a\< debug_commands.dbg \`\`\` 4. 调试提示: - 使用 \`Ctrl+Break\` 中断执行 - 使用 \`g\` 继续执行 - 使用 \`bp module!function\` 设置断点 - 使用 \`bl\` 查看所有断点 - 使用 \`k\` 查看调用栈 - 使用 \`!analyze -v\` 分析崩溃 5. 驱动调试: \`\`\` ; 在 ReactOS 中 load driver.sys ; 在 WinDbg 中 bp driver!DriverEntry g \`\`\`

相关推荐
vortex516 分钟前
解决 VSCode 中 C/C++ 编码乱码问题的两种方法
c语言·c++·vscode
醉颜凉2 小时前
【NOIP提高组】潜伏者
java·c语言·开发语言·c++·算法
hunandede2 小时前
FFmpeg 4.3 音视频-多路H265监控录放C++开发十三.2:avpacket中包含多个 NALU如何解析头部分析
c++·ffmpeg·音视频
tumu_C4 小时前
C++模板特化实战:在使用开源库boost::geometry::index::rtree时,用特化来让其支持自己的数据类型
c++·开源
杜若南星4 小时前
保研考研机试攻略(满分篇):第二章——满分之路上(1)
数据结构·c++·经验分享·笔记·考研·算法·贪心算法
Neophyte06084 小时前
C++算法练习-day40——617.合并二叉树
开发语言·c++·算法
云空4 小时前
《InsCode AI IDE:编程新时代的引领者》
java·javascript·c++·ide·人工智能·python·php
写bug的小屁孩4 小时前
websocket初始化
服务器·开发语言·网络·c++·websocket·网络协议·qt creator
湖南罗泽南5 小时前
Windows C++ TCP/IP 两台电脑上互相传输字符串数据
c++·windows·tcp/ip