Ejemplo n.º 1
0
 public bool Terminate(int exitCode) => CorProcess.Terminate(exitCode);
Ejemplo n.º 2
0
 public bool Equals(CorProcess other) => !ReferenceEquals(other, null) && RawObject == other.RawObject;
Ejemplo n.º 3
0
 static bool WriteReturnFalse(CorProcess process, ulong addr)
 {
     return(WriteBytes(process, addr, returnFalse));
 }
Ejemplo n.º 4
0
 static bool WriteReturnTrue(CorProcess process, ulong addr) => WriteBytes(process, addr, returnTrue);
Ejemplo n.º 5
0
 public CorProcessReader(CorProcess process) => this.process = process ?? throw new ArgumentNullException(nameof(process));
Ejemplo n.º 6
0
 bool WriteReturnFalse(CorProcess process, ulong addr) => WriteBytes(process, addr, returnFalse);
Ejemplo n.º 7
0
 public bool Equals(CorProcess other)
 {
     return(!ReferenceEquals(other, null) &&
            RawObject == other.RawObject);
 }
        bool Initialize(CorProcess process, string debuggeeVersion, string clrPath)
        {
            try {
                var mgr = new ECallManager(process.ProcessId, clrPath);
                if (!mgr.FoundClrModule)
                {
                    return(false);
                }

                const string debuggerClassName = "System.Diagnostics.Debugger";
                bool         error = false, b;

                bool isClrV2OrOlder =
                    debuggeeVersion != null &&
                    (debuggeeVersion.StartsWith("v1.", StringComparison.OrdinalIgnoreCase) ||
                     debuggeeVersion.StartsWith("v2.", StringComparison.OrdinalIgnoreCase));

                // Launch() returns true in CLR 4.x and false in earlier CLR versions when there's
                // no debugger. At least on my system...
                b      = mgr.FindFunc(debuggerClassName, "LaunchInternal", out ulong addr);
                error |= !b;
                if (b)
                {
                    error |= !(isClrV2OrOlder ? WriteReturnFalse(process, addr) : WriteReturnTrue(process, addr));
                }

                b = mgr.FindFunc(debuggerClassName, "get_IsAttached", out addr);
                if (!b)
                {
                    b = mgr.FindFunc(debuggerClassName, "IsDebuggerAttached", out addr);
                }
                error |= !b;
                if (b)
                {
                    error |= !WriteReturnFalse(process, addr);
                }

                b      = mgr.FindFunc(debuggerClassName, "IsLogging", out addr);
                error |= !b;
                if (b)
                {
                    error |= !WriteReturnFalse(process, addr);
                }

                b      = mgr.FindFunc(debuggerClassName, "IsAttached", out addr);
                error |= !b;
                if (b)
                {
                    error |= !WriteReturnFalse(process, addr);
                }

                b      = mgr.FindFunc(debuggerClassName, "CheckRemoteDebuggerPresent", out addr);
                error |= !b;
                if (b)
                {
                    error |= !WriteReturnFalse(process, addr);
                }


                return(!error);
            }
            catch {
                return(false);
            }
        }