Hi,
I've been added the EXE_PE_GetHeapReserve(), EXE_PE_GetHeapCommit(), EXE_PE_GetStackReserve() and EXE_PE_GetStackCommit functions to the EXE module.
You'll find this update in the next ThinBasic release.
Here is a test script:
[code=thinbasic] '---------------------------------------------------------------------------------
'---ThinBASIC needed modules
'---------------------------------------------------------------------------------
USES "LL"
USES "EXE"
USES "FILE"
uses "Console"
'---------------------------------------------------------------------------------
'---Global variables
'---------------------------------------------------------------------------------
GLOBAL nFiles as long
global nSkippedFiles as long
GLOBAL sTime as string
global geStackR as ext
global geStackC as ext
global geHeapR as ext
global geHeapC as ext
%MY_MAXPATH = 125
%OFN_PATHMUSTEXIST = &H00000800
%OFN_FILEMUSTEXIST = &H00001000
SUB ProcessFile(lDir AS STRING, sFileMask as string)
LOCAL Count AS LONG
LOCAL FileName AS STRING
LOCAL pList AS LONG
LOCAL nItems AS LONG
local eStackR as ext
local eStackC as ext
local eHeapR as ext
local eHeapC as ext
pList = DIR_LIST(lDir, sFileMask, %FILE_NORMAL OR %FILE_HIDDEN OR %FILE_SYSTEM OR %FILE_ADDPATH)
nItems = LL_Count(pList)
IF nItems > 0 THEN
FOR Count = 1 TO nItems
INCR nFiles
FileName = LL_GetItem(pList, Count)
eStackR = EXE_PE_GetStackReserve(FileName)
' Skip some unpleasant files
if eStackR < 0 then
incr nSkippedFiles
else
eStackC = EXE_PE_GetStackCommit(FileName)
eHeapR = EXE_PE_GetHeapReserve(FileName)
eHeapC = EXE_PE_GetHeapCommit(FileName)
geStackR += eStackR
geStackC += eStackC
geHeapR += eHeapR
geHeapC += eHeapC
console_writeLine(Lset$(Filename, %MY_MAXPATH) & ":" & hex$(eStackR,6) & " " & hex$(eStackC, 6) & " " & hex$(eHeapR, 6) & " " & Hex$(eHeapC, 6))
end if
NEXT
END IF
END SUB
FUNCTION ListDir(sDir AS STRING, sDirMask as string, sFileMask as string) AS LONG
LOCAL Count AS LONG
LOCAL Item AS STRING
LOCAL pList AS LONG
LOCAL nItems AS LONG
LOCAL CurrentRow AS LONG
LOCAL TFS AS QUAD
pList = DIR_LIST(sDir, sDirMask, %FILE_Subdir OR %FILE_HIDDEN OR %FILE_ADDPATH)
nItems = LL_Count(pList)
IF nItems > 0 THEN
FOR Count = 1 TO nItems
Item = LL_GetItem(pList, Count)
CurrentRow = nFiles
TFS = ProcessFile(Item, sFileMask)
INCR nFiles
ListDir(Item, sDirMask, sFileMask)
NEXT
END IF
END FUNCTION
'-------------------------------------------------------------------------
'Main Program
'-------------------------------------------------------------------------
sub Main()
DIM T1 as long
T1 = TIMER
console_writeLine(Lset$(" FILENAME", 125) & " STACK HEAP")
console_writeLine(string$(%MY_MAXPATH, " ") & " RESERVE COMMIT RESERVE COMMIT")
ListDir("c:\windows\", "*.*", "*.EXE")
sTime = FORMAT$(Timer - T1, "#0.00000")
console_writeLine("TOTAL TIME (Secs): " & sTime)
console_writeLine("FILE SCANNED: " & str$(nFiles))
console_writeLine(Lset$("MEAN VALUES: ", %MY_MAXPATH) & ":" & hex$(geStackR/(nFiles - nSkippedFiles),6) & " " & hex$(geStackC/(nFiles - nSkippedFiles), 6) & " " & hex$(geHeapR/(nFiles - nSkippedFiles), 6) & " " & Hex$(geHeapC/(nFiles - nSkippedFiles), 6))
end sub
'-------------------------------------------------------------------------
'Start
'-------------------------------------------------------------------------
CALL Main()[/code]
Regards,
Roberto
Bookmarks