/[RomCheater]/trunk/RomCheater.CorePlugins/Config/PCSX2Config.cs
ViewVC logotype

Contents of /trunk/RomCheater.CorePlugins/Config/PCSX2Config.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (show annotations) (download)
Sun May 27 23:05:18 2012 UTC (9 years, 3 months ago) by william
File size: 7978 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using RomCheater.PluginFramework.Core;
6 using System.IO;
7 using System.Diagnostics;
8 using RomCheater.Logging;
9
10 namespace RomCheater.CorePlugins.Config
11 {
12 //public sealed class PCSX2Config : ConfigPlugin
13 //{
14 // #region Configuration Memvers
15 // const string PCXS2_PROCESS_MAGIC = "pcsx2";
16 // const string PCXS2_LOOKUP_MAGIC_001 = "pcsx2";
17 // const string PCXS2_LOOKUP_MAGIC_002 = "compiled on";
18 // const uint VTLB_VADDR_OFFSET_DEBUG = 0x20000000;
19 // #endregion
20 // public PCSX2Config() : base(false) { }
21 // public PCSX2Config(bool doinit) : base(doinit) { }
22 // protected override bool IsNotValidProcess(ProcContainer p)
23 // {
24 // bool isDebug = false;
25 // uint VTLB_RELEASE_OFFSET = 0;
26 // bool notvalid = !IsValidPSX2Process(p.ProcessInfo.Id, out isDebug, out VTLB_RELEASE_OFFSET);
27 // if (notvalid)
28 // {
29 // logger.VerboseDebug.WriteLine(" Not Allowing process {0} to be added because it was filterd out", p.Name);
30 // }
31 // else
32 // {
33 // logger.VerboseDebug.WriteLine(" Allowing process {0} to be added", p.Name);
34 // }
35 // return notvalid;
36 // }
37 // #region IPluginBase Members
38 // public override Guid ID
39 // {
40 // get
41 // {
42 // return new GuidGenerator(typeof(PCSX2Config).FullName).Guid;
43 // }
44 // }
45 // public override string Name
46 // {
47 // get { return "PCSX2 Configuration Plugin"; }
48 // }
49 // public override string Description
50 // {
51 // get { return "This plugin provides a configuration suitable for use with PCSX2"; }
52 // }
53 // #endregion
54 // private static bool IsValidPSX2Process(int pid, out bool isDebug, out uint VTLB_RELEASE_OFFSET)
55 // {
56 // bool isValid = false;
57 // isDebug = false;
58 // VTLB_RELEASE_OFFSET = 0;
59 // try
60 // {
61 // Process p = Process.GetProcessById(pid);
62 // string filename = p.MainModule.FileName;
63 // FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
64 // BinaryReader r = new BinaryReader(fs);
65 // byte[] exe_check = new byte[] {
66 // 0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
67 // 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68 // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69 // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
70 // 0x0E, 0x1F, 0xBA, 0x0E, 0x00, 0xB4, 0x09, 0xCD, 0x21, 0xB8, 0x01, 0x4C, 0xCD, 0x21, 0x54, 0x68,
71 // 0x69, 0x73, 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, 0x61, 0x6D, 0x20, 0x63, 0x61, 0x6E, 0x6E, 0x6F,
72 // 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6E, 0x20, 0x69, 0x6E, 0x20, 0x44, 0x4F, 0x53, 0x20,
73 // 0x6D, 0x6F, 0x64, 0x65, 0x2E
74 // };
75 // r.BaseStream.Seek(0, SeekOrigin.Begin);
76 // byte[] data = r.ReadBytes(exe_check.Length);
77 // bool isExe = false;
78 // for (int i = 0; i < exe_check.Length; i++) { if (exe_check[i] == data[i]) { isExe = true; } else { isExe = false; } }
79 // r.Close();
80 // if (!isExe)
81 // {
82 // logger.VerboseDebug.WriteLine(" Process: {0} is not a valid executable file", filename);
83 // isValid = false;
84 // }
85 // else
86 // {
87 // // check for valid pcsx2 exe
88 // fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
89 // StreamReader sr = new StreamReader(fs);
90 // string found_string = sr.ReadToEnd();
91 // if (found_string.ToLower().Contains(PCXS2_LOOKUP_MAGIC_001.ToLower()) && found_string.ToLower().Contains(PCXS2_LOOKUP_MAGIC_002.ToLower()))
92 // {
93 // isValid = true;
94 // logger.VerboseDebug.WriteLine(" Process: {0} found MAGIC LOOKUP {1} and {2}", filename, PCXS2_LOOKUP_MAGIC_001.ToLower(), PCXS2_LOOKUP_MAGIC_002.ToLower());
95 // }
96 // sr.Close();
97 // // check for debug
98 // fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
99 // sr = new StreamReader(fs);
100 // found_string = sr.ReadToEnd();
101 // // DebugBreak should only be present in debug build version(s) of pcsx2
102 // if (found_string.ToLower().Contains("DebugBreak".ToLower()))
103 // {
104 // isDebug = true;
105 // logger.VerboseDebug.WriteLine(" Process: {0} found DebugBreak", filename);
106 // }
107 // sr.Close();
108 // }
109 // //this.IsDebugBuild = isDebug;
110 // // run check to see if we have a later version with offset fixed at: 0x20000000
111 // byte[] entrypoint_data = new byte[]{
112 // 0x01, 0x80, 0x1A, 0x3C, 0x78, 0x53, 0x59, 0xFF, 0x00, 0x68, 0x19, 0x40,
113 // 0x01, 0x80, 0x1A, 0x3C, 0x7C, 0x00, 0x39, 0x33, 0x21, 0xD0, 0x59, 0x03,
114 // 0x40, 0x53, 0x5A, 0x8F, 0x01, 0x80, 0x19, 0x3C, 0x08, 0x00, 0x40, 0x03,
115 // 0x78, 0x53, 0x39, 0xDF
116 // };
117 // //uint address = ramdumper.VTLB_VADDR_OFFSET_DEBUG;
118 // Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
119 // reader.ReadProcess = p;
120 // reader.OpenProcess();
121 // int bytesReadSize;
122 // byte[] check_data = reader.ReadProcessMemory((IntPtr)VTLB_VADDR_OFFSET_DEBUG, (uint)entrypoint_data.Length, out bytesReadSize);
123 // isDebug = check_data.SequenceEqual(entrypoint_data);
124 // logger.Debug.WriteLine(" Process: {0} isDebug: {1}", filename, isDebug.ToString());
125 // //List<uint> addresses = new List<uint>();
126 // if (!isDebug)
127 // {
128 // for (int i = 0x1000; i < 0x2000;i++ )
129 // {
130 // try
131 // {
132 // uint t = ((uint)i << 16) | 0x5000;
133 // check_data = reader.ReadProcessMemory((IntPtr)t, (uint)entrypoint_data.Length, out bytesReadSize);
134 // isValid = check_data.SequenceEqual(entrypoint_data);
135 // if (isValid)
136 // {
137 // //addresses.Add(t);
138 // VTLB_RELEASE_OFFSET = t;
139 // logger.VerboseDebug.WriteLine(" Process: {0} found release build entrypoint at 0x{1:x8}", filename, t);
140 // break; //use only the first valid value
141 // }
142 // }
143 // catch { }
144 // }
145 // }
146 // reader.CloseHandle();
147 // return isValid;
148 // }
149 // catch (System.ComponentModel.Win32Exception) { }
150 // catch (Exception) { }
151 // return isValid;
152 // }
153 //}
154 }

  ViewVC Help
Powered by ViewVC 1.1.22