dont crash if virtualallocex fails

This commit is contained in:
Yaakov 2020-05-22 14:33:01 +10:00
parent 4259c47579
commit 8b348b3dd3

View file

@ -114,10 +114,13 @@ namespace Notepad.Extensions.Logging
// Look away now, before its too late.
//
var threadID = GetWindowThreadProcessId(hwnd, out var remoteProcessId);
/* unused thread ID */ _ = GetWindowThreadProcessId(hwnd, out var remoteProcessId);
using var remoteProcess = Process.GetProcessById(remoteProcessId);
var mem = VirtualAllocEx(remoteProcess.Handle, IntPtr.Zero, (IntPtr)dataLength, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (mem == IntPtr.Zero) throw new Win32Exception();
if (mem == IntPtr.Zero)
{
return;
}
try
{