how to print source code from binary

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Akshobhya
    New Member
    • Nov 2006
    • 4

    how to print source code from binary

    Hi All,

    I need to write a program that will print source code of its source file.
    Assume that after building the binary i will delete the source file.

    Thanks,
    Akshobhya
  • sivadhas2006
    New Member
    • Nov 2006
    • 142

    #2
    Originally posted by Akshobhya
    Hi All,

    I need to write a program that will print source code of its source file.
    Assume that after building the binary i will delete the source file.

    Thanks,
    Akshobhya
    Hi Akshobhya,

    This may satisfy your need.

    Code:
    #include <stdio.h>
    char *program = "#include <stdio.h>%cchar *program = %c%s%c;%cint main()%c{%c%cprintf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);%c%creturn 0;%c}%c";
    int main()
    {
            printf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);
            return 0;
    }
    Regards,
    M.Sivadhas.

    Comment

    • Akshobhya
      New Member
      • Nov 2006
      • 4

      #3
      Originally posted by sivadhas2006
      Hi Akshobhya,

      This may satisfy your need.

      Code:
      #include <stdio.h>
      char *program = "#include <stdio.h>%cchar *program = %c%s%c;%cint main()%c{%c%cprintf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);%c%creturn 0;%c}%c";
      int main()
      {
              printf(program, 10, 34, program, 34, 10, 10, 10, 9, 10, 9, 10, 10,10);
              return 0;
      }
      Regards,
      M.Sivadhas.
      Hi Sivadhas,

      Thank you very much its very good interesting programming skill.
      Send me such puzzles if you find some time.

      Thanks,
      Aks

      Comment

      • khajeddin
        New Member
        • Nov 2006
        • 51

        #4
        Originally posted by Akshobhya
        Hi Sivadhas,

        Thank you very much its very good interesting programming skill.
        Send me such puzzles if you find some time.

        Thanks,
        Aks
        would some one please explain me this program and its process (to print the source code)?

        Comment

        • jayfriend
          New Member
          • Dec 2006
          • 8

          #5
          Originally posted by khajeddin
          would some one please explain me this program and its process (to print the source code)?
          The source is included in the printf statements.

          Comment

          • Soujiro
            New Member
            • Jan 2007
            • 35

            #6
            Yes.. good... you guys know of any dynamic approach using just GNU library.. C perhaps..

            Comment

            Working...