Files
dolphin/Tools/Dump-Process-Memory.ps1
T
Yaya48 a77c156bc8 IOS: add Starlet LLE milestone through HBC
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.
2026-08-25 17:11:49 +02:00

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)
}