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.

[VC]Injecting DLL in C++ to Read and Write Memory


EightyVice
 Share

Recommended Posts

Ok, Welcome guys, as the topic says, i know C++ and wrote that code as a DLL

#include "stdafx.h"BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, PVOID lpvReserved){	switch (ul_reason_for_call)	{	case DLL_PROCESS_ATTACH:		// DO STUFF HERE 				break;	case DLL_THREAD_ATTACH:		break;	case DLL_THREAD_DETACH:		break;	case DLL_PROCESS_DETACH:		break;	}	return TRUE;}

so.

What i write to read a memory and write it ? use WriteProcessMemory function or something else , can u show me guys a small example and thanks :D

Link to comment
Share on other sites

just cast memory address to pointer. For protected memory regions you should set virtual protect first.

oh thanks very much, can u show small example to cast memory , let memory address is 0xAAFE8C :D

Link to comment
Share on other sites

setting integer value at given address:

int* ptr = (int*)0xAAFE8C

*ptr = 123

 

or just *(int*)0xAAFE8C = 123

Edited by madleg
Link to comment
Share on other sites

setting integer value at given address:

int* ptr = (int*)0xAAFE8C

*ptr = 123

 

or just *(int*)0xAAFE8C = 123

Thanks mate u are Awesome :)

Link to comment
Share on other sites

ok well I did that code to make the health 100 forever

BOOL WINAPI VCCOOPDLL(HMODULE hModule, DWORD ul_reason_for_call, PVOID lpvReserved){	switch (ul_reason_for_call)	{	case DLL_PROCESS_ATTACH:		// DO STUFF HERE		for (;		{			*(float*)(0x94AD28 + 0x354) = 100;		}		break;	case DLL_THREAD_ATTACH:		break;	case DLL_THREAD_DETACH:		break;	case DLL_PROCESS_DETACH:		break;	}	return TRUE;}

so some people said compile that DLL and rename it into *.asi file and put it in root file of the game, i did that and the health decrease, also used cheat engine and injected the DLL and nothing happend , any help? did i do any thing wrong?

note: 0x94AD28 is CPed Pointer (Return to the player instance too) then we add 0x354 to get health and with value of float.

Link to comment
Share on other sites

spaceeinstein

It's much easier to use plugin-sdk if you are just modifying known values and behaviors. There are lots of examples available there.

Edited by spaceeinstein
Link to comment
Share on other sites

It's much easier to use plugin-sdk if you are just modifying known values and behaviors. There are lots of examples available there.

Thanks mate that will help me, but i have to make it DLL to control it from another C++ program, hmm let me explain

well iam making a Online COOP mod for Vice City , so i will make a DLL that will be injected with values like coordinates and health to make sync later

but the problem is in the DLL what i write, i make a DLL that can be injected easily in the game and be controled like the not working example above , or to make a DLL with (WriteProcessMemory) and that can be hard and take alot of time, i hope i explained that, so question is making a DLL in C++ that can be injected and thanks mates :) <3

Link to comment
Share on other sites

your "hello world" is not working or will not work cause of many reasons:

VCCOOPDLL is just a function, nothing is calling it.

for (; ; ) is infinite loop and it has no break condition in your example

if 0x94ad28 is pointer to CPlayerPed, then you have to read this pointer first *(float*)(*(unsigned int*)0x94ad28 + 0x354) = 100

Edited by madleg
Link to comment
Share on other sites

spaceeinstein

plugin-sdk still works if you're writing your code in C++. With plugin-sdk, madleg's line is equivalent to

 

FindPlayerPed()->m_fHealth = 100.0f;
Link to comment
Share on other sites

your "hello world" is not working or will not work cause of many reasons:

VCCOOPDLL is just a function, nothing is calling it.

for (; ; ) is infinite loop and it has no break condition in your example

if 0x94ad28 is pointer to CPlayerPed, then you have to read this pointer first *(float*)(*(unsigned int*)0x94ad28 + 0x354) = 100

yea that what i want is how to call it xD

 

plugin-sdk still works if you're writing your code in C++. With plugin-sdk, madleg's line is equivalent to

FindPlayerPed()->m_fHealth = 100.0f;

Awesome mate, can i make a DLL in that SDK or it only make ASI? to be called later :D

and thanks guy for helping , i didnt even expected that , i thought that my topic will be ignored , thanks :D

Link to comment
Share on other sites

  • 2 weeks later...

Yes, you can.

When project is created, go to project settings, and change target extension from ".asi" to ".dll" (for both Release and Debug modes).

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.