Page 1 of 1

File discrepancy between BB and Windows

Posted: Wed Nov 14, 2018 8:04 am
by DGDanforth
I can't believe what I am seeing! Its such a glaring difference I must be doing something wrong.
When I open Windows explorer to see files I am not seeing the same files as when I do an open file with BlackBox.
Specifically C:/Windows/System32 and looking at files beginning with "Sys" I see different results.

Here is a view
WindowsFiles.jpg
The red rectangle surrounds the files of interest.
The green circles are the files that BB shows. Those without the green circles
are not shown by BB.

You should be able to replicate my results.

NB: I selected All Files(*.*) for BB

Re: File discrepancy between BB and Windows

Posted: Thu Nov 15, 2018 7:14 am
by DGDanforth
I really do want your help.
Below is how the directory appears under BB File->Open and after
navigating to the same location as was done with Windows Explorer.
BBFiles.jpg
As you can see the two views (Windows & BB) are different.
Windows has 10 files where as BB has only 5 files'

Why the discrepancy?

Re: File discrepancy between BB and Windows

Posted: Thu Nov 15, 2018 9:53 am
by Robert
DGDanforth wrote:I really do want your help.
...
Windows has 10 files where as BB has only 5 files'

Why the discrepancy?
I can't give any help, but I notice something similar with build 1057 under Windows 10.
Windows has 34 files beginning "Sys", BlackBox has 19.

Re: File discrepancy between BB and Windows

Posted: Thu Nov 15, 2018 10:16 am
by DGDanforth
Thank you Robert for showing the "bug" is real.
Doug
Robert wrote:
DGDanforth wrote:I really do want your help.
...
Windows has 10 files where as BB has only 5 files'

Why the discrepancy?
I can't give any help, but I notice something similar with build 1057 under Windows 10.
Windows has 34 files beginning "Sys", BlackBox has 19.

Re: File discrepancy between BB and Windows

Posted: Thu Nov 15, 2018 10:43 am
by luowy
This is a "WOW" issue, it occurs when the win32 app is running on win64 OS.
you can get an answer form stackoverflow.
https://stackoverflow.com/questions/959 ... it-windows

luowy

Re: File discrepancy between BB and Windows

Posted: Thu Nov 15, 2018 11:07 pm
by DGDanforth
luowy wrote:This is a "WOW" issue, it occurs when the win32 app is running on win64 OS.
you can get an answer form stackoverflow.
https://stackoverflow.com/questions/959 ... it-windows

luowy
Thank you luowy.
File System Redirector
05/30/2018
2 minutes to read
The %windir%\System32 directory is reserved for 64-bit applications on 64-bit Windows. Most DLL file names were not changed when 64-bit versions of the DLLs were created, so 32-bit versions of the DLLs are stored in a different directory. WOW64 hides this difference by using a file system redirector
What a mess! I just stumbled upon the inconsistency when looking for a dll.

Doug

Re: File discrepancy between BB and Windows

Posted: Fri Nov 16, 2018 1:44 am
by luowy
that means the "C:\Windows\System32" is a special dir,
e.g. though win32app and win64app both have a "C:\Windows\System32\Kernel32.dll" files,
but they are not a same file.
If win32app wants to see all the files in that dir which win64app can see, two new functions must be used:

Code: Select all

MODULE TestWOWFiles;

	IMPORT Log := StdLog, WinApi, S := SYSTEM;

	
	(*  https://stackoverflow.com/search?q=findfirstfile+system32  *)
   (*  https://stackoverflow.com/questions/95956/findnextfile-fails-on-64-bit-windows  *)



	TYPE 
		HMODULE = WinApi.HMODULE;
		PVOID = WinApi.PtrVoid;
		BOOL = WinApi.BOOL;
(*	
	BOOL WINAPI Wow64DisableWow64FsRedirection(
 			 _Out_ PVOID *OldValue
		);

	BOOL WINAPI Wow64RevertWow64FsRedirection(
 			 _In_ PVOID OldValue
		);
*)

	VAR 		
		Wow64DisableWow64FsRedirection: PROCEDURE (VAR OldValue: PVOID): BOOL;
		Wow64RevertWow64FsRedirection: PROCEDURE (OldValue: PVOID): BOOL;
			
	
				
	PROCEDURE GetProcAddress (IN dll, pname: ARRAY OF SHORTCHAR; VAR adr: INTEGER);
		VAR h: HMODULE;
	BEGIN  
		h := WinApi.GetModuleHandleA(dll); adr := 0;
		IF h # 0 THEN 
			adr := S.VAL(INTEGER, WinApi.GetProcAddress(h, pname));
		END;
	END GetProcAddress;
	
	
	PROCEDURE Init ();
	BEGIN
		GetProcAddress("KERNEL32.DLL", "Wow64DisableWow64FsRedirection",
			S.VAL(INTEGER, Wow64DisableWow64FsRedirection));
		GetProcAddress("KERNEL32.DLL", "Wow64RevertWow64FsRedirection",
			S.VAL(INTEGER, Wow64RevertWow64FsRedirection));
	END Init;
	
		
	PROCEDURE Exist(IN fname: ARRAY OF CHAR): BOOLEAN; 
	BEGIN
		RETURN WinApi.GetFileAttributesW(fname) # -1;
	END Exist;
	
	(* pre: copy  sysclass.dll from system dir to Test\tmp *)
	
	PROCEDURE Check* ();
		VAR old, res: INTEGER;
	BEGIN 
		Log.String("win32"); Log.Ln;
		Log.Bool(Exist("C:\Windows\System32\Kernel32.dll")); Log.Ln;(* true*)
		Log.Bool(Exist("C:\Windows\System32\sysclass.dll")); Log.Ln;  (*false*)
		Log.Bool(Exist("Test\tmp\sysclass.dll")); Log.Ln;                         (* true*)
		Log.Bool(Exist("C:\Windows\System32\sysdm.cpl")); Log.Ln;(* true*)
		
		
		res := Wow64DisableWow64FsRedirection(old);
		IF res # 0 THEN 
			Log.String("win64 "); Log.Ln;
			Log.Bool(Exist("C:\Windows\System32\Kernel32.dll")); Log.Ln;(* true*)
			Log.Bool(Exist("C:\Windows\System32\sysclass.dll")); Log.Ln; (* true*)
			Log.Bool(Exist("Test\tmp\sysclass.dll")); Log.Ln;(* true*)
			Log.Bool(Exist("C:\Windows\System32\sysdm.cpl")); Log.Ln;(* true*)
			res := Wow64RevertWow64FsRedirection(old);
			IF res == 0 THEN Log.String("error2!"); Log.Ln; END;
		ELSE
			Log.String("error!"); Log.Ln;
		END;
	END Check;
	
	
BEGIN
	Init();
END TestWOWFiles.
luowy

Re: File discrepancy between BB and Windows

Posted: Fri Nov 16, 2018 2:14 am
by DGDanforth
Here is what I get on my Windows 10 64 bit HP laptop
win32
$TRUE
$FALSE
$FALSE
$TRUE
win64
$TRUE
$TRUE
$FALSE
$TRUE
which differs from your comments for the procedures
luowy wrote: Log.String("win32"); Log.Ln;
Log.Bool(Exist("C:\Windows\System32\Kernel32.dll")); Log.Ln;(* true*)
Log.Bool(Exist("C:\Windows\System32\sysclass.dll")); Log.Ln; (*false*)
Log.Bool(Exist("Test\tmp\sysclass.dll")); Log.Ln; (* true*)
Log.Bool(Exist("C:\Windows\System32\sysdm.cpl")); Log.Ln;(* true*)


res := Wow64DisableWow64FsRedirection(old);
IF res # 0 THEN
Log.String("win64 "); Log.Ln;
Log.Bool(Exist("C:\Windows\System32\Kernel32.dll")); Log.Ln;(* true*)
Log.Bool(Exist("C:\Windows\System32\sysclass.dll")); Log.Ln; (* true*)
Log.Bool(Exist("Test\tmp\sysclass.dll")); Log.Ln;(* true*)
Log.Bool(Exist("C:\Windows\System32\sysdm.cpl")); Log.Ln;(* true*)

luowy

Re: File discrepancy between BB and Windows

Posted: Fri Nov 16, 2018 5:04 am
by luowy
do you notice this comment?

Code: Select all

(* pre: copy  sysclass.dll from system dir to Test\tmp *)
that demonstrate the System32 is a special directory;

what I understand:
it is not a BB bug, it is a feature of WoW64:
that make win32 and win64 can use same name sysytem library,but they are actually not same file!
e.g. Kernel32.dll will be loaded by win32 app, also loaded by win64 app, but they are different file!

the explorer is win64 app, so it show different contents from BB(Win32app) ;

outside of the system32 directory, win32app and win64app will show same contents,
if you want to check the win64's system32 contents with BB, you can refer to the example I gave;

luowy