public static Debuggee Launch(string executable, string argumentString = null, string workingDirectory = null) { var si = new STARTUPINFO { cb = Marshal.SizeOf(typeof(STARTUPINFO)), }; var pi = new PROCESS_INFORMATION(); if (argumentString == string.Empty) argumentString = null; if (workingDirectory == string.Empty) workingDirectory = null; if (!API.CreateProcess(executable, argumentString, IntPtr.Zero, IntPtr.Zero, true, ProcessCreationFlags.CreateNewConsole | // Create extra console for the process ProcessCreationFlags.DebugOnlyThisProcess // Grant debugger access to the process ,IntPtr.Zero, workingDirectory, ref si, out pi)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } var dbg = new Debuggee(executable, pi.hProcess, pi.dwProcessId, pi.hThread, pi.dwThreadId, ExecutableMetaInfo.ExtractFrom(executable)); return dbg; }
public DebugProcess(Debuggee dbg, string executableFile, IntPtr processHandle, uint processId, IntPtr mainThreadHandle, uint mainThreadId, ExecutableMetaInfo emi) { this.Debuggee = dbg; Handle = processHandle; Id = processId; MainModule = new DebugProcessModule(new IntPtr(emi.PEHeader.OptionalHeader32.ImageBase),executableFile, emi); RegModule(MainModule); MainThread = new DebugThread(this, mainThreadHandle, mainThreadId, MainModule.StartAddress, IntPtr.Zero); RegThread(MainThread); }
public DebugProcess(Debuggee dbg, string executableFile, IntPtr processHandle, uint processId, IntPtr mainThreadHandle, uint mainThreadId, ExecutableMetaInfo emi) { this.Debuggee = dbg; Handle = processHandle; Id = processId; MainModule = new DebugProcessModule(new IntPtr(emi.PEHeader.OptionalHeader32.ImageBase), executableFile, emi); RegModule(MainModule); MainThread = new DebugThread(this, mainThreadHandle, mainThreadId, MainModule.StartAddress, IntPtr.Zero); RegThread(MainThread); }
public DebugProcess(Debuggee dbg, Win32.CREATE_PROCESS_DEBUG_INFO info, uint id, uint threadId) { this.Debuggee = dbg; Handle = info.hProcess; Id = id == 0 ? API.GetProcessId(Handle) : id; var moduleFile = APIIntermediate.GetModulePath(Handle, info.lpBaseOfImage, info.hFile); // Deduce main module MainModule = new DebugProcessModule(info.lpBaseOfImage, moduleFile, ExecutableMetaInfo.ExtractFrom(moduleFile)); RegModule(MainModule); // Create main thread MainThread = new DebugThread(this, info.hThread, threadId == 0 ? API.GetThreadId(info.hThread) : threadId, info.lpStartAddress, info.lpThreadLocalBase); RegThread(MainThread); }
private void button1_Click(object sender, EventArgs e) { var exe = input_executable.Text; if (!Path.IsPathRooted(exe)) exe = Environment.CurrentDirectory + "\\" + exe; if (!File.Exists(exe)) { MessageBox.Show(exe + " doesn't exist!", "Execute program", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DDebugger.DDebugger.EventListeners.Clear(); DDebugger.DDebugger.EventListeners.Add(new EventLogger(this, dbg)); dbg = DDebugger.DDebugger.Launch(exe); dbg.WaitForDebugEvent(); //dbg.Breakpoints.SetProgramEntryBreakpoint(); //dbg.Breakpoints.CreateBreakpoint(new IntPtr(0x004020c8u)); }
public MemoryManagement(Debuggee dbg) { this.Debuggee = dbg; }
internal BreakpointManagement(Debuggee debuggee) { this.Debuggee = debuggee; }
public EventLogger(MainForm f,Debuggee dbg) : base(dbg) { form = f; }
public Stepping(Debuggee dbg) { this.Debuggee = dbg; this.Breakpoints = dbg.Breakpoints; }
public DebugEventListener(Debuggee dbg) { this.Debuggee = dbg; }