Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (86,309 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Sign in to follow this  
Node

Changing pointer offsets

Recommended Posts

Node

Okay so I've got this C++ Console code for Vice City.

 

I'm trying to make my wanted level be 4 stars when I run this program.

 

Only problem is, I don't quite understand how to get to the 'Wanted counter' and increment it by 1200 (4 stars) - According to GTAmodding.

 

I tried manipulating the Gravity address and it worked since there was no offsets I had to go through to get to it.

 

Please forgive the utter mess you're about to see, I'm a beginner (The Title of this Topic probably doesn't even make sense suicidal.gif ):

 

 

#include <windows.h>#include <iostream>using namespace std;int main(){DWORD address = 0x94A5F4; //Ped PointerBYTE offset1 = 0x345; //Wanted PointerBYTE offset2 = 0x0; //Wanted Counter   BYTE newvalue[] = {1200}; //Four Wanted Stars   HWND hwnd;   HANDLE phandle;   DWORD pid;   hwnd = FindWindow(NULL, "GTA: Vice City");   if (hwnd != 0) {       GetWindowThreadProcessId(hwnd, &pid);       phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);   } else {       cout << "Could not find the window.";       cin.get();       return 0;   }   if (phandle != 0)   {       address = address + offset1 + offset2; //Thought adding them all up might do the trick but It didn't       WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 4, 0);       cout << "Memory wrote successfully.";       cin.get();   } else{       cout << "Couldn't get a handle";       cin.get();   }}

 

 

Any help would be greatly appreciated icon14.gif

Share this post


Link to post
Share on other sites
K^2

If I recall correctly, that 0x94A5F4 address isn't where the CPed structure is stored. It holds the pointer to that structure. In other words, that's where you should get the value for your address variable. Something along these lines should work.

 

 

ReadProcessMemory(phandle, (LPVOID)address, (LPVOID) &address, 4, 0);address = address + offset1 + offset2;WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 4, 0);

 

 

Basically, just adds one line of code to what you have already. I included the following two lines just for clarity. Try that, and call me in the morning.

 

 

Edit: Actually, wanted level is also an offset, you had wrong address values, and all of your BYTE values should be DWORD values. Here is the full working code.

 

 

#include <windows.h>#include <iostream>using namespace std;int main(){DWORD address = 0x94AD28; //Ped PointerDWORD offset1 = 0x5F4; //Wanted PointerDWORD offset2 = 0x0; //Wanted CounterDWORD newvalue[] = {1200}; //Four Wanted StarsHWND hwnd;HANDLE phandle;DWORD pid;hwnd = FindWindow(NULL, "GTA: Vice City");if (hwnd != 0){ GetWindowThreadProcessId(hwnd, &pid); phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);} else { cout << "Could not find the window."; cin.get(); return 0;}if (phandle != 0) { ReadProcessMemory(phandle, (LPVOID)address, (LPVOID) &address, 4, 0); cout << "New Address = " << address << "\n"; address = address + offset1; ReadProcessMemory(phandle, (LPVOID)address, (LPVOID) &address, 4, 0); cout << "New Address = " << address << "\n"; address = address + offset2; WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 4, 0); cout << "Memory wrote successfully."; cin.get();} else{ cout << "Couldn't get a handle"; cin.get();}}

 

Edited by K^2

Share this post


Link to post
Share on other sites
Node

Thanks K^2, I can't explain how much this helped me out.

 

I know it's just a simple process for someone with your knowledge but I really needed this clarifying, the tutorials on the internet aren't very good.

 

Thanks again! icon14.gifcookie.gifcookie.gifcookie.gif

Share this post


Link to post
Share on other sites
Node

I changed this code to work inside a .asi file:

 

 

#include <windows.h>#include <iostream>int main(){DWORD address = 0x94AD28; //Ped PointerDWORD offset1 = 0x5F4; //Wanted PointerDWORD offset2 = 0x0; //Wanted CounterDWORD newvalue[] = {1200}; //Four Wanted StarsHWND hwnd;HANDLE phandle = NULL;DWORD pid;hwnd = FindWindow(NULL, L"GTA: Vice City");if (hwnd != 0){ GetWindowThreadProcessId(hwnd, &pid); phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);} else {}if (phandle != 0) { ReadProcessMemory(phandle, (LPVOID)address, (LPVOID) &address, 4, 0); address = address + offset1; ReadProcessMemory(phandle, (LPVOID)address, (LPVOID) &address, 4, 0); address = address + offset2; WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 4, 0);} else{}}

 

 

The code compiled so I placed the .asi inside the Vice City folder, with no additional plugins since K^2 said asi's get loaded automatically with Vice City.

 

I started a new game but nothing happened.

All I've done is remove the console commands, the memory editing code is still there, still the same.

 

I did try to remove the window check since we know that Vice City will load it anyway but the memory code needs phandle.

 

EDIT: I also tried:

 

 

#include <windows.h>#include <iostream>int main(){DWORD address = 0x94AD28; //Ped PointerDWORD offset1 = 0x5F4; //Wanted PointerDWORD offset2 = 0x0; //Wanted CounterDWORD newvalue[] = {1200}; //Four Wanted StarsReadProcessMemory(GetCurrentProcess(), (LPVOID)address, (LPVOID) &address, 4, 0);address = address + offset1;ReadProcessMemory(GetCurrentProcess(), (LPVOID)address, (LPVOID) &address, 4, 0);address = address + offset2;WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, (LPVOID) &newvalue, 4, 0);return 0;}

 

 

 

Help appreciated, thanks icon14.gif

Edited by The_Sorrow

Share this post


Link to post
Share on other sites
Bad.boy!

An asi file is a renamed dll file. You're code is written like a separate application. You need to create an Dllmain function. This will make sure the dllmain function is execute on load and unload of the library. In the dllmain function you need to hook a game function somewhere, because you want to execute your code when the player is loaded. Then the code is executed automatically when the hooked function is called. Then you don't need to use "ReadProcessMemory" since you're code is executed in the process itself. So you'll have to force a new pointer on a certain memory address and then you can modify it.

 

Take a look at how Link2012 did this: http://www.gtaforums.com/index.php?showtopic=514465

Share this post


Link to post
Share on other sites
Node
An asi file is a renamed dll file. You're code is written like a separate application. You need to create an Dllmain function. This will make sure the dllmain function is execute on load and unload of the library. In the dllmain function you need to hook a game function somewhere, because you want to execute your code when the player is loaded. Then the code is executed automatically when the hooked function is called. Then you don't need to use "ReadProcessMemory" since you're code is executed in the process itself. So you'll have to force a new pointer on a certain memory address and then you can modify it.

 

Take a look at how Link2012 did this: http://www.gtaforums.com/index.php?showtopic=514465

Duh I totally forgot, thanks bad.boy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.