Skip to content

Commit

Permalink
Added: API Compatibility Shim for legacy process_vm_readv_k32 funct…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
Sewer56 committed Aug 1, 2024
1 parent 25b5d41 commit 59776f8
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Reloaded.Memory/ExternalMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private bool ReadProcessMemory(nuint location, void* buffer, nuint numBytes)
return Kernel32.ReadProcessMemory(_processHandle, location, (nuint)buffer, numBytes, out _);

if (Polyfills.IsLinux())
return Posix.process_vm_readv_k32(_processHandle, location, (nuint)buffer, numBytes);
return Posix.process_vm_readv_k32_2(_processHandle, location, (nuint)buffer, numBytes);

ThrowHelpers.ThrowPlatformNotSupportedException();
return false;
Expand Down
17 changes: 16 additions & 1 deletion src/Reloaded.Memory/Native/Unix/Posix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ public struct IoVec
public nuint iov_len;
}

/// <summary>
/// Helper around
/// <see
/// cref="process_vm_readv(int,Reloaded.Memory.Native.Unix.Posix.IoVec*,ulong,Reloaded.Memory.Native.Unix.Posix.IoVec*,ulong,ulong)" />
/// but with an API similar to <see cref="Kernel32.ReadProcessMemory" />.
/// </summary>
/// <param name="processId">Id of the process to read from.</param>
/// <param name="localIov">Local memory address.</param>
/// <param name="remoteIov">Remote memory address.</param>
/// <param name="numBytes">Memory size.</param>
/// <returns>True on success, else false.</returns>
[Obsolete("Use process_vm_readv_k32_2 instead. This function has incorrect parameter order.")]
[PublicAPI]
public static bool process_vm_readv_k32(nint processId, nuint localIov, nuint remoteIov, nuint numBytes) => process_vm_readv_k32_2(processId, remoteIov, localIov, numBytes);

/// <summary>
/// Helper around
/// <see
Expand All @@ -139,7 +154,7 @@ public struct IoVec
/// <param name="localIov">Local memory address.</param>
/// <param name="numBytes">Memory size.</param>
/// <returns>True on success, else false.</returns>
public static unsafe bool process_vm_readv_k32(nint processId, nuint remoteIov, nuint localIov, nuint numBytes)
public static unsafe bool process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, net6.0, x64)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, net6.0, x64)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net6.0, x64)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net6.0, x64)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (macos-13, net6.0, x64)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (macos-13, net6.0, x64)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, net6.0, x86)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, net6.0, x86)

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / upload

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check warning on line 157 in src/Reloaded.Memory/Native/Unix/Posix.cs

View workflow job for this annotation

GitHub Actions / upload

Symbol 'process_vm_readv_k32_2' is not part of the declared public API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
{
IoVec local = new() { iov_base = localIov, iov_len = numBytes };
IoVec remote = new() { iov_base = remoteIov, iov_len = numBytes };
Expand Down
1 change: 1 addition & 0 deletions src/Reloaded.Memory/PublicAPI/net48/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,4 @@ Reloaded.Memory.Utilities.CircularBufferStruct.ItemFit.Yes = 0 -> Reloaded.Memor
Reloaded.Memory.Utilities.CircularBufferStruct.Remaining.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Size.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Start.get -> nuint
static Reloaded.Memory.Native.Unix.Posix.process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes) -> bool
1 change: 1 addition & 0 deletions src/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,4 @@ Reloaded.Memory.Utilities.CircularBufferStruct.ItemFit.Yes = 0 -> Reloaded.Memor
Reloaded.Memory.Utilities.CircularBufferStruct.Remaining.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Size.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Start.get -> nuint
static Reloaded.Memory.Native.Unix.Posix.process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes) -> bool
1 change: 1 addition & 0 deletions src/Reloaded.Memory/PublicAPI/net7.0/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -992,3 +992,4 @@ Reloaded.Memory.Utilities.CircularBufferStruct.ItemFit.Yes = 0 -> Reloaded.Memor
Reloaded.Memory.Utilities.CircularBufferStruct.Remaining.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Size.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Start.get -> nuint
static Reloaded.Memory.Native.Unix.Posix.process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes) -> bool
1 change: 1 addition & 0 deletions src/Reloaded.Memory/PublicAPI/net8.0/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -992,3 +992,4 @@ Reloaded.Memory.Utilities.CircularBufferStruct.ItemFit.Yes = 0 -> Reloaded.Memor
Reloaded.Memory.Utilities.CircularBufferStruct.Remaining.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Size.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Start.get -> nuint
static Reloaded.Memory.Native.Unix.Posix.process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes) -> bool
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,4 @@ Reloaded.Memory.Utilities.CircularBufferStruct.ItemFit.Yes = 0 -> Reloaded.Memor
Reloaded.Memory.Utilities.CircularBufferStruct.Remaining.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Size.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Start.get -> nuint
static Reloaded.Memory.Native.Unix.Posix.process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes) -> bool
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,4 @@ Reloaded.Memory.Utilities.CircularBufferStruct.ItemFit.Yes = 0 -> Reloaded.Memor
Reloaded.Memory.Utilities.CircularBufferStruct.Remaining.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Size.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Start.get -> nuint
static Reloaded.Memory.Native.Unix.Posix.process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes) -> bool
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,4 @@ Reloaded.Memory.Utilities.CircularBufferStruct.ItemFit.Yes = 0 -> Reloaded.Memor
Reloaded.Memory.Utilities.CircularBufferStruct.Remaining.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Size.get -> nuint
Reloaded.Memory.Utilities.CircularBufferStruct.Start.get -> nuint
static Reloaded.Memory.Native.Unix.Posix.process_vm_readv_k32_2(nint processId, nuint remoteIov, nuint localIov, nuint numBytes) -> bool

0 comments on commit 59776f8

Please sign in to comment.