Your Ad Here Your Ad Here
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: MineSweeper Hacking

  1. #1
    BANNED BT Rep: +20BT Rep +20BT Rep +20BT Rep +20
    Join Date
    May 2007
    Posts
    1,638
    "I wrote a very simple program to read Minesweeper's memory and display a grid showing where the bombs are. I used OllyDbg for disassembly and reversing and CheatEngine for quickly finding known values in memory.

    During this process, I found out that Minesweeper CHEATS, only spawns about half the bombs, and moves bombs mid-game. (Sometimes to where you are clicking, sometimes it will move a bomb that you click on.) Regardless, I consider this project a success.
    During this process, I found that Minesweeper will sometimes assist you and move bombs away from where you are clicking on. Originally, I thought that Minesweeper was only "spawning" about half of the bombs, but as it turns out I misunderstood the way minefield was represented in memory and all bombs are generated at the beginning of the game and not first click or any later clicks.
    My error was in thinking that minefield was stored in a 2-dimensional array (ie: minefield[x][y] = FLAGS) where max(x) (and max(y)) are the size of the grid (ie: 9x9 on Beginner) but as xumiiz on Reddit pointed out:
    His program is buggy. It's not reading the grid in correctly - it's a constant width of 32 bytes, but a window from the top left is taken for the actual size of the playing field.
    So, first bugfix to his source:
    for(DWORD grid_loc = 0; grid_loc < grid_height * grid_width; grid_loc++) {
    should be:
    for(DWORD grid_loc = 0; grid_loc < grid_height * 32; grid_loc += ((grid_loc%32)==(grid_width-1))?(32-grid_width+1):1) {
    And:
    if((grid_loc % grid_width) == (grid_width - 1))
    should be changed to:
    if((grid_loc % 32) == (grid_width - 1))
    With these fixes, it reads all the bombs properly.
    And also this comment from Anonymous:
    Sorry but your program is reading the grid incorrectly. Minesweeper uses a grid with a fixed width of 32 bytes and the playing field is takena s a window of that grid from the top left. e.g. beginner mode uses bytes 0 to 8 and skips bytes 9 to 31 per every 32 byte row.* Fixing the program to read based on that patten shows that Minesweeper only moves the mine if it happens to be the first square you click on. Apart from that, all mines are randomly placed at the start of the game.
    (* Actually it would use bytes 0 to 10, where bytes 0 and 10 are 0x10 which is to indicate the border of the mine field, and bytes 1 to 9 are the actual squares. but that's not really relevant to the analysis if you're just &ing with 0x80 to find bombs.)
    The source of this program is available here: (This is the original and still requires an update, my code will be fixed soon.)
    http://www.room641a.net/files/projec...k/minehack.cpp
    Sample program output:
    Minehack - Reverse Engineering and Coding by Sub <sub@room641a.net>
    ---
    Fairly simple program to display already-placed bombs in minesweeper.
    ---
    PID: 2836
    Height: 9
    Width: 9
    ---
    [ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ][ ] And now, probably the most important comment block of my entire program (I have updated this information here to be current, but the source file still needs updated):
    /* Did you know?
    *
    * Minesweeper stores its minefield in an array char-sized (1 byte) multi-dimensional array. Each byte
    * in memory corresponds to a specific location on the grid. It appears to use
    * simple bit masks. (This section needs updating, but the information below is current.)
    *
    * 0x10 "Border" - Appears to mark the beginning of a row, which means my offset is off by +1
    * 0x40 Button has been pressed already
    * 0x80 Bomb is in place. These can move mid-game if clicked on
    * Bit-wise OR with:
    * 0x00 The square is exposed
    * 0x0X X is 1-8 -- # on square (number of mines neighboring this square)
    * 0x0D Square is marked with question mark
    * 0x0E Square is marked with flag
    * 0x0F Blank squares are all 0x0F
    *
    * AND THEN THERE'S 0xCC WHICH MEANS YOU CLICKED A DAMN BOMB AND LOST! "
    */ Please note: At 12:20AM EST on 7/3 I have edited this post by merging a couple of updates, adding contributions from comments here and on Reddit, and retracting false, invalid, or unfounded statements (these are still available to read, they are just "crossed out") I'm still on the road (writing this from a hotel in Iowa) but will try to reply to comments when I arrive in California.


    ------------------------------------------------------------------------------------------------------------------

    I found this on digg. It was quite interesting to me..


    [b][b] Source: http://www.subversity.net/reversing/...-minesweeper?1
    Last edited by Hairbautt; 07-04-2008 at 08:29 PM. Reason: Image; Updated.

  2. Games   -   #2
    Why is this news, I doubt anyone could care less.
    ELITE BITTORENT USER SORRY I CANNOT TELL YOU MY TRACKERS THEY ARE OVER LEVEL 9000 AND I AM SWORN TO SECRECY (P.S No traders allowed)

  3. Games   -   #3
    BANNED BT Rep: +18BT Rep +18BT Rep +18BT Rep +18
    Join Date
    May 2008
    Posts
    1,970
    yeah mine sweeper is an awesome game, but why would i try to cheat? what is the point? some people may like it though

  4. Games   -   #4
    BawA's Avatar FST Pioneer BT Rep: +1
    Join Date
    Jun 2003
    Location
    Some Where but not here
    Age
    35
    Posts
    4,541
    Quote Originally Posted by Tranquill View Post
    Why is this news, I doubt anyone could care less.
    yeh... but what i care about is that downblouse avatar of her


    "You can be mad as a mad dog at the way things went; you can swear and curse the fates, but when it comes to the end, you have to let go"
    Benjamen button

  5. Games   -   #5
    BANNED BT Rep: +18BT Rep +18BT Rep +18BT Rep +18
    Join Date
    May 2008
    Posts
    1,970
    ahahahha, if anyone wanna play on the msn, contact me looking for players actually we shall have an online game playing community like backgammon and so forth... Yeah there are sites like yahoo and so forth, but you dont know them much and that sucks, on msn, it is much better, so line up guyz

  6. Games   -   #6
    Hairbautt's Avatar *haircut
    Join Date
    Jul 2004
    Location
    Florida
    Age
    20
    Posts
    11,028
    Quote Originally Posted by Tranquill View Post
    Why is this news, I doubt anyone could care less.
    I'll toss it when we have something better to post.
    _________________________________________________________________________________________
    Last edited by Alien5; Jun 6th, 2006 at
    06:36 PM..

  7. Games   -   #7
    BANNED BT Rep: +20BT Rep +20BT Rep +20BT Rep +20
    Join Date
    May 2007
    Posts
    1,638
    I didn't post this for you to cheat. I posted this because minesweeper cheats according to this article.

  8. Games   -   #8
    BANNED BT Rep: +18BT Rep +18BT Rep +18BT Rep +18
    Join Date
    May 2008
    Posts
    1,970
    oh i see sorry for the misunderstanding

  9. Games   -   #9
    BANNED BT Rep: +20BT Rep +20BT Rep +20BT Rep +20
    Join Date
    May 2007
    Posts
    1,638
    But,You're right,I should have made that clear in my original post.

  10. Games   -   #10
    BANNED BT Rep: +18BT Rep +18BT Rep +18BT Rep +18
    Join Date
    May 2008
    Posts
    1,970
    no matter m8 if u need mine partner, always a pleasure

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •