ReactOS Development Notes

ReactOS Development Notes

禁止使用clean 整个编译目录,只能针对某个局部目录。

VM Name

实际 VM 名称是 ReactOS-Test-New(不是 ReactOS-Test)。

Build & Run VM (CDROM)

1. Build bootcd

powershell 复制代码
cd d:\reactos\output-MinGW-i386
ninja -j 20 bootcd

2. Power off VM if running

powershell 复制代码
& "E:\VirtualBox\VBoxManage.exe" controlvm "ReactOS-Test-New" poweroff

3. Detach old CDROM ISO

powershell 复制代码
& "E:\VirtualBox\VBoxManage.exe" storageattach "ReactOS-Test-New" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium none

4. Attach new bootcd.iso

powershell 复制代码
& "E:\VirtualBox\VBoxManage.exe" storageattach "ReactOS-Test-New" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium "D:\reactos\output-MinGW-i386\bootcd.iso"

5. Delete old serial log

powershell 复制代码
Remove-Item "D:\reactos\output-MinGW-i386\serial_output.log" -ErrorAction SilentlyContinue

6. Start VM (headless)

powershell 复制代码
& "E:\VirtualBox\VBoxManage.exe" startvm "ReactOS-Test-New" --type headless

7. Check serial output (after ~15s)

powershell 复制代码
Get-Content "D:\reactos\output-MinGW-i386\serial_output.log" -Tail 30

VDI 修改工作流(经验证)

修改 VDI(添加/替换文件)的标准流程。

准备工作:mount/detach 脚本

mount_vhd.txtD:\reactos\output-MinGW-i386\mount_vhd.txt):

复制代码
select vdisk file="D:\reactos\output-MinGW-i386\temp_deploy.vhd"
attach vdisk
select partition 1
assign letter=V
exit

detach_vhd.txtD:\reactos\output-MinGW-i386\detach_vhd.txt):

复制代码
select vdisk file="D:\reactos\output-MinGW-i386\temp_deploy.vhd"
detach vdisk
exit

完整操作步骤

powershell 复制代码
# 0. 先关闭 VM
& "E:\VirtualBox\VBoxManage.exe" controlvm "ReactOS-Test-New" poweroff 2>$null

# 1. 清理 VirtualBox 中所有过期的介质注册(关键!否则后续 clonehd 会失败)
& "E:\VirtualBox\VBoxManage.exe" list hdds | Select-String "UUID:" | ForEach-Object {
    $uuid = $_.ToString().Trim().Replace("UUID:","").Trim()
    & "E:\VirtualBox\VBoxManage.exe" closemedium disk $uuid 2>$null
}

# 2. 克隆 VDI → VHD
& "E:\VirtualBox\VBoxManage.exe" clonehd "D:\reactos\output-MinGW-i386\ReactOS-Test.vdi" "D:\reactos\output-MinGW-i386\temp_deploy.vhd" --format VHD

# 3. 挂载 VHD 为 V: 盘
diskpart /s D:\reactos\output-MinGW-i386\mount_vhd.txt

# 4. 拷贝文件(必须用 [System.IO.File]::Copy,不能用 Copy-Item)
#    因为 V: 盘不在 PowerShell 安全策略允许路径中
[System.IO.File]::Copy("D:\reactos\output-MinGW-i386\dll\win32\kernel32\kernel32.dll", "V:\ReactOS\system32\kernel32.dll", $true)
[System.IO.File]::Copy("D:\reactos\output-MinGW-i386\dll\win32\kernel32\kernel32_vista\kernel32_vista.dll", "V:\ReactOS\system32\kernel32_vista.dll", $true)
[System.IO.File]::Copy("D:\reactos\output-MinGW-i386\109.0.5414.120_chrome_installer.exe", "V:\109.0.5414.120_chrome_installer.exe", $true)

# 5. 卸载 VHD
diskpart /s D:\reactos\output-MinGW-i386\detach_vhd.txt

# 6. 清理旧 VDI 注册和文件
& "E:\VirtualBox\VBoxManage.exe" closemedium disk "D:\reactos\output-MinGW-i386\ReactOS-Test.vdi" 2>$null
Remove-Item "D:\reactos\output-MinGW-i386\ReactOS-Test.vdi" -Force

# 7. VHD → VDI
& "E:\VirtualBox\VBoxManage.exe" clonehd "D:\reactos\output-MinGW-i386\temp_deploy.vhd" "D:\reactos\output-MinGW-i386\ReactOS-Test.vdi" --format VDI

# 8. 附加到 VM
& "E:\VirtualBox\VBoxManage.exe" storageattach "ReactOS-Test-New" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium "D:\reactos\output-MinGW-i386\ReactOS-Test.vdi"

# 9. 清理临时 VHD 和旧日志
Remove-Item "D:\reactos\output-MinGW-i386\temp_deploy.vhd" -Force -ErrorAction SilentlyContinue
Remove-Item "D:\reactos\output-MinGW-i386\serial_output.log" -ErrorAction SilentlyContinue

# 10. 启动 VM(GUI 模式不加 --type,headless 模式加 --type headless)
& "E:\VirtualBox\VBoxManage.exe" startvm "ReactOS-Test-New"

注意事项

  • VBoxManage.exe 路径:E:\VirtualBox\VBoxManage.exe
  • 每次 clonehd 到已存在的路径时,必须先清理 VirtualBox 注册表中同路径的旧记录,否则会报 E_INVALIDARG
  • closemedium 如果失败(提示 still attached),先 storageattach ... --medium none 分离
  • V: 盘的文件操作必须用 [System.IO.File]::Copy(),不能用 Copy-Itemcmd /c copy

kernel32 添加新 API 的模式

ReactOS 中 Vista+ API 的实现模式(以 SetFileInformationByHandle 为例):

  1. 实现文件 :放在 dll/win32/kernel32/kernel32_vista/ 目录下
  2. CMakeLists.txt :在 dll/win32/kernel32/kernel32_vista/CMakeLists.txtSOURCE 列表中添加
  3. kernel32_vista.spec :在 dll/win32/kernel32/kernel32_vista/kernel32_vista.spec 中添加导出,函数会同时出现在 kernel32_vista.dllkernel32.dll(通过静态链接)
  4. kernel32.spec :在 dll/win32/kernel32/kernel32.spec 中添加转发 @ stdcall FunctionName(params) kernel32_vista.FunctionName
  5. 不能直接转发到 kernelbase :该版本的 ReactOS 没有 kernelbase.dll

WRK Reference

D:\work\Windows-Research-Kernel-WRK

相关推荐
爱学习的大牛1232 年前
通过VirtualBox虚拟机安装和调试编译好的 ReactOS
reactos·windows内核学习
zhyjhacker2 年前
ReactOS 4.2 OBJECT_TYPE_INITIALIZERj结构体的实现
c++·windows·reactos
zhyjhacker2 年前
3.1.1ReactOS系统中搜索给定长度的空间地址区间函数的实现
linux·c++·嵌入式硬件·reactos
zhyjhacker2 年前
memset()函数的实现
c++·windows·内核·reactos
zhyjhacker2 年前
3.1.1 ReactOS系统中二叉树创建一个MEMORY_AREA节点
java·前端·c++·windows·算法·内核·reactos
zhyjhacker2 年前
2.6.ReactOS系统中从内核中发起系统调用
c++·windows·算法·内核·reactos
zhyjhacker2 年前
2.4.ReactOS系统提升IRQL级别KfRaiseIrql 函数
c++·windows·reactos
zhyjhacker2 年前
1.3.ReactOS系统 PAGED_CODE 宏函数的实现
c++·windows·reactos
zhyjhacker2 年前
2.1.ReactOS系统NtReadFile函数的实现。
c++·windows·reactos·ntreadfile