Author: akhaldi Date: Sat May 19 14:07:00 2012 New Revision: 56627
URL: http://svn.reactos.org/svn/reactos?rev=56627&view=rev Log: [SETUPAPI] * Import SetupDuplicateDiskSpaceListA/W and SetupQuerySpaceRequiredOnDriveW from Wine 1.5.4.
Modified: trunk/reactos/dll/win32/setupapi/diskspace.c trunk/reactos/dll/win32/setupapi/setupapi.spec
Modified: trunk/reactos/dll/win32/setupapi/diskspace.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/diskspac... ============================================================================== --- trunk/reactos/dll/win32/setupapi/diskspace.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/diskspace.c [iso-8859-1] Sat May 19 14:07:00 2012 @@ -85,6 +85,44 @@ return SetupCreateDiskSpaceListW( Reserved1, Reserved2, Flags ); }
+/*********************************************************************** + * SetupDuplicateDiskSpaceListW (SETUPAPI.@) + */ +HDSKSPC WINAPI SetupDuplicateDiskSpaceListW(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags) +{ + DISKSPACELIST *list_copy, *list_original = DiskSpace; + + if (Reserved1 || Reserved2 || Flags) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + if (!DiskSpace) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + + list_copy = HeapAlloc(GetProcessHeap(), 0, sizeof(DISKSPACELIST)); + if (!list_copy) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } + + *list_copy = *list_original; + + return list_copy; +} + +/*********************************************************************** + * SetupDuplicateDiskSpaceListA (SETUPAPI.@) + */ +HDSKSPC WINAPI SetupDuplicateDiskSpaceListA(HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags) +{ + return SetupDuplicateDiskSpaceListW(DiskSpace, Reserved1, Reserved2, Flags); +}
/*********************************************************************** * SetupAddInstallSectionToDiskSpaceListA (SETUPAPI.@) @@ -98,24 +136,42 @@ }
/*********************************************************************** -* SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@) +* SetupQuerySpaceRequiredOnDriveW (SETUPAPI.@) */ -BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace, - LPCSTR DriveSpec, LONGLONG* SpaceRequired, +BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace, + LPCWSTR DriveSpec, LONGLONG *SpaceRequired, PVOID Reserved1, UINT Reserved2) { - WCHAR driveW[20]; + WCHAR *driveW; unsigned int i; - LPDISKSPACELIST list = (LPDISKSPACELIST)DiskSpace; + LPDISKSPACELIST list = DiskSpace; BOOL rc = FALSE; static const WCHAR bkslsh[]= {'\',0};
- MultiByteToWideChar(CP_ACP,0,DriveSpec,-1,driveW,20); - + if (!DiskSpace) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (!DriveSpec) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + driveW = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(DriveSpec) + 2) * sizeof(WCHAR)); + if (!driveW) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + lstrcpyW(driveW,DriveSpec); lstrcatW(driveW,bkslsh);
TRACE("Looking for drive %s\n",debugstr_w(driveW)); - + for (i = 0; i < list->dwDriveCount; i++) { TRACE("checking drive %s\n",debugstr_w(list->Drives[i].lpzName)); @@ -127,7 +183,54 @@ } }
+ HeapFree(GetProcessHeap(), 0, driveW); + + if (!rc) SetLastError(ERROR_INVALID_DRIVE); return rc; +} + +/*********************************************************************** +* SetupQuerySpaceRequiredOnDriveA (SETUPAPI.@) +*/ +BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace, + LPCSTR DriveSpec, LONGLONG *SpaceRequired, + PVOID Reserved1, UINT Reserved2) +{ + DWORD len; + LPWSTR DriveSpecW; + BOOL ret; + + /* The parameter validation checks are in a different order from the + * Unicode variant of SetupQuerySpaceRequiredOnDrive. */ + if (!DriveSpec) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (!DiskSpace) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + len = MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, NULL, 0); + + DriveSpecW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!DriveSpecW) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, DriveSpecW, len); + + ret = SetupQuerySpaceRequiredOnDriveW(DiskSpace, DriveSpecW, SpaceRequired, + Reserved1, Reserved2); + + HeapFree(GetProcessHeap(), 0, DriveSpecW); + + return ret; }
/***********************************************************************
Modified: trunk/reactos/dll/win32/setupapi/setupapi.spec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupapi... ============================================================================== --- trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] Sat May 19 14:07:00 2012 @@ -388,8 +388,8 @@ @ stdcall SetupDiSetSelectedDriverA(ptr ptr ptr) @ stdcall SetupDiSetSelectedDriverW(ptr ptr ptr) @ stdcall SetupDiUnremoveDevice(ptr ptr) -@ stub SetupDuplicateDiskSpaceListA -@ stub SetupDuplicateDiskSpaceListW +@ stdcall SetupDuplicateDiskSpaceListA(ptr ptr long long) +@ stdcall SetupDuplicateDiskSpaceListW(ptr ptr long long) @ stdcall SetupEnumInfSectionsA(long long ptr long ptr) @ stdcall SetupEnumInfSectionsW(long long ptr long ptr) @ stdcall SetupFindFirstLineA(long str str ptr) @@ -481,7 +481,7 @@ @ stub SetupQuerySourceListA @ stub SetupQuerySourceListW @ stdcall SetupQuerySpaceRequiredOnDriveA(long str ptr ptr long) -@ stub SetupQuerySpaceRequiredOnDriveW +@ stdcall SetupQuerySpaceRequiredOnDriveW(long wstr ptr ptr long) @ stdcall SetupQueueCopyA(long str str str str str str str long) @ stdcall SetupQueueCopyIndirectA(ptr) @ stdcall SetupQueueCopyIndirectW(ptr)