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.

[ C++ ] Calling functions of gta v


buridan
 Share

Recommended Posts

Flying Scotsman

Well, to start you aren't using the scripthook which, as the name suggests, 'hooks' onto the game's script thread and passes it commands. You're just pushing code into the game when the DLL is first injected + attached which is doing nothing in this instance (you're basically injecting a string with a type. The game doesn't know what you're doing and it's never executed as a result). You should also have just told it to run main() or some other function/method instead of putting your code directly into the attach statement (good programming practice!) but that won't be executed either without some form of thread being told to execute it.

 

Secondly you aren't using a native invoker so the game doesn't know what you're doing, so even if you had a hook - it doesn't know what those natives are because you aren't calling the invoker, which means any natives you do manage to execute somehow, will never actually be executed because the invoker is never used.

 

Thirdly those aren't addresses for the natives - they're hashes. You can't call natives via hash. The first long string is the hash of the "original native" (as in day 1 game release) which the scripthook 'maps' onto the most recent native hash (otherwise known as a "crosshashmap" because it crosses the original native hash with the most recent one so it can be called).

 

Why aren't you just using A.B's scripthook dev menu? It's a functional menu with source code that you can look over to see how to properly execute natives.

Link to comment
Share on other sites

Well, to start you aren't using the scripthook which, as the name suggests, 'hooks' onto the game's script thread and passes it commands. You're just pushing code into the game when the DLL is first injected + attached which is doing nothing in this instance (you're basically injecting a string with a type. The game doesn't know what you're doing and it's never executed as a result). You should also have just told it to run main() or some other function/method instead of putting your code directly into the attach statement (good programming practice!) but that won't be executed either without some form of thread being told to execute it.

 

Secondly you aren't using a native invoker so the game doesn't know what you're doing, so even if you had a hook - it doesn't know what those natives are because you aren't calling the invoker, which means any natives you do manage to execute somehow, will never actually be executed because the invoker is never used.

 

Thirdly those aren't addresses for the natives - they're hashes. You can't call natives via hash. The first long string is the hash of the "original native" (as in day 1 game release) which the scripthook 'maps' onto the most recent native hash (otherwise known as a "crosshashmap" because it crosses the original native hash with the most recent one so it can be called).

 

Why aren't you just using A.B's scripthook dev menu? It's a functional menu with source code that you can look over to see how to properly execute natives.

Okey, I realized that I do not understand everything about this.

I'm very interested to understand how these things work, and how they can be done by myself. Can you give any advice, maybe you know the books on these topics?

 

If i inject DLL in process thread, and it work(i tested it), how can i call gta5 function by hash?

Edited by buridan
Link to comment
Share on other sites

Flying Scotsman

I'd highly recommend learning GTA modding through A.B's native trainer. That'll give you an idea on how to call natives and how they work etc. It's part of the Scripthook SDK so comes with the sources for you to look over. An ASI is just a DLL with a different extension so it should help you anyway.

 

You can't call GTA functions through a hash without the native invoker. Your DLL injection worked due to how DLLs function, but the code wouldn't have been executed because the game doesn't know what you're wanting to do.

 

In this case, you were missing the native invoker to call the function directly (there are alternative means of doing this but since those can be used for Online modding - won't be discussed here). If you look through A.B's Native Trainer, you'll find how the invoker works. In essence, you find the block of memory where all the natives begin and store that address (this is done in the scripthook.dll file). When you call a native, the invoker is given the hash of the native you are calling and finds the corresponding address in memory before calling it with the args given. It's quite a complicated system to be honest.

 

There's no books as far as I can tell (I'm interested in this sort of thing, but haven't found any books on it) but it's an interesting method of modding.

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.