当前位置: 首页 > article >正文

通过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!
```

2. 创建启动调试脚本 `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!
```

3. 创建 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!
```

4. 创建 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
```

5. 创建完整的 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
```

6. 创建调试命令文件 `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
   ```

2. 启动调试环境:
   ```batch
   call start_vmware_environment.bat
   ```

3. 在 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
   ```


 


http://www.kler.cn/a/394826.html

相关文章:

  • ES6字符串的新增方法
  • Zookeeper的安装与使用
  • Android 10 默认授权安装app运行时权限(去掉运行时所有权限授权弹窗)
  • OCR识别铁路电子客票
  • python: postgreSQL using psycopg2 or psycopg
  • ML 系列: 第 23 节 — 离散概率分布 (多项式分布)
  • 使用etl工具kettle的日常踩坑梳理之一、从mysql中导出数据
  • 【springboot使用sqlite数据库】Java后台同时使用mysql、sqlite
  • 零基础想学习 Web 安全,如何入门?
  • 深入探索 React Hooks:原理、用法与性能优化全解
  • nVisual自定义工单内容
  • 力扣第48题“旋转图像”
  • 计算机网络-2.1物理层
  • C++全局构造和初始化
  • 算法训练(leetcode)二刷第二十五天 | *134. 加油站、*135. 分发糖果、860. 柠檬水找零、*406. 根据身高重建队列
  • 24/11/14 算法笔记 EM算法期望最大化算法
  • CentOS网络配置
  • 利用飞书多维表格自动发布版本
  • Matlab实现麻雀优化算法优化随机森林算法模型 (SSA-RF)(附源码)
  • 【Android、IOS、Flutter、鸿蒙、ReactNative 】标题栏
  • Isaac Sim+SKRL机器人并行强化学习
  • 【Android、IOS、Flutter、鸿蒙、ReactNative 】文本点击事件
  • 【CICD】GitLab Runner 和执行器(Executor
  • 通过PHP创建AWS的CloudFront并绑定证书添加备用域名
  • sql server创建固定的链路服务器
  • kafka:使用flume自定义拦截器,将json文件抽取到kafka的消息队列(topic)中,再从topic中将数据抽取到hdfs上