Categories > Coding > C++ >

C++ Intermediate Lessons: EP 1 : Memory

Posts: 127

Threads: 21

Joined: Mar, 2022

Reputation: -2

Replied

nice very cool Vouch 

  • 0

exploits i use: kiwi x

ChargedX

Owner of ChargedX

Posts: 80

Threads: 5

Joined: Jul, 2022

Reputation: -10

Replied

dang my guy is helping a lot of ppl lol

  • 0

https://cdn.discordapp.com/attachments/980336249820831744/1016151409261027428/standard_1.gif

https://cdn.discordapp.com/attachments/994242253864312843/1016368013534052453/standard_3.gif

Posts: 123

Threads: 26

Joined: Feb, 2021

Reputation: 3

Replied

I know what pointers are, but I've never understood why developers can just do:

/* using char instead of int because I don't need to take as much memory as an int does */
uint8_t x = 5;
int pointerToChar = &x;

instead of:

uint8_t *pointer = 5

Honestly I find the second option a little harder to understand (sometimes)

  • 0

Contribute to Express, an open-source ROBLOX exploit written fully in C.

Posts: 228

Threads: 43

Joined: May, 2022

Reputation: -5

Replied

@lilbiden69

 

both your code snippets won't even compile, simply because you cannot initialize a pointer from an integer value and you cannot initialize a integer value from a address. the entire point of pointers ( no pun intended ) is to hold addresses to things that are stored in memory, and allowing access to them for either reading or writing to said memory address. 

  • 0

https://media.discordapp.net/attachments/1044764388546068510/1051935933836050482/Signature_4.png

Posts: 123

Threads: 26

Joined: Feb, 2021

Reputation: 3

Replied

Oh I thought addresses were 32-bit numbers and intwere also 32-bit numbers, so why would the compiler not allow an int variable to contain the address of another variable?

I believe it works with the GCC compiler

  • 0

Contribute to Express, an open-source ROBLOX exploit written fully in C.

Posts: 228

Threads: 43

Joined: May, 2022

Reputation: -5

Replied

@lilbiden69

 

 

the size of addresses and variables depends on the architecture you're compiling on, not the compiler.

addresses in x86 are 32 bit numbers and int is a 32 bit data type.

 

Ints are 4 bytes of memory meaning they can store values up to 4 bytes( the data type int is always 4 bytes independent of the architecture ), that's why when dealing with addresses in x64 ( more specifically x86_x64 ) you utilize std::uintptr_t ( or std::size_t as they're the same and both change depending on the architecture ) as it will be 4 bytes on x86 and 8 bytes in x64 which is usually what you want..

 

and the thing is, what you're saying is true, but the code snippets you provided don't work because that's not how C++ works. 

 

/* using char instead of int because I don't need to take as much memory as an int does */
uint8_t x = 5;
int pointerToChar = &x;

If you try to compile this you get an error saying you cannot construct an int from a uint8_t / unsigned char*. 

uint8_t *pointer = 5

this also causes an error as you cannot construct an uint8_t* from an int. you should also know, in the second snippet, even if you did it "correctly" it still would not work as you're trying to create an uint8_t* from an int*.

 

	int y = 10;
	uint8_t* x = &y;

This would not compile, because it's trying to create a uint8_t* from a int*.

  • 0

https://media.discordapp.net/attachments/1044764388546068510/1051935933836050482/Signature_4.png

Prev

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )