Advertisement
Guest User

code

a guest
Feb 19th, 2017
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.38 KB | None | 0 0
  1. void MainThread(uint64_t arg)
  2. {
  3.     int GameProcessID = 0, lastGameProcessID = 0;
  4.  
  5.  
  6.     while (true)
  7.     {
  8.         if (GetGameRunningFlag() == 1)
  9.         {
  10.             GameProcessID = GetGameProcessID();
  11.             if (GameProcessID != 0)
  12.             {
  13.                 if (GameProcessID != lastGameProcessID)
  14.                 {
  15.                     for (int x = 0; x < (10 * 100); x++) //10 second delay
  16.                     {
  17.                         sys_timer_usleep(10000);
  18.                         sys_ppu_thread_yield();
  19.                     }
  20.  
  21.                     if (create_ingameThread)
  22.                     {
  23.                         _printf("init_ingame\n");
  24.                         sys_ppu_thread_t id;
  25.                         sys_ppu_thread_create(&id, init_ingame, 0, 3000, 0x2000, 0, "init_ingame");
  26.                         create_ingameThread = 0;
  27.                     }
  28.  
  29.                 }
  30.             }
  31.         }
  32.         sys_timer_usleep(100 * 1000); //0.1 second delay
  33.     }
  34.     lastGameProcessID = GameProcessID;
  35.  
  36.  
  37.     //sys_timer_usleep(1668);
  38.     //sys_ppu_thread_yield();
  39.     //sys_ppu_thread_exit(0);
  40. }
  41.  
  42. BOOL __cdecl GTAHOOK()
  43. {
  44.     _printf("GTAHOOK() sucess\n");
  45.     return 1;
  46. }
  47.  
  48. void ScriptMain(uint64_t arg)
  49. {
  50.     _printf("GTA Thread Created\n");
  51.     sleep(8000);
  52.     XNotifyUI("WELCOME TO SUCCESSFUL!!!");
  53.     sleep(30000);
  54.  
  55.  
  56.     //writing into mem
  57.     //works
  58.     //SET_CHEAT(0x3F8B84, 1);
  59.     //crashes
  60.     //*(char *)(0x3F8B84) = 60000000;
  61.  
  62.  
  63.     //hooking
  64.     //crashes
  65.     //PatchInJump(0x3E3A20, (int)GTAHOOK, false);
  66. }
  67.  
  68. char *lastGameID = 0, *GameID = 0;
  69. bool createGTAThread = 1;
  70.  
  71. void init_ingame(uint64_t ulParameter)
  72. {
  73.     _printf("in ingame_client\n");
  74.     sleep(38000);
  75.     while (true)
  76.     {
  77.         //to do;
  78.         //fix GameID, when switching games. make it reset
  79.  
  80.         GameID = GetGameID();
  81.         //is GTA
  82.         if (!strcmp(GameID, "BLES01807"))
  83.         {
  84.             _printf("in GTA\n");
  85.            
  86.             sleep(8000);
  87.             LoadGameProcessID = GetGameProcessID();
  88.             sleep(30000);
  89.             if (createGTAThread)
  90.             {
  91.                 //hook into the game preccess
  92.                 //PatchInJump(LoadGameProcessID, (int)GTAHOOK, false);
  93.                 //PatchInJump(0x3E3A20, (int)GTAHOOK, false);
  94.                 sys_ppu_thread_t g_thread_id;
  95.                 sys_ppu_thread_create(&g_thread_id, ScriptMain, 0, 300, 0x2000, SYS_PPU_THREAD_CREATE_JOINABLE, "GTA THREAD");
  96.                 createGTAThread = 0;
  97.             }
  98.         }
  99.  
  100.         //is BO2
  101.         if (!strcmp(GameID, "BLUS31011") || !strcmp(GameID, "BLES01717") || !strcmp(GameID, "BLES01718") || !strcmp(GameID, "BLES01719") || !strcmp(GameID, "BLES01720"))
  102.         {
  103.             _printf("in BO2\n");
  104.         }
  105.  
  106.         //RDR
  107.         if (!strcmp(GameID, "BLES01294"))
  108.         {
  109.             _printf("in RDR\n");
  110.         }
  111.  
  112.         sys_timer_usleep(100 * 1000); //0.1 second delay
  113.     }
  114.  
  115.     lastGameID = GameID;
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement