Author: ion
Date: Tue Nov 29 15:04:31 2011
New Revision: 54536
URL:
http://svn.reactos.org/svn/reactos?rev=54536&view=rev
Log:
[KERNEL32]: Write out the 3 internal APIs which will do path resolution, and define the
structures that determine the search path order which each one will use. No functional
change.
Modified:
trunk/reactos/dll/win32/kernel32/client/path.c
trunk/reactos/dll/win32/kernel32/include/kernel32.h
trunk/reactos/include/psdk/winbase.h
Modified: trunk/reactos/dll/win32/kernel32/client/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/path.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/path.c [iso-8859-1] Tue Nov 29 15:04:31 2011
@@ -33,7 +33,120 @@
0x10000000 // 7C not allowed
};
+BASE_SEARCH_PATH_TYPE BaseDllOrderCurrent[BaseCurrentDirMax][BaseSearchPathMax] =
+{
+ {
+ BaseSearchPathApp,
+ BaseSearchPathCurrent,
+ BaseSearchPathDefault,
+ BaseSearchPathEnv,
+ BaseSearchPathInvalid
+ },
+ {
+ BaseSearchPathApp,
+ BaseSearchPathDefault,
+ BaseSearchPathCurrent,
+ BaseSearchPathEnv,
+ BaseSearchPathInvalid
+ }
+};
+
+BASE_SEARCH_PATH_TYPE BaseProcessOrderNoCurrent[BaseSearchPathMax] =
+{
+ BaseSearchPathApp,
+ BaseSearchPathDefault,
+ BaseSearchPathEnv,
+ BaseSearchPathInvalid,
+ BaseSearchPathInvalid
+};
+
+BASE_SEARCH_PATH_TYPE BaseDllOrderNoCurrent[BaseSearchPathMax] =
+{
+ BaseSearchPathApp,
+ BaseSearchPathDll,
+ BaseSearchPathDefault,
+ BaseSearchPathEnv,
+ BaseSearchPathInvalid
+};
+
+BASE_SEARCH_PATH_TYPE BaseProcessOrder[BaseSearchPathMax] =
+{
+ BaseSearchPathApp,
+ BaseSearchPathCurrent,
+ BaseSearchPathDefault,
+ BaseSearchPathEnv,
+ BaseSearchPathInvalid
+};
+
/* PRIVATE FUNCTIONS **********************************************************/
+
+LPWSTR
+WINAPI
+BasepComputeProcessPath(IN PBASE_SEARCH_PATH_TYPE PathOrder,
+ IN LPWSTR AppName,
+ IN LPVOID Environment)
+{
+ return NULL;
+}
+
+LPWSTR
+WINAPI
+BaseComputeProcessSearchPath(VOID)
+{
+ DPRINT1("Computing Process Search path\n");
+
+ /* Compute the path using default process order */
+ return BasepComputeProcessPath(BaseProcessOrder, NULL, NULL);
+}
+
+LPWSTR
+WINAPI
+BaseComputeProcessExePath(IN LPWSTR FullPath)
+{
+ PBASE_SEARCH_PATH_TYPE PathOrder;
+ DPRINT1("Computing EXE path: %wZ\n", FullPath);
+
+ /* Check if we should use the current directory */
+ PathOrder = NeedCurrentDirectoryForExePathW(FullPath) ?
+ BaseProcessOrder : BaseProcessOrderNoCurrent;
+
+ /* And now compute the path */
+ return BasepComputeProcessPath(PathOrder, NULL, NULL);
+}
+
+LPWSTR
+WINAPI
+BaseComputeProcessDllPath(IN LPWSTR FullPath,
+ IN PVOID Environment)
+{
+ LPWSTR DllPath = NULL;
+ DPRINT1("Computing DLL path: %wZ with BaseDll: %wZ\n", FullPath,
&BaseDllDirectory);
+
+ /* Acquire DLL directory lock */
+ RtlEnterCriticalSection(&BaseDllDirectoryLock);
+
+ /* Check if we have a base dll directory */
+ if (BaseDllDirectory.Buffer)
+ {
+ /* Then compute the process path using DLL order (without curdir) */
+ DllPath = BasepComputeProcessPath(BaseDllOrderNoCurrent, FullPath, Environment);
+
+ /* Release DLL directory lock */
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
+
+ /* Return dll path */
+ return DllPath;
+ }
+
+ /* Release DLL directory lock */
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
+
+ /* There is no base DLL directory */
+ UNIMPLEMENTED;
+
+ /* Return dll path */
+ return DllPath;
+}
BOOLEAN
WINAPI
@@ -45,7 +158,7 @@
UNICODE_STRING CurDirCopy;
CurDir = &NtCurrentPeb()->ProcessParameters->CurrentDirectory.DosPath;
-
+
CurLength = CurDir->Length;
if (CurDir->Length <= 6)
{
@@ -55,12 +168,12 @@
{
if ((CurLength - 2) != DirName->Length) return FALSE;
}
-
+
RtlAcquirePebLock();
CurDirCopy = *CurDir;
if (CurDirCopy.Length > 6) CurDirCopy.Length -= 2;
-
+
Result = 0;
if (RtlEqualUnicodeString(&CurDirCopy, DirName, TRUE)) Result = TRUE;
@@ -1672,21 +1785,21 @@
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
return FALSE;
}
-
+
DirName = Basep8BitStringToStaticUnicodeString(lpPathName);
if (!DirName) return FALSE;
-
+
if (CheckForSameCurdir(DirName)) return FALSE;
-
+
Status = RtlSetCurrentDirectory_U(DirName);
if (NT_SUCCESS(Status)) return TRUE;
-
+
if ((*DirName->Buffer != L'"') || (DirName->Length <= 2))
{
BaseSetLastNTError(Status);
return 0;
}
-
+
DirName = Basep8BitStringToStaticUnicodeString(lpPathName + 1);
if (!DirName) return FALSE;
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Tue Nov 29 15:04:31
2011
@@ -88,6 +88,24 @@
DWORD dwReserved;
} LOADPARMS32;
+typedef enum _BASE_CURRENT_DIR_PRIORITY
+{
+ BaseCurrentDirInvalid = -1,
+ BaseCurrentDirFirst,
+ BaseCurrentDirLast,
+ BaseCurrentDirMax
+} BASE_CURRENT_DIR_PRIORITY;
+
+typedef enum _BASE_SEARCH_PATH_TYPE
+{
+ BaseSearchPathInvalid,
+ BaseSearchPathDll,
+ BaseSearchPathApp,
+ BaseSearchPathDefault,
+ BaseSearchPathEnv,
+ BaseSearchPathCurrent,
+ BaseSearchPathMax
+} BASE_SEARCH_PATH_TYPE, *PBASE_SEARCH_PATH_TYPE;
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_ERROR 1
#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS 2
Modified: trunk/reactos/include/psdk/winbase.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winbase.h?rev…
==============================================================================
--- trunk/reactos/include/psdk/winbase.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winbase.h [iso-8859-1] Tue Nov 29 15:04:31 2011
@@ -1626,6 +1626,12 @@
BOOL WINAPI GetModuleHandleExA(DWORD,LPCSTR,HMODULE*);
BOOL WINAPI GetModuleHandleExW(DWORD,LPCWSTR,HMODULE*);
#endif
+
+#if _WIN32_WINNT >= 0x0502
+WINBASEAPI WINBOOL WINAPI NeedCurrentDirectoryForExePathA(LPCSTR ExeName);
+WINBASEAPI WINBOOL WINAPI NeedCurrentDirectoryForExePathW(LPCWSTR ExeName);
+#endif
+
BOOL WINAPI GetNamedPipeHandleStateA(HANDLE,PDWORD,PDWORD,PDWORD,PDWORD,LPSTR,DWORD);
BOOL WINAPI GetNamedPipeHandleStateW(HANDLE,PDWORD,PDWORD,PDWORD,PDWORD,LPWSTR,DWORD);
BOOL WINAPI GetNamedPipeInfo(HANDLE,PDWORD,PDWORD,PDWORD,PDWORD);