Announcement

Collapse
No announcement yet.

Binary Access On Self

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binary Access On Self

    I'm a working on a project, pretty much a setup type kit, in which I attach data to the end of the executeable file, and when the executeable is launched, it extracts the data/files, etc. I've tested this on another .tmp file I've created and it works, but when I try to open the exe itself for binary access, I can not seem to do anything with it, I can not even return the LOF of the exe, 0 is returned. Any ideas guys?

    Thanks in advance,
    ------------------
    Matt

    ------------------

  • #2
    I have 3 or 4 programs that open themselves up and read data from the end of the file. Note that you will not be able to write the exe you're running. When you open, make sure to specify "shared" e.g.

    Open "myself.exe" for binary shared as #1

    --Don

    ------------------
    www.basicguru.com/dickinson
    Don Dickinson
    www.greatwebdivide.com

    Comment


    • #3
      This tells you the first two bytes and the length of your exe when it runs
      Code:
      #COMPILE EXE "readexe.exe"
      #INCLUDE "win32api.inc"
       
      FUNCTION ExeName() AS STRING
      ON ERROR RESUME NEXT
        LOCAL hModule AS LONG
        LOCAL buffer  AS ASCIIZ * 256
        hModule = GetModuleHandle(BYVAL 0&)
        GetModuleFileName hModule, Buffer, 256
        FUNCTION = Buffer
      END FUNCTION
       
      FUNCTION PBMAIN() AS LONG
       Dim MZID AS STRING * 2
       OPEN ExeName FOR BINARY ACCESS READ LOCK SHARED AS #1
        GET #1, 1, MZID
        MSGBOX "LOF=" & STR$(LOF(1)) & CHR$(13) & CHR$(10) & "MZID=" & MZID
       CLOSE #1
      END FUNCTION
      Best regards,
      Wayne



      ------------------
      -

      Comment


      • #4
        Wayne,
        thanks for this code example! I didn't know about the "share" parameter... new ideas coming up
        Does someone know, how I can set a pointer at the end of a file to append to a file in binary mode? Something with SEEK or LOC, I think...
        ------------------
        e-mail: [email protected]



        [This message has been edited by Sven Blumenstein (edited December 22, 2000).]

        Comment


        • #5
          Matt,

          I've found a solution for your problem. Source avaible in the Source Code Forum!

          ------------------
          e-mail: [email protected]

          Comment


          • #6
            Why not write your "setup-program" to simply ask the user
            for a folder to install into:
            Then "MOVE" your files to this folder
            Use PE-bundle to pack your software into your 'setup-program'
            and specify "extract to current folder"
            and you will have a proffessional looking install-program.
            Make your "setup-program" fancy with WIN-LIFT and animation and stuff
            Progress-bar etc, and every-one will be impressed...
            When user start your setup, PEBundle will have extracted all
            files to your setup-folder, just kill them when setup is finished if user
            choose to abort installation.
            http://www.collakesoftware.com/

            ------------------
            Fred
            mailto:[email protected][email protected]</A>
            http://www.oxenby.se



            [This message has been edited by Fred Oxenby (edited December 22, 2000).]
            Fred
            mailto:[email protected][email protected]</A>
            http://www.oxenby.se

            Comment


            • #7
              Fred--
              also an good and logical idea to work with a programm like PEBundle. But PEBundle or similar Programms are mostly Shareware.
              And, in my point of view, it's much more nice, if you make such a routine by yourself

              I'm just improving my Source to add an *unlimited* number of files into on SelfExtractor.

              ------------------
              e-mail: [email protected]

              [This message has been edited by Sven Blumenstein (edited December 22, 2000).]

              Comment


              • #8
                Thanks everyone,

                The kit is basically complete aside from compression (implimenting LZ-77 compression algorithms from source code section soon, thanks in advance to the authors). If you're interested in the source to this executeable let me know. All information bound to the end is layered on top of an XML based template. EXE_FILEBYTES%<FILECOUNT>#</FILECOUNT><FILE1 name=name$ action=#>ARCHIVE_FILEBYTES%</FILE1><FILE2...

                In response to the PEBUNDLE suggestion, thanks, but I think writing my own routine, in this case, was called for. I wanted to design the wizard that creates the executeable and in order to do so it was required I be able to append and package the files myself, in my own format.

                Anywho, thanks to everyone. Merry X-mas.

                -----------
                Matty Claus

                ------------------

                Comment


                • #9
                  >If you're interested in the source to this executeable let me know

                  Yes, I'm interested. Please send the source to [email protected]

                  Have you already looked at my SelfExtractor in the SourceCode Forum?

                  regards,
                  Sven

                  ------------------
                  e-mail: [email protected]

                  [This message has been edited by Sven Blumenstein (edited December 25, 2000).]

                  Comment


                  • #10
                    Matt --
                    > implimenting LZ-77 compression algorithms from source code section

                    What do you mean ? Don Dickinson's code ?
                    Or something new (I saw enough fast VB code on planetsource ?) ?



                    ------------------
                    E-MAIL: [email protected]

                    Comment

                    Working...
                    X