Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Write a value to 4Bytes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
CityOfTheIris
Newbie cheater
Reputation: 0

Joined: 18 Sep 2016
Posts: 16

PostPosted: Tue Jan 24, 2017 2:48 am    Post subject: [C++] Write a value to 4Bytes Reply with quote

Code:

// FramelimiterASI.cpp : Defines the exported functions for the DLL application.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
DWORD WINAPI LoopFunction( LPVOID lpParam )
{
   Sleep(10000);
   HANDLE gta3 = GetCurrentProcess();
   BYTE Peds = {1431787091};
   WriteProcessMemory(gta3,(void*)(0x04F4AB0),&Peds,1,0);
   Sleep(200);
   return 0;
}
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwAttached, LPVOID lpvReserved)
{
    if (dwAttached == DLL_PROCESS_ATTACH) {
        CreateThread(NULL,0,&LoopFunction,NULL,0,NULL);
    }
    return 1;
}



I want to set 4bytes (CE address from gta 3) in C++, but this only adds bytes and crashes my game
http://imgur.com/a/4UlyR

it just doesnt set to the value of what i want
how ?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Tue Jan 24, 2017 2:00 pm    Post subject: Reply with quote

Since you are injected, don't use WriteProcessMemory, it is a waste of resources and pointless. You can do direct casting to the data instead.

Code:
*(DWORD*)(0x04F4AB0) = 1431787091;


Multiple parts of your code are wrong as well, you should probably go back and learn what you are doing first.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites