|
You last visited: Today at 03:40
Advertisement
C++ memcpy Arrays ?
Discussion on C++ memcpy Arrays ? within the C/C++ forum part of the Coders Den category.
12/04/2013, 09:59
|
#1
|
elite*gold: 0
Join Date: Jun 2013
Posts: 53
Received Thanks: 5
|
C++ memcpy Arrays ?
Hi,
I'm trying to learn c++ by myself. but i didn't understand how to do it with those arrays. Like this :
WriteProcessMemory(OpenProcess(PROCESS_ALL_ACCESS, false,FindProcessId("notepad.exe")),(LPVOID)0x0040 CAE1,(PBYTE)"\xEB",1,0);
I don't understand the "\xEB" . Any helps please ?
|
|
|
12/04/2013, 10:08
|
#2
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
"\xEB" is a string, the "\x" is an escape sequence which tells the compiler to interpret the next 2 characters as a hex value and insert it into the string.
its actually the same as
Code:
BYTE Buf[] = { 0xEB, 0x00 }; // 0x00 because of the trailing zero character of the string. because only the first byte is accessed at Writeprocessmemory it doesnt really matter.
so it wrill wite one byte with 0xEB to 0x0040CAE1.
|
|
|
12/04/2013, 10:29
|
#3
|
elite*gold: 0
Join Date: Jun 2013
Posts: 53
Received Thanks: 5
|
Quote:
Originally Posted by Dr. Coxxy
"\xEB" is a string, the "\x" is an escape sequence which tells the compiler to interpret the next 2 characters as a hex value and insert it into the string.
its actually the same as
Code:
BYTE Buf[] = { 0xEB, 0x00 }; // 0x00 because of the trailing zero character of the string. because only the first byte is accessed at Writeprocessmemory it doesnt really matter.
so it wrill wite one byte with 0xEB to 0x0040CAE1.
|
Mhm. I'll prob. try to do it with VB or C#. But \xEB is not valid for VB and C#. How can i do it with 4 byte or float value instead of \xEB ?
|
|
|
12/04/2013, 14:11
|
#4
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
simply use a single byte:
Code:
BYTE Buf = 0xEB;
WriteProcessMemory(OpenProcess(PROCESS_ALL_ACCESS, false,FindProcessId("notepad.exe")), (LPVOID)0x0040CAE1, &Buf,1,0);
|
|
|
12/05/2013, 21:15
|
#5
|
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
|
With C# you do :
Code:
byte buffer = 0xEB; //The '0x' before EB shows that EB is an hexadecimal number
I'm not sure for the syntaxt in VB, but its something like that :
Code:
Dim buffer as Byte = &hEB //Here it's the '&h' that shows an HEX number
Also, you should put your process handle in a variable, and then call CloseHandle when you are done with it.
|
|
|
Similar Threads
|
[question] memcpy, access violation
10/02/2011 - General Coding - 1 Replies
is it ok to type cast byte buffer by (void*)?
DWORD dwAddress = 0x12345678;
BYTE bPatch = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
memcpy( (void*)dwAddress, (void*)bPatch, 7);
this piece of my code was working fine till now - it is causing ACCESS VIOLATION and I can't figure out why.
edited:
nvm, it was all about memory protection.
|
C++ Memcpy
12/28/2010 - C/C++ - 6 Replies
Hey Leute,
wie immer!! hab mal ne Frage ;D Kann mir einer denn Fehler im Source sagen?!
Source:
#include <Windows.h>
#include <stdio.h>
#pragma warning(disable: 4312)
void Hack()
{
|
[c++] memcpy, float, address
07/21/2010 - Kal Online - 0 Replies
omfg, how to write float value using memcpy?
DWORD addr = 0x12345678;
FLOAT value = { 100, 200, 300 };
memcpy((void*)addr, (void*)((FLOAT)value),4);
gives me an engine crash.
EDITED:
problem solved. nvm lol. please, delete this thread.
|
All times are GMT +1. The time now is 03:40.
|
|