Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---- BEFORE ------------------------------------------------------------------------------------*/
- public CCAPI()
- {
- RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\FrenchModdingTeam\CCAPI\InstallFolder");
- if (key != null)
- {
- string str = key.GetValue("path") as string;
- if (!string.IsNullOrEmpty(str))
- {
- string path = str + @"\CCAPI.dll";
- if (File.Exists(path))
- {
- if (BitConverter.ToString(MD5.Create().ComputeHash(File.ReadAllBytes(path))).Replace("-", "").Equals(this.CCAPIHASH))
- {
- if (this.libModule == IntPtr.Zero)
- {
- this.libModule = LoadLibrary(path);
- }
- if (this.libModule != IntPtr.Zero)
- {
- this.connectConsole = (connectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIConnectConsole"), typeof(connectConsoleDelegate));
- this.disconnectConsole = (disconnectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIDisconnectConsole"), typeof(disconnectConsoleDelegate));
- this.getConnectionStatus = (getConnectionStatusDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConnectionStatus"), typeof(getConnectionStatusDelegate));
- this.getConsoleInfo = (getConsoleInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConsoleInfo"), typeof(getConsoleInfoDelegate));
- this.getDllVersion = (getDllVersionDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetDllVersion"), typeof(getDllVersionDelegate));
- this.getFirmwareInfo = (getFirmwareInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetFirmwareInfo"), typeof(getFirmwareInfoDelegate));
- this.getNumberOfConsoles = (getNumberOfConsolesDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetNumberOfConsoles"), typeof(getNumberOfConsolesDelegate));
- this.getProcessList = (getProcessListDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessList"), typeof(getProcessListDelegate));
- this.getProcessMemory = (getProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetMemory"), typeof(getProcessMemoryDelegate));
- this.getProcessName = (getProcessNameDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessName"), typeof(getProcessNameDelegate));
- this.getTemperature = (getTemperatureDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetTemperature"), typeof(getTemperatureDelegate));
- this.notify = (notifyDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIVshNotify"), typeof(notifyDelegate));
- this.ringBuzzer = (ringBuzzerDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIRingBuzzer"), typeof(ringBuzzerDelegate));
- this.setBootConsoleIds = (setBootConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetBootConsoleIds"), typeof(setBootConsoleIdsDelegate));
- this.setConsoleIds = (setConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleIds"), typeof(setConsoleIdsDelegate));
- this.setConsoleLed = (setConsoleLedDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleLed"), typeof(setConsoleLedDelegate));
- this.setProcessMemory = (setProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetMemory"), typeof(setProcessMemoryDelegate));
- this.shutdown = (shutdownDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIShutdown"), typeof(shutdownDelegate));
- }
- else
- {
- MessageBox.Show("Impossible to load CCAPI.dll version 2.60.", "CCAPI.dll cannot be load", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- }
- else
- {
- MessageBox.Show("You're not using the right CCAPI.dll please install the version 2.60.", "CCAPI.dll version incorrect", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- }
- else
- {
- MessageBox.Show("You need to install CCAPI to use this library.", "CCAPI.dll not found", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- }
- else
- {
- MessageBox.Show("Invalid CCAPI folder, please re-install it.", "CCAPI not installed", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- }
- else
- {
- MessageBox.Show("You need to install CCAPI to use this library.", "CCAPI not installed", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- }
- /*---- After ------------------------------------------------------------------------------------*/
- public class CCAPI
- {
- //private readonly string CCAPIHASH = "C2FE9E1C387CF29AAC781482C28ECF86"; Won't be needing this :P
- private connectConsoleDelegate connectConsole;
- private disconnectConsoleDelegate disconnectConsole;
- private getConnectionStatusDelegate getConnectionStatus;
- private getConsoleInfoDelegate getConsoleInfo;
- private getDllVersionDelegate getDllVersion;
- private getFirmwareInfoDelegate getFirmwareInfo;
- private getNumberOfConsolesDelegate getNumberOfConsoles;
- private getProcessListDelegate getProcessList;
- private getProcessMemoryDelegate getProcessMemory;
- private getProcessNameDelegate getProcessName;
- private getTemperatureDelegate getTemperature;
- private IntPtr libModule = (IntPtr)Convert.ToInt32("1751121920"); //Pointer to Function;//
- private notifyDelegate notify;
- private TargetInfo pInfo = new TargetInfo();
- private ringBuzzerDelegate ringBuzzer;
- private setBootConsoleIdsDelegate setBootConsoleIds;
- private setConsoleIdsDelegate setConsoleIds;
- private setConsoleLedDelegate setConsoleLed;
- private setProcessMemoryDelegate setProcessMemory;
- private shutdownDelegate shutdown;
- public string getCurrentDir()
- {
- string Dir;
- Dir = Directory.GetCurrentDirectory();
- return Dir;
- }
- public CCAPI()
- {
- string dapath = getCurrentDir() + @"\CCAPI.dll"; //This will get CCAPI 2.60 from your current Directory.
- if (File.Exists(getCurrentDir() + @"\CCAPI.dll"))
- {
- // IntPtr newP = (IntPtr)Convert.ToInt32("1751121920"); //This is the pointer that is used in the main functions of every call, such as loadlib.
- // credits: jandromeda @-http://www.experts-exchange.com/Programming/Languages/.NET/Q_23237956.html
- LoadLibrary(dapath); //This will load CCAPI from your currently directory
- this.connectConsole = (connectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIConnectConsole"), typeof(connectConsoleDelegate));
- this.disconnectConsole = (disconnectConsoleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIDisconnectConsole"), typeof(disconnectConsoleDelegate));
- this.getConnectionStatus = (getConnectionStatusDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConnectionStatus"), typeof(getConnectionStatusDelegate));
- this.getConsoleInfo = (getConsoleInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetConsoleInfo"), typeof(getConsoleInfoDelegate));
- this.getDllVersion = (getDllVersionDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetDllVersion"), typeof(getDllVersionDelegate));
- this.getFirmwareInfo = (getFirmwareInfoDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetFirmwareInfo"), typeof(getFirmwareInfoDelegate));
- this.getNumberOfConsoles = (getNumberOfConsolesDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetNumberOfConsoles"), typeof(getNumberOfConsolesDelegate));
- this.getProcessList = (getProcessListDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessList"), typeof(getProcessListDelegate));
- this.getProcessMemory = (getProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetMemory"), typeof(getProcessMemoryDelegate));
- this.getProcessName = (getProcessNameDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetProcessName"), typeof(getProcessNameDelegate));
- this.getTemperature = (getTemperatureDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIGetTemperature"), typeof(getTemperatureDelegate));
- this.notify = (notifyDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIVshNotify"), typeof(notifyDelegate));
- this.ringBuzzer = (ringBuzzerDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIRingBuzzer"), typeof(ringBuzzerDelegate));
- this.setBootConsoleIds = (setBootConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetBootConsoleIds"), typeof(setBootConsoleIdsDelegate));
- this.setConsoleIds = (setConsoleIdsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleIds"), typeof(setConsoleIdsDelegate));
- this.setConsoleLed = (setConsoleLedDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetConsoleLed"), typeof(setConsoleLedDelegate));
- this.setProcessMemory = (setProcessMemoryDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPISetMemory"), typeof(setProcessMemoryDelegate));
- this.shutdown = (shutdownDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(this.libModule, "CCAPIShutdown"), typeof(shutdownDelegate)); }
- else
- {
- MessageBox.Show("Failed to load CCAPI.dll version 2.60. Not In current Directory!", "CCAPI.dll doesn't exist!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- }
- /*---- #NotSecure ------------------------------------------------------------------------------------*/
- //BaSs_HaXoR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement