Advertisement
Fabio3rs

Selecionar cor no pay'n spray - Source

Sep 10th, 2014
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.33 KB | None | 0 0
  1. // http://brmodstudio.forumeiros.com/t4227-selecionar-cor-no-pay-n-spray#158995
  2.  
  3. #define _CRT_SECURE_NO_WARNINGS
  4. #include <Windows.h>
  5. #include <injector\injector.hpp>
  6. #include <injector\assembly.hpp>
  7. #include <injector\calling.hpp>
  8.  
  9. auto createPanel = &injector::cstd<int(unsigned char, const char**, float, float, float, unsigned char, char, char, char)>::call<0x582300>;
  10. auto getPlayerCWanted = &injector::cstd<int(int)>::call<0x56E230>;
  11. auto sub_5625A0 = &injector::thiscall<int(int)>::call<0x5625A0>;
  12. auto getPlayerVehicle = &injector::cstd<uint32_t(int, char)>::call<0x56E0D0>;
  13. auto CGarages__TriggerMessage = &injector::cstd<int(const char*, int16_t, int16_t, int16_t)>::call<0x447B80>;
  14. auto getPanelActiveRow = &injector::cstd<int(int)>::call<0x5807E0>;
  15. auto CMenuSystem__GetCarColourFromGrid = &injector::cstd<uint8_t(uint8_t, uint8_t)>::call<0x5822B0>;
  16. auto removePanel = &injector::cstd<uint8_t(uint8_t)>::call<0x580750>;
  17. auto CScriptThread__getPlayerKeyState = &injector::thiscall<uint16_t(void*, uint16_t, uint16_t)>::call<0x485B10>;
  18. int &playerMoney = *(int*)(0xB7CD98 + 0xB8);
  19. bool &CGarages__RespraysAreFree = *(bool*)0x96C009;
  20. auto CAudioEngine__ReportFrontendAudioEvent = &injector::thiscall<void(void*, int, float, float)>::call<0x506EA0>;
  21.  
  22. unsigned int &currentTime = *(unsigned int*)0xB7CB84;
  23.  
  24. const char *panelWat[] = { "DUMMY", "DUMMY", "DUMMY", "DUMMY"};
  25.  
  26. int myPanel = -1;
  27.  
  28. void inject(){
  29.     injector::MakeJMP(0x44AEC0 + 5, 0x44B3FF);
  30.    
  31.     injector::MakeNOP(0x44AE39, 13);
  32.     injector::MakeNOP(0x44AE4A, 5);
  33.  
  34.     injector::MakeInline<0x44AEC0>([](injector::reg_pack& regs)
  35.     {
  36.         if (myPanel == -1){
  37.             myPanel = createPanel(1, panelWat, 29.0, 145.0, 40.0, 8, 1, 1, 1);
  38.         }
  39.  
  40.         int selectedColor = getPanelActiveRow(myPanel);
  41.  
  42.         /* Repair player's vehicle */
  43.         uint32_t playersVeh = getPlayerVehicle(-1, 0);
  44.  
  45.         *(float*)(playersVeh + 0x4C0) = 1000.0;
  46.  
  47.         if (selectedColor >= 0 && CScriptThread__getPlayerKeyState(0, 0, 16)){
  48.             bool pol = *(DWORD*)(getPlayerCWanted(-1) + 44) != 0;
  49.  
  50.             if (pol){
  51.                 sub_5625A0(getPlayerCWanted(-1));
  52.             }
  53.  
  54.             // Primary color
  55.             *(uint8_t*)(playersVeh + 0x434) = CMenuSystem__GetCarColourFromGrid(myPanel, selectedColor);
  56.  
  57.             // Dirt level
  58.             *(uint8_t*)(playersVeh + 0x4B0) = 0;
  59.            
  60.             (*(void(__thiscall **)(int))(*(DWORD*)playersVeh + 200))(playersVeh);
  61.             *(DWORD*)(playersVeh + 1216) = 1148846080;
  62.  
  63.             // Garage door
  64.             *(uint8_t*)(regs.esi + 77) = 3;
  65.             *(DWORD*)(regs.esi + 60) = currentTime + 2000;
  66.  
  67.             if (*(int8_t*)(regs.esi + 0x4E) > 0){
  68.                 if (CGarages__RespraysAreFree){
  69.                     CGarages__TriggerMessage((rand() & 1) ? "GA_15" : "GA_16", -1, 4000, -1);
  70.                 }
  71.                 else{
  72.                     CGarages__TriggerMessage(pol ? "GA_2" : "GA_XX", -1, 4000, -1);
  73.                     playerMoney -= 100;
  74.                 }
  75.             }
  76.             else{
  77.                 CGarages__TriggerMessage("GA_22", -1, 4000, -1);
  78.             }
  79.  
  80.             removePanel(myPanel);
  81.             myPanel = -1;
  82.  
  83.             CAudioEngine__ReportFrontendAudioEvent((void*)0xB6BC90, 16, 0.0, 1.0);
  84.         }
  85.         else if (CScriptThread__getPlayerKeyState(0, 0, 15)){
  86.             // Garage door
  87.             *(uint8_t*)(regs.esi + 77) = 3;
  88.             *(DWORD*)(regs.esi + 60) = currentTime + 2000;
  89.  
  90.             removePanel(myPanel);
  91.             myPanel = -1;
  92.         }
  93.     });
  94. }
  95.  
  96. BOOL WINAPI DllMain(
  97.     _In_  HINSTANCE hinstDLL,
  98.     _In_  DWORD fdwReason,
  99.     _In_  LPVOID lpvReserved
  100.     ){
  101.     if (fdwReason == DLL_PROCESS_ATTACH) inject();
  102.  
  103.  
  104.     return true;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement