diff --git a/reactos/lib/setupapi/devinst.c b/reactos/lib/setupapi/devinst.c index 915c5e78c5e..15a5e15dfe3 100644 --- a/reactos/lib/setupapi/devinst.c +++ b/reactos/lib/setupapi/devinst.c @@ -25,6 +25,7 @@ #include "windef.h" #include "winbase.h" +#include "winnt.h" #include "winreg.h" #include "winternl.h" #include "wingdi.h" @@ -41,12 +42,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(setupapi); /* Unicode constants */ +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}; +static const WCHAR NoDisplayClass[] = {'N','o','D','i','s','p','l','a','y','C','l','a','s','s',0}; +static const WCHAR NoInstallClass[] = {'N','o','I','s','t','a','l','l','C','l','a','s','s',0}; +static const WCHAR NoUseClass[] = {'N','o','U','s','e','C','l','a','s','s',0}; static const WCHAR NtExtension[] = {'.','N','T',0}; static const WCHAR NtPlatformExtension[] = {'.','N','T','x','8','6',0}; +static const WCHAR Version[] = {'V','e','r','s','i','o','n',0}; static const WCHAR WinExtension[] = {'.','W','i','n',0}; -static const WCHAR ClassInstall32[] = {'C','l','a','s','s','I','n','s','t','a','l','l','3','2',0}; -static const WCHAR Class[] = {'C','l','a','s','s',0}; +/* Registry key and value names */ +static const WCHAR ControlClass[] = {'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'C','l','a','s','s',0}; + +static const WCHAR DeviceClasses[] = {'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'D','e','v','i','c','e','C','l','a','s','s','e','s',0}; /*********************************************************************** * SetupDiBuildClassInfoList (SETUPAPI.@) @@ -57,7 +73,7 @@ BOOL WINAPI SetupDiBuildClassInfoList( DWORD ClassGuidListSize, PDWORD RequiredSize) { - TRACE("SetupDiBuildClassInfoList() called\n"); + TRACE("\n"); return SetupDiBuildClassInfoListExW(Flags, ClassGuidList, ClassGuidListSize, RequiredSize, NULL, NULL); @@ -97,7 +113,7 @@ BOOL WINAPI SetupDiBuildClassInfoListExW( LONG lError; DWORD dwGuidListIndex = 0; - TRACE("SetupDiBuildClassInfoListExW() called\n"); + TRACE("\n"); if (RequiredSize != NULL) *RequiredSize = 0; @@ -126,7 +142,7 @@ BOOL WINAPI SetupDiBuildClassInfoListExW( TRACE("RegEnumKeyExW() returns %ld\n", lError); if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA) { - TRACE("Key name: %S\n", szKeyName); + TRACE("Key name: %p\n", szKeyName); if (RegOpenKeyExW(hClassesKey, szKeyName, @@ -139,7 +155,7 @@ BOOL WINAPI SetupDiBuildClassInfoListExW( } if (!RegQueryValueExW(hClassKey, - L"NoUseClass", + NoUseClass, NULL, NULL, NULL, @@ -152,7 +168,7 @@ BOOL WINAPI SetupDiBuildClassInfoListExW( if ((Flags & DIBCI_NOINSTALLCLASS) && (!RegQueryValueExW(hClassKey, - L"NoInstallClass", + NoInstallClass, NULL, NULL, NULL, @@ -165,7 +181,7 @@ BOOL WINAPI SetupDiBuildClassInfoListExW( if ((Flags & DIBCI_NODISPLAYCLASS) && (!RegQueryValueExW(hClassKey, - L"NoDisplayClass", + NoDisplayClass, NULL, NULL, NULL, @@ -178,14 +194,14 @@ BOOL WINAPI SetupDiBuildClassInfoListExW( RegCloseKey(hClassKey); - TRACE("Guid: %S\n", szKeyName); + TRACE("Guid: %p\n", szKeyName); if (dwGuidListIndex < ClassGuidListSize) { if (szKeyName[0] == L'{' && szKeyName[37] == L'}') { szKeyName[37] = 0; } - TRACE("Guid: %S\n", &szKeyName[1]); + TRACE("Guid: %p\n", &szKeyName[1]); UuidFromStringW(&szKeyName[1], &ClassGuidList[dwGuidListIndex]); @@ -302,7 +318,7 @@ BOOL WINAPI SetupDiClassGuidsFromNameExW( TRACE("RegEnumKeyExW() returns %ld\n", lError); if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA) { - TRACE("Key name: %S\n", szKeyName); + TRACE("Key name: %p\n", szKeyName); if (RegOpenKeyExW(hClassesKey, szKeyName, @@ -322,20 +338,20 @@ BOOL WINAPI SetupDiClassGuidsFromNameExW( (LPBYTE)szClassName, &dwLength)) { - TRACE("Class name: %S\n", szClassName); + TRACE("Class name: %p\n", szClassName); - if (_wcsicmp(szClassName, ClassName) == 0) + if (strcmpiW(szClassName, ClassName) == 0) { TRACE("Found matching class name\n"); - TRACE("Guid: %S\n", szKeyName); + TRACE("Guid: %p\n", szKeyName); if (dwGuidListIndex < ClassGuidListSize) { if (szKeyName[0] == L'{' && szKeyName[37] == L'}') { szKeyName[37] = 0; } - TRACE("Guid: %S\n", &szKeyName[1]); + TRACE("Guid: %p\n", &szKeyName[1]); UuidFromStringW(&szKeyName[1], &ClassGuidList[dwGuidListIndex]); @@ -508,7 +524,7 @@ SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, */ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo) { - FIXME("%04lx\n", (DWORD)devinfo); + FIXME("%p\n", devinfo); return FALSE; } @@ -571,13 +587,13 @@ BOOL WINAPI SetupDiGetActualSectionToInstallW( PWSTR *Extension) { WCHAR szBuffer[MAX_PATH]; - OSVERSIONINFO OsVersionInfo; + OSVERSIONINFOW OsVersionInfo; DWORD dwLength; DWORD dwFullLength; LONG lLineCount = -1; - OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx(&OsVersionInfo)) + OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); + if (!GetVersionExW(&OsVersionInfo)) { return FALSE; } @@ -707,7 +723,7 @@ BOOL WINAPI SetupDiGetClassDescriptionExW( Reserved); if (hKey == INVALID_HANDLE_VALUE) { - ERR("SetupDiOpenClassRegKeyExW() failed (Error %lu)\n", GetLastError()); + WARN("SetupDiOpenClassRegKeyExW() failed (Error %lu)\n", GetLastError()); return FALSE; } @@ -855,8 +871,8 @@ static HKEY CreateClassKey(HINF hInf) if (!SetupGetLineTextW(NULL, hInf, - L"Version", - L"ClassGUID", + Version, + ClassGUID, Buffer, MAX_PATH, &RequiredSize)) @@ -864,7 +880,7 @@ static HKEY CreateClassKey(HINF hInf) return INVALID_HANDLE_VALUE; } - lstrcpyW(FullBuffer, L"System\\CurrentControlSet\\Control\\Class\\"); + lstrcpyW(FullBuffer, ControlClass); lstrcatW(FullBuffer, Buffer); if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, @@ -875,8 +891,8 @@ static HKEY CreateClassKey(HINF hInf) { if (!SetupGetLineTextW(NULL, hInf, - L"Version", - L"Class", + Version, + Class, Buffer, MAX_PATH, &RequiredSize)) @@ -900,7 +916,7 @@ static HKEY CreateClassKey(HINF hInf) } if (RegSetValueExW(hClassKey, - L"Class", + Class, 0, REG_SZ, (LPBYTE)Buffer, @@ -931,7 +947,7 @@ BOOL WINAPI SetupDiInstallClassW( HKEY hClassKey; - FIXME("Incomplete function.\n"); + FIXME("\n"); if ((Flags & DI_NOVCP) && (FileQueue == NULL || FileQueue == INVALID_HANDLE_VALUE)) { @@ -1001,7 +1017,6 @@ BOOL WINAPI SetupDiInstallClassW( /* FIXME: More code! */ -ByeBye: if (bFileQueueCreated) SetupCloseFileQueue(FileQueue); @@ -1051,7 +1066,7 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW( LPWSTR lpGuidString; HKEY hClassesKey; HKEY hClassKey; - LPWSTR lpKeyName; + LPCWSTR lpKeyName; if (MachineName != NULL) { @@ -1061,11 +1076,11 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW( if (Flags == DIOCR_INSTALLER) { - lpKeyName = L"SYSTEM\\CurrentControlSet\\Control\\Class"; + lpKeyName = ControlClass; } else if (Flags == DIOCR_INTERFACE) { - lpKeyName = L"SYSTEM\\CurrentControlSet\\Control\\DeviceClasses"; + lpKeyName = DeviceClasses; } else { @@ -1109,7 +1124,6 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW( return hClassKey; } - /*********************************************************************** * SetupDiOpenDeviceInterfaceA (SETUPAPI.@) */ diff --git a/reactos/lib/setupapi/dirid.c b/reactos/lib/setupapi/dirid.c index 63f2e86377b..639da022258 100644 --- a/reactos/lib/setupapi/dirid.c +++ b/reactos/lib/setupapi/dirid.c @@ -29,6 +29,7 @@ #include "winuser.h" #include "winnls.h" #include "setupapi.h" +#include "shlobj.h" #include "wine/unicode.h" #include "setupapi_private.h" #include "wine/debug.h" @@ -36,6 +37,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(setupapi); #define MAX_SYSTEM_DIRID DIRID_PRINTPROCESSOR +#define MIN_CSIDL_DIRID 0x4000 +#define MAX_CSIDL_DIRID 0x403f struct user_dirid { @@ -47,6 +50,7 @@ static int nb_user_dirids; /* number of user dirids in use */ static int alloc_user_dirids; /* number of allocated user dirids */ static struct user_dirid *user_dirids; static const WCHAR *system_dirids[MAX_SYSTEM_DIRID+1]; +static const WCHAR *csidl_dirids[MAX_CSIDL_DIRID-MIN_CSIDL_DIRID+1]; /* retrieve the string for unknown dirids */ static const WCHAR *get_unknown_dirid(void) @@ -64,6 +68,8 @@ static const WCHAR *get_unknown_dirid(void) return unknown_dirid; } +static const WCHAR *get_csidl_dir(DWORD csidl); + /* create the string for a system dirid */ static const WCHAR *create_system_dirid( int dirid ) { @@ -76,8 +82,9 @@ static const WCHAR *create_system_dirid( int dirid ) static const WCHAR Viewers[] = {'\\','v','i','e','w','e','r','s',0}; static const WCHAR System[] = {'\\','s','y','s','t','e','m',0}; static const WCHAR Spool[] = {'\\','s','p','o','o','l',0}; + static const WCHAR UserProfile[] = {'U','S','E','R','P','R','O','F','I','L','E',0}; - WCHAR buffer[MAX_PATH+16], *str; + WCHAR buffer[MAX_PATH+32], *str; int len; switch(dirid) @@ -126,9 +133,11 @@ static const WCHAR *create_system_dirid( int dirid ) GetWindowsDirectoryW( buffer, MAX_PATH ); strcatW( buffer, Spool ); break; + case DIRID_USERPROFILE: + if (GetEnvironmentVariableW( UserProfile, buffer, MAX_PATH )) break; + return get_csidl_dir(CSIDL_PROFILE); case DIRID_LOADER: return C_Root; /* FIXME */ - case DIRID_USERPROFILE: /* FIXME */ case DIRID_COLOR: /* FIXME */ case DIRID_PRINTPROCESSOR: /* FIXME */ default: @@ -140,6 +149,21 @@ static const WCHAR *create_system_dirid( int dirid ) return str; } +static const WCHAR *get_csidl_dir( DWORD csidl ) +{ + WCHAR buffer[MAX_PATH], *str; + int len; + + if (!SHGetSpecialFolderPathW( NULL, buffer, csidl, TRUE )) + { + FIXME( "CSIDL %lx not found\n", csidl ); + return get_unknown_dirid(); + } + len = (strlenW(buffer) + 1) * sizeof(WCHAR); + if ((str = HeapAlloc( GetProcessHeap(), 0, len ))) memcpy( str, buffer, len ); + return str; +} + /* retrieve the string corresponding to a dirid, or NULL if none */ const WCHAR *DIRID_get_string( HINF hinf, int dirid ) { @@ -154,6 +178,13 @@ const WCHAR *DIRID_get_string( HINF hinf, int dirid ) ERR("user id %d not found\n", dirid ); return NULL; } + else if (dirid >= MIN_CSIDL_DIRID) + { + if (dirid > MAX_CSIDL_DIRID) return get_unknown_dirid(); + dirid -= MIN_CSIDL_DIRID; + if (!csidl_dirids[dirid]) csidl_dirids[dirid] = get_csidl_dir( dirid ); + return csidl_dirids[dirid]; + } else { if (dirid > MAX_SYSTEM_DIRID) return get_unknown_dirid(); diff --git a/reactos/lib/setupapi/queue.c b/reactos/lib/setupapi/queue.c index 7e82d376353..c320b5ba7ec 100644 --- a/reactos/lib/setupapi/queue.c +++ b/reactos/lib/setupapi/queue.c @@ -173,7 +173,7 @@ static void concat_W( WCHAR *buffer, const WCHAR *src1, const WCHAR *src2, const */ static BOOL build_filepathsW( const struct file_op *op, FILEPATHS_W *paths ) { - int src_len = 1, dst_len = 1; + unsigned int src_len = 1, dst_len = 1; WCHAR *source = (PWSTR)paths->Source, *target = (PWSTR)paths->Target; if (op->src_root) src_len += strlenW(op->src_root) + 1; @@ -991,7 +991,7 @@ BOOL static do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style) LPVOID VersionTarget; VS_FIXEDFILEINFO *TargetInfo; VS_FIXEDFILEINFO *SourceInfo; - INT length; + UINT length; WCHAR SubBlock[2]={'\\',0}; DWORD ret; @@ -1370,6 +1370,57 @@ UINT WINAPI SetupDefaultQueueCallbackA( PVOID context, UINT notification, UINT WINAPI SetupDefaultQueueCallbackW( PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2 ) { - FIXME( "notification %d params %x,%x\n", notification, param1, param2 ); + FILEPATHS_W *paths = (FILEPATHS_W *)param1; + + switch(notification) + { + case SPFILENOTIFY_STARTQUEUE: + TRACE( "start queue\n" ); + return TRUE; + case SPFILENOTIFY_ENDQUEUE: + TRACE( "end queue\n" ); + return 0; + case SPFILENOTIFY_STARTSUBQUEUE: + TRACE( "start subqueue %d count %d\n", param1, param2 ); + return TRUE; + case SPFILENOTIFY_ENDSUBQUEUE: + TRACE( "end subqueue %d\n", param1 ); + return 0; + case SPFILENOTIFY_STARTDELETE: + TRACE( "start delete %s\n", debugstr_w(paths->Target) ); + return FILEOP_DOIT; + case SPFILENOTIFY_ENDDELETE: + TRACE( "end delete %s\n", debugstr_w(paths->Target) ); + return 0; + case SPFILENOTIFY_DELETEERROR: + ERR( "delete error %d %s\n", paths->Win32Error, debugstr_w(paths->Target) ); return FILEOP_SKIP; + case SPFILENOTIFY_STARTRENAME: + TRACE( "start rename %s -> %s\n", debugstr_w(paths->Source), debugstr_w(paths->Target) ); + return FILEOP_DOIT; + case SPFILENOTIFY_ENDRENAME: + TRACE( "end rename %s -> %s\n", debugstr_w(paths->Source), debugstr_w(paths->Target) ); + return 0; + case SPFILENOTIFY_RENAMEERROR: + ERR( "rename error %d %s -> %s\n", paths->Win32Error, + debugstr_w(paths->Source), debugstr_w(paths->Target) ); + return FILEOP_SKIP; + case SPFILENOTIFY_STARTCOPY: + TRACE( "start copy %s -> %s\n", debugstr_w(paths->Source), debugstr_w(paths->Target) ); + return FILEOP_DOIT; + case SPFILENOTIFY_ENDCOPY: + TRACE( "end copy %s -> %s\n", debugstr_w(paths->Source), debugstr_w(paths->Target) ); + return 0; + case SPFILENOTIFY_COPYERROR: + ERR( "copy error %d %s -> %s\n", paths->Win32Error, + debugstr_w(paths->Source), debugstr_w(paths->Target) ); + return FILEOP_SKIP; + case SPFILENOTIFY_NEEDMEDIA: + TRACE( "need media\n" ); + return FILEOP_SKIP; + default: + FIXME( "notification %d params %x,%x\n", notification, param1, param2 ); + break; + } + return 0; }