From aff5f4da3a33c34e3c34aa5946052e4a9af27f88 Mon Sep 17 00:00:00 2001 From: tetyys Date: Fri, 7 Dec 2018 19:06:57 +0200 Subject: [PATCH 1/4] Fix uncaught exception when trying to retrieve negative addresses --- LoadBinaryPluginExt.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LoadBinaryPluginExt.cs b/LoadBinaryPluginExt.cs index d791260..854b943 100644 --- a/LoadBinaryPluginExt.cs +++ b/LoadBinaryPluginExt.cs @@ -148,6 +148,10 @@ public bool ReadRemoteMemory(IntPtr process, IntPtr address, ref byte[] buffer, { lock (sync) { + if (address.ToInt64() < 0) + { + return false; + } var info = GetMappedFileById(process); if (info != null) { From 1cf009705f3feb829524d5f3b34ff126944e1a4d Mon Sep 17 00:00:00 2001 From: tetyys Date: Fri, 7 Dec 2018 21:20:39 +0200 Subject: [PATCH 2/4] Rewrite address to non-negative instead of rejecting it --- LoadBinaryPluginExt.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/LoadBinaryPluginExt.cs b/LoadBinaryPluginExt.cs index 854b943..3ffe416 100644 --- a/LoadBinaryPluginExt.cs +++ b/LoadBinaryPluginExt.cs @@ -148,15 +148,28 @@ public bool ReadRemoteMemory(IntPtr process, IntPtr address, ref byte[] buffer, { lock (sync) { - if (address.ToInt64() < 0) - { - return false; - } var info = GetMappedFileById(process); if (info != null) { try { + /* + * This ensures that addresses larger than 0x7FFF_FFFF are not negative after calling + * ToInt64 by removing low side from long address from IntPtr (which seems to be casted + * from int to long non-bitwise). Same problem applies to addresses that are larger than + * 0x7FFF_FFFF_FFFF_FFFF, however CreateViewStream only accepts long parameter. + */ + long addressInt64 = address.ToInt64(); + if (addressInt64 < 0) + { + addressInt64 &= 0xFFFF_FFFF; + } + using (var stream = info.File.CreateViewStream(addressInt64, size)) + { + stream.Read(buffer, 0, size); + + return true; + } using (var stream = info.File.CreateViewStream(address.ToInt64(), size)) { stream.Read(buffer, 0, size); From b461f39a4897dcfe4ff2e044594f346bb8c36e8d Mon Sep 17 00:00:00 2001 From: tetyys Date: Fri, 7 Dec 2018 21:23:29 +0200 Subject: [PATCH 3/4] Fix copy paste mistake --- LoadBinaryPluginExt.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/LoadBinaryPluginExt.cs b/LoadBinaryPluginExt.cs index 3ffe416..737a58e 100644 --- a/LoadBinaryPluginExt.cs +++ b/LoadBinaryPluginExt.cs @@ -164,12 +164,6 @@ public bool ReadRemoteMemory(IntPtr process, IntPtr address, ref byte[] buffer, { addressInt64 &= 0xFFFF_FFFF; } - using (var stream = info.File.CreateViewStream(addressInt64, size)) - { - stream.Read(buffer, 0, size); - - return true; - } using (var stream = info.File.CreateViewStream(address.ToInt64(), size)) { stream.Read(buffer, 0, size); From 2761d18d6a58e0a4bf664887ac39418d1af10c36 Mon Sep 17 00:00:00 2001 From: tetyys Date: Fri, 7 Dec 2018 21:43:49 +0200 Subject: [PATCH 4/4] Fix copy paste mistake --- LoadBinaryPluginExt.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LoadBinaryPluginExt.cs b/LoadBinaryPluginExt.cs index 737a58e..acc2407 100644 --- a/LoadBinaryPluginExt.cs +++ b/LoadBinaryPluginExt.cs @@ -164,7 +164,7 @@ public bool ReadRemoteMemory(IntPtr process, IntPtr address, ref byte[] buffer, { addressInt64 &= 0xFFFF_FFFF; } - using (var stream = info.File.CreateViewStream(address.ToInt64(), size)) + using (var stream = info.File.CreateViewStream(addressInt64, size)) { stream.Read(buffer, 0, size); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy