So these primitive types are also made with assembly right? The assembly code for them just allocate some memory for them and tells how the high-level language should interpret the 0s and 1s that are allocated.
Sortof. 'primitive types' vary from language to language, but basically in the hardware you have two types: integers, and floats. 32 bit integers, 64 bit integers, 32 bit floats, 64 bit floats, possibly other sizes as well like 16 bit floats or 128 bit floats or integers. This depends on the hardware. They aren't 'made with' anything, except binary in memory. Assembly modifies them, telling the OS to do some operation implemented in the actual hardware of the CPU.
bool's in C++ are just integers. 0 = false, anything else is true.
char's are just integers. We just assigned permanent numbers to specific letters and symbols. See
ASCII chart. The number 65 is '
A', 66 is '
B', 97 is '
a', 98 is '
b'. 37 is '
%'.
Strings are just multiple chars in a row. C and C++ don't have a native 'string' type, but they have arrays of chars, and C++ has std::string which is a class that wraps an array of chars for convenience and safety.
About the other questions about memory addresses, I was thinking like this: If you could scan all the memory adresses and see what type of variables they were, you could do something with them. Like I have a game where there is a tutorial where there is a text that says "Jump over the spikes".
I would make something like this:
for(>>from 0x000000 to the last adress<<){
if(>>current adress is a String<<){
if(>>current adress is equal to "Jump over the spikes"<<){
String myString = "ahah I changed something in the game";
>>make the current adress equal to myString<<
}
}
}
Well, many games load their data from files, so you can use a program to edit the data of the files.
The executable itself (.exe, .dmg, etc...) is just a file with data as well. Data is just binary, and it only depends on how you treat the binary. I can pretend a string is a float, or a float is a string. Doing so will give me jibberish, but it'll work.
The computer doesn't store what *type* of variable is at a certain location, it just stores binary. The program decides how to use that binary. This is important because A) it saves memory (don't store what you don't need), and B) you occasionally
want to treat the same chunk of memory as different types.
So, if you open an executable in something like an hex editor (such as
HxD), you can directly edit the binary. Doing so can obviously break the game if you accidentally edited the wrong value, so create a backup copy before editing it. Looking through the binary, you might notice patterns. HxD shows the binary as hexadecimal value (hence the term 'hex editor') and as chars, so if you're looking for a string, you might be able to spot it, or maybe do a Ctrl+F for it. Then you can modify it, save it, then run the executable. Note: Because assembly is referring to certain memory addresses (jump to 0x0FA3B4 and etc...), you can't remove any bytes or it'll throw off the memory jumps, so make sure anything you replace is the same size of bytes as previously. (Any strings you are modifying can't be larger than what you are replacing, and if it's smaller, pad it out with spaces or something so it's the same length).