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

通过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.mrgr.cn/news/70823.html

相关文章:

  • 浅谈 proxy
  • 虚拟浏览器可以应对哪些浏览器安全威胁?
  • 第十章综合案例——————轮播广告
  • 2.langchain中的prompt模板 (FewShotPromptTemplate)
  • 如何用AI写小说(二):Gradio 超简单的网页前端交互
  • 【npm设置代理-解决npm网络连接error network失败问题】
  • 前端 call、bind、apply的实际使用
  • GitHub Org
  • 私域流量平台建设方案与运营方案
  • 【JS】不定参数函数
  • 高效视觉方案:AR1335与i.MX8MP的完美结合
  • 抛弃UNet,首个基于DiT的图像编辑框架!DiT4Edit:多尺寸编辑质量更优 | 北大港科大
  • SQL语句执行的基本架构——数据库
  • java + maven + sqlit3 最简单的数据库操作,建表,插入,查询
  • 【快捷入门笔记】mysql基本操作大全-SQL表
  • Ansible常用模块介绍
  • MobaXterm 软件及如何设置取消自动断开连接
  • 高级java每日一道面试题-2024年11月04日-Redis篇-Redis如何做内存优化?
  • C++ | Leetcode C++题解之第560题和为K的子数组
  • Vue功能菜单的异步加载、动态渲染
  • windows C#-默认约定(下)
  • JavaWeb——Web入门(8/9)- Tomcat:基本使用(下载与安装、目录结构介绍、启动与关闭、可能出现的问题及解决方案、总结)
  • Pure Adminrelease(水滴框架配置)
  • python-27-Python ORM系列之彻底搞明白ORM概念,对ORM进行封装结合FastAPI实现数据库的增删改查,联表查询等接口
  • C++学习笔记----11、模块、头文件及各种主题(二)---- 函数模板(2)
  • VirtIO实现原理(2)