Closed psytrx closed 7 years ago
Another approach might be removing the createInjector
parameter from the constructors which don't expect ProcessAccess
as an argument in order to prevent using shady defaults.
Fixed in #8 . Moving the ProcessHandle
to NativeMemory
, as it's internal, which allows us to simply call OpenProcess
in the native memory ctor when we're external (local procs don't require the call anyway)
MCVE:
The
ExternalProcessMemory
constructor throws aNullReferenceException
when being called withcreateInjector = true
. This is due to the constructor in question calling its base constructor (in which the Injector gets instantiated) before the ProcessHandle gets instantiated, which is required for injection.See https://github.com/aevitas/bluerain/blob/v2/src/BlueRain/ExternalProcessMemory.cs#L36
My suggestion is to move
ProcessHandle = OpenProcess(access, false, process.Id);
up into its base constructor with saneProcessAccess
defaults.Any thoughts?