mirror of
https://github.com/yaakov-h/Notepad.Extensions.Logging.git
synced 2024-11-22 11:14:50 +00:00
dont crash if virtualallocex fails
This commit is contained in:
parent
4259c47579
commit
8b348b3dd3
1 changed files with 9 additions and 6 deletions
|
@ -114,10 +114,13 @@ namespace Notepad.Extensions.Logging
|
||||||
// Look away now, before its too late.
|
// 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);
|
using var remoteProcess = Process.GetProcessById(remoteProcessId);
|
||||||
var mem = VirtualAllocEx(remoteProcess.Handle, IntPtr.Zero, (IntPtr)dataLength, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue