Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 04:38

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Writing char to adress

Discussion on Writing char to adress within the C/C++ forum part of the Coders Den category.

Closed Thread
 
Old   #1
 
XxharCs's Avatar
 
elite*gold: 34
Join Date: Apr 2011
Posts: 1,475
Received Thanks: 1,227
Writing char to adress

Hey, after a long time i started again with memory editing and i stucked at one point.

I dont wanna use WriteProcessMemory to write new chars/intīs and so on, to an address. (from a dll)

Normally with a number it works..
example:
Code:
DWORD BasePointer = 0x006FA108;
...
...
DWORD dwBasePointer = *(DWORD*)BasePointer;
*(DWORD*)(dwBasePointer) = 2;

but when i try to do the same, but with a char, it doesnīt work:
Code:
char* helVal= "Hello";
LPVOID dwBasePointer = (DWORD*)0x006FA108;

dwBasePointer = helVal;
am i forgetting something or what?
if this method doesnīt work (with chars), then i am going to work with WriteProcessMemory to write chars..

Thanks!
XxharCs is offline  
Old 10/28/2013, 18:58   #2
 
elite*gold: 0
Join Date: Nov 2007
Posts: 99
Received Thanks: 6
memcpy, strcpy
kingdeking is offline  
Thanks
1 User
Old 10/28/2013, 19:07   #3
 
XxharCs's Avatar
 
elite*gold: 34
Join Date: Apr 2011
Posts: 1,475
Received Thanks: 1,227
ah thanks, forgot that there is also a memcpy

can be closed
XxharCs is offline  
Old 10/28/2013, 19:14   #4


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,904
Received Thanks: 25,394
You don't understand pointers correctly, I think.


Code:
//x86 compatible only, haters gonna hate

DWORD *dwPtr = (DWORD *)0xDEADBEEF;   //writing 0xDEADBEEF into the variable dwPtr (or: at address of dwPtr) 
*dwPtr = 5;    //writing 5 at address 0xDEADBEEF

const char *cstrVal = "C-Style-String";

const char *strPtr = (const char *)0xDEADBEEF;   //writing 0xDEADBEEF into the variable strPtr (or: at address of strPtr)

strPtr = cstrVal;    //writing the address of "C-Style-String" into the variable strPtr (or: at the address of strPtr) - NOT writing the content ("C-Style-String") at the address saved in strPtr (0xDEADBEEF)
A C-Style string is simply a pointer to a char-Array or rather to the first element of that array. The pointer works exactly the same way an int* does.

Code:
char *strPtr = (char *)0xDEADBEEF; //now leaving out const to make the ptr writeable
*strPtr = *cstrVal; //writing the 'C', the first character of the string pointed to by cstrVal (because it is actually a pointer to that one char) at 0xDEADBEEF
You wouldn't think that
Code:
DWORD vals[] = { 1, 2, 3 };

dwPtr = vals;
//or
*dwPtr = *vals;
would copy the whole DWORD array either, would you?
Of course not. You need a loop for that. Luckily, there is already a well-optimized solution for that provided by the standard library: memcpy/strcpy/strcpy_s.


Btw.

Code:
char *helVal = "Hello";
Your compiler should complain about that line, because you are implicitly converting a const char* into a non-const char* there, which is not possible.


Anyway, #closed
MrSm!th is offline  
Thanks
1 User
Closed Thread


Similar Threads Similar Threads
Where to start with bot writing
09/21/2011 - General Coding - 1 Replies
I have always used bots for various games that I have played so that I don't have to spend hours doing the repetitive tasks that some games have you doing over and over again. However after years of leeching I would like to learn how to create my own bot. I know this is not going to happen over night and I plan to start somewhere relatively easy. My first target is to create a bot for the Facebook game 'Monster World'. What it would need to do is: Check for harvestable plants If...
How to find camera and char adress
11/17/2010 - 12Sky2 - 6 Replies
Hi all ! Is it possible to make a decent TUT about how to find camera en Char adresses ? I tryed some TUT's out but nothing seems to work me :( Thanks B...
Help Writing Script
12/03/2009 - Dekaron - 8 Replies
!!!!!Problem solved, please close!!!! I am trying to learn how to write CE scripts, and I'm almost done with my first one, but I'm having a bit of an issue. I found the pointer and then the offset for what I'm looking for, and now I just need to figure out one small detail. The code at my offset is mov ecx,
plz help me iin writing ver code
10/04/2009 - Silkroad Online - 3 Replies
hi plz help me i can't write the verification code



All times are GMT +2. The time now is 04:38.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.