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.txt(D:\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.txt(D:\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-Item或cmd /c copy
kernel32 添加新 API 的模式
ReactOS 中 Vista+ API 的实现模式(以 SetFileInformationByHandle 为例):
- 实现文件 :放在
dll/win32/kernel32/kernel32_vista/目录下 - CMakeLists.txt :在
dll/win32/kernel32/kernel32_vista/CMakeLists.txt的SOURCE列表中添加 - kernel32_vista.spec :在
dll/win32/kernel32/kernel32_vista/kernel32_vista.spec中添加导出,函数会同时出现在kernel32_vista.dll和kernel32.dll(通过静态链接) - kernel32.spec :在
dll/win32/kernel32/kernel32.spec中添加转发@ stdcall FunctionName(params) kernel32_vista.FunctionName - 不能直接转发到
kernelbase:该版本的 ReactOS 没有kernelbase.dll
WRK Reference
D:\work\Windows-Research-Kernel-WRK