Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

GetModuleSize???

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

  • GetModuleSize???

    Well GetModuleFileName works just fine to get the name of the EXE, but is there a function to get hte SIZE of it?

    I'm appending data to the EXE and want to recover the EXE size before the data is added.
    Does the app know data is appended (Doesn't by my calculations)....

    basically it would be a faster way than using this darned equate:

    THIS_EXE_SIZE= 68029

    And having to change it every time I recompile..




    Scott

    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    How about...

    Code:
    SEEK x, EOF(x)+1
    Or just OPEN FOR APPEND.

    -- Eric


    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited February 04, 2001).]
    "Not my circus, not my monkeys."

    Comment


    • #3
      Scott,
      I am courious why you append data to the end of an exe instead of using
      RCDATA in a resource file??

      James

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

      Comment


      • #4
        Thanks guys, here's what is happening:

        A) A compiler appends the data onto the exe and writes it out as a new EXE.
        B) Resource files are not dynamic.

        The module size now has data on and if you open an EXE for append you are opening the total file and will get a total filesize back.
        I just want to find the size the EXE thought it was before I added my data to it.

        But when dealing with EXE's never use append, use Binary., much safer that way....

        I was just hoping there an API for it.
        I may try that SEEK statement but it will likely find the EOF after my data, in fact I'm sure of it....hmmm


        Scott

        ------------------
        Scott
        mailto:[email protected][email protected]</A>

        [This message has been edited by Scott Turchin (edited February 04, 2001).]
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


        • #5
          How about appending the data you need, and make the last 4 bytes of the appended data a LONG that points to the original end of the file? That way your program would always know where to look for the original file length, i.e. the start of the appended data.

          Or you could embed a string in your program like this:

          lOrigFileLen = CVL("OrigEXELen=xxxx",12)

          Have your "compiler" program append the data to the end of the EXE, then search for and modify that string by inserting MKL$(lOrigFileLen) on top of the xxxx part.

          When the program runs it will see the value you embedded, and lOrigFileLen will contain the value you need.

          -- Eric


          ------------------
          Perfect Sync: Perfect Sync Development Tools
          Email: mailto:[email protected][email protected]</A>
          "Not my circus, not my monkeys."

          Comment


          • #6
            I've actually got two systems in place.
            One is to just compile it, verify the size, then edit the Equate of THISEXE_SIZE and the other is to record the length of the header and the length of the data.
            So I go to the end of the original file, %THIS_EXE_SIZE and then read the remainder of the file.
            The header is then pulled off by the g_hdHeaderSize value and the data is then pulled off by the g_hdDataSize value, if they do not match the file does not open.

            It actually works good, I read 20 bytes of data from the end of the EXE, before the user presses "Uncompress".
            In that 20 bytes I grab the first two variables separated by | symbol and then seek back to the origianl end of the EXE (THIS_EXE_SIZE) and then read the g_hdHeaderSize, post those values to the GUI and wait for the Uncompress button to be read.
            IT's quite efficient, but would be even more efficient if my program knew where it had originally ended.

            And the header is quite encrypted too

            Thanks for the tip tho, took me 3 days of staring at the computer to finally figure out what would be the most reliable method, and I think I have it....


            Scott

            ------------------
            Scott
            mailto:[email protected][email protected]</A>
            Scott Turchin
            MCSE, MCP+I
            http://www.tngbbs.com
            ----------------------
            True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

            Comment


            • #7
              scott, have you looked into this self extractor....
              http://www.powerbasic.com/support/pb...ad.php?t=22573

              use it for free !!!

              adrian

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

              Comment


              • #8
                Yup saw that one too, very nice and tight.

                I've optimised mine, it's VERY tight, does compression and encryption but is not a freeware app.
                It's tight, VERY VERY TIght and secure. You won't be breaking into this file anytime soon

                and the entire EXE is only 68k before adding files, not bad.
                It takes about 10 seconds to unpack 10 megs.


                It's functional, just got some GUI issues to work out with the progress bar and then it will be done


                Scott

                ------------------
                Scott
                mailto:[email protected][email protected]</A>
                Scott Turchin
                MCSE, MCP+I
                http://www.tngbbs.com
                ----------------------
                True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                Comment


                • #9
                  Scott,
                  Do you change this data after it is added to the exe from within the
                  program itself?

                  If you only add the data to exe after a compile and then only read (not alter) I
                  see no reason why you can't use RCDATA.
                  You can't use this method using PBRES but it can be accomplished using the rsrc
                  utility on my web site.

                  James


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

                  Comment


                  • #10
                    Just one thing: Virus detection software will scream if exe is
                    changed in any way after installation. For public use, this is
                    a good way to cause lot of support burdon. For private use, it
                    probably doesn't matter..


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

                    Comment

                    Working...
                    X