Results 1 to 4 of 4
  1. #1
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold

    Intro. to Memory Hacking part1

    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.
    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
    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.
    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.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  2. #2
    Raow's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Location
    47°37′39″N 122°14′32″W
    Posts
    2,720
    Reputation
    140
    Thanks
    596
    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.

  3. #3
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    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.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  4. #4
    Honesty is an expensive gift do not expect it from cheap people!
    MPGH Member
    Matroix73's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    706
    Reputation
    42
    Thanks
    5,668
    My Mood
    Confused
    Very nice. that would be very helpful to continue
    I think creating a PDF would be way better

Similar Threads

  1. Source code for any d3d/memory hack
    By Ragehax in forum C++/C Programming
    Replies: 6
    Last Post: 10-01-2009, 09:10 PM
  2. Wats possible and not possible through memory hacking?
    By ClanTag in forum C++/C Programming
    Replies: 13
    Last Post: 07-13-2009, 06:48 PM
  3. where can i find memory hacking software?
    By headsup in forum General Hacking
    Replies: 4
    Last Post: 06-22-2009, 09:57 AM
  4. Memory Hacking (the ones that works/doesn't work)
    By Kuro Tenshi in forum Combat Arms Europe Hacks
    Replies: 2
    Last Post: 04-12-2009, 02:36 AM
  5. Memory Hacking Software (MHS)
    By ElmoCA in forum Combat Arms Hacks & Cheats
    Replies: 5
    Last Post: 02-04-2009, 05:56 PM