Advertisement
BaSs_HaXoR

PS3TMAPI C++ Library (100% Working) *UPDATED

Nov 9th, 2014
1,550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.13 KB | None | 0 0
  1. // PS3.h
  2. //Updated and fixed code: 11-18-14
  3.  
  4. /*Credits: Me - BaSs_HaXoR, for coding this library, BadLuckBrian for his conversion and I/O methods, Milky4444 for helping me understand ProcessID (PID) and get it working.
  5.  
  6. RELATED LINKS:
  7. http://www.nextgenupdate.com/forums/ps3-cheats-customization/709164-tut-how-use-ps3tmapi-dll-c-win32-clr-post5629749.html
  8. http://www.mediafire.com/view/l7irme6pkrhk1i1/SNPS3.h
  9. http://www.se7ensins.com/forums/threads/release-development-application-ps3tmapi_net-dll-c-c-vb-net.883290/?jdfwkey=0f1qw1
  10. http://www.nextgenupdate.com/forums/ps3-cheats-customization/634548-release-development-application-ps3tmapi_net-dll-c-c-vb-net-10.html
  11. http://pastebin.com/9LnzYZtS
  12. http://pastebin.com/8wq3ywnh //THANKS TO BLB
  13. */
  14.   /*
  15.   /$$$$$$                  /$$                 /$$       /$$$$$$$              
  16.  /$$__  $$                | $$                | $$      | $$__  $$              
  17. | $$  \__/  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$      | $$  \ $$ /$$   /$$ /$$
  18. | $$       /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$      | $$$$$$$ | $$  | $$|__/
  19. | $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  | $$      | $$__  $$| $$  | $$    
  20. | $$    $$| $$  | $$| $$  | $$| $$_____/| $$  | $$      | $$  \ $$| $$  | $$ /$$
  21. |  $$$$$$/|  $$$$$$/|  $$$$$$$|  $$$$$$$|  $$$$$$$      | $$$$$$$/|  $$$$$$$|__/
  22.  \______/  \______/  \_______/ \_______/ \_______/      |_______/  \____  $$    
  23.                                                                    /$$  | $$    
  24.                                                                   |  $$$$$$/    
  25.                                                                    \______/    
  26. Yeaboii BaSs_HaXoR
  27.  
  28. Yb        dP 8           w      .d88b.                       w  w          dP"Yb
  29.  Yb  db  dP  8d8b. .d88 w8ww    YPwww. .d88b .d8b 8   8 8d8b w w8ww Yb  dP "  d8
  30.   YbdPYbdP   8P Y8 8  8  8          d8 8.dP' 8    8b d8 8P   8  8    YbdP    dP  
  31.    YP  YP    8   8 `Y88  Y8P    `Y88P' `Y88P `Y8P `Y8P8 8    8  Y8P   dP     w  
  32.                                                                      dP      x  
  33.      */
  34.  
  35.  
  36. #pragma once
  37. #include <iostream>
  38. #include <Windows.h>
  39. #include "C:\Program Files (x86)\SN Systems\PS3\sdk\include\ps3tmapi.h"
  40.  
  41.  
  42. /*
  43. IN YOUR PROJECT SETTINGS! ADD THESE:
  44. C/C++/Additional Include Directories/-> C:\Program Files (x86)\SN Systems\PS3\sdk\include\
  45. Linker/Input/Additional Dependencies/-> C:\Program Files (x86)\SN Systems\PS3\sdk\lib\PS3TMAPI.lib
  46. Linker/Input/Additional Dependencies/-> C:\Program Files (x86)\SN Systems\PS3\sdk\lib\PS3TMAPIx64.lib
  47. */
  48.  
  49.  
  50. int target=0xfffffffe; //target default
  51. unsigned int pid; //This is a decimal value of your ProcessID, Convert to HEX if to see (Thanks to Milky4444 for clearing that up)
  52. using namespace System;
  53. namespace PS3 {
  54.  
  55.     public ref class PS3TMAPI
  56.     {
  57.     public: void Connect()
  58.             {
  59.                 SNPS3InitTargetComms();
  60.                 SNPS3Connect(target, NULL);
  61.     }
  62.     public: void Attach()
  63.             {
  64.                 SNPS3InitTargetComms();
  65.                 SNPS3Connect(target,NULL);
  66.                 unsigned int pCount[32];
  67.                 SNPS3InitTargetComms();
  68.                 SNPS3ProcessList(target,pCount,&pid);
  69.                 SNPS3ProcessAttach(target,0,pid);
  70.                 SNPS3ProcessContinue(target,pid);
  71.             }
  72.     public: void writestring(UINT32 Address, std::string text)
  73.         {
  74.                 SNPS3InitTargetComms();
  75.                 SetMemory(Address, (BYTE*)text.c_str(), text.length() + 1);
  76.         }
  77.     public: void SetMemory(UINT32 Address, BYTE *bytes, int sizeOfArray)
  78.         {
  79.                 SNPS3InitTargetComms();
  80.                 SNPS3ProcessSetMemory(target, 0, pid, 0, Address, sizeOfArray, bytes);
  81.         }
  82.     public: BYTE* GetMemory(UINT32 Address, INT32 Length)
  83.         {
  84.                 SNPS3InitTargetComms();
  85.                 BYTE* ret = new BYTE[Length];
  86.                 SNPS3ProcessGetMemory(target, 0, pid, 0, Address, Length, ret);
  87.                 return ret;
  88.         }
  89.     public: void writeByte(UINT32 Address, BYTE input)
  90.         {
  91.             SNPS3InitTargetComms();
  92.                 BYTE bytes[] = { input };
  93.                 SetMemory(Address, bytes, 1);
  94.         }
  95.     public: void writeBool(UINT32 Address, bool input)
  96.         {
  97.             SNPS3InitTargetComms();
  98.                 BYTE bytes[] = { input };
  99.                 bytes[0] = input ? (BYTE)1 : (BYTE)0;
  100.                 SetMemory(Address, bytes, 1);
  101.         }
  102.     public: BYTE readByte(UINT32 Address)
  103.         {
  104.             SNPS3InitTargetComms();
  105.                 return (BYTE)GetMemory(Address, 1)[0];
  106.         }
  107.     public: char* ReadString(UINT32 Address)
  108.         {
  109.             SNPS3InitTargetComms();
  110.                 int i = 0;
  111.                 while (PS3::PS3TMAPI::readByte(Address + i) != 0x00){ i++; }
  112.                 i++;//null terminate
  113.                 return (char*)PS3::PS3TMAPI::GetMemory(Address, i);
  114.         }
  115.     public: bool readBool(UINT32 Address)
  116.         {
  117.             SNPS3InitTargetComms();
  118.                 return GetMemory(Address, 1)[0] != 0;
  119.         }
  120.     public: INT16 readShort(UINT32 Address)
  121.         {
  122.             SNPS3InitTargetComms();
  123.                 BYTE* read = GetMemory(Address, 2);
  124.                 std::reverse(read, read + 2);
  125.                 return *(INT16*)read;
  126.         }
  127.     public: INT32 readInt(UINT32 Address)
  128.         {
  129.             SNPS3InitTargetComms();
  130.                 BYTE* read = GetMemory(Address, 4);
  131.                 std::reverse(read, read + 4);
  132.                 return *(INT32*)read;
  133.         }
  134.     public: INT64 readInt64(UINT64 Address)
  135.         {
  136.             SNPS3InitTargetComms();
  137.                 BYTE* read = GetMemory(Address, 8);
  138.                 std::reverse(read, read + 8);
  139.                 return *(INT64*)read;
  140.         }
  141.     public: UINT16 readUShort(UINT32 Address)
  142.         {
  143.             SNPS3InitTargetComms();
  144.                 BYTE* read = GetMemory(Address, 2);
  145.                 std::reverse(read, read + 2);
  146.                 return *(UINT16*)read;
  147.         }
  148.     public: UINT32 readUInt(UINT32 Address)
  149.         {
  150.             SNPS3InitTargetComms();
  151.                 BYTE* read = GetMemory(Address, 4);
  152.                 std::reverse(read, read + 4);
  153.                 return *(UINT32*)read;
  154.         }
  155.     public: UINT64 readUInt64(UINT32 Address)
  156.         {
  157.             SNPS3InitTargetComms();
  158.                 BYTE* read = GetMemory(Address, 8);
  159.                 std::reverse(read, read + 8);
  160.                 return *(UINT64*)read;
  161.         }
  162.     public: FLOAT readFloat(UINT32 Address)
  163.         {
  164.             SNPS3InitTargetComms();
  165.                 BYTE* read = GetMemory(Address, 4);
  166.                 std::reverse(read, read + 4);
  167.                 return *(FLOAT*)read;
  168.         }
  169.     public: DOUBLE readDouble(UINT32 Address)
  170.         {
  171.             SNPS3InitTargetComms();
  172.                 BYTE* read = GetMemory(Address, 8);
  173.                 std::reverse(read, read + 8);
  174.                 return *(DOUBLE*)read;
  175.         }
  176.     public: bool cmpArray(BYTE* a, BYTE* b, INT32 ArrayLength)
  177.         {
  178.             SNPS3InitTargetComms();
  179.                 INT32 CheckArray = 0;
  180.                 for (INT32 i = 0; i < ArrayLength; i++)
  181.                         if (a[i] == b[i])
  182.                                 CheckArray++;
  183.                 return CheckArray == ArrayLength;
  184.         }
  185.     public: void writeShort(UINT32 Address, INT16 input)
  186.         {
  187.             SNPS3InitTargetComms();
  188.                 BYTE bytes[2];
  189.                 *(INT16*)bytes = input;
  190.                 std::reverse(bytes, bytes + 2);
  191.                 SetMemory(Address, bytes, 2);
  192.         }
  193.     public: void writeInt(UINT32 Address, INT32 input)
  194.         {
  195.             SNPS3InitTargetComms();
  196.                 BYTE bytes[4];
  197.                 *(INT32*)bytes = input;
  198.                 std::reverse(bytes, bytes + 4);
  199.                 SetMemory(Address, bytes, 4);
  200.         }
  201.     public: void writeInt64(UINT32 Address, INT64 input)
  202.         {
  203.             SNPS3InitTargetComms();
  204.                 BYTE bytes[8];
  205.                 *(INT64*)bytes = input;
  206.                 std::reverse(bytes, bytes + 8);
  207.                 SetMemory(Address, bytes, 8);
  208.         }
  209.     public: void writeUShort(UINT32 Address, UINT16 input)
  210.         {
  211.             SNPS3InitTargetComms();
  212.                 BYTE bytes[2];
  213.                 *(UINT16*)bytes = input;
  214.                 std::reverse(bytes, bytes + 2);
  215.                 SetMemory(Address, bytes, 2);
  216.         }
  217.     public: void writeUInt(UINT32 Address, UINT32 input)
  218.         {
  219.             SNPS3InitTargetComms();
  220.                 BYTE bytes[4];
  221.                 *(UINT32*)bytes = input;
  222.                 std::reverse(bytes, bytes + 4);
  223.                 SetMemory(Address, bytes, 4);
  224.         }
  225.     public: void writeUInt64(UINT32 Address, UINT64 input)
  226.         {
  227.             SNPS3InitTargetComms();
  228.                 BYTE bytes[8];
  229.                 *(UINT64*)bytes = input;
  230.                 std::reverse(bytes, bytes + 8);
  231.                 SetMemory(Address, bytes, 8);
  232.         }
  233.     public: void writeFloat(UINT32 Address, float input)
  234.         {
  235.             SNPS3InitTargetComms();
  236.                 BYTE bytes[4];
  237.                 *(float*)bytes = input;
  238.                 std::reverse(bytes, bytes + 4);
  239.                 SetMemory(Address, bytes, 4);
  240.         }
  241.     public: void writeDouble(UINT32 Address, DOUBLE input)
  242.         {
  243.             SNPS3InitTargetComms();
  244.                 BYTE bytes[8];
  245.                 *(DOUBLE*)bytes = input;
  246.                 std::reverse(bytes, bytes + 8);
  247.                 SetMemory(Address, bytes, 8);
  248.         }
  249.     };
  250. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement