Advertisement
BaSs_HaXoR

Before and After of my PS3Lib portable

Feb 23rd, 2015
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.10 KB | None | 0 0
  1. /*---- BEFORE ------------------------------------------------------------------------------------*/
  2.  
  3.  public CCAPI()
  4.         {
  5.             RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\FrenchModdingTeam\CCAPI\InstallFolder");
  6.             if (key != null)
  7.             {
  8.                 string str = key.GetValue("path") as string;
  9.                 if (!string.IsNullOrEmpty(str))
  10.                 {
  11.                     string path = str + @"\CCAPI.dll";
  12.                     if (File.Exists(path))
  13.                     {
  14.                         if (BitConverter.ToString(MD5.Create().ComputeHash(File.ReadAllBytes(path))).Replace("-", "").Equals(this.CCAPIHASH))
  15.                         {
  16.                             if (this.libModule == IntPtr.Zero)
  17.                             {
  18.                                 this.libModule = LoadLibrary(path);
  19.                             }
  20.                             if (this.libModule != IntPtr.Zero)
  21.                             {
  22.                                 this.connectConsole = (connectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIConnectConsole"), typeof(connectConsoleDelegate));
  23.                                 this.disconnectConsole = (disconnectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIDisconnectConsole"), typeof(disconnectConsoleDelegate));
  24.                                 this.getConnectionStatus = (getConnectionStatusDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConnectionStatus"), typeof(getConnectionStatusDelegate));
  25.                                 this.getConsoleInfo = (getConsoleInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConsoleInfo"), typeof(getConsoleInfoDelegate));
  26.                                 this.getDllVersion = (getDllVersionDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetDllVersion"), typeof(getDllVersionDelegate));
  27.                                 this.getFirmwareInfo = (getFirmwareInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetFirmwareInfo"), typeof(getFirmwareInfoDelegate));
  28.                                 this.getNumberOfConsoles = (getNumberOfConsolesDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetNumberOfConsoles"), typeof(getNumberOfConsolesDelegate));
  29.                                 this.getProcessList = (getProcessListDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessList"), typeof(getProcessListDelegate));
  30.                                 this.getProcessMemory = (getProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetMemory"), typeof(getProcessMemoryDelegate));
  31.                                 this.getProcessName = (getProcessNameDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessName"), typeof(getProcessNameDelegate));
  32.                                 this.getTemperature = (getTemperatureDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetTemperature"), typeof(getTemperatureDelegate));
  33.                                 this.notify = (notifyDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIVshNotify"), typeof(notifyDelegate));
  34.                                 this.ringBuzzer = (ringBuzzerDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIRingBuzzer"), typeof(ringBuzzerDelegate));
  35.                                 this.setBootConsoleIds = (setBootConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetBootConsoleIds"), typeof(setBootConsoleIdsDelegate));
  36.                                 this.setConsoleIds = (setConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleIds"), typeof(setConsoleIdsDelegate));
  37.                                 this.setConsoleLed = (setConsoleLedDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleLed"), typeof(setConsoleLedDelegate));
  38.                                 this.setProcessMemory = (setProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetMemory"), typeof(setProcessMemoryDelegate));
  39.                                 this.shutdown = (shutdownDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIShutdown"), typeof(shutdownDelegate));
  40.                             }
  41.                             else
  42.                             {
  43.                                 MessageBox.Show("Impossible to load CCAPI.dll version 2.60.", "CCAPI.dll cannot be load", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  44.                             }
  45.                         }
  46.                         else
  47.                         {
  48.                             MessageBox.Show("You're not using the right CCAPI.dll please install the version 2.60.", "CCAPI.dll version incorrect", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  49.                         }
  50.                     }
  51.                     else
  52.                     {
  53.                         MessageBox.Show("You need to install CCAPI to use this library.", "CCAPI.dll not found", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  54.                     }
  55.                 }
  56.                 else
  57.                 {
  58.                     MessageBox.Show("Invalid CCAPI folder, please re-install it.", "CCAPI not installed", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  59.                 }
  60.             }
  61.             else
  62.             {
  63.                 MessageBox.Show("You need to install CCAPI to use this library.", "CCAPI not installed", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  64.             }
  65.         }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. /*---- After ------------------------------------------------------------------------------------*/
  72.  
  73.  public class CCAPI
  74.     {
  75.         //private readonly string CCAPIHASH = "C2FE9E1C387CF29AAC781482C28ECF86"; Won't be needing this :P
  76.         private connectConsoleDelegate connectConsole;
  77.         private disconnectConsoleDelegate disconnectConsole;
  78.         private getConnectionStatusDelegate getConnectionStatus;
  79.         private getConsoleInfoDelegate getConsoleInfo;
  80.         private getDllVersionDelegate getDllVersion;
  81.         private getFirmwareInfoDelegate getFirmwareInfo;
  82.         private getNumberOfConsolesDelegate getNumberOfConsoles;
  83.         private getProcessListDelegate getProcessList;
  84.         private getProcessMemoryDelegate getProcessMemory;
  85.         private getProcessNameDelegate getProcessName;
  86.         private getTemperatureDelegate getTemperature;
  87.         private IntPtr libModule = (IntPtr)Convert.ToInt32("1751121920"); //Pointer to Function;//
  88.         private notifyDelegate notify;
  89.         private TargetInfo pInfo = new TargetInfo();
  90.         private ringBuzzerDelegate ringBuzzer;
  91.         private setBootConsoleIdsDelegate setBootConsoleIds;
  92.         private setConsoleIdsDelegate setConsoleIds;
  93.         private setConsoleLedDelegate setConsoleLed;
  94.         private setProcessMemoryDelegate setProcessMemory;
  95.         private shutdownDelegate shutdown;
  96.  
  97.         public string getCurrentDir()
  98.         {
  99.             string Dir;
  100.             Dir = Directory.GetCurrentDirectory();
  101.             return Dir;
  102.         }
  103.         public CCAPI()
  104.         {
  105.             string dapath = getCurrentDir() + @"\CCAPI.dll"; //This will get CCAPI 2.60 from your current Directory.
  106.                             if (File.Exists(getCurrentDir() + @"\CCAPI.dll"))
  107.                             {
  108.                                 // IntPtr newP = (IntPtr)Convert.ToInt32("1751121920"); //This is the pointer that is used in the main functions of every call, such as loadlib.
  109.                                 // credits: jandromeda @-http://www.experts-exchange.com/Programming/Languages/.NET/Q_23237956.html
  110.                                 LoadLibrary(dapath); //This will load CCAPI from your currently directory
  111.                                 this.connectConsole = (connectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIConnectConsole"), typeof(connectConsoleDelegate));
  112.                                 this.disconnectConsole = (disconnectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIDisconnectConsole"), typeof(disconnectConsoleDelegate));
  113.                                 this.getConnectionStatus = (getConnectionStatusDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConnectionStatus"), typeof(getConnectionStatusDelegate));
  114.                                 this.getConsoleInfo = (getConsoleInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConsoleInfo"), typeof(getConsoleInfoDelegate));
  115.                                 this.getDllVersion = (getDllVersionDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetDllVersion"), typeof(getDllVersionDelegate));
  116.                                 this.getFirmwareInfo = (getFirmwareInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetFirmwareInfo"), typeof(getFirmwareInfoDelegate));
  117.                                 this.getNumberOfConsoles = (getNumberOfConsolesDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetNumberOfConsoles"), typeof(getNumberOfConsolesDelegate));
  118.                                 this.getProcessList = (getProcessListDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessList"), typeof(getProcessListDelegate));
  119.                                 this.getProcessMemory = (getProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetMemory"), typeof(getProcessMemoryDelegate));
  120.                                 this.getProcessName = (getProcessNameDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessName"), typeof(getProcessNameDelegate));
  121.                                 this.getTemperature = (getTemperatureDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetTemperature"), typeof(getTemperatureDelegate));
  122.                                 this.notify = (notifyDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIVshNotify"), typeof(notifyDelegate));
  123.                                 this.ringBuzzer = (ringBuzzerDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIRingBuzzer"), typeof(ringBuzzerDelegate));
  124.                                 this.setBootConsoleIds = (setBootConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetBootConsoleIds"), typeof(setBootConsoleIdsDelegate));
  125.                                 this.setConsoleIds = (setConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleIds"), typeof(setConsoleIdsDelegate));
  126.                                 this.setConsoleLed = (setConsoleLedDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleLed"), typeof(setConsoleLedDelegate));
  127.                                 this.setProcessMemory = (setProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetMemory"), typeof(setProcessMemoryDelegate));
  128.                                 this.shutdown = (shutdownDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIShutdown"), typeof(shutdownDelegate)); }
  129.                             else
  130.                             {
  131.                                 MessageBox.Show("Failed to load CCAPI.dll version 2.60. Not In current Directory!", "CCAPI.dll doesn't exist!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  132.                             }
  133.                         }
  134. /*---- #NotSecure ------------------------------------------------------------------------------------*/
  135. //BaSs_HaXoR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement