Results 1 to 15 of 15

Thread: Adding data to an exe

  1. #1
    Guest
    Seems to me that you should be able to initialize a string variable with a distinctive string set, then be able to change the string with relative impunity in the .exe

    Since you know the path to the executable (app.path) getting the exe file to read in is not a problem. I don't have any idea what will happen when you re-write the the string back out.....

    Care must be taken however:

    1. You must have the exact same number of characters after the change as before

    2. You have to be able to find the string in the executable

    3. You have to know lots of high-level curses for when you screw it up.

    In the DOS days, people would change the command.com using a hex editor. They did this to get distinctive (usually obscene) error messages. Same principle.

    Good Luck
    DerFarm

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    I think I can do it, if I don't modify the legth, but I need to modify the length.

  3. #3
    Guest
    If you have to modify the length of the program, then you're SOL.

    You'll have to use an outside file to communicate from one session to another.

    In actuality, while the scheme of using the .exe to hold data changes is intriguing, it isn't worth the effort for the return.

    Good Luck
    DefFarm

  4. #4
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    as far as I know, its not possible to do what you're describing. if the length is constant, it is easy, but with flexible lengths its not possible. only thing I know of is to store it in an external file.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Here's how:

    1. Copy the stub exe into a new file
    2. Store current offset
    3. Append your data
    4. At the end of the file, write the offset

    Then, when the stub loads, it reads the last few bytes from the file, seeks to that offset, and loads the data. Depending on how you load it, you may need to chop the offset bytes off.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Wink

    Lets say you want to write the user registered to the program into the exe file.

    Code:
    Type reg_t
         Name as string * 15
         ID as string * 5
    End Type
    Dim reg as reg_t
    
    
    Open App.Path & "\" App.ExeName for binary as #1
         Seek #1, LOF(1) - 21 'Go to end of file munus
                               our type struct + 1 for the seek
         Get #1, reg
         If reg.ID <> "REGID" Then
              'Not registered
              MsgBox "Program not registered!"
    
              'Now promped the user to type in there name
              'and just seek back to where you saved the type
              'at the end of the file and save it using Put
         Else
              'Registered
              Msgbox "Thank you " & reg.name
         End If
    Close #1
    [Edited by nkad on 09-29-2000 at 02:58 PM]

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    So you can just append it at the end of the file?

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yes, although I would suggest (to help discourage fiddling), that some kind of processing be done on the data. (Also, surrounding it in an arbitrary length of random data is often helpful).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Thanks for the help.

  10. #10
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Does this really work?!?!?!? COOOLLL!!!
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yeah, I've used it in some of my software.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  12. #12
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    Sure it works

    I posted a reply to a similar question a couple of days ago. The other question was about storing company logog in the exe, but the principal is the same.

    The program should never ever get to your data so there would be no problem.

    Virus checkers or innoculators are likely to pick up on the change and complain however. Also, in a LAN distribution (or any multi-user situation), such a thing is not recommended at all.

    Cheers
    Paul Lewis

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    In that situation, then it's not a good idea. In fact, I think I would probably say - never change the executable. You just can't tell if someone else is running it from somewhere else. There are usually much better ways of storing the data. (Unless the data will be inserted into the EXE statically)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    ok, that's what I thought. I had read up on it and got a similar idea, so it seemed kind of interesting to me to think that it might work.

    its still a cool technique tho. anybody know if you can use VS98 to edit resources (pics/strings/etc) in a compiled program (non vb)?
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  15. #15
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Originally posted by mlewis
    ok, that's what I thought. I had read up on it and got a similar idea, so it seemed kind of interesting to me to think that it might work.

    its still a cool technique tho. anybody know if you can use VS98 to edit resources (pics/strings/etc) in a compiled program (non vb)?
    You will get more views (and more answers to your question) if you open a new thread.

Posting Permissions

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



Click Here to Expand Forum to Full Width