Exemple #1
0
        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;
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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));
        }
Exemple #7
0
 public MemoryManagement(Debuggee dbg)
 {
     this.Debuggee = dbg;
 }
Exemple #8
0
 public MemoryManagement(Debuggee dbg)
 {
     this.Debuggee = dbg;
 }
 internal BreakpointManagement(Debuggee debuggee)
 {
     this.Debuggee = debuggee;
 }
Exemple #10
0
 public EventLogger(MainForm f,Debuggee dbg)
     : base(dbg)
 {
     form = f;
 }
Exemple #11
0
 public Stepping(Debuggee dbg)
 {
     this.Debuggee = dbg;
     this.Breakpoints = dbg.Breakpoints;
 }
Exemple #12
0
 public DebugEventListener(Debuggee dbg)
 {
     this.Debuggee = dbg;
 }
 public DebugEventListener(Debuggee dbg)
 {
     this.Debuggee = dbg;
 }