mirror of
https://github.com/yaakov-h/Notepad.Extensions.Logging.git
synced 2024-11-22 03:04:48 +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
|
@ -97,10 +97,10 @@ namespace Notepad.Extensions.Logging
|
|||
break;
|
||||
|
||||
case WindowKind.NotepadPlusPlus:
|
||||
{
|
||||
WriteToNotepadPlusPlus(hwnd, message);
|
||||
break;
|
||||
}
|
||||
{
|
||||
WriteToNotepadPlusPlus(hwnd, message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue