Пример #1
0
        private void MenuStrip_Dump_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 selectedCellCount = ModuleList.GetCellCount(DataGridViewElementStates.Selected);
                if (selectedCellCount > 0)
                {
                    int    index        = ModuleList.SelectedRows[0].Index;
                    int    ModuleHandle = Convert.ToInt32(ModuleList.Rows[index].Cells["mHandle"].Value);
                    string ModuleName   = Convert.ToString(ModuleList.Rows[index].Cells["ModuleName"].Value);

                    SetStatus("Dumping Module " + ModuleName + "...");

                    ModuleInfo Info = PS4.SelectedTarget.Process.ModuleList.Find(x => x.Name == ModuleName);

                    int    Length   = (int)(Info.TextSegmentLen + Info.DataSegmentLen);
                    byte[] Buffer   = new byte[Length];
                    string FilePath = string.Empty;

                    //If its module 0 thats the process so we want to dump the process else we dump a module.
                    if (ModuleHandle == 0)
                    {
                        API_ERRORS Result = PS4.SelectedTarget.Process.DumpModule(ModuleName, Length, Buffer);
                        //API_ERRORS Result = PS4.SelectedTarget.DumpProcess(ModuleName, Length, Buffer);
                        ModuleName = $"{PS4.SelectedTarget.Process.Current.TitleID}-{ModuleName}";
                        if (Result != API_ERRORS.API_OK)
                        {
                            DarkMessageBox.ShowError(string.Format("Failed to Dump Process \"{0}\".\n{1}", ModuleName, OrbisDef.API_ERROR_STR[(int)Result]), "Error dumping module.");

                            return;
                        }
                    }
                    else
                    {
                        API_ERRORS Result = PS4.SelectedTarget.Process.DumpModule(ModuleName, Length, Buffer);
                        if (Result != API_ERRORS.API_OK)
                        {
                            DarkMessageBox.ShowError(string.Format("Failed to Dump Module \"{0}\".\n{1}", ModuleName, OrbisDef.API_ERROR_STR[(int)Result]), "Error dumping module.");

                            return;
                        }
                    }

                    //Create the Orbis Suite Directory in Documents.
                    Directory.CreateDirectory($"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\\Orbis Suite\\");

                    //Write the file some where.
                    FilePath = string.Format(@"{0}\Orbis Suite\{1}", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Utilities.IndexedFilename(Path.GetFileNameWithoutExtension(ModuleName) + "-Dump", Path.GetExtension(ModuleName)));
                    using (FileStream fs = File.OpenWrite(FilePath))
                        fs.Write(Buffer, 0, (int)Length);

                    SetStatus("Ready");
                }
            }
            catch
            {
            }
        }
Пример #2
0
        public API_ERRORS DumpProcess(string ProcName, int Length, byte[] Out)
        {
            IntPtr ptr = Marshal.AllocHGlobal(Length);

            UInt64     RealLength = 0;
            API_ERRORS Result     = Imports.Target.DumpProcess(Info.IPAddr, ProcName, out RealLength, ptr);

            Marshal.Copy(ptr, Out, 0, Length);

            //free unmanageed memory.
            Marshal.FreeHGlobal(ptr);

            return(Result);
        }
Пример #3
0
        public API_ERRORS Read(UInt64 Address, Int32 Len, byte[] List)
        {
            IntPtr ptr = Marshal.AllocHGlobal(Len);

            API_ERRORS err = Imports.Process.Read(Target.Info.IPAddr, Address, Len, ptr);

            for (int i = 0; i < Len; i++)
            {
                List[i] = Marshal.ReadByte(ptr, i);
            }

            Marshal.FreeHGlobal(ptr);

            return(err);
        }
Пример #4
0
        public API_ERRORS DumpModule(string Name, int Length, byte[] Out)
        {
            //allocate un managed memory to get module.
            IntPtr ptr = Marshal.AllocHGlobal(Length);

            //Call to the api to send dump
            int        RealLength = 0;
            API_ERRORS Result     = Imports.Process.DumpModule(Target.Info.IPAddr, Name, out RealLength, ptr);

            //copy the data out of unmanaged to managed memory.
            Marshal.Copy(ptr, Out, 0, Length);

            //free unmanageed memory.
            Marshal.FreeHGlobal(ptr);

            return(Result);
        }
Пример #5
0
        public void AttachtoSelected()
        {
            Int32 selectedCellCount = ProcessList.GetCellCount(DataGridViewElementStates.Selected);

            if (selectedCellCount > 0)
            {
                int index = ProcessList.SelectedRows[0].Index;
                SelectedProcess = Convert.ToString(ProcessList.Rows[index].Cells["ProcName"].Value);
                API_ERRORS res = PS4.Target[TargetName].Process.Attach(SelectedProcess);

                if (res == API_ERRORS.API_OK)
                {
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    DarkMessageBox.ShowError(OrbisDef.API_ERROR_STR[(int)res], "Error: Failed to Attach!");
                }
            }
            else
            {
                DarkMessageBox.ShowError("Please Select a Process", "Error: No Process Selected!");
            }
        }