Inheritance: DebuggerEventArgs
Esempio n. 1
0
        private void OnDebuggerEvalCompleted(object sender, DebuggerEvalEventArgs e)
        {
            if (_assemblyCodeInTargetProcess == null && _injectorFunction == null)
            {
                _assemblyCodeInTargetProcess = CopyInjectorAssembly(e);
                InvokeAssemblyLoad((ICorDebugEval2)e.Eval, _assemblyCodeInTargetProcess);
            }

            if (_nextEvalShouldCloseApplication)
            {
                OnFinished();
            }
        }
Esempio n. 2
0
 private void OnDebuggerEvalFailed(object sender, DebuggerEvalEventArgs e)
 {
     Logger.WriteLine("Function evaluation failed :(");
 }
Esempio n. 3
0
        private ICorDebugValue CopyInjectorAssembly(DebuggerEvalEventArgs e)
        {
            Logger.WriteLine("Copying assembly code to target process...");

            ICorDebugValue assemblyCode;
            e.Eval.GetResult(out assemblyCode);

            var arrayReference = assemblyCode as ICorDebugReferenceValue;

            ICorDebugValue arrayDereferenced;
            arrayReference.Dereference(out arrayDereferenced);

            var array = arrayDereferenced as ICorDebugArrayValue;

            ICorDebugValue startElement;
            array.GetElementAtPosition((uint)0, out startElement);
            ICorDebugGenericValue startElementValue = startElement as ICorDebugGenericValue;
            ulong startAddress;
            startElementValue.GetAddress(out startAddress);

            ICorDebugProcess ppProcess;
            e.Thread.GetProcess(out ppProcess);
            IntPtr written;
            var assemblyLength = (uint)_assemblyBytes.Length;
            ppProcess.WriteMemory(startAddress, assemblyLength, _assemblyBytes, out written);

            Logger.WriteLine("{0} out {1} bytes of assembly code is written to the target process.", written.ToInt32(), assemblyLength);
            return assemblyCode;
        }