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. General Programming
  3. C / C++ / MFC
  4. Read an executable and write the data to a file.

Read an executable and write the data to a file.

Scheduled Pinned Locked Moved C / C++ / MFC
question
11 Posts 6 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.
  • A Offline
    A Offline
    ALLERSLIT
    wrote on last edited by
    #1

    Hey, i just wanted to ask if theres a way i can read the data of a file so i can paste it to another file? Like i read the data of cmd.exe and paste it to whatever.exe?

    N C A E L 5 Replies Last reply
    0
    • A ALLERSLIT

      Hey, i just wanted to ask if theres a way i can read the data of a file so i can paste it to another file? Like i read the data of cmd.exe and paste it to whatever.exe?

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Please be clear what you are asking.

      ALLERSLIT wrote:

      i can read the data of a file so i can paste it to another file?

      cmd.exe is not a file to be read from, it's an executable.


      I know the language. I've read a book. - _Madmatt

      L 1 Reply Last reply
      0
      • A ALLERSLIT

        Hey, i just wanted to ask if theres a way i can read the data of a file so i can paste it to another file? Like i read the data of cmd.exe and paste it to whatever.exe?

        C Offline
        C Offline
        Code o mat
        wrote on last edited by
        #3

        I believe we are going to need more details about what you want to do...till now it sounds like you either want to read file data to the clipboard to paste it somewhere OR you need a filecopy method (like copy in a dos prompt).

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

        A 1 Reply Last reply
        0
        • N Not Active

          Please be clear what you are asking.

          ALLERSLIT wrote:

          i can read the data of a file so i can paste it to another file?

          cmd.exe is not a file to be read from, it's an executable.


          I know the language. I've read a book. - _Madmatt

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Executables are files though

          N 1 Reply Last reply
          0
          • C Code o mat

            I believe we are going to need more details about what you want to do...till now it sounds like you either want to read file data to the clipboard to paste it somewhere OR you need a filecopy method (like copy in a dos prompt).

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

            A Offline
            A Offline
            ALLERSLIT
            wrote on last edited by
            #5

            I want to create a program out of a program. We all have a cmd.exe in our windows folder, how would i be able to create the cmd.exe out of my own program?

            C 1 Reply Last reply
            0
            • A ALLERSLIT

              Hey, i just wanted to ask if theres a way i can read the data of a file so i can paste it to another file? Like i read the data of cmd.exe and paste it to whatever.exe?

              A Offline
              A Offline
              ant damage
              wrote on last edited by
              #6

              Are you asking how to find executable code inside a program and copy it to another file, in order to run it? If so, you have to learn the structure of the program.

              1 Reply Last reply
              0
              • A ALLERSLIT

                Hey, i just wanted to ask if theres a way i can read the data of a file so i can paste it to another file? Like i read the data of cmd.exe and paste it to whatever.exe?

                E Offline
                E Offline
                El Corazon
                wrote on last edited by
                #7

                ALLERSLIT wrote:

                Hey, i just wanted to ask if theres a way i can read the data of a file so i can paste it to another file? Like i read the data of cmd.exe and paste it to whatever.exe?

                back in the 1990's, all programs started at the same offset. This made chaining programs easy. In fact a tool called LzExe[^] would compress an executable code, replace the loader function, and chain to the offset starting block. Now it is a little more difficult. Without knowing your intentions, few people here are likely to give you a step-by-step walk-through. The process is similar, but you will have to read the EXE header and still replace it, that much remains the same, chaining to the code is a little more difficult, but not impossible, but the act of which will cause any security product on the machine such as anti-virus software to halt your action. If your intent is only to insert program code into a process there are other safer ways to do this without modifying an executable. Dlls offer the safest disk method of injecting code into programs. There are also active methods of inserting code into running processes. So.... as others have asked, what exactly are you trying to do? modify an executable inserting your own code? for what reason? what are you trying to accomplish?

                _________________________ John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others." Shhhhh.... I am not really here. I am a figment of your imagination.... I am still in my cave so this must be an illusion....

                1 Reply Last reply
                0
                • L Lost User

                  Executables are files though

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #8

                  and an ice cube is water. What's your point?


                  I know the language. I've read a book. - _Madmatt

                  L 1 Reply Last reply
                  0
                  • N Not Active

                    and an ice cube is water. What's your point?


                    I know the language. I've read a book. - _Madmatt

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    That it's fine to read from cmd.exe, it's just unusual

                    1 Reply Last reply
                    0
                    • A ALLERSLIT

                      Hey, i just wanted to ask if theres a way i can read the data of a file so i can paste it to another file? Like i read the data of cmd.exe and paste it to whatever.exe?

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      You already asked this question (although in a slightly different way) here[^]. Reading the contents of an executable file and writing it somewhere else is the same as reading and writing any file; files are composed of bytes and bytes are bytes are bytes. In either case your objective is not clear, try rewording your question to clarify what problem you are actually trying to solve.

                      It's time for a new signature.

                      1 Reply Last reply
                      0
                      • A ALLERSLIT

                        I want to create a program out of a program. We all have a cmd.exe in our windows folder, how would i be able to create the cmd.exe out of my own program?

                        C Offline
                        C Offline
                        Code o mat
                        wrote on last edited by
                        #11

                        What would your program do?

                        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

                        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