Page 1 of 1

[Done] 6.40 b1 - FileSize() returns incorrect result

Posted: Tue Mar 10, 2026 5:18 pm
by breeze4me
The string modification function called first within the FileSize() function does not set the string length.
This seems to be why incorrect values like the ones below are being returned.

BTW, it appears that within the FileSize() function, the string length is read from the 4 bytes(x86) preceding the memory address allocated by HeapAlloc.

Code: Select all

short * FUN_14000187c(short *Filename)
{
  short *psVar1;
  short *psVar2;
  longlong lVar3;
  
  psVar1 = (short *)0x0;
  if ((Filename != (short *)0x0) && (psVar1 = (short *)0x0, *Filename != 0)) {
    lVar3 = *(longlong *)(Filename + -4) * 2 >> 1;
    psVar1 = HeapAlloc(DAT_14003ee10,0,lVar3 * 2 + 0x22);
    if (psVar1 != (short *)0x0) {
      FUN_140001ca8(psVar1,Filename);
      for (psVar2 = psVar1 + lVar3 + -1;
          (psVar1 <= psVar2 && ((*psVar2 == L'\\' || (*psVar2 == L'/')))); psVar2 = psVar2 + -1) {
        *psVar2 = 0;
      }
    }
  }
  return psVar1;
}
Results for 6.30 and earlier.

Code: Select all

Debug FileSize("c:\")
Debug FileSize("d:\")
Debug FileSize("e:\")
Debug FileSize("z:\")

; -2
; -2
; -2
; -2
Results for 6.40 b1

Code: Select all

Debug FileSize("c:\")
Debug FileSize("d:\")
Debug FileSize("e:\")
Debug FileSize("z:\")

; -2
; -1
; -1
; -1

Re: [6.40 b1] FileSize() returns incorrect result

Posted: Wed Mar 11, 2026 9:10 am
by Fred
Fixed.