Recent

Author Topic: [RESOLVED] Significant Discrepancy in FindAllFiles in 64-bit code vs 32-bit code  (Read 473 times)

ASBzone

  • Jr. Member
  • **
  • Posts: 97
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
On this machine, I'm running Lazarus 1.8.4 with FPC 3.0.4

I have the 32-bit edition installed, plus cross-compile to 64-bit.

I've tested the code generation from several Windows 10 x64 systems, and I've tested the resulting executables on Windows 10, Windows Server 2012-R2, and Windows Server 2016, and the results are similar.   (Identical on same platforms)

The 32-bit compiled code finds less files which clearly exist as compared to a DIR command or other file manipulation.
The 64-bit compiled code finds all the same files.

The 32-bit list is much smaller (when I use larger search criteria).   I found this while testing output from my 32-bit and 64-bit utility...

It affects FindFirstFileExW as well.

Please see the attached sample code.

« Last Edit: November 30, 2018, 03:23:49 pm by ASBzone »
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 + FPC 3.0.4 (32-bit w/64-bit cross-compile)
Occasional testing of NewPascal
Current testing of Lazarus 2.0RC2
Windows 10 Pro x64, Version 1803 (Build 17134.228)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...

Bart

  • Hero Member
  • *****
  • Posts: 3161
    • Bart en Mariska's Webstek
Re: Significant Discrepancy in FindAllFiles in 64-bit code vs 32-bit code
« Reply #1 on: November 29, 2018, 07:26:55 pm »
The system32 folder is a bit of a strange one.
64-bit processes will find other files there than 32-bit processes.

Bart

ASBzone

  • Jr. Member
  • **
  • Posts: 97
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Significant Discrepancy in FindAllFiles in 64-bit code vs 32-bit code
« Reply #2 on: November 30, 2018, 05:01:55 am »
@Bart, I was so ready to contest that statement, but I tested with a different utility -- compiled in C++ -- and it turns out that you are quite correct.

Which is somewhat comforting, since I didn't want to think that I had broken utilities out there.

So, then, there is nothing to fix, eh?    :-[
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 + FPC 3.0.4 (32-bit w/64-bit cross-compile)
Occasional testing of NewPascal
Current testing of Lazarus 2.0RC2
Windows 10 Pro x64, Version 1803 (Build 17134.228)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...

440bx

  • Sr. Member
  • ****
  • Posts: 375
Re: Significant Discrepancy in FindAllFiles in 64-bit code vs 32-bit code
« Reply #3 on: November 30, 2018, 05:37:52 am »
As Bart mentioned, the Windows system folders are special cases.  The results will be different depending on the bitness of the program. 

The difference is likely due to file system redirection.  You can temporarily disable redirection using Windows APIs.  Once redirection is disabled, the results between the two programs will be much closer (I hesitate to say the same because Windows has a way of doing unexpected things behind a program's back.)

check out:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365743(v=vs.85).aspx

HTH

ASBzone

  • Jr. Member
  • **
  • Posts: 97
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Significant Discrepancy in FindAllFiles in 64-bit code vs 32-bit code
« Reply #4 on: November 30, 2018, 05:43:15 am »
So, then, there is nothing to fix, eh?    :-[

I ran my utility against the entire Windows folder, to see if this was just limited to System32 or what.

I only tracked for files up to 1000 bytes, just to make it fast.

Thanks again for that insight, @Bart.  Now I just have to do some digging at Microsoft to see why that approach was taken.

(My attachments are too big, unfortunately -- just accept that there was a huge file discrepancy: 46117 files via 32-bit code, 46314 files via 64-bit code)
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 + FPC 3.0.4 (32-bit w/64-bit cross-compile)
Occasional testing of NewPascal
Current testing of Lazarus 2.0RC2
Windows 10 Pro x64, Version 1803 (Build 17134.228)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...

ASBzone

  • Jr. Member
  • **
  • Posts: 97
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Significant Discrepancy in FindAllFiles in 64-bit code vs 32-bit code
« Reply #5 on: November 30, 2018, 05:47:09 am »
check out:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365743(v=vs.85).aspx

HTH


It does indeed help!

I had forgotten all about WOW64 redirection, and didn't even consider it would apply here.   Now, I just have to add the code to adjust for that when the 32-bit version is running so that I can accurately track changes on a disk.

Good stuff.  Thank you kindly.
-ASB: https://www.BrainWaveCC.com

Lazarus 1.8.4 + FPC 3.0.4 (32-bit w/64-bit cross-compile)
Occasional testing of NewPascal
Current testing of Lazarus 2.0RC2
Windows 10 Pro x64, Version 1803 (Build 17134.228)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...