Lazarus
Free Pascal => Windows => Topic started by: ASBzone on November 29, 2018, 06:50:15 pm
-
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.
-
The system32 folder is a bit of a strange one.
64-bit processes will find other files there than 32-bit processes.
Bart
-
@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? :-[
-
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 (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365743(v=vs.85).aspx)
HTH
-
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)
-
check out:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365743(v=vs.85).aspx (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.
-
You can also use the SysNative folder (http://"http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm") in a 32 bit application to access the 64 bit system folder :)