# SolvedMemory problem

#### Liduen

##### Hacker
Dank Tier VIP
I'm using the following code to write a value of 1 into a specific adress. (Thx to Fleep)
C++:
``````BYTE Value[] = {0x1,0x0,0x0,0x0};
WriteProcessMemory( hProcHandle, (BYTE*)BaseAddress, &Value, sizeof(Value), NULL);``````
How do I write the value 30000 or 12.4567 into this adress?
How would this line
C++:
``BYTE Value[] = {0x?,0x?,0x?,0x?};``
look like?

#### NTvalk

##### Hacker
Meme Tier VIP
Do you want to address the individual bytes of a 32-bit int? One possible method is a union:
C++:
``````union
{
uint32_t integer;
unsigned char byte[4];
} foo;

int main()
{
foo.integer = 123456789;
BYTE Value[] = { foo.byte[3], foo.byte[2], foo.byte[1], foo.byte[0]};
}``````
Or you can do it with pointers (pseudo code ,not sure it works)

C++:
``````unsigned char* GetBytes(uint32_t integer){
char[] temp;

for (int i = 0; i < sizeof(integer); ++i) {
unsigned char byte = *((unsigned char *)&x + i);
temp[i] =  (unsigned)byte;
return temp;
}``````

Last edited:

#### Liduen

##### Hacker
Dank Tier VIP
I looked up "endian" and after about 10 minutes I ended up in a forum where a nice guy postet this example:

The first need to care about in which machine the program is running because of the difference between Big and Little Ending save bytes in memory.

Big endian saves the most significant byte in lower memory address's, to the opposite of Little endian that saves the less significant byte in lower memoriy address 's.

Example the following integer variable (assuming int = 4 bytes) : 0X1A1B1C1D

in big endian would be saved in memory (assuming address's grow from left to right)
1A | 1B | 1C | 1D
in little endian would be
1D | 1C | 1B | 1A
So in my case it would work like this:
Value to write: 30000 -> 0x7530
C++:
``BYTE Value[] = {0x30,0x75,0x0,0x0};``
Can I write it also like this?:
C++:
``BYTE Value[] = {0x30,0x75};``
And if I have an adress containing a float number- how could I write that?

Thx guys

#### NTvalk

##### Hacker
Meme Tier VIP
I looked up "endian" and after about 10 minutes I ended up in a forum where a nice guy postet this example:

So in my case it would work like this:
Value to write: 30000 -> 0x7530
C++:
``BYTE Value[] = {0x30,0x75,0x0,0x0};``
Can I write it also like this?:
C++:
``BYTE Value[] = {0x30,0x75};``
And if I have an adress containing a float number- how could I write that?

Thx guys
Well you could use the union examplei posted above and instead of uint32_t use a float and replace byte[4] with byte[sizeof(float)]

#### Rake

C++:
``````void FunctionNameHere()
{
__asm
{
mov eax, 0xDE77A4
mov ecx, 0x7530
mov dword ptr [eax], ecx
}
}

void FunctionNameHere(DWORD base)
{
__asm
{
mov eax, base
mov dword ptr [eax], 0x7530
}
}

void FunctionNameHere(DWORD base, int value)
{
__asm
{
mov eax, base
mov ecx, value
mov dword ptr [eax], ecx
}
}``````

#### c5

##### Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
I looked up "endian" and after about 10 minutes I ended up in a forum where a nice guy postet this example:

So in my case it would work like this:
Value to write: 30000 -> 0x7530
C++:
``BYTE Value[] = {0x30,0x75,0x0,0x0};``
Can I write it also like this?:
C++:
``BYTE Value[] = {0x30,0x75};``
And if I have an adress containing a float number- how could I write that?

Thx guys
memset((void*)&Value, 1337.f, sizeof(float));

#### till0sch

##### Respected Hacker
Dank Tier VIP
Dank Tier Donator
Why not just defining as DWORD and using DWORD Value = 30000; ? Or did I understand sth wrong here?

#### Liduen

##### Hacker
Dank Tier VIP
Why not just defining as DWORD and using DWORD Value = 30000; ? Or did I understand sth wrong here?
Thanks, that made it a lot easier... lol

Last edited:
Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language