mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
throw around some unchecked because warnings
This commit is contained in:
parent
e0585a2feb
commit
2542ec7bcd
1 changed files with 20 additions and 14 deletions
|
|
@ -583,15 +583,18 @@ public static unsafe class MemoryHelper
|
||||||
/// <param name="value">The read in bytes.</param>
|
/// <param name="value">The read in bytes.</param>
|
||||||
public static void ReadProcessMemory(IntPtr memoryAddress, ref byte[] value)
|
public static void ReadProcessMemory(IntPtr memoryAddress, ref byte[] value)
|
||||||
{
|
{
|
||||||
var length = value.Length;
|
unchecked
|
||||||
var result = NativeFunctions.ReadProcessMemory((IntPtr)0xFFFFFFFF, memoryAddress, value, length, out _);
|
{
|
||||||
|
var length = value.Length;
|
||||||
|
var result = NativeFunctions.ReadProcessMemory((IntPtr)0xFFFFFFFF, memoryAddress, value, length, out _);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
throw new MemoryReadException($"Unable to read memory at 0x{memoryAddress.ToInt64():X} of length {length} (result={result})");
|
throw new MemoryReadException($"Unable to read memory at 0x{memoryAddress.ToInt64():X} of length {length} (result={result})");
|
||||||
|
|
||||||
var last = Marshal.GetLastWin32Error();
|
var last = Marshal.GetLastWin32Error();
|
||||||
if (last > 0)
|
if (last > 0)
|
||||||
throw new MemoryReadException($"Unable to read memory at 0x{memoryAddress.ToInt64():X} of length {length} (error={last})");
|
throw new MemoryReadException($"Unable to read memory at 0x{memoryAddress.ToInt64():X} of length {length} (error={last})");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -602,15 +605,18 @@ public static unsafe class MemoryHelper
|
||||||
/// <param name="data">The bytes to write to memoryAddress.</param>
|
/// <param name="data">The bytes to write to memoryAddress.</param>
|
||||||
public static void WriteProcessMemory(IntPtr memoryAddress, byte[] data)
|
public static void WriteProcessMemory(IntPtr memoryAddress, byte[] data)
|
||||||
{
|
{
|
||||||
var length = data.Length;
|
unchecked
|
||||||
var result = NativeFunctions.WriteProcessMemory((IntPtr)0xFFFFFFFF, memoryAddress, data, length, out _);
|
{
|
||||||
|
var length = data.Length;
|
||||||
|
var result = NativeFunctions.WriteProcessMemory((IntPtr)0xFFFFFFFF, memoryAddress, data, length, out _);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
throw new MemoryWriteException($"Unable to write memory at 0x{memoryAddress.ToInt64():X} of length {length} (result={result})");
|
throw new MemoryWriteException($"Unable to write memory at 0x{memoryAddress.ToInt64():X} of length {length} (result={result})");
|
||||||
|
|
||||||
var last = Marshal.GetLastWin32Error();
|
var last = Marshal.GetLastWin32Error();
|
||||||
if (last > 0)
|
if (last > 0)
|
||||||
throw new MemoryWriteException($"Unable to write memory at 0x{memoryAddress.ToInt64():X} of length {length} (error={last})");
|
throw new MemoryWriteException($"Unable to write memory at 0x{memoryAddress.ToInt64():X} of length {length} (error={last})");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue