![]() ![]() |
![]() Post #1 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | So I created this topic for questions about plugins creating for GTA games. For this time I have some questions: How to assign the .exe preocedure to procedure which I use in my code? And also, how to assign the .exe adresses to the variables? And second - what to do with virtual protect when I want to change the value for memory adress? Which is not .data, but .text? Hoping ![]() |
![]() Post #2 | |
![]() Devil's Advocate ![]() Posts: 413 From: CA US Joined: 26-July 09 ![]() | Hey wait a minute... I thought I saw Deji and Silent viewing this topic. ![]() lol well sorry I can't help you out. I'm nubz at this. ![]() -------------------- ![]() |
![]() Post #3 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | Well, you might have to explain the question a bit more... I don't get whether you're trying to make an EXE or ASI, for starters. -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() Post #4 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | Ok, I want to create an dll in C++ builder. And I would wanna to know how to work with .exe procedures there, and with adresses also. At this time I use that scheme for creating dlls: CODE #include <windows.h> void Disable() { while(1) { Sleep(30); { __asm { mov dword ptr ds:[590C7Fh], 0x90909090 mov byte ptr ds:[590C83h], 0x90 } Sleep(60000); } } } #pragma argsused int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved) { if(reason==DLL_PROCESS_ATTACH) { CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Disable, 0, 0, 0); } return 1; } This post has been edited by DK22: Jul 26 2011, 12:09 PM |
![]() Post #5 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | That's a pretty demanding way of keeping the script running. I don't know much about multithreading to be honest but I still feel it would be better to overwrite an SA function call and call the replaced function or replace a function which is not useful. Be aware of where the function occurs in game processing, though. You can't write function addresses without first enabling virtual protect on the memory region. The function I use for patching function memory is: CODE // this define automatically typecasts everything for you when you use patch() #define patch(a, v, s) _patch((void*)(a), (DWORD)(v), (s)) // USAGE: patch(0x400000, 0x90909090, 4); void _patch(void* pAddress, DWORD data, DWORD iSize) { unsigned long dwProtect[2]; VirtualProtect(pAddress, iSize, PAGE_EXECUTE_READWRITE, &dwProtect[0]); switch(iSize) { case 1: *(BYTE*)pAddress = (BYTE)data; break; case 2: *(WORD*)pAddress = (WORD)data; break; case 4: *(DWORD*)pAddress = (DWORD)data; break; default: memset(pAddress, data, iSize); break; } VirtualProtect(pAddress, iSize, dwProtect[0], &dwProtect[1]); } A bit nooby, to be honest.. but it made it easier for me to transition from CLEO. Defining an EXE Function: CODE // Add to header void(__thiscall *SetMaxWantedLevel)(DWORD); // Add to code (untested) if(*(DWORD*)0x8A4004 == 0x8339CA || *(DWORD*)0x8A4004 == 0x833A0A) { // Game version: 1.0 SetMaxWantedLevel = (void(__thiscall*)(DWORD))0x561E70; } else { SetMaxWantedLevel = (void(__thiscall*)(DWORD))0x562310; } // USAGE: SetMaxWantedLevel(0); -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() Post #6 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | Thank you, but I can't compile it. I got a syntax error: "Undefined symbol 'void'" And also, I putted the "define" line near at the begin of code, and the function above the main function, was I right? (I'm about the "patch" function, the second one with wanted level I didn't test yet.) This post has been edited by DK22: Jul 26 2011, 08:19 PM |
![]() Post #7 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | I don't know why that would happen. Could you show your own code and tell me which line number has the error? -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() Post #8 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | Ahh, sorry for late reply... Here is code: CODE #include <windows.h> #define patch(a, v, s) _patch((void*)(a), (DWORD)(v), (s)) void DisableL() { while(1) { Sleep(30); { __asm { patch(0x590C7F, 0x90909090, 4); patch(0x590C83, 0x90, 1); } Sleep(60000); } } } void _patch(void* pAddress, DWORD data, DWORD iSize) { unsigned long dwProtect[2]; VirtualProtect(pAddress, iSize, PAGE_EXECUTE_READWRITE, &dwProtect[0]); switch(iSize) { case 1: *(BYTE*)pAddress = (BYTE)data; break; case 2: *(WORD*)pAddress = (WORD)data; break; case 4: *(DWORD*)pAddress = (DWORD)data; break; default: memset(pAddress, data, iSize); break; } VirtualProtect(pAddress, iSize, dwProtect[0], &dwProtect[1]); } #pragma argsused int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved) { if(reason==DLL_PROCESS_ATTACH) { CreateThread(0, 0, (LPTHREAD_START_ROUTINE)DisableL, 0, 0, 0); } return 1; } This post has been edited by DK22: Jul 31 2011, 09:06 PM |
![]() Post #9 | |
![]() The master of cut retort ![]() Posts: 239 From: Warsaw, PL Joined: 21-July 10 ![]() | I still can't see the point of making separate thread. Why not just patch it once? |
![]() Post #10 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | Hi, Silent. It will be good if you will posting an example (or something). Cause I'm newbie in this. |
![]() Post #11 | |
![]() The master of cut retort ![]() Posts: 239 From: Warsaw, PL Joined: 21-July 10 ![]() | You can just paste these patches in reason==DLL_PROCESS_ATTACH construct, it will works well. |
![]() Post #12 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | But can you please show me a full example of a code which just changes some .text-adress? Cause that one which I made won't compile. PS I have already made over 100 posts here, it's the 4th rate here ![]() This post has been edited by DK22: Aug 2 2011, 10:38 PM |
![]() Post #13 | |
![]() The master of cut retort ![]() Posts: 239 From: Warsaw, PL Joined: 21-July 10 ![]() | This code should compile fine, unless you screwed up something with project settings. CODE #include <windows.h> #include <stdio.h> #include <stdlib.h> BOOL APIENTRY DllMain(HMODULE, DWORD, LPVOID); void _patch(void*,DWORD,DWORD); BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) { if(reason==DLL_PROCESS_ATTACH) { patch(0x590C7F, 0x90909090, 4); patch(0x590C83, 0x90, 1); } return TRUE; } // patch() function here, too lazy to add it as I wrote whole code in Quick Reply window xO |
![]() Post #14 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | Thanx bro, now it works ![]() I'll back here later ![]() |
![]() Post #15 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | Is it right? ![]() CODE _asm { mov car_struct, esi mov RpClump, [car_struct+0x18] } if(RpClump<>0) { DamageManager = car_struct + 0x5A0; _asm { push 2 mov ecx, DamageManager mov eax, 0x6C2130 call eax mov Light_2_state, eax push 3 mov ecx, DamageManager mov eax, 0x6C2130 call eax mov Light_3_state, eax } !Light_2_state; !Light_3_state; } Could someone post here, how to make that CDamagerManager::getLightState in C++? I mean, attach it to .exe adress This post has been edited by DK22: Oct 30 2011, 06:57 AM |
![]() ![]() |