ok i've got strange result using GetDiskFreeSpaceExA func
as it use some qwords as data to be filled
i use the proc qwordto2dwords to split qwords into 2 dword (high and low)
and use DwordValToAscii to convert them into 2 string (numeric)
then cat them into a string that should display a full 64bit number in ascii

but it works fine for freeuserbytes (the caller) freebytes but not for totalbytes
i've got a partition of 7,98Go (8570400768 bytes)

DwordValToAscii proc,dwValue:DWORD,lpBuffer:dword

; -------------------------------------------------------------
; convert DWORD to ascii string
; dwValue is value to be converted
; lpBuffer is the address of the receiving buffer
; invoke dwtoa,edx,ADDR buffer
; Uses: eax, ecx, edx.
; -------------------------------------------------------------

mov eax, dwValue
mov edi, lpbuffer

.if (eax != 0)

; Is the value negative?

.if (sdword ptr eax < 0)
mov byte ptr , '-' ; store a minus sign
inc edi
neg eax ; and invert the value

mov esi, edi ; save pointer to first digit

mov ecx, 10
.while (eax > 0) ; while there is more to convert...
xor edx, edx
div ecx ; put next digit in edx
add dl, '0' ; convert to ASCII
mov , dl ; store it
inc edi

mov byte ptr , 0 ; terminate the string

; We now have all the digits, but in reverse order.

.while (esi < edi)
dec edi
mov al,
mov ah,
mov , al
mov , ah
inc esi

mov word ptr , 0030H ; string "0", 0 in little endian


DwordValToAscii endp

QwordTo2Dwords PROC num1:QWORD
QwordTo2DwordsDD1 dd 0
QwordTo2DwordsDD2 dd 0
movq mm0, num1
movd eax, mm0
mov QwordTo2DwordsDD1,eax
punpckhdq mm0, mm0
movd edx, mm0
mov QwordTo2DwordsDD2,edx
mov eax,QwordTo2DwordsDD1
mov ebx,QwordTo2DwordsDD2
QwordTo2Dwords ENDP

QwordValToAscii proc,val1:qword,dest:dword
QwordValToAscciDD1 dd 0
QwordValToAscciDD2 dd 0
QwordValToAscciTempString db 1024 dup(0)
QwordValToAsccival1string db 512 dup(0)
QwordValToAsccival2string db 512 dup(0)
call QwordTo2Dwords,val1
mov QwordValToAscciDD1,eax
mov QwordValToAscciDD2,ebx
call DwordValToAscii,QwordValToAscciDD1,offset QwordValToAsccival1string
call DwordValToAscii,QwordValToAscciDD2,offset QwordValToAsccival2string
call Scopy,offset QwordValToAsccitempstring,offset QwordValToAsccival1string ;Scopy if equivalent to lstrcopy
call scat,offset QwordValToAsccitempstring,offset QwordValToAsccival2string ; scat to lstrcat
call scopy,dest,offset QwordValToAsccitempstring
QwordValToAscii endp

GetFreeBytesHDD proc,src:dword,freeuserbytes:dword,totalbytes:dword,freebytes:dword
call GetDiskFreeSpaceExA,src,freeuserbytes,totalbytes,freebytes
GetFreeBytesHDD endp

now my sample code
call GetFreeBytesHDD,offset DirName,offset freeuserdq,offset totaldq,offset freebytesdq
call QwordValToAscii,freeuserdq,offset freeusertxt
call QwordValToAscii,freebytesdq,offset freebytestxt
call QwordValToAscii,totaldq,offset totalbytestxt
call MessageBoxA,0,offset freeusertxt,offset messtxt,0 ;displayed:48961694561 it is not correct bytes free (no quota)
call MessageBoxA,0,offset freebytestxt,offset messtxt,0 ;displayed:48961694561 it is not correct bytes free
call MessageBoxA,0,offset totalbytestxt,offset messtxt,0 ;displayed:-195338241 it is not correct

so can anyone show me how to implement a correct funtion that get and convert this values into ascii strings

Posted on 2002-12-03 21:15:21 by Thor0Asgard