ARchive old spec

This commit is contained in:
kbe
2026-07-21 22:30:10 +02:00
parent 0380705e76
commit 184dec86ca
17 changed files with 550 additions and 191 deletions
+4 -19
View File
@@ -42,7 +42,8 @@ public sealed class ExternalReader : MemoryBase
}
// Process.MainModule throws Win32Exception for a bitness-mismatched or protected
// target; a missing image base must not sink the whole reader.
// target. A missing image base must not sink the whole reader — callers can still
// use absolute addresses when ImageBase is unknown.
try
{
_imageBase = process.MainModule?.BaseAddress ?? IntPtr.Zero;
@@ -65,18 +66,7 @@ public sealed class ExternalReader : MemoryBase
if (isRelative)
address = GetAbsolute(address);
byte[] buffer = new byte[count];
if (!NativeMethods.ReadProcessMemory(_handle, address, buffer, count, out nint bytesRead))
{
return [];
}
if ((int)bytesRead != count)
{
Array.Resize(ref buffer, (int)bytesRead);
}
return buffer;
return RpmHelper.ReadBytes(_handle, address, count);
}
/// <inheritdoc />
@@ -85,12 +75,7 @@ public sealed class ExternalReader : MemoryBase
if (isRelative)
address = GetAbsolute(address);
if (!NativeMethods.WriteProcessMemory(_handle, address, bytes, bytes.Length, out nint written))
{
return 0;
}
return (int)written;
return RpmHelper.WriteBytes(_handle, address, bytes);
}
/// <inheritdoc />