@@ -257,19 +257,24 @@ static char *get_search_path(void)
257257 if (!(p = strrchr ( module , '\\' ))) p = module ;
258258 * p = 0 ;
259259 }
260+ char windir [MAX_PATH ];
261+ char windir2 [MAX_PATH ];
262+ char * windir3 ;
263+ GetWindowsDirectoryA (windir , MAX_PATH );
264+ windir3 = RedirectSystemDir (windir , windir2 , MAX_PATH );
260265
261266 len = (2 + /* search order: first current dir */
262267 GetSystemDirectory16 ( NULL , 0 ) + 1 + /* then system dir */
263- GetWindowsDirectoryA ( NULL , 0 ) + 1 + /* then windows dir */
268+ strlen ( windir3 ) + 1 + /* then windows dir */
264269 strlen ( module ) + 1 + /* then module path */
265- GetEnvironmentVariableA ( "PATH " , NULL , 0 ) + 1 ); /* then look in PATH */
270+ GetEnvironmentVariableA ( "PATH16 " , NULL , 0 ) + 1 ); /* then look in PATH */
266271 if (!(ret = HeapAlloc ( GetProcessHeap (), 0 , len ))) return NULL ;
267272 strcpy ( ret , ".;" );
268273 p = ret + 2 ;
269274 GetSystemDirectory16 ( p , ret + len - p );
270275 p += strlen ( p );
271276 * p ++ = ';' ;
272- GetWindowsDirectoryA ( p , ret + len - p );
277+ strcpy ( p , windir3 ); // GetWindowsDirectoryA( p, ret + len - p );
273278 p += strlen ( p );
274279 * p ++ = ';' ;
275280 if (module [0 ])
@@ -278,7 +283,7 @@ static char *get_search_path(void)
278283 p += strlen ( p );
279284 * p ++ = ';' ;
280285 }
281- GetEnvironmentVariableA ( "PATH " , p , ret + len - p );
286+ GetEnvironmentVariableA ( "PATH16 " , p , ret + len - p );
282287 return ret ;
283288}
284289
@@ -324,6 +329,8 @@ HFILE16 WINAPI OpenFile16( LPCSTR name, OFSTRUCT *ofs, UINT16 mode )
324329 return 0 ;
325330 }
326331
332+ CHAR buf [OFS_MAXPATHNAME ];
333+ name = RedirectSystemDir (name , buf , OFS_MAXPATHNAME );
327334 if (mode & OF_CREATE )
328335 {
329336 handle = (HANDLE )OpenFile ( name , ofs , mode );
@@ -533,10 +540,10 @@ LONG WINAPI _hwrite16( HFILE16 hFile, LPCSTR buffer, LONG count )
533540 */
534541UINT WINAPI GetTempDrive ( BYTE ignored )
535542{
536- WCHAR buffer [8 ];
543+ WCHAR buffer [MAX_PATH ];
537544 BYTE ret ;
538545
539- if (GetTempPathW ( 8 , buffer )) ret = (BYTE )toupperW (buffer [0 ]);
546+ if (GetTempPathW (MAX_PATH , buffer )) ret = (BYTE )toupperW (buffer [0 ]);
540547 else ret = 'C' ;
541548 return MAKELONG ( ret | (':' << 8 ), 1 );
542549}
@@ -610,6 +617,7 @@ const char *GetRedirectWindowsDir()
610617 GetModuleFileNameA (GetModuleHandleA ("krnl386.exe16" ), windowsPath , MAX_PATH );
611618 PathRemoveFileSpecA (windowsPath );
612619 PathCombineA (windowsPath , windowsPath , "WINDOWS" );
620+ GetShortPathNameA (windowsPath , windowsPath , sizeof (windowsPath ));
613621 return windowsPath ;
614622}
615623
@@ -728,7 +736,13 @@ BOOL16 WINAPI WritePrivateProfileString16( LPCSTR section, LPCSTR entry,
728736 */
729737UINT16 WINAPI GetWindowsDirectory16 ( LPSTR path , UINT16 count )
730738{
731- return GetWindowsDirectoryA ( path , count );
739+ const char * w = GetRedirectWindowsDir ();
740+ UINT16 len = strlen (w );
741+ if (len + 1 > count )
742+ return strlen (w ) + 1 ;
743+ strcpy (path , w );
744+ return len ;
745+ //return GetWindowsDirectoryA( path, count );
732746}
733747
734748
0 commit comments