BaSs_HaXoR

PS3Lib 4.4 PORTABLE [NO ControlConsoleAPI.exe]

Feb 23rd, 2015
1,737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 28.08 KB | None | 0 0
  1. /*#########################################################################################################################################################################*/
  2. /*                                                      Download: http://adf.ly/13t8e1                                                     */
  3. /*                                                    Download SRC: http://adf.ly/13t8g7                                                                   */
  4. /*#########################################################################################################################################################################*/
  5.  
  6. // - UPDATE [2]: Seems to be FULLY FUNCTIONAL. No need to patch CCAPI. Portable PS3Lib 4.4 is confirmed working and verified by iMoD1998. -Thanks <3
  7.  
  8. // - UPDATE [1]: It's possible their is a check in CCAPI.dll for currentdir as well as the registrykey, so this might need to be patched to be fully functioning.
  9.  
  10. /*
  11. @Author: iMCSx [Modified by: BaSs_HaXoR]
  12. @Date: 02/23/15
  13. @Project: PS3Lib 4.4 PORTABLE [NO ControlConsoleAPI.exe] [PS3Lib.dll 4.4 Portable]
  14. @PwN: Security Flaw: Not knowing how to properly and securely make calls to the functions. [Pointer is in plain-view]
  15. @Shoutout: BLM - BadLuckModding
  16. */
  17.  
  18. //This is the CCAPI.cs, so essentially if you wanted to, just copy and paste this over your CCAPI.cs :)
  19.  
  20. namespace PS3Lib
  21. {
  22.     using Microsoft.Win32;
  23.     using System;
  24.     using System.Collections.Generic;
  25.     using System.IO;
  26.     using System.Linq;
  27.     using System.Runtime.CompilerServices;
  28.     using System.Runtime.InteropServices;
  29.     using System.Security.Cryptography;
  30.     using System.Windows.Forms;
  31.     using System.Threading;
  32.     public class CCAPI
  33.     {
  34.         //private readonly string CCAPIHASH = "C2FE9E1C387CF29AAC781482C28ECF86"; Won't be needing this :P
  35.         private connectConsoleDelegate connectConsole;
  36.         private disconnectConsoleDelegate disconnectConsole;
  37.         private getConnectionStatusDelegate getConnectionStatus;
  38.         private getConsoleInfoDelegate getConsoleInfo;
  39.         private getDllVersionDelegate getDllVersion;
  40.         private getFirmwareInfoDelegate getFirmwareInfo;
  41.         private getNumberOfConsolesDelegate getNumberOfConsoles;
  42.         private getProcessListDelegate getProcessList;
  43.         private getProcessMemoryDelegate getProcessMemory;
  44.         private getProcessNameDelegate getProcessName;
  45.         private getTemperatureDelegate getTemperature;
  46.         private IntPtr libModule = (IntPtr)Convert.ToInt32("1751121920"); //Pointer to Function;//
  47.         private notifyDelegate notify;
  48.         private TargetInfo pInfo = new TargetInfo();
  49.         private ringBuzzerDelegate ringBuzzer;
  50.         private setBootConsoleIdsDelegate setBootConsoleIds;
  51.         private setConsoleIdsDelegate setConsoleIds;
  52.         private setConsoleLedDelegate setConsoleLed;
  53.         private setProcessMemoryDelegate setProcessMemory;
  54.         private shutdownDelegate shutdown;
  55.  
  56.         public string getCurrentDir()
  57.         {
  58.             string Dir;
  59.             Dir = Directory.GetCurrentDirectory();
  60.             return Dir;
  61.         }
  62.         public CCAPI()
  63.         {
  64.             string daPath = getCurrentDir() + @"\CCAPI.dll"; //This will get CCAPI 2.60 from your current Directory.
  65.                             if (File.Exists(getCurrentDir() + @"\CCAPI.dll"))
  66.                             {
  67.                                 // IntPtr newP = (IntPtr)Convert.ToInt32("1751121920"); //This is the pointer that is used in the calls to the main functions, such as loadlib.
  68.                                 // credits: jandromeda @-http://www.experts-exchange.com/Programming/Languages/.NET/Q_23237956.html
  69.                                 LoadLibrary(daPath); //This will load CCAPI from your currently directory
  70.                                 this.connectConsole = (connectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIConnectConsole"), typeof(connectConsoleDelegate));
  71.                                 this.disconnectConsole = (disconnectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIDisconnectConsole"), typeof(disconnectConsoleDelegate));
  72.                                 this.getConnectionStatus = (getConnectionStatusDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConnectionStatus"), typeof(getConnectionStatusDelegate));
  73.                                 this.getConsoleInfo = (getConsoleInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConsoleInfo"), typeof(getConsoleInfoDelegate));
  74.                                 this.getDllVersion = (getDllVersionDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetDllVersion"), typeof(getDllVersionDelegate));
  75.                                 this.getFirmwareInfo = (getFirmwareInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetFirmwareInfo"), typeof(getFirmwareInfoDelegate));
  76.                                 this.getNumberOfConsoles = (getNumberOfConsolesDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetNumberOfConsoles"), typeof(getNumberOfConsolesDelegate));
  77.                                 this.getProcessList = (getProcessListDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessList"), typeof(getProcessListDelegate));
  78.                                 this.getProcessMemory = (getProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetMemory"), typeof(getProcessMemoryDelegate));
  79.                                 this.getProcessName = (getProcessNameDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessName"), typeof(getProcessNameDelegate));
  80.                                 this.getTemperature = (getTemperatureDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetTemperature"), typeof(getTemperatureDelegate));
  81.                                 this.notify = (notifyDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIVshNotify"), typeof(notifyDelegate));
  82.                                 this.ringBuzzer = (ringBuzzerDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIRingBuzzer"), typeof(ringBuzzerDelegate));
  83.                                 this.setBootConsoleIds = (setBootConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetBootConsoleIds"), typeof(setBootConsoleIdsDelegate));
  84.                                 this.setConsoleIds = (setConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleIds"), typeof(setConsoleIdsDelegate));
  85.                                 this.setConsoleLed = (setConsoleLedDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleLed"), typeof(setConsoleLedDelegate));
  86.                                 this.setProcessMemory = (setProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetMemory"), typeof(setProcessMemoryDelegate));
  87.                                 this.shutdown = (shutdownDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIShutdown"), typeof(shutdownDelegate)); }
  88.                             else
  89.                             {
  90.                                 MessageBox.Show("Failed to load CCAPI.dll version 2.60. Not In current Directory!", "CCAPI.dll doesn't exist!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  91.                             }
  92.                         }
  93.  
  94.         public int AttachProcess()
  95.         {
  96.             int @void = -1;
  97.             System.processID = 0;
  98.             @void = this.GetProcessList(out System.processIDs);
  99.             if (!this.SUCCESS(@void) || (System.processIDs.Length <= 0))
  100.             {
  101.                 return -1;
  102.             }
  103.             for (int i = 0; i < System.processIDs.Length; i++)
  104.             {
  105.                 string name = string.Empty;
  106.                 @void = this.GetProcessName(System.processIDs[i], out name);
  107.                 if (!this.SUCCESS(@void))
  108.                 {
  109.                     break;
  110.                 }
  111.                 if (!name.Contains("flash"))
  112.                 {
  113.                     System.processID = System.processIDs[i];
  114.                     break;
  115.                 }
  116.                 @void = -1;
  117.             }
  118.             if (System.processID == 0)
  119.             {
  120.                 System.processID = System.processIDs[System.processIDs.Length - 1];
  121.             }
  122.             return @void;
  123.         }
  124.  
  125.         public int AttachProcess(ProcessType procType)
  126.         {
  127.             int processList = -1;
  128.             System.processID = 0;
  129.             processList = this.GetProcessList(out System.processIDs);
  130.             if ((processList < 0) || (System.processIDs.Length <= 0))
  131.             {
  132.                 return -1;
  133.             }
  134.             for (int i = 0; i < System.processIDs.Length; i++)
  135.             {
  136.                 string name = string.Empty;
  137.                 processList = this.GetProcessName(System.processIDs[i], out name);
  138.                 if (processList < 0)
  139.                 {
  140.                     break;
  141.                 }
  142.                 if ((procType == ProcessType.VSH) && name.Contains("vsh"))
  143.                 {
  144.                     System.processID = System.processIDs[i];
  145.                     break;
  146.                 }
  147.                 if ((procType == ProcessType.SYS_AGENT) && name.Contains("agent"))
  148.                 {
  149.                     System.processID = System.processIDs[i];
  150.                     break;
  151.                 }
  152.                 if ((procType == ProcessType.CURRENTGAME) && !name.Contains("flash"))
  153.                 {
  154.                     System.processID = System.processIDs[i];
  155.                     break;
  156.                 }
  157.             }
  158.             if (System.processID == 0)
  159.             {
  160.                 System.processID = System.processIDs[System.processIDs.Length - 1];
  161.             }
  162.             return processList;
  163.         }
  164.  
  165.         public int AttachProcess(uint process)
  166.         {
  167.             int @void = -1;
  168.             uint[] processIds = new uint[0x40];
  169.             @void = this.GetProcessList(out processIds);
  170.             if (this.SUCCESS(@void))
  171.             {
  172.                 for (int i = 0; i < processIds.Length; i++)
  173.                 {
  174.                     if (processIds[i] == process)
  175.                     {
  176.                         @void = 0;
  177.                         System.processID = process;
  178.                         break;
  179.                     }
  180.                     @void = -1;
  181.                 }
  182.             }
  183.             processIds = null;
  184.             return @void;
  185.         }
  186.  
  187.         public void ClearTargetInfo()
  188.         {
  189.             this.pInfo = new TargetInfo();
  190.         }
  191.  
  192.         private void CompleteInfo(ref TargetInfo Info, int fw, int ccapi, ulong sysTable, int consoleType, int tempCELL, int tempRSX)
  193.         {
  194.             Info.Firmware = fw;
  195.             Info.CCAPI = ccapi;
  196.             Info.SysTable = sysTable;
  197.             Info.ConsoleType = consoleType;
  198.             Info.TempCell = tempCELL;
  199.             Info.TempRSX = tempRSX;
  200.         }
  201.  
  202.         public bool ConnectTarget()
  203.         {
  204.             return new PS3API.ConsoleList(new PS3API(SelectAPI.ControlConsole)).Show();
  205.         }
  206.  
  207.         public int ConnectTarget(string targetIP)
  208.         {
  209.             return this.connectConsole(targetIP);
  210.         }
  211.  
  212.         public int DisconnectTarget()
  213.         {
  214.             return this.disconnectConsole();
  215.         }
  216.  
  217.         public uint GetAttachedProcess()
  218.         {
  219.             return System.processID;
  220.         }
  221.  
  222.         public byte[] GetBytes(uint offset, uint length)
  223.         {
  224.             byte[] buffer = new byte[length];
  225.             this.GetMemory(offset, buffer);
  226.             return buffer;
  227.         }
  228.  
  229.         public byte[] GetBytes(ulong offset, uint length)
  230.         {
  231.             byte[] buffer = new byte[length];
  232.             this.GetMemory(offset, buffer);
  233.             return buffer;
  234.         }
  235.  
  236.         public int GetConnectionStatus()
  237.         {
  238.             int status = 0;
  239.             this.getConnectionStatus(ref status);
  240.             return status;
  241.         }
  242.  
  243.         public List<ConsoleInfo> GetConsoleList()
  244.         {
  245.             List<ConsoleInfo> list = new List<ConsoleInfo>();
  246.             int num = this.getNumberOfConsoles();
  247.             IntPtr ptrN = Marshal.AllocHGlobal(0x100);
  248.             IntPtr ptrI = Marshal.AllocHGlobal(0x100);
  249.             for (int i = 0; i < num; i++)
  250.             {
  251.                 ConsoleInfo item = new ConsoleInfo();
  252.                 this.getConsoleInfo(i, ptrN, ptrI);
  253.                 item.Name = Marshal.PtrToStringAnsi(ptrN);
  254.                 item.Ip = Marshal.PtrToStringAnsi(ptrI);
  255.                 list.Add(item);
  256.             }
  257.             Marshal.FreeHGlobal(ptrN);
  258.             Marshal.FreeHGlobal(ptrI);
  259.             return list;
  260.         }
  261.  
  262.         public int GetDllVersion()
  263.         {
  264.             return this.getDllVersion();
  265.         }
  266.  
  267.         public string GetFirmwareType()
  268.         {
  269.             if (this.pInfo.ConsoleType.ToString() == "")
  270.             {
  271.                 this.GetTargetInfo(out this.pInfo);
  272.             }
  273.             string str = string.Empty;
  274.             if (this.pInfo.ConsoleType == 1)
  275.             {
  276.                 return "CEX";
  277.             }
  278.             if (this.pInfo.ConsoleType == 2)
  279.             {
  280.                 return "DEX";
  281.             }
  282.             if (this.pInfo.ConsoleType == 3)
  283.             {
  284.                 str = "TOOL";
  285.             }
  286.             return str;
  287.         }
  288.  
  289.         public string GetFirmwareVersion()
  290.         {
  291.             if (this.pInfo.Firmware == 0)
  292.             {
  293.                 this.GetTargetInfo();
  294.             }
  295.             string str = this.pInfo.Firmware.ToString("X8");
  296.             string str2 = str.Substring(1, 1) + ".";
  297.             string str3 = str.Substring(3, 1);
  298.             string str4 = str.Substring(4, 1);
  299.             return (str2 + str3 + str4);
  300.         }
  301.  
  302.         public int GetMemory(uint offset, byte[] buffer)
  303.         {
  304.             return this.getProcessMemory(System.processID, (ulong) offset, (uint) buffer.Length, buffer);
  305.         }
  306.  
  307.         public int GetMemory(ulong offset, byte[] buffer)
  308.         {
  309.             return this.getProcessMemory(System.processID, offset, (uint) buffer.Length, buffer);
  310.         }
  311.  
  312.         [DllImport("kernel32.dll")]
  313.         private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
  314.         public int GetProcessList(out uint[] processIds)
  315.         {
  316.             uint numberProcesses = 0x40;
  317.             int @void = -1;
  318.             IntPtr processIdPtr = Marshal.AllocHGlobal(0x100);
  319.             @void = this.getProcessList(ref numberProcesses, processIdPtr);
  320.             processIds = new uint[numberProcesses];
  321.             if (this.SUCCESS(@void))
  322.             {
  323.                 IntPtr unBuf = processIdPtr;
  324.                 for (uint i = 0; i < numberProcesses; i++)
  325.                 {
  326.                     unBuf = this.ReadDataFromUnBufPtr<uint>(unBuf, ref processIds[i]);
  327.                 }
  328.             }
  329.             Marshal.FreeHGlobal(processIdPtr);
  330.             return @void;
  331.         }
  332.  
  333.         public int GetProcessName(uint processId, out string name)
  334.         {
  335.             IntPtr strPtr = Marshal.AllocHGlobal(0x211);
  336.             int @void = -1;
  337.             @void = this.getProcessName(processId, strPtr);
  338.             name = string.Empty;
  339.             if (this.SUCCESS(@void))
  340.             {
  341.                 name = Marshal.PtrToStringAnsi(strPtr);
  342.             }
  343.             Marshal.FreeHGlobal(strPtr);
  344.             return @void;
  345.         }
  346.  
  347.         private int GetTargetInfo()
  348.         {
  349.             int num = -1;
  350.             int[] numArray = new int[2];
  351.             int firmware = 0;
  352.             int ccapi = 0;
  353.             int consoleType = 0;
  354.             ulong sysTable = 0L;
  355.             num = this.getFirmwareInfo(ref firmware, ref ccapi, ref consoleType);
  356.             if (num >= 0)
  357.             {
  358.                 num = this.getTemperature(ref numArray[0], ref numArray[1]);
  359.                 if (num >= 0)
  360.                 {
  361.                     this.CompleteInfo(ref this.pInfo, firmware, ccapi, sysTable, consoleType, numArray[0], numArray[1]);
  362.                 }
  363.             }
  364.             return num;
  365.         }
  366.  
  367.         public int GetTargetInfo(out TargetInfo Info)
  368.         {
  369.             Info = new TargetInfo();
  370.             int num = -1;
  371.             int[] numArray = new int[2];
  372.             int firmware = 0;
  373.             int ccapi = 0;
  374.             int consoleType = 0;
  375.             ulong sysTable = 0L;
  376.             num = this.getFirmwareInfo(ref firmware, ref ccapi, ref consoleType);
  377.             if (num >= 0)
  378.             {
  379.                 num = this.getTemperature(ref numArray[0], ref numArray[1]);
  380.                 if (num >= 0)
  381.                 {
  382.                     this.CompleteInfo(ref Info, firmware, ccapi, sysTable, consoleType, numArray[0], numArray[1]);
  383.                     this.CompleteInfo(ref this.pInfo, firmware, ccapi, sysTable, consoleType, numArray[0], numArray[1]);
  384.                 }
  385.             }
  386.             return num;
  387.         }
  388.  
  389.         public string GetTemperatureCELL()
  390.         {
  391.             if (this.pInfo.TempCell == 0)
  392.             {
  393.                 this.GetTargetInfo(out this.pInfo);
  394.             }
  395.             return (this.pInfo.TempCell.ToString() + " C");
  396.         }
  397.  
  398.         public string GetTemperatureRSX()
  399.         {
  400.             if (this.pInfo.TempRSX == 0)
  401.             {
  402.                 this.GetTargetInfo(out this.pInfo);
  403.             }
  404.             return (this.pInfo.TempRSX.ToString() + " C");
  405.         }
  406.  
  407.         [DllImport("kernel32.dll")]
  408.         private static extern IntPtr LoadLibrary(string dllName);
  409.         public int Notify(NotifyIcon icon, string message)
  410.         {
  411.             return this.notify((int) icon, message);
  412.         }
  413.  
  414.         public int Notify(int icon, string message)
  415.         {
  416.             return this.notify(icon, message);
  417.         }
  418.  
  419.         private IntPtr ReadDataFromUnBufPtr<T>(IntPtr unBuf, ref T storage)
  420.         {
  421.             storage = (T) Marshal.PtrToStructure(unBuf, typeof(T));
  422.             return new IntPtr(unBuf.ToInt64() + Marshal.SizeOf((T) storage));
  423.         }
  424.  
  425.         public int ResetBootConsoleID(IdType Type = 0)
  426.         {
  427.             return this.setBootConsoleIds((int) Type, 0, null);
  428.         }
  429.  
  430.         public int RingBuzzer(BuzzerMode flag)
  431.         {
  432.             return this.ringBuzzer((int) flag);
  433.         }
  434.  
  435.         public int SetBootConsoleID(string consoleID, IdType Type = 0)
  436.         {
  437.             if (consoleID.Length >= 0x20)
  438.             {
  439.                 consoleID.Substring(0, 0x20);
  440.             }
  441.             return this.SetBootConsoleID(StringToByteArray(consoleID), Type);
  442.         }
  443.  
  444.         public int SetBootConsoleID(byte[] consoleID, IdType Type = 0)
  445.         {
  446.             return this.setBootConsoleIds((int) Type, 1, consoleID);
  447.         }
  448.  
  449.         public int SetConsoleID(string consoleID)
  450.         {
  451.             if (string.IsNullOrEmpty(consoleID))
  452.             {
  453.                 MessageBox.Show("Cannot send an empty value", "Empty or null console id", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  454.                 return -1;
  455.             }
  456.             string hex = string.Empty;
  457.             if (consoleID.Length >= 0x20)
  458.             {
  459.                 hex = consoleID.Substring(0, 0x20);
  460.             }
  461.             return this.SetConsoleID(StringToByteArray(hex));
  462.         }
  463.  
  464.         public int SetConsoleID(byte[] consoleID)
  465.         {
  466.             if (consoleID.Length <= 0)
  467.             {
  468.                 MessageBox.Show("Cannot send an empty value", "Empty or null console id", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  469.                 return -1;
  470.             }
  471.             return this.setConsoleIds(0, consoleID);
  472.         }
  473.  
  474.         public int SetConsoleLed(LedColor color, LedMode mode)
  475.         {
  476.             return this.setConsoleLed((int) color, (int) mode);
  477.         }
  478.  
  479.         public int SetMemory(uint offset, byte[] buffer)
  480.         {
  481.             return this.setProcessMemory(System.processID, (ulong) offset, (uint) buffer.Length, buffer);
  482.         }
  483.  
  484.         public int SetMemory(ulong offset, byte[] buffer)
  485.         {
  486.             return this.setProcessMemory(System.processID, offset, (uint) buffer.Length, buffer);
  487.         }
  488.  
  489.         public int SetMemory(ulong offset, string hexadecimal, EndianType Type = EndianType.LittleEndian)
  490.         {
  491.             byte[] array = StringToByteArray(hexadecimal);
  492.             if (Type == EndianType.LittleEndian)
  493.             {
  494.                 Array.Reverse(array);
  495.             }
  496.             return this.setProcessMemory(System.processID, offset, (uint) array.Length, array);
  497.         }
  498.  
  499.         public int SetPSID(string PSID)
  500.         {
  501.             if (string.IsNullOrEmpty(PSID))
  502.             {
  503.                 MessageBox.Show("Cannot send an empty value", "Empty or null psid", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  504.                 return -1;
  505.             }
  506.             string hex = string.Empty;
  507.             if (PSID.Length >= 0x20)
  508.             {
  509.                 hex = PSID.Substring(0, 0x20);
  510.             }
  511.             return this.SetPSID(StringToByteArray(hex));
  512.         }
  513.  
  514.         public int SetPSID(byte[] consoleID)
  515.         {
  516.             if (consoleID.Length <= 0)
  517.             {
  518.                 MessageBox.Show("Cannot send an empty value", "Empty or null psid", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  519.                 return -1;
  520.             }
  521.             return this.setConsoleIds(1, consoleID);
  522.         }
  523.  
  524.         public int ShutDown(RebootFlags flag)
  525.         {
  526.             return this.shutdown((int) flag);
  527.         }
  528.  
  529.         internal static byte[] StringToByteArray(string hex)
  530.         {
  531.             try
  532.             {
  533.                 bool flag;
  534.                 Func<int, byte> selector = null;
  535.                 Func<int, byte> func2 = null;
  536.                 string replace = hex.Replace("0x", "");
  537.                 string Stringz = replace.Insert(replace.Length - 1, "0");
  538.                 if ((replace.Length % 2) == 0)
  539.                 {
  540.                     flag = true;
  541.                 }
  542.                 else
  543.                 {
  544.                     flag = false;
  545.                 }
  546.                 if (flag)
  547.                 {
  548.                     if (selector == null)
  549.                     {
  550.                         selector = x => Convert.ToByte(replace.Substring(x, 2), 0x10);
  551.                     }
  552.                     return (from x in Enumerable.Range(0, replace.Length)
  553.                         where (x % 2) == 0
  554.                         select x).Select<int, byte>(selector).ToArray<byte>();
  555.                 }
  556.                 if (func2 == null)
  557.                 {
  558.                     func2 = x => Convert.ToByte(Stringz.Substring(x, 2), 0x10);
  559.                 }
  560.                 return (from x in Enumerable.Range(0, replace.Length)
  561.                     where (x % 2) == 0
  562.                     select x).Select<int, byte>(func2).ToArray<byte>();
  563.             }
  564.             catch
  565.             {
  566.                 MessageBox.Show("Incorrect value (empty)", "StringToByteArray Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  567.                 return new byte[1];
  568.             }
  569.         }
  570.  
  571.         public bool SUCCESS(int Void)
  572.         {
  573.             return (Void == 0);
  574.         }
  575.  
  576.         public PS3Lib.Extension Extension
  577.         {
  578.             get
  579.             {
  580.                 return new PS3Lib.Extension(SelectAPI.ControlConsole);
  581.             }
  582.         }
  583.  
  584.         public enum BuzzerMode
  585.         {
  586.             Continuous,
  587.             Single,
  588.             Double
  589.         }
  590.  
  591.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  592.         private delegate int connectConsoleDelegate(string targetIP);
  593.  
  594.         public class ConsoleInfo
  595.         {
  596.             public string Ip;
  597.             public string Name;
  598.         }
  599.  
  600.         public enum ConsoleType
  601.         {
  602.             CEX = 1,
  603.             DEX = 2,
  604.             TOOL = 3
  605.         }
  606.  
  607.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  608.         private delegate int disconnectConsoleDelegate();
  609.  
  610.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  611.         private delegate int getConnectionStatusDelegate(ref int status);
  612.  
  613.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  614.         private delegate int getConsoleInfoDelegate(int index, IntPtr ptrN, IntPtr ptrI);
  615.  
  616.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  617.         private delegate int getDllVersionDelegate();
  618.  
  619.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  620.         private delegate int getFirmwareInfoDelegate(ref int firmware, ref int ccapi, ref int consoleType);
  621.  
  622.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  623.         private delegate int getNumberOfConsolesDelegate();
  624.  
  625.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  626.         private delegate int getProcessListDelegate(ref uint numberProcesses, IntPtr processIdPtr);
  627.  
  628.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  629.         private delegate int getProcessMemoryDelegate(uint processID, ulong offset, uint size, byte[] buffOut);
  630.  
  631.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  632.         private delegate int getProcessNameDelegate(uint processID, IntPtr strPtr);
  633.  
  634.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  635.         private delegate int getTemperatureDelegate(ref int cell, ref int rsx);
  636.  
  637.         public enum IdType
  638.         {
  639.             IDPS,
  640.             PSID
  641.         }
  642.  
  643.         public enum LedColor
  644.         {
  645.             Green = 1,
  646.             Red = 2
  647.         }
  648.  
  649.         public enum LedMode
  650.         {
  651.             Off,
  652.             On,
  653.             Blink
  654.         }
  655.  
  656.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  657.         private delegate int notifyDelegate(int mode, string msgWChar);
  658.  
  659.         public enum NotifyIcon
  660.         {
  661.             INFO,
  662.             CAUTION,
  663.             FRIEND,
  664.             SLIDER,
  665.             WRONGWAY,
  666.             DIALOG,
  667.             DIALOGSHADOW,
  668.             TEXT,
  669.             POINTER,
  670.             GRAB,
  671.             HAND,
  672.             PEN,
  673.             FINGER,
  674.             ARROW,
  675.             ARROWRIGHT,
  676.             PROGRESS,
  677.             TROPHY1,
  678.             TROPHY2,
  679.             TROPHY3,
  680.             TROPHY4
  681.         }
  682.  
  683.         public enum ProcessType
  684.         {
  685.             VSH,
  686.             SYS_AGENT,
  687.             CURRENTGAME
  688.         }
  689.  
  690.         public enum RebootFlags
  691.         {
  692.             HardReboot = 3,
  693.             ShutDown = 1,
  694.             SoftReboot = 2
  695.         }
  696.  
  697.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  698.         private delegate int ringBuzzerDelegate(int type);
  699.  
  700.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  701.         private delegate int setBootConsoleIdsDelegate(int idType, int on, byte[] ID);
  702.  
  703.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  704.         private delegate int setConsoleIdsDelegate(int idType, byte[] consoleID);
  705.  
  706.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  707.         private delegate int setConsoleLedDelegate(int color, int status);
  708.  
  709.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  710.         private delegate int setProcessMemoryDelegate(uint processID, ulong offset, uint size, byte[] buffIn);
  711.  
  712.         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  713.         private delegate int shutdownDelegate(int mode);
  714.  
  715.         private class System
  716.         {
  717.             public static int connectionID = -1;
  718.             public static uint processID = 0;
  719.             public static uint[] processIDs;
  720.         }
  721.  
  722.         public class TargetInfo
  723.         {
  724.             public int CCAPI;
  725.             public int ConsoleType;
  726.             public int Firmware;
  727.             public ulong SysTable;
  728.             public int TempCell;
  729.             public int TempRSX;
  730.         }
  731.     }
  732. }
Add Comment
Please, Sign In to add comment