Boot original Wii firmware through boot0, boot1, boot2 and IOS on an emulated ARM Starlet. Model the required IPC, memory, SD, USB and Bluetooth hardware behavior, including IOS reload into IOS58, and add focused tests, launch utilities and architecture documentation.
46 lines
1.6 KiB
PowerShell
46 lines
1.6 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)] [int] $ProcessId,
|
|
[Parameter(Mandatory = $true)] [UInt64] $Address,
|
|
[Parameter(Mandatory = $true)] [int] $Length,
|
|
[Parameter(Mandatory = $true)] [string] $OutputPath
|
|
)
|
|
|
|
Add-Type -TypeDefinition @'
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
public static class ProcessMemoryDumpNative
|
|
{
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
public static extern IntPtr OpenProcess(uint access, bool inheritHandle, int processId);
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
public static extern bool ReadProcessMemory(IntPtr process, UIntPtr address, byte[] buffer,
|
|
UIntPtr size, out UIntPtr bytesRead);
|
|
|
|
[DllImport("kernel32.dll")]
|
|
public static extern bool CloseHandle(IntPtr handle);
|
|
}
|
|
'@
|
|
|
|
$handle = [ProcessMemoryDumpNative]::OpenProcess(0x410, $false, $ProcessId)
|
|
if ($handle -eq [IntPtr]::Zero) {
|
|
throw "OpenProcess failed: $([Runtime.InteropServices.Marshal]::GetLastWin32Error())"
|
|
}
|
|
|
|
try {
|
|
$buffer = [byte[]]::new($Length)
|
|
$bytesRead = [UIntPtr]::Zero
|
|
if (-not [ProcessMemoryDumpNative]::ReadProcessMemory(
|
|
$handle, [UIntPtr]::new($Address), $buffer, [UIntPtr]::new([UInt64]$Length), [ref]$bytesRead)) {
|
|
throw "ReadProcessMemory failed: $([Runtime.InteropServices.Marshal]::GetLastWin32Error())"
|
|
}
|
|
if ($bytesRead.ToUInt64() -ne [UInt64]$Length) {
|
|
throw "Short read: requested $Length bytes, got $($bytesRead.ToUInt64())"
|
|
}
|
|
[IO.File]::WriteAllBytes((Join-Path (Get-Location) $OutputPath), $buffer)
|
|
}
|
|
finally {
|
|
[void][ProcessMemoryDumpNative]::CloseHandle($handle)
|
|
}
|