Wow dude, not bad.
You should definitely continue writing, i wouldn't mind reading them at all.
Depending on how much you plan to write you could make an ebook or something and possibly even sell it.
Keep it up dude.
I'm working (slowly) on a set of tutorials for basic memory hacking concepts. I'm posting a snippet here, tell me what you think? Am I a shitty writer and should stop? Overusing the words obviously/clearly? Maybe explained things it in a nice way? Maybe should make changes / additions?
Would you read more if I kept writing tuts. in this style?
--------------------------------------------------------------------------
Introduction
Most of the time while programming, we do not know or care where our variables are actually being kept in ram: that's the beauty of having identifiers(variable names) in the first place. We could create an integer variable, let's say named myInt, and manipulate it in a few different ways like addition and multiplication, while never having to know where that variable is being stored in ram, or even how many bytes it takes up. That is powerful because it simplifies our lives as programmers, but a lot of work is being done behind the scenes that we don't necessarily care about. Until now.
Data Types and Size
In a strongly typed language (which C++ and vb.net are), every variable must be of some type. There are a lot of built in types for us: char, short, int, long, float, double, just to name a few, and of course we can make our own types by creating classes and structures. Each object of a type takes up a predetermined amount of bytes (in memory).
One question you might be asking right away is: Why so many types?
Actually it's pretty intuitive once you think about it. In past times, computer hardware was very limited so when you told the computer "I want to store a number", you had to be very specific and tell it how many bytes of memory you wanted for that number. Obviously the more bytes you use, the larger your number can be. So if you only need a very small number, let's say, 0 to 100, you only needed 1 byte to store that number, so you would use a char. (Note: numeric types are signed and unsigned, we'll get to that later) If you needed to store a larger number, like 0 to 50,000 you might use a short, or 2 bytes. You see the pattern?
Basic Binary
I'm only going to skim the surface on this one, there are a few other binary concepts you should be aware of (like math operations, xor), but this is more of an add-on to data size.
Let's analyze for a minute exactly what a 'byte' is, and what it can store. We know a byte can store 8 bits, so a byte is 8 pieces of information.
We could keep doing this for n number of bits, but to be honest it's already becoming a pain (trying not to write the same combination twice), and we have enough examples to figure out the the math we need.Data Size: 1 Bit
All Combinations: 0, 1
We see that 1 bit can store 2 unique combinations. Maximum value in "1" in binary = 1 in decimal
Data Size: 2 Bits
All Combinations: 00, 01, 10, 11
We see that 2 bits can store 4 unique combinations. Maximum value in "11" in binary = 3 in decimal
Data Size: 3 Bits
All Combinations: 000, 001, 010, 100, 101, 111, 011, 110
We see that 3 bits can store 8 unique combinations. Maximum value is "111" in binary = 7 in decimal
Data Size: 4 Bits
All Combinations: 0000, 0001, 0011, 0111, 1111, 1000, 1001, 1011, 1100, 1101 . . .
I didn't show them all, but 4 bits can store 16 unique combinations. Maximum value is "1111" in binary = 15 in decimal
For any of number of bits, n, we can calculate:
Maximum combinations: 2^n
Maximum value: (2^n) -1
I'm not going to explain the math behind that..if you've ever worked with numbers in other bases is should be pretty obvious.
For example (..I do this in my head before working with base 2, just fyi) in base 10, with 2 digits:
Most of us know by heart that the max value a 2 digit number can hold is 99.
But if we look at the equation above, and do 10^2 , we get 100. Huh?
There is a huge concept here: total combinations vs. maximum value. Because 00 is one of the combinations, it actually counts towards the 100 combinations. 00 - 99.
It makes sense in base 10, it should be the same for base 2.</br>
Hopefully now you have an idea of why the numeric data types (short,int,long,float,double..) require as many bytes as they do.
Memory (aka ram)
I'm sure by now most of us have a mental picture of what memory looks: A very long, single row of cubby-boxes, each with its own unique ID number so we can refer to it: its address. Each cubby-box (on most modern hardware: there are exceptions) can store 1 byte, or 8 bits of information.
For Example: If you created a few variables, let's say 2 char's and an int, some section of ram might end up looking like below:
A very similar example is when a structure/struct is stored in memory. Since a structure is just a collection of variables, it will be layed out in memory (generally) in the same order the variables were declared. Pretend we have a structure which has 4 int fields: age, height, weight, money.
Most likely the structure will be laid out in memory as 16 bytes: The first 4 bytes for age, the next 4 for height, etc.
Start thinking of "your data" as just <i>sections</i> in this long row of boxes.
To be continued. Please leave comments.
Last edited by abuckau907; 09-03-2013 at 03:49 AM.
'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
--
Wow dude, not bad.
You should definitely continue writing, i wouldn't mind reading them at all.
Depending on how much you plan to write you could make an ebook or something and possibly even sell it.
Keep it up dude.

162
It's a huge subjects, it's hard to explain 1 thing without first explaining others : ( But I'll try.
Much thanks.
edit: I plan to write a lot. I'm trying to force myself to use C++ more so I'm going to start on a MemoryManager class for it. I figured I'd make tuts. as I learned. Trying to start with the "intro" tuts, but it's a lot of info to cover.
Last edited by abuckau907; 09-02-2013 at 07:08 PM.
'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
--

42
Very nice. that would be very helpful to continue
I think creating a PDF would be way better![]()