Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. EXE file checking its own checksum

EXE file checking its own checksum

Scheduled Pinned Locked Moved The Lounge
questiondiscussion
15 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Marek Grzenkowicz

    Is it possible to create an EXE file checking its own checksum? This is the structure of the program:

    //computing the checksum
    //...
    //...
     
    //checking the checksum
    if (checksum == AD435G)
    {
        //OK message box
    }
    else
    {
        //not OK message box
    }

    After compiling it, we compute the checksum of the EXE file (using some external application). We put it in if condition and compile the EXE one more time. However, since we changed the code, the EXE file is different, so it's checksum is different. Therefore, we can never see the OK message box. What do you think about it? I know that there are installers that check if they were downloaded correctly, but I do not know how they work. You're so cute when you're frustrated. --from 'PDA' by Interpol

    N Offline
    N Offline
    Nick Seng
    wrote on last edited by
    #2

    Clickety[^];P Woohoo!! I've been waiting a while to use this. [Edit] Seriously, dude, No programming languages in the Lounge[/Edit]


    "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

    R M M M 4 Replies Last reply
    0
    • N Nick Seng

      Clickety[^];P Woohoo!! I've been waiting a while to use this. [Edit] Seriously, dude, No programming languages in the Lounge[/Edit]


      "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

      R Offline
      R Offline
      Rob Manderson
      wrote on last edited by
      #3

      I bet not 20 years though :) Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003

      N 1 Reply Last reply
      0
      • R Rob Manderson

        I bet not 20 years though :) Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003

        N Offline
        N Offline
        Nick Seng
        wrote on last edited by
        #4

        Errr......No. You know us young'uns. 3 weeks is , like, forever,dude!. :rolleyes:


        "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

        R 1 Reply Last reply
        0
        • N Nick Seng

          Errr......No. You know us young'uns. 3 weeks is , like, forever,dude!. :rolleyes:


          "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

          R Offline
          R Offline
          Rob Manderson
          wrote on last edited by
          #5

          I do have to admit that 1979 doesn't seem that long ago :) Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003

          R 1 Reply Last reply
          0
          • N Nick Seng

            Clickety[^];P Woohoo!! I've been waiting a while to use this. [Edit] Seriously, dude, No programming languages in the Lounge[/Edit]


            "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

            M Offline
            M Offline
            Monty2
            wrote on last edited by
            #6

            That was a Good One !:-D Live as if your were to die tomorrow. Learn as if you were to live forever. -Mahatma Gandhi

            1 Reply Last reply
            0
            • M Marek Grzenkowicz

              Is it possible to create an EXE file checking its own checksum? This is the structure of the program:

              //computing the checksum
              //...
              //...
               
              //checking the checksum
              if (checksum == AD435G)
              {
                  //OK message box
              }
              else
              {
                  //not OK message box
              }

              After compiling it, we compute the checksum of the EXE file (using some external application). We put it in if condition and compile the EXE one more time. However, since we changed the code, the EXE file is different, so it's checksum is different. Therefore, we can never see the OK message box. What do you think about it? I know that there are installers that check if they were downloaded correctly, but I do not know how they work. You're so cute when you're frustrated. --from 'PDA' by Interpol

              3 Offline
              3 Offline
              3ddA
              wrote on last edited by
              #7

              suppose that you have three numbers like this: long[] check = {0x1234567812345678, 0x0, 0x1234567812345678}; //compute checksum //do not include a code block starting with 0x1234567812345678 //and ending with 0x1234567812345678. if (checksum == check[1]) { //Ok } else { //Not ok } Then you need a small program calculate the checksum in the above way and insert the reslult into the exe between the two 0x1234567812345678 numbers. What you need to be absolutely sure of is that the sequence 0x1234567812345678 is not in the exe at some other place, chosing a longer sequence makes that less likely but not certain. Also note that this scheme does not protect against external tampering, which might be the reason for having the checksum in the first place. But it should work for ensuring correct download and it also make it possible release patches.

              3 1 Reply Last reply
              0
              • N Nick Seng

                Clickety[^];P Woohoo!! I've been waiting a while to use this. [Edit] Seriously, dude, No programming languages in the Lounge[/Edit]


                "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

                M Offline
                M Offline
                Marek Grzenkowicz
                wrote on last edited by
                #8

                This is NOT a programming questions (I am not asking HOW to do it). This is more a philosophical problem - I am wondering if it is possible at all. You're so cute when you're frustrated. --from 'PDA' by Interpol

                N K 2 Replies Last reply
                0
                • M Marek Grzenkowicz

                  This is NOT a programming questions (I am not asking HOW to do it). This is more a philosophical problem - I am wondering if it is possible at all. You're so cute when you're frustrated. --from 'PDA' by Interpol

                  N Offline
                  N Offline
                  Nick Seng
                  wrote on last edited by
                  #9

                  Then it's customary to put the title as "This is not a programming question". That way, even if it is one, the natives can't do anything about it. :rolleyes:;)


                  "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

                  1 Reply Last reply
                  0
                  • M Marek Grzenkowicz

                    Is it possible to create an EXE file checking its own checksum? This is the structure of the program:

                    //computing the checksum
                    //...
                    //...
                     
                    //checking the checksum
                    if (checksum == AD435G)
                    {
                        //OK message box
                    }
                    else
                    {
                        //not OK message box
                    }

                    After compiling it, we compute the checksum of the EXE file (using some external application). We put it in if condition and compile the EXE one more time. However, since we changed the code, the EXE file is different, so it's checksum is different. Therefore, we can never see the OK message box. What do you think about it? I know that there are installers that check if they were downloaded correctly, but I do not know how they work. You're so cute when you're frustrated. --from 'PDA' by Interpol

                    G Offline
                    G Offline
                    Gary R Wheeler
                    wrote on last edited by
                    #10

                    Ok, everyone else has yelled at you. Now, in the spirit of the holiday season (Peace on Earth, Good Will to People-Who-Post-Programming-Questions-In-The-Lounge), here's an answer to your question. Yes, you can have an .EXE verify it's own checksum. The key is not have the checksum in the .EXE's code itself. You do this by having the verification code look for a final checksum of zero. Your external application then places the negative of the actual checksum at a safe location in the file (typically, append it to the end of the file). I hope this helps, and Merry Christmas!


                    Software Zen: delete this;

                    1 Reply Last reply
                    0
                    • 3 3ddA

                      suppose that you have three numbers like this: long[] check = {0x1234567812345678, 0x0, 0x1234567812345678}; //compute checksum //do not include a code block starting with 0x1234567812345678 //and ending with 0x1234567812345678. if (checksum == check[1]) { //Ok } else { //Not ok } Then you need a small program calculate the checksum in the above way and insert the reslult into the exe between the two 0x1234567812345678 numbers. What you need to be absolutely sure of is that the sequence 0x1234567812345678 is not in the exe at some other place, chosing a longer sequence makes that less likely but not certain. Also note that this scheme does not protect against external tampering, which might be the reason for having the checksum in the first place. But it should work for ensuring correct download and it also make it possible release patches.

                      3 Offline
                      3 Offline
                      3ddA
                      wrote on last edited by
                      #11

                      Ignore this, Gary's solution is much smarter.

                      G 1 Reply Last reply
                      0
                      • M Marek Grzenkowicz

                        This is NOT a programming questions (I am not asking HOW to do it). This is more a philosophical problem - I am wondering if it is possible at all. You're so cute when you're frustrated. --from 'PDA' by Interpol

                        K Offline
                        K Offline
                        Kastellanos Nikos
                        wrote on last edited by
                        #12

                        There are two posibilities. One is to keep re-calculating the new file, till it stop to a number. The second is to keep re-calculating the new file, forever. ...or till you see the same number twice and quit. or adjust a not used byte and try again. till you get bored. ;P Uh... ya, i forgot. You can also ignore the position where you store the checksum, when you calculate the checksum, but of course this is an obvious old-fasion way to go. :rolleyes: - - - - - - - - - - - - - - - - - - Memory leaks is the price we pay \0 01234567890123456789012345678901234

                        1 Reply Last reply
                        0
                        • 3 3ddA

                          Ignore this, Gary's solution is much smarter.

                          G Offline
                          G Offline
                          Gary R Wheeler
                          wrote on last edited by
                          #13

                          :-O


                          Software Zen: delete this;

                          1 Reply Last reply
                          0
                          • R Rob Manderson

                            I do have to admit that 1979 doesn't seem that long ago :) Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003

                            R Offline
                            R Offline
                            Roger Wright
                            wrote on last edited by
                            #14

                            Rob Manderson wrote: 1979 doesn't seem that long ago Wasn't it just last week?:confused: "Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.

                            1 Reply Last reply
                            0
                            • N Nick Seng

                              Clickety[^];P Woohoo!! I've been waiting a while to use this. [Edit] Seriously, dude, No programming languages in the Lounge[/Edit]


                              "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone

                              M Offline
                              M Offline
                              Megan Forbes
                              wrote on last edited by
                              #15

                              Nick Seng wrote: Woohoo!! I've been waiting a while to use this. :laugh: Excellent!


                              Look at the world about you and trust to your own convictions. - Ansel Adams
                              Meg's World - Blog Photography

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups