Hi,

Perhaps we need to reverse engineer to understand how cd command
works... :) It seems it is not based on SetCurrentDirectory() function.

cmd.exe:

Command:
C:\Documents and Settings\Administrator>cd d:\prg

API call:
GetCurrentDirectoryW(DWORD:260, PWSTR:0x13f80c:"??")         0x4ad041f0      
GetCurrentDirectoryW returned 0x27
GetCurrentDirectoryW(DWORD:260, PWSTR:0x4ad34400:"C:\Documents and Settings\Administrator")
GetCurrentDirectoryW returned 0x27
GetCurrentDirectoryW(DWORD:260, PWSTR:0x4ad34400:"C:\Documents and Settings\Administrator")
GetCurrentDirectoryW returned 0x27

Conclusion: no SetCurrentDirectory() called!

--------------------------------------------------
Command:
C:\Documents and Settings\Administrator>d:

API call:
SetCurrentDirectoryW(PWSTR:0x4ad2ba20:"D:\PRG")
SetCurrentDirectoryW returned 0x1
GetCurrentDirectoryW(DWORD:260, PWSTR:0x4ad34400:"C:\Documents and Settings\Administrator")
GetCurrentDirectoryW returned 0x6
GetCurrentDirectoryW(DWORD:260, PWSTR:0x4ad34400:"D:\PRG")
GetCurrentDirectoryW returned 0x6

Conclusion: here SetCurrentDirectory() is called! So, cmd.exe caches cd instructions for all drives and calls real SetCurrentDirectory() on disk change.

--------------------------------------------------
Command:
D:\PRG>cd c:
C:\Documents and Settings\Administrator

API call:
GetCurrentDirectoryW(DWORD:260, PWSTR:0x4ad34400:"D:\PRG")
GetCurrentDirectoryW returned 0x6

Conclusion: no SetCurrentDirectoryW() is called at all. GetCurrentDirectoryW() returned 6 bytes sting (i.e., "D:\PRG"). So command result (C:\Documents and Settings\Administrator) is printed from cmd.exe "cache".


Regards,
Mindaugas
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to