Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding File Size

Status
Not open for further replies.

storm1899

Programmer
Apr 25, 2005
1
US
How would you find the size of a given file without opening it up? I'm trying to find the size of the .exe file that is being run so that I can reallocate memory (can't just do size from .asm file because it's two .asm's linked together... or is there a way to do that?). Thanks.
 
Int 21h Function 4eh (Find First function).

Offsets 1ah (low word) and 1ch (high word) of the returned DTA have the file size

Use function 2fh to get the address of the DTA into ES:BX

Hope this helps
 
but remember that
(1) the size of an exe file
(2) the amount of memory filled by that file when loaded as an executable ready to be run, and
(3) the amount of memory the exe file asked to be allocated to its program on loading

are three potentially very different things.
 
Or try this:

define a segment some where in your source:

ZZZZZZZZ segment public "TEXT"

ZZZZZZZZ ends

you don't have to put any info into it.

Then the most linkers will put this segment
as the last one in your exe file.

So that the following will tell you the real amount
of memory the running exe takes.


Main .startup

mov Temp,es
mov ax,seg ZZZZZZZZ
sub ax,Temp

....

AX now contains the size in paragraphs (16 bytes).

Just afther starting the program es contains the
starting segment of the program

succes,

Tessa

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top