Solved Memory problem

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
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};
DWORD BaseAddress = {0xDE77A4};
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
Jul 6, 2013
499
3,108
8
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
May 19, 2013
702
8,478
33
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
Jul 6, 2013
499
3,108
8
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

Cesspool Admin
Administrator
Jan 21, 2014
12,376
78,998
2,414
How about some inline asm? :ftb:

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
Jul 19, 2012
1,187
12,638
76
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
Oct 14, 2012
1,104
12,593
51
Why not just defining as DWORD and using DWORD Value = 30000; ? Or did I understand sth wrong here?
 
Attention! Before you post:

Read the How to Ask Questions Guide
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
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods