Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

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

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

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

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

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. 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. 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. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
outlier

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

Recommended Posts

outlier

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
sasuke78200

Remebering that you shouldn't call game's functions in an other thread.

Share this post


Link to post
Share on other sites
XeClutch

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.

Share this post


Link to post
Share on other sites
outlier

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.

Share this post


Link to post
Share on other sites
XeClutch

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);}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 3 Users Currently Viewing
    0 members, 0 Anonymous, 3 Guests

×
×
  • Create New...

Important Information

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