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. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    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 IV 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 SA Mods
    10. GTA Vice City

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

      1. Guides & Strategies
      2. Help & Support
      3. GTA III 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  
buridan

[ C++ ] Calling functions of gta v

Recommended Posts

buridan

I have a Injector programm and DLL. In my DLL file I have description of native functions of gta with adresses. But when i call functions nothink happens.

P.S. Addreses of function I took there -> http://www.dev-c.com/nativedb/

CODE: https://pastebin.com/YaA4nf1j

Edited by buridan

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
buridan

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

Share this post


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

Share this post


Link to post
Share on other sites
CamxxCore

OpenVHook is an open- source Scripthook implementation. Maybe it offers some insight (:

Share this post


Link to post
Share on other sites
buridan

Guys, thanks for giving the direction and prompting where to start!

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.
Note: Your post will require moderator approval before it will be visible.

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  

  • 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.