Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://brmodstudio.forumeiros.com/t4227-selecionar-cor-no-pay-n-spray#158995
- #define _CRT_SECURE_NO_WARNINGS
- #include <Windows.h>
- #include <injector\injector.hpp>
- #include <injector\assembly.hpp>
- #include <injector\calling.hpp>
- auto createPanel = &injector::cstd<int(unsigned char, const char**, float, float, float, unsigned char, char, char, char)>::call<0x582300>;
- auto getPlayerCWanted = &injector::cstd<int(int)>::call<0x56E230>;
- auto sub_5625A0 = &injector::thiscall<int(int)>::call<0x5625A0>;
- auto getPlayerVehicle = &injector::cstd<uint32_t(int, char)>::call<0x56E0D0>;
- auto CGarages__TriggerMessage = &injector::cstd<int(const char*, int16_t, int16_t, int16_t)>::call<0x447B80>;
- auto getPanelActiveRow = &injector::cstd<int(int)>::call<0x5807E0>;
- auto CMenuSystem__GetCarColourFromGrid = &injector::cstd<uint8_t(uint8_t, uint8_t)>::call<0x5822B0>;
- auto removePanel = &injector::cstd<uint8_t(uint8_t)>::call<0x580750>;
- auto CScriptThread__getPlayerKeyState = &injector::thiscall<uint16_t(void*, uint16_t, uint16_t)>::call<0x485B10>;
- int &playerMoney = *(int*)(0xB7CD98 + 0xB8);
- bool &CGarages__RespraysAreFree = *(bool*)0x96C009;
- auto CAudioEngine__ReportFrontendAudioEvent = &injector::thiscall<void(void*, int, float, float)>::call<0x506EA0>;
- unsigned int ¤tTime = *(unsigned int*)0xB7CB84;
- const char *panelWat[] = { "DUMMY", "DUMMY", "DUMMY", "DUMMY"};
- int myPanel = -1;
- void inject(){
- injector::MakeJMP(0x44AEC0 + 5, 0x44B3FF);
- injector::MakeNOP(0x44AE39, 13);
- injector::MakeNOP(0x44AE4A, 5);
- injector::MakeInline<0x44AEC0>([](injector::reg_pack& regs)
- {
- if (myPanel == -1){
- myPanel = createPanel(1, panelWat, 29.0, 145.0, 40.0, 8, 1, 1, 1);
- }
- int selectedColor = getPanelActiveRow(myPanel);
- /* Repair player's vehicle */
- uint32_t playersVeh = getPlayerVehicle(-1, 0);
- *(float*)(playersVeh + 0x4C0) = 1000.0;
- if (selectedColor >= 0 && CScriptThread__getPlayerKeyState(0, 0, 16)){
- bool pol = *(DWORD*)(getPlayerCWanted(-1) + 44) != 0;
- if (pol){
- sub_5625A0(getPlayerCWanted(-1));
- }
- // Primary color
- *(uint8_t*)(playersVeh + 0x434) = CMenuSystem__GetCarColourFromGrid(myPanel, selectedColor);
- // Dirt level
- *(uint8_t*)(playersVeh + 0x4B0) = 0;
- (*(void(__thiscall **)(int))(*(DWORD*)playersVeh + 200))(playersVeh);
- *(DWORD*)(playersVeh + 1216) = 1148846080;
- // Garage door
- *(uint8_t*)(regs.esi + 77) = 3;
- *(DWORD*)(regs.esi + 60) = currentTime + 2000;
- if (*(int8_t*)(regs.esi + 0x4E) > 0){
- if (CGarages__RespraysAreFree){
- CGarages__TriggerMessage((rand() & 1) ? "GA_15" : "GA_16", -1, 4000, -1);
- }
- else{
- CGarages__TriggerMessage(pol ? "GA_2" : "GA_XX", -1, 4000, -1);
- playerMoney -= 100;
- }
- }
- else{
- CGarages__TriggerMessage("GA_22", -1, 4000, -1);
- }
- removePanel(myPanel);
- myPanel = -1;
- CAudioEngine__ReportFrontendAudioEvent((void*)0xB6BC90, 16, 0.0, 1.0);
- }
- else if (CScriptThread__getPlayerKeyState(0, 0, 15)){
- // Garage door
- *(uint8_t*)(regs.esi + 77) = 3;
- *(DWORD*)(regs.esi + 60) = currentTime + 2000;
- removePanel(myPanel);
- myPanel = -1;
- }
- });
- }
- BOOL WINAPI DllMain(
- _In_ HINSTANCE hinstDLL,
- _In_ DWORD fdwReason,
- _In_ LPVOID lpvReserved
- ){
- if (fdwReason == DLL_PROCESS_ATTACH) inject();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement