I am using filesize to compare the length of source and key files, to make sure that the key is as long as the source, but it only returns eax. Is there another register set if one of the file is longer than 4G ?
GetFileSize returns two dwords.
Thanks
Here is a very simple app. Note the use of the stack as lpHighDword.
include \masm32\include\masm32rt.inc
.code
start:
mov ebx, fopen("\Masm32\include\Windows.inc")
print str$(ebx), 9, "the handle", 13, 10
push eax ; create lpHighDword
invoke GetFileSize, ebx, esp
print str$(eax), 9, "low dword", 13, 10
pop eax ; pop lpHighDword
print str$(eax), 9, "high dword", 13, 10
fclose ebx
print str$(eax), 9, "for close"
exit
end start
GetFileAttributesEx is faster
however, it is a little more work, as there is a structure involved
i like to create temporary space for the structure on the stack, then adjust the stack and POP the values
xor eax,eax
push eax
push eax
sub esp,sizeof WIN32_FILE_ATTRIBUTE_DATA-8
INVOKE GetFileAttributesEx,offset szPathFileNamei,eax,esp
add esp,sizeof WIN32_FILE_ATTRIBUTE_DATA-8
pop edx
pop eax
;EDX:EAX = file size
notice that, if the file does not exist, EAX = EDX = 0
Quote from: dedndave on November 05, 2011, 07:01:58 PM
GetFileAttributesEx is faster
I like it simple: Inkey Str$("Size of Windows.inc=%i", Lof("\Masm32\include\Windows.inc"))
... but under the hood you'll find indeed GetFileAttributesEx :wink
i modified the code above
xor eax,eax
push eax
push eax
sub esp,sizeof WIN32_FILE_ATTRIBUTE_DATA-12
push eax
INVOKE GetFileAttributesEx,offset szPathFileName,eax,esp
pop ecx
add esp,sizeof WIN32_FILE_ATTRIBUTE_DATA-12
or eax,eax
pop edx
pop eax
;EDX:EAX = file size
;ECX = file attributes
;ZF = true if error, false if success
for a list of file attribute pins...
http://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx
Thanks, I'll give all your suggestions a try.