Advertisement
BaSs_HaXoR

C++ PS3LIB (ccapi 2.00 ONLY)(very buggy)

Sep 15th, 2014
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.76 KB | None | 0 0
  1. //CREDITS TO MILKY4444! :) <3
  2. //NOT FINISHED!!!!!!!!!!!!!!!!!!!!!
  3. //SOURCE: http://www.nextgenupdate.com/forums/showthread.php?t=763738&p=6037938#post6037938
  4.  
  5. //WORKING (NATIVE C++) NOTIFY: http://www.mediafire.com/download/s4pezozowvcwyz6/%5BPS3%5DC+++CLI+NOTIFY.rar
  6.  
  7. // ConsoleApplication40.cpp : Defines the entry point for the console application.
  8. //PS3 C++ CCAPI, CCAPI C++, CCAPI SOURCE, Call CCAPI from C++, DLLIMPORT CCAPI.dll, CCAPI.dll C++, PS3LIB C++, C++ PS3Lib,
  9. //Native PS3lib, ccapi from c++, ccapi C++ CLI, cli c++ ccapi.dll
  10. //#CCAPI, #DLL, #import, #PS3Lib, #Native, #PS3, #C++, #programming
  11. //BaSs_HaXoR, BaSs HaXoR, CODNoobFriendly
  12.  
  13. #include "stdafx.h"
  14. #include <Windows.h>
  15. #include <string>
  16. #include <iostream>
  17. typedef unsigned int uint;
  18. typedef unsigned long ulong;
  19. typedef unsigned long long ullong;
  20. typedef unsigned char byte;
  21. class CCAPIGlobalPointer
  22.         {
  23.         private:
  24.             void* _intPtr;
  25.  
  26.         public:
  27.              CCAPIGlobalPointer(void* intPtr)
  28.             {
  29.                 _intPtr = intPtr;
  30.             }
  31.              ~CCAPIGlobalPointer()
  32.              {
  33.                  free(_intPtr);
  34.              }
  35.             void* GetPtr()
  36.             {
  37.                 return _intPtr;
  38.             }
  39.         };
  40. enum ProcessType
  41.         {
  42.             VSH,
  43.             SYS_AGENT,
  44.             CURRENTGAME
  45.         };
  46.  enum NotifyIcon
  47.         {
  48.             INFO,
  49.             CAUTION,
  50.             FRIEND,
  51.             SLIDER,
  52.             WRONGWAY,
  53.             DIALOG,
  54.             DIALOGSHADOW,
  55.             TEXT,
  56.             POINTER,
  57.             GRAB,
  58.             HAND,
  59.             PEN,
  60.             FINGER,
  61.             ARROW,
  62.             ARROWRIGHT,
  63.             PROGRESS
  64.         };
  65. typedef class
  66. {
  67. public:
  68.     int connectionid;
  69.     uint ids;
  70.     uint processid;
  71.     uint processids[3];
  72. }sys;
  73. sys System;
  74. typedef class
  75. {
  76. public:
  77.     int connectionid;
  78.     uint ids;
  79.     uint processid;
  80.     uint* processids;
  81. }sys2;
  82. sys2 System2;
  83.  typedef struct
  84.         {
  85.             int Firmware;
  86.  
  87.             int CCAPI;
  88.  
  89.             int ConsoleType;
  90.  
  91.              int TempCell;
  92.  
  93.              int TempRSX;
  94.  
  95.              ulong SysTable;
  96.  
  97.         }TargetInfo;
  98.  TargetInfo CCAPI;
  99. #define RDFUB(T,uBuf,storage,out) storage = (T)uBuf; out = (void*)(long)sizeof(storage)
  100.  
  101.  typedef int (__cdecl* DllInfo)(void);
  102.  DllInfo DLLinfo = (DllInfo)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"getDllVersion");
  103.  
  104.  
  105.  
  106.  
  107.  
  108. /* BOOL APIENTRY DllMain(HMODULE hModule, DWORD EntryPoint, LPVOID ipReserved)
  109.  {
  110.      switch (DllMain(LoadLibrary(L"CCAPI.DLL"), char("_ZN5CcApi14connectConsoleEPKc"), "connectConsole"))
  111.      {
  112.      case DLL_PROCESS_ATTACH:
  113.          break;
  114.      case DLL_THREAD_ATTACH:
  115.          break;
  116.      case DLL_THREAD_DETACH:
  117.          break;
  118.      case DLL_PROCESS_DETACH:
  119.          break;
  120.      }
  121.      return TRUE;
  122.  }*/
  123. typedef int (__cdecl* Connectf)(const char*);
  124. Connectf Connect  = (Connectf)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"connectConsole");
  125.  
  126. BOOL APIENTRY DllMain(HANDLE hModule,
  127.     DWORD  EntryPoint,
  128.     LPVOID lpReserved
  129.     )
  130. {
  131.     return TRUE;
  132. }
  133.  
  134. typedef int(__cdecl* Connectfx)(const char*);
  135. Connectfx Connectx = (Connectfx)DllMain(LoadLibrary(L"CCAPI.DLL"), char("_ZN5CcApi14connectConsoleEPKc"), "connectConsole");
  136.  
  137.  
  138.  
  139. extern "C" __declspec(dllexport)void ConnectMe(const char*)
  140. {
  141.     typedef int(__cdecl* Connectf)(const char*);
  142.     Connectf Connect = (Connectf)DllMain(L"CCAPI.DLL", char("_ZN5CcApi14connectConsoleEPKc"), "connectConsole");
  143.     //DllMain(L"CCAPI.DLL", char("_ZN5CcApi14connectConsoleEPKc"), "connectConsole");
  144. };
  145.  
  146.  
  147.  
  148.  
  149.  
  150. typedef int (__cdecl* getProcessList)(int connectionID,uint& numberProcesses, void* processIdPtr);
  151. getProcessList GetProcList = (getProcessList)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"getProcessList");
  152. typedef int (__cdecl* getProcesslist)(int connectionID,uint& numberProcesses, uint*& processids);
  153. getProcesslist GetProcList_t = (getProcesslist)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"getProcessList");
  154. typedef int (__cdecl* GetProcN)(int connectionID, uint processID, void* name);
  155. GetProcN GetProcessName = (GetProcN)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"getProcessName");
  156. typedef int (__cdecl* GetProcn)(int connectionID, uint processID, char* name);
  157. GetProcn GetProcessName_t = (GetProcn)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"getProcessName");
  158. typedef int (__cdecl* setmem)(int cid,uint proc,ullong  address,uint size,byte* input);
  159. setmem SetMemory = (setmem)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"setProcessMemory");
  160. typedef int (__cdecl* initTargetCommsF)(void);
  161. initTargetCommsF initTargetComms = (initTargetCommsF)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"initTargetComms");
  162. typedef int (__cdecl* GetFWI)(int connectionID,int& fw,int& ccapi,ulong& systable,int& cType);
  163. GetFWI GetFirmwareInfo = (GetFWI)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"getFirmwareInfo");
  164. typedef int (__cdecl* Gettemp)(int connectionId, void* tempPtr);
  165. Gettemp GetTempInfo = (Gettemp)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"getTemperature");
  166. typedef int (__cdecl* notifyF)(int cid, int icon, wchar_t * msg);
  167. notifyF notify = (notifyF)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"notify");
  168. int GetTargInfo(TargetInfo& targinfo)
  169. {
  170.     int buff[2];
  171.     int fw = 0;
  172.     int ccapi = 0;
  173.     int ctype = 0;
  174.     ulong table = 0;
  175.     int fwi = GetFirmwareInfo(System.connectionid,fw,ccapi,table,ctype);
  176.     if(fwi >= 0)
  177.     {
  178.         CCAPIGlobalPointer cCAPIGlobalPointer = new CCAPIGlobalPointer(malloc(8));
  179.         fwi = GetTempInfo(System.connectionid,cCAPIGlobalPointer.GetPtr());
  180.         if(fwi >= 0)
  181.         {
  182.             void* ptr;
  183.              for (uint i = 0; i < 2; i++)
  184.              {
  185.                  RDFUB(int,cCAPIGlobalPointer.GetPtr(),buff[i],ptr);
  186.              }
  187.              targinfo.CCAPI = ccapi;
  188.              targinfo.ConsoleType = ctype;
  189.              targinfo.Firmware = fw;
  190.              targinfo.SysTable = table;
  191.              targinfo.TempCell = buff[0];
  192.              targinfo.TempRSX = buff[1];
  193.         }
  194.     }
  195.     return fwi;
  196. }
  197. uint ids = 0;
  198. uint* idz;
  199. int Attach()
  200. {
  201.     CCAPIGlobalPointer cCAPIGlobalPointer = new CCAPIGlobalPointer((void*)256);
  202.    
  203.     int procL = GetProcList(System.connectionid,ids, cCAPIGlobalPointer.GetPtr());
  204.     void* ptr = cCAPIGlobalPointer.GetPtr();
  205.     for(int i = 0; i < ids;i++)
  206.     {
  207.         System.processids[i] = (uint)ptr;
  208.         void*buff = (void*)(long)sizeof(System.processids[i]);
  209.     }
  210.     int count = 0;
  211.     const char* namec;
  212.     while(count < sizeof(System.processids[count]))
  213.     {
  214.         void* buff = (void*)529;
  215.         int pn = GetProcessName(System.connectionid,System.processids[count],buff);
  216.         namec = (const char*)buff;
  217.         std::string sBuff (namec,std::strlen(namec));
  218.         if (sBuff.find("flash"))
  219.         {
  220.             System.processid = -1;
  221.             count++;
  222.         }
  223.         else
  224.         {
  225.             System.processid = System.processids[count];
  226.             break;
  227.         }
  228.     }
  229.     if(System.processid == 0)
  230.     {
  231.         System.processid = System.processids[sizeof(System.processids) -1];
  232.     }
  233.     return procL;
  234. }
  235. int attach_t()
  236. {
  237.     CCAPIGlobalPointer cCAPIGlobalPointer = new CCAPIGlobalPointer((void*)256);
  238.     uint ids = 0;
  239.     int procL = GetProcList(System.connectionid,ids, cCAPIGlobalPointer.GetPtr());
  240.     //System.processid =
  241.     return 0;
  242. }
  243. int Attach_Game(ProcessType proctype)
  244. {
  245.     CCAPIGlobalPointer cCAPIGlobalPointer = new CCAPIGlobalPointer(malloc(256));
  246.     void* ptr = cCAPIGlobalPointer.GetPtr();
  247.     uint ids = 0;
  248.     int procL = GetProcList(System.connectionid,ids, ptr);
  249.     for(int i = 0; i < ids;i++)
  250.     {
  251.         System.processids[i] = (uint)ptr;
  252.         void*buff = (void*)(long)sizeof(System.processids[i]);
  253.     }
  254.     //  void*buff = (void*)(long)sizeof(System.processids[i]);
  255.     int count = 0;
  256.     const char* namec;
  257.     while(count < sizeof(System.processids[count]))
  258.     {
  259.         void* buff = malloc(529);
  260.         int pn = GetProcessName(System.connectionid,System.processids[count],buff);
  261.         namec = (const char*)buff;
  262.         std::string sBuff (namec,std::strlen(namec));
  263.         if(proctype == ProcessType::VSH && sBuff.find("vsh"))
  264.         {
  265.             System.processid = System.processids[count];
  266.             break;
  267.         }
  268.         if(proctype == ProcessType::SYS_AGENT && sBuff.find("agent"))
  269.         {
  270.             System.processid = System.processids[count];
  271.             break;
  272.         }
  273.         else if (proctype != ProcessType::CURRENTGAME || sBuff.find("flash"))
  274.         {
  275.             count++;
  276.         }
  277.         else
  278.         {
  279.            
  280.             break;
  281.         }
  282.     }
  283.     System.processid = System.processids[count];
  284.         if(System.processid == 0)
  285.     {
  286.         uint buffer = std::end(System.processids) - std::begin(System.processids);
  287.  
  288.         System.processid = System.processids[(int)buffer -1];
  289.     }
  290.     return 0;
  291. }
  292. int Attach_Game_t(ProcessType proctype)
  293. {
  294.     int procL = GetProcList_t(System.connectionid,ids,System2.processids);
  295.     int count = 0;
  296.     System.processid = System2.processids[2];
  297.     /*while(count < sizeof(System.processids[count]))
  298.     {
  299.         char* namec[3];
  300.         int pn = GetProcessName_t(System.connectionid,System2.processids[count],namec[count]);
  301.         std::string sBuff (namec[count],std::strlen(namec[count]));
  302.         if(proctype == ProcessType::VSH && sBuff.find("vsh"))
  303.         {
  304.             System.processid = System.processids[count];
  305.             break;
  306.         }
  307.         if(proctype == ProcessType::SYS_AGENT && sBuff.find("agent"))
  308.         {
  309.             System.processid = System.processids[count];
  310.             break;
  311.         }
  312.         else if (proctype != ProcessType::CURRENTGAME || sBuff.find("flash"))
  313.         {
  314.             count++;
  315.         }
  316.         else
  317.         {
  318.             System.processid = System.processids[count];
  319.             break;
  320.         }
  321.     }
  322.         if(System.processid == 0)
  323.     {
  324.         uint buffer = std::end(System.processids) - std::begin(System.processids);
  325.  
  326.         System.processid = System.processids[(int)buffer -1];
  327.     }
  328.    
  329.     */return procL;
  330. }
  331. int _tmain(int argc, _TCHAR* argv[])
  332. {  
  333.     std::string ip = "";
  334.     std::cout<<"enter ip:\n";
  335.     std::cin>>ip;
  336.     initTargetComms();
  337.     //System.connectionid = ConnectMe(ip.c_str());
  338.     System.connectionid = Connect(ip.c_str());
  339.     notify(System.connectionid, NotifyIcon::INFO, L"Connected to: ");
  340.     Attach_Game(ProcessType::CURRENTGAME);
  341.     std::cout<<System.connectionid<<std::endl<<System.processid<<std::endl;
  342.     byte b[1] = {0xFF};
  343.     SetMemory(System.connectionid,0x1030600,(ullong)0x2100000,1,b);
  344.     system("pause");
  345.     return 0;
  346. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement