Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

[V] Calling GTA V Natives XEX/C++


outlier
 Share

Recommended Posts

Hey guys and girls,

 

Sorry if this is not the correct section for this.

 

I started messing with GTA V a while back. I see the great native research thread by Alex and others was posted recently so I thought I'd get back and (try) finish my simple vehicle spawner.

 

Thanks to all the research already done and shared by others, I can see exactly what I was doing wrong before LOL...

 

I am basically trying to call 3 natives. CREATE_VEHICLE/0xDD75460A, PLAYER_PED_ID/0xDD75460A and GET_ENTITY_COORDS/0x1647F1CB. I have the locations of these functions (0x82D02D70, 0x82CA4C80 and 0x82C57270 respectively). PLAYER_PED_ID and GET_ENTITY_COORDS seem to be right because I am able to call them and they're returning seemingly correct values but the game crashes a few seconds later. Here's what my debug logs say:

Thread startedGTA V launchedD-Pad Up and Y button were pushedSuccessfully called PLAYER_PED_ID (2)Successfully called GET_ENTITY_COORDS (X: -686.525085, Y: -962.122314, Z: 20.057621)

My ped id is 2 (was playing in SP as Franklin) and the entity coords seem to be correct (AFAIK anyway lol). I've tried just calling each function and no matter which one I call, the game crashes back to FSD.

 

Assuming I have the correct memory locations, do I need to somehow hook into the default.xex thread and call myself from there perhaps? I was thinking it was some sort of thread access violation and I need to run as a child thread from the game's parent thread rather than my own thread from my own dll. I know how to do this in windows but not xdk. It seems docs for this stuff is non-existant (prolly a good thing) so I've been raking google for any clues for weeks now :O

 

Any help (guidance) would be much appreciated. I don't want to be spoon fed, just directed on the right path. I mod for the challenge and I'm not a 15 year old kid who will abuse this priviledge. My RGH is not even online so I am SP bound only. I really could use a car spawner in the game, it would be quite handy :)

 

Here's snippets of my code that I'm using:

//defstypedef unsigned int u32;struct Vector3{    float x, y, z;};//function prototypestypedef u32 (*NATIVE_CREATE_VEHICLE)(u32 vehicleHash, float X, float Y, float Z, float heading, bool createNetworkHandle, bool createVehHandle);typedef u32 (*NATIVE_PLAYER_PED_ID)(void);typedef Vector3 (*NATIVE_GET_ENTITY_COORDS)(u32 p, bool b);//function pointersNATIVE_CREATE_VEHICLE CREATE_VEHICLE = (NATIVE_CREATE_VEHICLE)0x82D02D70;NATIVE_PLAYER_PED_ID PLAYER_PED_ID = (NATIVE_PLAYER_PED_ID)0x82CA4C80;NATIVE_GET_ENTITY_COORDS GET_ENTITY_COORDS = (NATIVE_GET_ENTITY_COORDS)0x82C57270;//function useu32 ped = PLAYER_PED_ID();Vector3 pos = GET_ENTITY_COORDS(ped, 0);CREATE_VEHICLE(0xB779A091 /* adder */, pos.x, pos.y, pos.z, 0.0,  false, false);
Edited by outlier
Link to comment
Share on other sites

Alexander Blade

We are not doing console modding here , sorry :) As I said before in the main topic - you need to be inside the game's script engine , not just making calls

  • Like 2
Link to comment
Share on other sites

Since the TU17 update most functions cannot be called this way, as Alex said, you need to be inside the games script engine to do most things. You can do this by hooking the start of the virtual machine and patching 3 branches in the function that loads the natives. Afterward you need to remove the breakpoint and you'll be set.

Link to comment
Share on other sites

Since the TU17 update most functions cannot be called this way, as Alex said, you need to be inside the games script engine to do most things. You can do this by hooking the start of the virtual machine and patching 3 branches in the function that loads the natives. Afterward you need to remove the breakpoint and you'll be set.

Thanks! I am happy playing without any TU's :) Thanks again, it works great now.

Link to comment
Share on other sites

Since the TU17 update most functions cannot be called this way, as Alex said, you need to be inside the games script engine to do most things. You can do this by hooking the start of the virtual machine and patching 3 branches in the function that loads the natives. Afterward you need to remove the breakpoint and you'll be set.

Thanks! I am happy playing without any TU's :) Thanks again, it works great now.

Not a problem, back on TU0 I used this to get ped id.. (I wasn't using the VM, I was reversing the functions so they worked when called)

 

#define unsigned int uintuint PLAYER_PED_ID(){    uint val = (uint)ReadDword(0x83A14E04) + 4;    if (val == 0)        return Call(0x82DF0598);    return Call(0x82395A98, val);}
Link to comment
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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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