Author: hpoussin Date: Tue May 30 20:05:27 2006 New Revision: 22118
URL: http://svn.reactos.ru/svn/reactos?rev=22118&view=rev Log: Fix installation from default directory (%SYSTEMROOT%\Inf). Thanks WaxDragon for reporting.
Modified: trunk/reactos/dll/win32/setupapi/devinst.c trunk/reactos/dll/win32/setupapi/parser.c trunk/reactos/dll/win32/setupapi/setupapi_private.h
Modified: trunk/reactos/dll/win32/setupapi/devinst.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/setupapi/devinst.c... ============================================================================== --- trunk/reactos/dll/win32/setupapi/devinst.c (original) +++ trunk/reactos/dll/win32/setupapi/devinst.c Tue May 30 20:05:27 2006 @@ -25,6 +25,7 @@
/* Unicode constants */ static const WCHAR AddInterface[] = {'A','d','d','I','n','t','e','r','f','a','c','e',0}; +static const WCHAR BackSlash[] = {'\',0}; static const WCHAR ClassGUID[] = {'C','l','a','s','s','G','U','I','D',0}; static const WCHAR Class[] = {'C','l','a','s','s',0}; static const WCHAR ClassInstall32[] = {'C','l','a','s','s','I','n','s','t','a','l','l','3','2',0}; @@ -34,6 +35,7 @@ static const WCHAR DotHW[] = {'.','H','W',0}; static const WCHAR DotInterfaces[] = {'.','I','n','t','e','r','f','a','c','e','s',0}; static const WCHAR DotServices[] = {'.','S','e','r','v','i','c','e','s',0}; +static const WCHAR InfDirectory[] = {'i','n','f','\',0}; static const WCHAR InterfaceInstall32[] = {'I','n','t','e','r','f','a','c','e','I','n','s','t','a','l','l','3','2',0}; static const WCHAR Linked[] = {'L','i','n','k','e','d',0}; static const WCHAR SymbolicLink[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0}; @@ -1693,9 +1695,9 @@ if (rc != ERROR_SUCCESS) goto cleanup; strcpyW(InstancePath, Enumerator); - strcatW(InstancePath, L"\"); + strcatW(InstancePath, BackSlash); strcatW(InstancePath, KeyBuffer); - strcatW(InstancePath, L"\"); + strcatW(InstancePath, BackSlash); pEndOfInstancePath = &InstancePath[strlenW(InstancePath)];
/* Enumerate instance IDs (subkeys of hDeviceIdKey) */ @@ -6021,8 +6023,17 @@ LPCWSTR filename; LPWSTR pFullFilename;
- if (!(InstallParams.Flags & DI_ENUMSINGLEINF) && *InstallParams.DriverPath) - { + if (InstallParams.Flags & DI_ENUMSINGLEINF) + { + /* Only a filename */ + FullInfFileName = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); + if (!FullInfFileName) + goto done; + pFullFilename = &FullInfFileName[0]; + } + else if (*InstallParams.DriverPath) + { + /* Directory name specified */ DWORD len; len = GetFullPathNameW(InstallParams.DriverPath, 0, NULL, NULL); if (len == 0) @@ -6034,15 +6045,26 @@ if (len == 0) goto done; if (*FullInfFileName && FullInfFileName[strlenW(FullInfFileName) - 1] != '\') - strcatW(FullInfFileName, L"\"); + strcatW(FullInfFileName, BackSlash); pFullFilename = &FullInfFileName[strlenW(FullInfFileName)]; } else { - FullInfFileName = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); + /* Nothing specified ; need to get the %SYSTEMROOT%\ directory */ + DWORD len; + len = GetSystemWindowsDirectoryW(NULL, 0); + if (len == 0) + goto done; + FullInfFileName = HeapAlloc(GetProcessHeap(), 0, (len + 1 + strlenW(InfDirectory) + MAX_PATH) * sizeof(WCHAR)); if (!FullInfFileName) goto done; - pFullFilename = &FullInfFileName[0]; + len = GetSystemWindowsDirectoryW(FullInfFileName, len); + if (len == 0) + goto done; + if (*FullInfFileName && FullInfFileName[strlenW(FullInfFileName) - 1] != '\') + strcatW(FullInfFileName, BackSlash); + strcatW(FullInfFileName, InfDirectory); + pFullFilename = &FullInfFileName[strlenW(FullInfFileName)]; }
for (filename = (LPCWSTR)Buffer; *filename; filename += strlenW(filename) + 1) @@ -7911,19 +7933,23 @@ } else { - WCHAR Windir[MAX_PATH]; + WCHAR Windir[MAX_PATH + 1 + strlenW(InfDirectory)]; UINT ret;
- ret = GetWindowsDirectory(Windir, MAX_PATH); - if (ret == 0 || ret >= MAX_PATH) + ret = GetSystemWindowsDirectoryW(Windir, MAX_PATH); + if (ret == 0 || ret > MAX_PATH) { SetLastError(ERROR_GEN_FAILURE); return FALSE; } - - if (strncmpW(FullName, Windir, last - FullName) == 0) - { - /* The path is %WINDIR%\Inf */ + if (*Windir && Windir[strlenW(Windir) - 1] != '\') + strcatW(Windir, BackSlash); + strcatW(Windir, InfDirectory); + + DPRINT1("Comparing %S and %S\n", FullName, Windir); + if (strncmpiW(FullName, Windir, last - FullName) == 0) + { + /* The path is %SYSTEMROOT%\Inf */ *IsOEMLocation = FALSE; } else
Modified: trunk/reactos/dll/win32/setupapi/parser.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/setupapi/parser.c?... ============================================================================== --- trunk/reactos/dll/win32/setupapi/parser.c (original) +++ trunk/reactos/dll/win32/setupapi/parser.c Tue May 30 20:05:27 2006 @@ -2019,7 +2019,7 @@ /* "DirectoryPath" form */ len = strlenW(DirectoryPath) + 1 + 1; else - /* "%WINDIR%\Inf" form */ + /* "%SYSTEMROOT%\Inf" form */ len = MAX_PATH + 1 + strlenW(InfDirectory) + 1; len += MAX_PATH; /* To contain file name or "*.inf" string */ pFullFileName = MyMalloc(len * sizeof(WCHAR));
Modified: trunk/reactos/dll/win32/setupapi/setupapi_private.h URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/setupapi/setupapi_... ============================================================================== --- trunk/reactos/dll/win32/setupapi/setupapi_private.h (original) +++ trunk/reactos/dll/win32/setupapi/setupapi_private.h Tue May 30 20:05:27 2006 @@ -74,8 +74,7 @@ HINF hInf; LONG References;
- /* Contains the directory name of the .inf file. This field may - * be NULL if the file is already in %SYSTEMROOT%\Inf. + /* Contains the directory name of the .inf file. * Points into szData at then end of the structure */ PCWSTR DirectoryName; /* Contains the .inf file name (without directory name).