How are integers stored in the binary after compilation?How do you set, clear, and toggle a single bit?What does a just-in-time (JIT) compiler do?How do I detect unsigned integer multiply overflow?Why does C++ compilation take so long?How do function pointers in C work?Compile and run a file.c using Tiny C Compiler on WindowsfPrintf an integerConvert POSIX integer errno to compile-time constantCompiling an application for use in highly radioactive environmentsFinding words in a file does not work correctly

Can a UK national work as a paid shop assistant in the USA?

A nasty indefinite integral

Is it normal to "extract a paper" from a master thesis?

Why is unzipped file smaller than zipped file

Passport queue length in UK in relation to arrival method

How did the Allies achieve air superiority on Sicily?

Why do testers need root cause analysis?

Does the fact that we can only measure the two-way speed of light undermine the axiom of invariance?

Is there any mention of ghosts who live outside the Hogwarts castle?

Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?

What pc resources are used when bruteforcing?

To exponential digit growth and beyond!

JavaScript: Access 'this' when calling function stored in variable

Way of refund if scammed?

How to become an Editorial board member?

Meaning of "half-crown enclosure"

Why is Ni[(PPh₃)₂Cl₂] tetrahedral?

Is ideal gas incompressible?

Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?

Is being an extrovert a necessary condition to be a manager?

How to safely discharge oneself

"Official wife" or "Formal wife"?

Team member is vehemently against code formatting

Real Analysis: Proof of the equivalent definitions of the derivative.



How are integers stored in the binary after compilation?


How do you set, clear, and toggle a single bit?What does a just-in-time (JIT) compiler do?How do I detect unsigned integer multiply overflow?Why does C++ compilation take so long?How do function pointers in C work?Compile and run a file.c using Tiny C Compiler on WindowsfPrintf an integerConvert POSIX integer errno to compile-time constantCompiling an application for use in highly radioactive environmentsFinding words in a file does not work correctly






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am trying to create a program that can modify a compiled (or equivalent) file. The problem is to locate the different values in the compiled file, I manage to find string values but not integer values.



What I have done so far is that I take a compiled file as an input and produce a new file that is "human readable", basically I read the compiled file byte by byte and write each byte in the new file as a string of bits, for example a byte in the original file with value 124 becomes "01111100" in the new file. This seems to be working fine, I am able to do the reverse operation on the "human readable" file and run it.



#include <stdlib.h>
#include <stdio.h>

int main()

printf("Hello world!n");
return 0;



For example, if I compile and translate the output file of the code above, I can find a sequence of bits corresponding to "Hello world!n".



But in the code below, when translating the output file after compiling it, I can't find something corresponding to 3000 (whether I am looking for an Integer or a String corresponding to 3000).



#include <stdlib.h>
#include <stdio.h>

int main()

int x = 3000;
printf("%d", x);
return 0;



My guess so far is that 3000 is written in a way I do not know about. Although it is equally possible that I'm doing something wrong in the translation process. So far I have tried to look for 3000 with the two following sequence of bits:



  • As a Integer 00001011 10111000

  • As a String 00110011 00110000 00110000 00110000

Edit: It may be important to underline that I compile with the no optimization flag -O0.










share|improve this question






























    1















    I am trying to create a program that can modify a compiled (or equivalent) file. The problem is to locate the different values in the compiled file, I manage to find string values but not integer values.



    What I have done so far is that I take a compiled file as an input and produce a new file that is "human readable", basically I read the compiled file byte by byte and write each byte in the new file as a string of bits, for example a byte in the original file with value 124 becomes "01111100" in the new file. This seems to be working fine, I am able to do the reverse operation on the "human readable" file and run it.



    #include <stdlib.h>
    #include <stdio.h>

    int main()

    printf("Hello world!n");
    return 0;



    For example, if I compile and translate the output file of the code above, I can find a sequence of bits corresponding to "Hello world!n".



    But in the code below, when translating the output file after compiling it, I can't find something corresponding to 3000 (whether I am looking for an Integer or a String corresponding to 3000).



    #include <stdlib.h>
    #include <stdio.h>

    int main()

    int x = 3000;
    printf("%d", x);
    return 0;



    My guess so far is that 3000 is written in a way I do not know about. Although it is equally possible that I'm doing something wrong in the translation process. So far I have tried to look for 3000 with the two following sequence of bits:



    • As a Integer 00001011 10111000

    • As a String 00110011 00110000 00110000 00110000

    Edit: It may be important to underline that I compile with the no optimization flag -O0.










    share|improve this question


























      1












      1








      1








      I am trying to create a program that can modify a compiled (or equivalent) file. The problem is to locate the different values in the compiled file, I manage to find string values but not integer values.



      What I have done so far is that I take a compiled file as an input and produce a new file that is "human readable", basically I read the compiled file byte by byte and write each byte in the new file as a string of bits, for example a byte in the original file with value 124 becomes "01111100" in the new file. This seems to be working fine, I am able to do the reverse operation on the "human readable" file and run it.



      #include <stdlib.h>
      #include <stdio.h>

      int main()

      printf("Hello world!n");
      return 0;



      For example, if I compile and translate the output file of the code above, I can find a sequence of bits corresponding to "Hello world!n".



      But in the code below, when translating the output file after compiling it, I can't find something corresponding to 3000 (whether I am looking for an Integer or a String corresponding to 3000).



      #include <stdlib.h>
      #include <stdio.h>

      int main()

      int x = 3000;
      printf("%d", x);
      return 0;



      My guess so far is that 3000 is written in a way I do not know about. Although it is equally possible that I'm doing something wrong in the translation process. So far I have tried to look for 3000 with the two following sequence of bits:



      • As a Integer 00001011 10111000

      • As a String 00110011 00110000 00110000 00110000

      Edit: It may be important to underline that I compile with the no optimization flag -O0.










      share|improve this question
















      I am trying to create a program that can modify a compiled (or equivalent) file. The problem is to locate the different values in the compiled file, I manage to find string values but not integer values.



      What I have done so far is that I take a compiled file as an input and produce a new file that is "human readable", basically I read the compiled file byte by byte and write each byte in the new file as a string of bits, for example a byte in the original file with value 124 becomes "01111100" in the new file. This seems to be working fine, I am able to do the reverse operation on the "human readable" file and run it.



      #include <stdlib.h>
      #include <stdio.h>

      int main()

      printf("Hello world!n");
      return 0;



      For example, if I compile and translate the output file of the code above, I can find a sequence of bits corresponding to "Hello world!n".



      But in the code below, when translating the output file after compiling it, I can't find something corresponding to 3000 (whether I am looking for an Integer or a String corresponding to 3000).



      #include <stdlib.h>
      #include <stdio.h>

      int main()

      int x = 3000;
      printf("%d", x);
      return 0;



      My guess so far is that 3000 is written in a way I do not know about. Although it is equally possible that I'm doing something wrong in the translation process. So far I have tried to look for 3000 with the two following sequence of bits:



      • As a Integer 00001011 10111000

      • As a String 00110011 00110000 00110000 00110000

      Edit: It may be important to underline that I compile with the no optimization flag -O0.







      c compilation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 21:29









      Jonathan Leffler

      579k966931049




      579k966931049










      asked Mar 23 at 20:55









      LeopLeop

      456




      456






















          1 Answer
          1






          active

          oldest

          votes


















          4














          You're probably on an Intel machine which stores integers in little-endian order. You'd need to search for 10111000 00001011 (written in binary — the bytes in the reverse order from what you used before) or 0xB8 0x0B in hex bytes.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318285%2fhow-are-integers-stored-in-the-binary-after-compilation%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            You're probably on an Intel machine which stores integers in little-endian order. You'd need to search for 10111000 00001011 (written in binary — the bytes in the reverse order from what you used before) or 0xB8 0x0B in hex bytes.






            share|improve this answer



























              4














              You're probably on an Intel machine which stores integers in little-endian order. You'd need to search for 10111000 00001011 (written in binary — the bytes in the reverse order from what you used before) or 0xB8 0x0B in hex bytes.






              share|improve this answer

























                4












                4








                4







                You're probably on an Intel machine which stores integers in little-endian order. You'd need to search for 10111000 00001011 (written in binary — the bytes in the reverse order from what you used before) or 0xB8 0x0B in hex bytes.






                share|improve this answer













                You're probably on an Intel machine which stores integers in little-endian order. You'd need to search for 10111000 00001011 (written in binary — the bytes in the reverse order from what you used before) or 0xB8 0x0B in hex bytes.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 23 at 21:07









                Jonathan LefflerJonathan Leffler

                579k966931049




                579k966931049





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318285%2fhow-are-integers-stored-in-the-binary-after-compilation%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript