ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
29 participants
250 discussions
Start a n
N
ew thread
02/02: [SETUPAPI] Don't let LZClose() reset error code
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=497a9c8087995039258c0…
commit 497a9c8087995039258c0afaa6ef4d9c546028fe Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Fri Nov 2 09:34:25 2018 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Fri Nov 2 09:34:25 2018 +0100 [SETUPAPI] Don't let LZClose() reset error code --- dll/win32/setupapi/queue.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dll/win32/setupapi/queue.c b/dll/win32/setupapi/queue.c index e5919bba5c..4da2b5b5b7 100644 --- a/dll/win32/setupapi/queue.c +++ b/dll/win32/setupapi/queue.c @@ -1068,6 +1068,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, WCHAR TempPath[MAX_PATH]; WCHAR TempFile[MAX_PATH]; LONG lRes; + DWORD dwLastError; #endif TRACE("copy %s to %s style 0x%x\n",debugstr_w(source),debugstr_w(target),style); @@ -1090,11 +1091,16 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, if (!GetTempFileNameW(TempPath, L"", 0, TempFile)) { + dwLastError = GetLastError(); + ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath)); /* Close the source handle */ LZClose(hSource); + /* Restore error condition triggered by GetTempFileNameW */ + SetLastError(dwLastError); + return FALSE; } @@ -1102,6 +1108,8 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE); if (hTemp < 0) { + dwLastError = GetLastError(); + ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile)); /* Close the source handle */ @@ -1110,11 +1118,16 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, /* Delete temp file if an error is signaled */ DeleteFileW(TempFile); + /* Restore error condition triggered by LZOpenFileW */ + SetLastError(dwLastError); + return FALSE; } lRes = LZCopy(hSource, hTemp); + dwLastError = GetLastError(); + LZClose(hSource); LZClose(hTemp); @@ -1125,6 +1138,9 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, /* Delete temp file if copy was not successful */ DeleteFileW(TempFile); + /* Restore error condition triggered by LZCopy */ + SetLastError(dwLastError); + return FALSE; } #endif
6 years, 1 month
1
0
0
0
01/02: Avoid stray temp files in failure cases of do_file_copyW. CORE-12616
by Carlo Bramini
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8236bb8f38aa72bfc4288…
commit 8236bb8f38aa72bfc4288df570afaccb6da22a07 Author: Carlo Bramini <carlo.bramix(a)libero.it> AuthorDate: Fri Mar 2 10:14:07 2018 +0100 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Fri Nov 2 09:22:34 2018 +0100 Avoid stray temp files in failure cases of do_file_copyW. CORE-12616 --- dll/win32/setupapi/queue.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/dll/win32/setupapi/queue.c b/dll/win32/setupapi/queue.c index 060984be8f..e5919bba5c 100644 --- a/dll/win32/setupapi/queue.c +++ b/dll/win32/setupapi/queue.c @@ -1067,6 +1067,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, OFSTRUCT OfStruct; WCHAR TempPath[MAX_PATH]; WCHAR TempFile[MAX_PATH]; + LONG lRes; #endif TRACE("copy %s to %s style 0x%x\n",debugstr_w(source),debugstr_w(target),style); @@ -1078,11 +1079,6 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, ERR("GetTempPathW error\n"); return FALSE; } - if (!GetTempFileNameW(TempPath, L"", 0, TempFile)) - { - ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath)); - return FALSE; - } /* Try to open the source file */ hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ); @@ -1092,25 +1088,45 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, return FALSE; } + if (!GetTempFileNameW(TempPath, L"", 0, TempFile)) + { + ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath)); + + /* Close the source handle */ + LZClose(hSource); + + return FALSE; + } + /* Extract the compressed file to a temp location */ hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE); if (hTemp < 0) { - DWORD dwLastError = GetLastError(); - ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile)); /* Close the source handle */ LZClose(hSource); - /* Restore error condition triggered by LZOpenFileW */ - SetLastError(dwLastError); + /* Delete temp file if an error is signaled */ + DeleteFileW(TempFile); + return FALSE; } - LZCopy(hSource, hTemp); + lRes = LZCopy(hSource, hTemp); + LZClose(hSource); LZClose(hTemp); + + if (lRes < 0) + { + ERR("LZCopy error %d (%s, %s)\n", (int)lRes, debugstr_w(source), debugstr_w(TempFile)); + + /* Delete temp file if copy was not successful */ + DeleteFileW(TempFile); + + return FALSE; + } #endif /* before copy processing */
6 years, 1 month
1
0
0
0
01/01: [WIN32SS][FONT] Move IntUnLockFreeType(); in ftGdiGetTextMetricsW (#1002)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5d26cf5e2afa9c92f28dc…
commit 5d26cf5e2afa9c92f28dc999569b2670ac0e79c5 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Fri Nov 2 16:29:18 2018 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Fri Nov 2 16:29:18 2018 +0900 [WIN32SS][FONT] Move IntUnLockFreeType(); in ftGdiGetTextMetricsW (#1002) Adjust timing of FreeType unlocking in ftGdiGetTextMetricsW function of "freetype.c". JIRA issue: N/A --- win32ss/gdi/ntgdi/freetype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index dfdb3768f6..693056b9a2 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -4326,8 +4326,6 @@ ftGdiGetTextMetricsW( Error = FT_Get_WinFNT_Header(Face, &Win); - IntUnLockFreeType(); - if (NT_SUCCESS(Status)) { FillTM(&ptmwi->TextMetric, FontGDI, pOS2, pHori, !Error ? &Win : 0); @@ -4335,6 +4333,8 @@ ftGdiGetTextMetricsW( /* FIXME: Fill Diff member */ RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff)); } + + IntUnLockFreeType(); } TEXTOBJ_UnlockText(TextObj); }
6 years, 1 month
1
0
0
0
01/01: [WIN32SS][FONT] Add DPRINT1 and ASSERT for font resize failure (#1003)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ce077bb5d37f2aea4602c…
commit ce077bb5d37f2aea4602c50d027a24be3f8b3b54 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Fri Nov 2 16:28:00 2018 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Fri Nov 2 16:28:00 2018 +0900 [WIN32SS][FONT] Add DPRINT1 and ASSERT for font resize failure (#1003) Add DPRINT1 and ASSERT calls for font resize failure in IntRequestFontSize function. JIRA issue: N/A --- win32ss/gdi/ntgdi/freetype.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index 31a4b4920e..dfdb3768f6 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -3274,7 +3274,11 @@ IntRequestFontSize(PDC dc, PFONTGDI FontGDI, LONG lfWidth, LONG lfHeight) { error = FT_Get_WinFNT_Header(face, &WinFNT); if (error) + { + DPRINT1("%s: Failed to request font size.\n", face->family_name); + ASSERT(FALSE); return error; + } FontGDI->tmHeight = WinFNT.pixel_height; FontGDI->tmAscent = WinFNT.ascent;
6 years, 1 month
1
0
0
0
01/01: [REACTOS] Temporarily exclude the 1st-stage GUI setup from build, until I (or someone else) finds the correct way to fix the GCC builds.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8cbaca5724b2a8567dbd6…
commit 8cbaca5724b2a8567dbd62f9f3fef3aa1ccae552 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Nov 1 23:20:27 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Nov 1 23:20:27 2018 +0100 [REACTOS] Temporarily exclude the 1st-stage GUI setup from build, until I (or someone else) finds the correct way to fix the GCC builds. --- base/setup/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/setup/CMakeLists.txt b/base/setup/CMakeLists.txt index ee5a90d0bc..ce9adc709f 100644 --- a/base/setup/CMakeLists.txt +++ b/base/setup/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(lib) -add_subdirectory(reactos) +#add_subdirectory(reactos) add_subdirectory(setup) add_subdirectory(usetup) add_subdirectory(welcome)
6 years, 1 month
1
0
0
0
04/04: [SETUPLIB][USETUP] Minor improvements.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1b0c26e21cbdb73998529…
commit 1b0c26e21cbdb739985290dc5b5135af6c313cb4 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Jan 7 01:35:48 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Nov 1 18:55:45 2018 +0100 [SETUPLIB][USETUP] Minor improvements. - Use adequate access flag when opening symbolic links. - Simplify the prototype of UpdateRegistry() since now both Setup INF handle and settings lists are inside the USETUP_DATA structure. --- base/setup/lib/setuplib.c | 25 +++++++++++-------------- base/setup/lib/setuplib.h | 4 ---- base/setup/lib/utils/arcname.c | 6 +++--- base/setup/usetup/usetup.c | 8 ++------ 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c index 34eb2283bb..915acd5a36 100644 --- a/base/setup/lib/setuplib.c +++ b/base/setup/lib/setuplib.c @@ -391,7 +391,7 @@ GetSourcePaths( OUT PUNICODE_STRING SourceRootDir) { NTSTATUS Status; - HANDLE Handle; + HANDLE LinkHandle; OBJECT_ATTRIBUTES ObjectAttributes; UCHAR ImageFileBuffer[sizeof(UNICODE_STRING) + MAX_PATH * sizeof(WCHAR)]; PUNICODE_STRING InstallSourcePath = (PUNICODE_STRING)&ImageFileBuffer; @@ -439,7 +439,7 @@ GetSourcePaths( NULL, NULL); - Status = NtOpenSymbolicLinkObject(&Handle, + Status = NtOpenSymbolicLinkObject(&LinkHandle, SYMBOLIC_LINK_QUERY, &ObjectAttributes); if (!NT_SUCCESS(Status)) @@ -458,10 +458,11 @@ GetSourcePaths( SystemRootBuffer, sizeof(SystemRootBuffer)); - Status = NtQuerySymbolicLinkObject(Handle, + /* Resolve the link and close its handle */ + Status = NtQuerySymbolicLinkObject(LinkHandle, &SystemRootPath, &BufferSize); - NtClose(Handle); + NtClose(LinkHandle); if (!NT_SUCCESS(Status)) return Status; // Unexpected error @@ -790,15 +791,11 @@ FinishSetup( */ ERROR_NUMBER UpdateRegistry( - IN HINF SetupInf, IN OUT PUSETUP_DATA pSetupData, /**/IN BOOLEAN RepairUpdateFlag, /* HACK HACK! */ /**/IN PPARTLIST PartitionList, /* HACK HACK! */ /**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */ /**/IN PCWSTR SelectedLanguageId, /* HACK HACK! */ - IN PGENERIC_LIST DisplayList, - IN PGENERIC_LIST LayoutList, - IN PGENERIC_LIST LanguageList, IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL) { ERROR_NUMBER ErrorNumber; @@ -860,9 +857,9 @@ DoUpdate: * "repair" (aka. recreate: ShouldRepairRegistry == TRUE). */ - Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible + Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible if (!Success) - Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific + Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific if (!Success) { @@ -879,7 +876,7 @@ DoUpdate: * we only update the hives. */ - Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext); + Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext); if (!Success) { /* Nothing to do for update! */ @@ -939,7 +936,7 @@ DoUpdate: /* Update display registry settings */ if (StatusRoutine) StatusRoutine(DisplaySettingsUpdate); - if (!ProcessDisplayRegistry(SetupInf, DisplayList)) + if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayList)) { ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS; goto Cleanup; @@ -947,7 +944,7 @@ DoUpdate: /* Set the locale */ if (StatusRoutine) StatusRoutine(LocaleSettingsUpdate); - if (!ProcessLocaleRegistry(LanguageList)) + if (!ProcessLocaleRegistry(pSetupData->LanguageList)) { ErrorNumber = ERROR_UPDATE_LOCALESETTINGS; goto Cleanup; @@ -972,7 +969,7 @@ DoUpdate: { /* Update keyboard layout settings */ if (StatusRoutine) StatusRoutine(KeybSettingsUpdate); - if (!ProcessKeyboardLayoutRegistry(LayoutList, SelectedLanguageId)) + if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutList, SelectedLanguageId)) { ErrorNumber = ERROR_UPDATE_KBSETTINGS; goto Cleanup; diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h index 0686b00d58..585808f6fa 100644 --- a/base/setup/lib/setuplib.h +++ b/base/setup/lib/setuplib.h @@ -176,15 +176,11 @@ typedef VOID ERROR_NUMBER UpdateRegistry( - IN HINF SetupInf, IN OUT PUSETUP_DATA pSetupData, /**/IN BOOLEAN RepairUpdateFlag, /* HACK HACK! */ /**/IN PPARTLIST PartitionList, /* HACK HACK! */ /**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */ /**/IN PCWSTR SelectedLanguageId, /* HACK HACK! */ - IN PGENERIC_LIST DisplayList, - IN PGENERIC_LIST LayoutList, - IN PGENERIC_LIST LanguageList, IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL); /* EOF */ diff --git a/base/setup/lib/utils/arcname.c b/base/setup/lib/utils/arcname.c index 56f44cfef3..5d63dd02b3 100644 --- a/base/setup/lib/utils/arcname.c +++ b/base/setup/lib/utils/arcname.c @@ -616,7 +616,7 @@ ResolveArcNameNtSymLink( DirectoryHandle, NULL); Status = NtOpenSymbolicLinkObject(&LinkHandle, - SYMBOLIC_LINK_ALL_ACCESS, + SYMBOLIC_LINK_QUERY, &ObjectAttributes); /* Close the \ArcName object directory handle */ @@ -632,8 +632,9 @@ ResolveArcNameNtSymLink( /* Reserve one WCHAR for the NULL-termination */ NtName->MaximumLength -= sizeof(UNICODE_NULL); - /* Resolve the link */ + /* Resolve the link and close its handle */ Status = NtQuerySymbolicLinkObject(LinkHandle, NtName, NULL); + NtClose(LinkHandle); /* Restore the NULL-termination */ NtName->MaximumLength += sizeof(UNICODE_NULL); @@ -650,7 +651,6 @@ ResolveArcNameNtSymLink( NtName->Buffer[NtName->Length / sizeof(WCHAR)] = UNICODE_NULL; } - NtClose(LinkHandle); return Status; } diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index 46da942935..d951a65a86 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -21,7 +21,7 @@ * PROJECT: ReactOS text-mode setup * FILE: base/setup/usetup/usetup.c * PURPOSE: Text-mode setup - * PROGRAMMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net) + * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net) * Herv� Poussineau (hpoussin(a)reactos.org) */ @@ -4300,15 +4300,11 @@ RegistryPage(PINPUT_RECORD Ir) MUIDisplayPage(REGISTRY_PAGE); - Error = UpdateRegistry(USetupData.SetupInf, - &USetupData, + Error = UpdateRegistry(&USetupData, RepairUpdateFlag, PartitionList, DestinationDriveLetter, SelectedLanguageId, - USetupData.DisplayList, - USetupData.LayoutList, - USetupData.LanguageList, RegistryStatus); if (Error != ERROR_SUCCESS) {
6 years, 1 month
1
0
0
0
03/04: [USETUP] Improve SetupCommitFileQueueW() to make it compatible with its Win32 counterpart.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=13998a15c986f825a7d4e…
commit 13998a15c986f825a7d4e6b98b72aa54d79a70b0 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Mon Jan 15 18:48:51 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Nov 1 18:55:44 2018 +0100 [USETUP] Improve SetupCommitFileQueueW() to make it compatible with its Win32 counterpart. This means, call in the correct order the user callback with the correct parameters (in particular the correct paths for file copy operations), and check also for the callback returned value to know whether or not to continue the file operations. --- base/setup/usetup/spapisup/fileqsup.c | 283 ++++++++++++++++++++++++---------- base/setup/usetup/usetup.c | 26 +++- 2 files changed, 220 insertions(+), 89 deletions(-) diff --git a/base/setup/usetup/spapisup/fileqsup.c b/base/setup/usetup/spapisup/fileqsup.c index 75f6b36d41..b82fcd889d 100644 --- a/base/setup/usetup/spapisup/fileqsup.c +++ b/base/setup/usetup/spapisup/fileqsup.c @@ -621,12 +621,12 @@ SetupCommitFileQueueW( IN PVOID Context OPTIONAL) { BOOL Success = TRUE; // Suppose success + UINT Result; NTSTATUS Status; PFILEQUEUEHEADER QueueHeader; PLIST_ENTRY ListEntry; PQUEUEENTRY Entry; FILEPATHS_W FilePathInfo; - WCHAR CabinetName[MAX_PATH]; WCHAR FileSrcPath[MAX_PATH]; WCHAR FileDstPath[MAX_PATH]; @@ -635,32 +635,40 @@ SetupCommitFileQueueW( QueueHeader = (PFILEQUEUEHEADER)QueueHandle; - MsgHandler(Context, - SPFILENOTIFY_STARTQUEUE, - (UINT_PTR)Owner, - 0); + Result = MsgHandler(Context, + SPFILENOTIFY_STARTQUEUE, + (UINT_PTR)Owner, + 0); + if (Result == FILEOP_ABORT) + return FALSE; /* * Commit the delete queue */ - MsgHandler(Context, - SPFILENOTIFY_STARTSUBQUEUE, - FILEOP_DELETE, - QueueHeader->DeleteCount); + if (!IsListEmpty(&QueueHeader->DeleteQueue)) + { + Result = MsgHandler(Context, + SPFILENOTIFY_STARTSUBQUEUE, + FILEOP_DELETE, + QueueHeader->DeleteCount); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto Quit; + } + } - ListEntry = QueueHeader->DeleteQueue.Flink; - while (ListEntry != &QueueHeader->DeleteQueue) + for (ListEntry = QueueHeader->DeleteQueue.Flink; + ListEntry != &QueueHeader->DeleteQueue; + ListEntry = ListEntry->Flink) { Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); - ListEntry = ListEntry->Flink; /* Build the full target path */ CombinePaths(FileDstPath, ARRAYSIZE(FileDstPath), 2, Entry->TargetDirectory, Entry->TargetFileName); - // RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), Entry->TargetDirectory); - // ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFileName); DPRINT1(" -----> " "Delete: '%S'\n", FileDstPath); @@ -669,52 +677,85 @@ SetupCommitFileQueueW( FilePathInfo.Win32Error = STATUS_SUCCESS; FilePathInfo.Flags = 0; // FIXME: Unused yet... - MsgHandler(Context, - SPFILENOTIFY_STARTDELETE, - (UINT_PTR)&FilePathInfo, - FILEOP_DELETE); + Result = MsgHandler(Context, + SPFILENOTIFY_STARTDELETE, + (UINT_PTR)&FilePathInfo, + FILEOP_DELETE); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto EndDelete; + } + else if (Result == FILEOP_SKIP) + goto EndDelete; + // else (Result == FILEOP_DOIT) +RetryDelete: /* Force-delete the file */ Status = SetupDeleteFile(FileDstPath, TRUE); if (!NT_SUCCESS(Status)) { /* An error happened */ FilePathInfo.Win32Error = (UINT)Status; - MsgHandler(Context, - SPFILENOTIFY_DELETEERROR, - (UINT_PTR)&FilePathInfo, - 0); + Result = MsgHandler(Context, + SPFILENOTIFY_DELETEERROR, + (UINT_PTR)&FilePathInfo, + 0); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto EndDelete; + } + else if (Result == FILEOP_SKIP) + goto EndDelete; + else if (Result == FILEOP_RETRY) + goto RetryDelete; + Success = FALSE; } +EndDelete: /* This notification is always sent, even in case of error */ FilePathInfo.Win32Error = (UINT)Status; MsgHandler(Context, SPFILENOTIFY_ENDDELETE, (UINT_PTR)&FilePathInfo, 0); + if (Success == FALSE /* && Result == FILEOP_ABORT */) + goto Quit; } - MsgHandler(Context, - SPFILENOTIFY_ENDSUBQUEUE, - FILEOP_DELETE, - 0); + if (!IsListEmpty(&QueueHeader->DeleteQueue)) + { + MsgHandler(Context, + SPFILENOTIFY_ENDSUBQUEUE, + FILEOP_DELETE, + 0); + } /* * Commit the rename queue */ - MsgHandler(Context, - SPFILENOTIFY_STARTSUBQUEUE, - FILEOP_RENAME, - QueueHeader->RenameCount); + if (!IsListEmpty(&QueueHeader->RenameQueue)) + { + Result = MsgHandler(Context, + SPFILENOTIFY_STARTSUBQUEUE, + FILEOP_RENAME, + QueueHeader->RenameCount); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto Quit; + } + } - ListEntry = QueueHeader->RenameQueue.Flink; - while (ListEntry != &QueueHeader->RenameQueue) + for (ListEntry = QueueHeader->RenameQueue.Flink; + ListEntry != &QueueHeader->RenameQueue; + ListEntry = ListEntry->Flink) { Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); - ListEntry = ListEntry->Flink; /* Build the full source path */ CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 2, @@ -723,8 +764,6 @@ SetupCommitFileQueueW( /* Build the full target path */ CombinePaths(FileDstPath, ARRAYSIZE(FileDstPath), 2, Entry->TargetDirectory, Entry->TargetFileName); - // RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), Entry->TargetDirectory); - // ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFileName); DPRINT1(" -----> " "Rename: '%S' ==> '%S'\n", FileSrcPath, FileDstPath); @@ -733,11 +772,20 @@ SetupCommitFileQueueW( FilePathInfo.Win32Error = STATUS_SUCCESS; FilePathInfo.Flags = 0; // FIXME: Unused yet... - MsgHandler(Context, - SPFILENOTIFY_STARTRENAME, - (UINT_PTR)&FilePathInfo, - FILEOP_RENAME); + Result = MsgHandler(Context, + SPFILENOTIFY_STARTRENAME, + (UINT_PTR)&FilePathInfo, + FILEOP_RENAME); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto EndRename; + } + else if (Result == FILEOP_SKIP) + goto EndRename; + // else (Result == FILEOP_DOIT) +RetryRename: /* Move or rename the file */ Status = SetupMoveFile(FileSrcPath, FileDstPath, MOVEFILE_REPLACE_EXISTING @@ -747,61 +795,105 @@ SetupCommitFileQueueW( { /* An error happened */ FilePathInfo.Win32Error = (UINT)Status; - MsgHandler(Context, - SPFILENOTIFY_RENAMEERROR, - (UINT_PTR)&FilePathInfo, - 0); + Result = MsgHandler(Context, + SPFILENOTIFY_RENAMEERROR, + (UINT_PTR)&FilePathInfo, + 0); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto EndRename; + } + else if (Result == FILEOP_SKIP) + goto EndRename; + else if (Result == FILEOP_RETRY) + goto RetryRename; + Success = FALSE; } +EndRename: /* This notification is always sent, even in case of error */ FilePathInfo.Win32Error = (UINT)Status; MsgHandler(Context, SPFILENOTIFY_ENDRENAME, (UINT_PTR)&FilePathInfo, 0); + if (Success == FALSE /* && Result == FILEOP_ABORT */) + goto Quit; } - MsgHandler(Context, - SPFILENOTIFY_ENDSUBQUEUE, - FILEOP_RENAME, - 0); + if (!IsListEmpty(&QueueHeader->RenameQueue)) + { + MsgHandler(Context, + SPFILENOTIFY_ENDSUBQUEUE, + FILEOP_RENAME, + 0); + } /* * Commit the copy queue */ - MsgHandler(Context, - SPFILENOTIFY_STARTSUBQUEUE, - FILEOP_COPY, - QueueHeader->CopyCount); + if (!IsListEmpty(&QueueHeader->CopyQueue)) + { + Result = MsgHandler(Context, + SPFILENOTIFY_STARTSUBQUEUE, + FILEOP_COPY, + QueueHeader->CopyCount); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto Quit; + } + } - ListEntry = QueueHeader->CopyQueue.Flink; - while (ListEntry != &QueueHeader->CopyQueue) + for (ListEntry = QueueHeader->CopyQueue.Flink; + ListEntry != &QueueHeader->CopyQueue; + ListEntry = ListEntry->Flink) { Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); - ListEntry = ListEntry->Flink; + + // + // TODO: Send a SPFILENOTIFY_NEEDMEDIA notification + // when we switch to a new installation media. + // Param1 = (UINT_PTR)(PSOURCE_MEDIA)SourceMediaInfo; + // Param2 = (UINT_PTR)(TCHAR[MAX_PATH])NewPathInfo; + // /* Build the full source path */ - CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 3, - Entry->SourceRootPath, Entry->SourcePath, - Entry->SourceFileName); + if (Entry->SourceCabinet == NULL) + { + CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 3, + Entry->SourceRootPath, Entry->SourcePath, + Entry->SourceFileName); + } + else + { + /* + * The cabinet must be in Entry->SourceRootPath only! + * (Should we ignore Entry->SourcePath?) + */ + CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 3, + Entry->SourceRootPath, Entry->SourcePath, + Entry->SourceCabinet); + } /* Build the full target path */ RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), Entry->TargetDirectory); - - /* - * If the file is in a cabinet, use only the destination path. - * Otherwise possibly use a different target name. - */ if (Entry->SourceCabinet == NULL) { + /* If the file is not in a cabinet, possibly use a different target name */ if (Entry->TargetFileName != NULL) ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFileName); else ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->SourceFileName); } + else + { + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->SourceFileName); + } DPRINT(" -----> " "Copy: '%S' ==> '%S'\n", FileSrcPath, FileDstPath); @@ -811,29 +903,35 @@ SetupCommitFileQueueW( // FilePathInfo.Target = FileDstPath; - FilePathInfo.Source = FileSrcPath; // when SourceCabinet not NULL, use CabinetName ... + FilePathInfo.Source = FileSrcPath; FilePathInfo.Win32Error = STATUS_SUCCESS; FilePathInfo.Flags = 0; // FIXME: Unused yet... - MsgHandler(Context, - SPFILENOTIFY_STARTCOPY, - (UINT_PTR)&FilePathInfo, - FILEOP_COPY); + Result = MsgHandler(Context, + SPFILENOTIFY_STARTCOPY, + (UINT_PTR)&FilePathInfo, + FILEOP_COPY); + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto EndCopy; + } + else if (Result == FILEOP_SKIP) + goto EndCopy; + // else (Result == FILEOP_DOIT) +RetryCopy: if (Entry->SourceCabinet != NULL) { /* - * Extract the file from the cabinet. - * The cabinet must be in Entry->SourceRootPath only! - * (ignore Entry->SourcePath). + * The file is in a cabinet, use only the destination path + * and keep the source name as the target name. */ - CombinePaths(CabinetName, ARRAYSIZE(CabinetName), 3, - Entry->SourceRootPath, Entry->SourcePath, - Entry->SourceCabinet); + /* Extract the file from the cabinet */ Status = SetupExtractFile(QueueHeader, - CabinetName, + FileSrcPath, // Specifies the cabinet path Entry->SourceFileName, - FileDstPath); + Entry->TargetDirectory); } else { @@ -845,27 +943,46 @@ SetupCommitFileQueueW( { /* An error happened */ FilePathInfo.Win32Error = (UINT)Status; - MsgHandler(Context, - SPFILENOTIFY_COPYERROR, - (UINT_PTR)&FilePathInfo, - (UINT_PTR)NULL); // FIXME: Unused yet... + Result = MsgHandler(Context, + SPFILENOTIFY_COPYERROR, + (UINT_PTR)&FilePathInfo, + (UINT_PTR)NULL); // FIXME: Unused yet... + if (Result == FILEOP_ABORT) + { + Success = FALSE; + goto EndCopy; + } + else if (Result == FILEOP_SKIP) + goto EndCopy; + else if (Result == FILEOP_RETRY) + goto RetryCopy; + else if (Result == FILEOP_NEWPATH) + goto RetryCopy; // TODO! + Success = FALSE; } +EndCopy: /* This notification is always sent, even in case of error */ FilePathInfo.Win32Error = (UINT)Status; MsgHandler(Context, SPFILENOTIFY_ENDCOPY, (UINT_PTR)&FilePathInfo, 0); + if (Success == FALSE /* && Result == FILEOP_ABORT */) + goto Quit; } - MsgHandler(Context, - SPFILENOTIFY_ENDSUBQUEUE, - FILEOP_COPY, - 0); + if (!IsListEmpty(&QueueHeader->CopyQueue)) + { + MsgHandler(Context, + SPFILENOTIFY_ENDSUBQUEUE, + FILEOP_COPY, + 0); + } +Quit: /* All the queues have been committed */ MsgHandler(Context, SPFILENOTIFY_ENDQUEUE, diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index 7fe24fcf2d..46da942935 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -4103,8 +4103,12 @@ FileCopyCallback(PVOID Context, if (DstFileName) ++DstFileName; else DstFileName = FilePathInfo->Target; - // TODO: Determine whether using STRING_RENAMING or STRING_MOVING - CONSOLE_SetStatusText(MUIGetString(STRING_MOVING), + if (!wcsicmp(SrcFileName, DstFileName)) + Param2 = STRING_MOVING; + else + Param2 = STRING_RENAMING; + + CONSOLE_SetStatusText(MUIGetString(Param2), SrcFileName, DstFileName); } else if (Notification == SPFILENOTIFY_STARTCOPY) @@ -4112,18 +4116,28 @@ FileCopyCallback(PVOID Context, /* Display copy message */ ASSERT(Param2 == FILEOP_COPY); - SrcFileName = wcsrchr(FilePathInfo->Source, L'\\'); - if (SrcFileName) ++SrcFileName; - else SrcFileName = FilePathInfo->Source; + /* NOTE: When extracting from CABs the Source is the CAB name */ + DstFileName = wcsrchr(FilePathInfo->Target, L'\\'); + if (DstFileName) ++DstFileName; + else DstFileName = FilePathInfo->Target; CONSOLE_SetStatusText(MUIGetString(STRING_COPYING), - SrcFileName); + DstFileName); } SetupUpdateMemoryInfo(CopyContext, FALSE); break; } + case SPFILENOTIFY_COPYERROR: + { + FilePathInfo = (PFILEPATHS_W)Param1; + + DPRINT1("An error happened while trying to copy file '%S' (error 0x%08lx), skipping it...\n", + FilePathInfo->Target, FilePathInfo->Win32Error); + return FILEOP_SKIP; + } + case SPFILENOTIFY_ENDDELETE: case SPFILENOTIFY_ENDRENAME: case SPFILENOTIFY_ENDCOPY:
6 years, 1 month
1
0
0
0
02/04: [SETUPLIB][REACTOS][USETUP] Further improve the interfacing with INF and File-Queue APIs.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8f1ab791faa1ca06ecfe1…
commit 8f1ab791faa1ca06ecfe1abac2a2ea5ab86c9353 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sat Jan 6 16:47:37 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Nov 1 18:55:43 2018 +0100 [SETUPLIB][REACTOS][USETUP] Further improve the interfacing with INF and File-Queue APIs. This allows using some of the SetupApi.dll functions when SETUPLIB is used in the (Win32) GUI 1st-stage installer "REACTOS", while using the custom implemented NT-aware functions in "USETUP". --- base/setup/lib/CMakeLists.txt | 5 +- base/setup/lib/registry.c | 60 +++---- base/setup/lib/settings.c | 44 ++--- base/setup/lib/setuplib.c | 102 ++++++------ base/setup/lib/setuplib.h | 3 +- base/setup/lib/spapisup/fileqsup.c | 34 ++++ .../filequeue.h => lib/spapisup/fileqsup.h} | 108 ++++++------- base/setup/lib/{utils => spapisup}/infsupp.c | 59 ++++--- base/setup/lib/{utils => spapisup}/infsupp.h | 178 +++++++++++---------- base/setup/lib/spapisup/spapisup.h | 29 ++++ base/setup/reactos/CMakeLists.txt | 3 +- base/setup/reactos/spapisup/fileqsup.c | 155 ++++++++++++++++++ .../reactos/{inffile.c => spapisup/infsupp.c} | 34 +++- base/setup/usetup/CMakeLists.txt | 6 +- base/setup/usetup/devinst.c | 19 +-- base/setup/usetup/{ => spapisup}/cabinet.c | 0 base/setup/usetup/{ => spapisup}/cabinet.h | 0 .../usetup/{filequeue.c => spapisup/fileqsup.c} | 37 +++-- base/setup/usetup/{ => spapisup}/inffile.h | 14 +- .../setup/usetup/{inffile.c => spapisup/infsupp.c} | 93 ++++++----- base/setup/usetup/usetup.c | 108 +++++++------ base/setup/usetup/usetup.h | 7 +- 22 files changed, 702 insertions(+), 396 deletions(-) diff --git a/base/setup/lib/CMakeLists.txt b/base/setup/lib/CMakeLists.txt index 199dffd86b..7c23e24045 100644 --- a/base/setup/lib/CMakeLists.txt +++ b/base/setup/lib/CMakeLists.txt @@ -1,14 +1,15 @@ add_definitions(${I18N_DEFS}) -include_directories(utils) +include_directories(spapisup utils) list(APPEND SOURCE + spapisup/fileqsup.c + spapisup/infsupp.c utils/arcname.c utils/bldrsup.c utils/filesup.c utils/genlist.c - utils/infsupp.c utils/inicache.c utils/ntverrsrc.c utils/osdetect.c diff --git a/base/setup/lib/registry.c b/base/setup/lib/registry.c index 810002d840..bc97489da0 100644 --- a/base/setup/lib/registry.c +++ b/base/setup/lib/registry.c @@ -55,18 +55,6 @@ #define FLG_ADDREG_TYPE_MASK (0xFFFF0000 | FLG_ADDREG_BINVALUETYPE) #endif -#ifdef _M_IX86 -#define Architecture L"x86" -#elif defined(_M_AMD64) -#define Architecture L"amd64" -#elif defined(_M_IA64) -#define Architecture L"ia64" -#elif defined(_M_ARM) -#define Architecture L"arm" -#elif defined(_M_PPC) -#define Architecture L"ppc" -#endif - /* GLOBALS ******************************************************************/ #define REGISTRY_SETUP_MACHINE L"\\Registry\\Machine\\SYSTEM\\USetup_Machine\\" @@ -301,13 +289,13 @@ do_reg_operation(HANDLE KeyHandle, } if (!(Flags & FLG_ADDREG_BINVALUETYPE) || - (Type == REG_DWORD && SetupGetFieldCount (Context) == 5)) + (Type == REG_DWORD && SpInfGetFieldCount(Context) == 5)) { PWCHAR Str = NULL; if (Type == REG_MULTI_SZ) { - if (!SetupGetMultiSzFieldW (Context, 5, NULL, 0, &Size)) + if (!SpInfGetMultiSzField(Context, 5, NULL, 0, &Size)) Size = 0; if (Size) @@ -316,7 +304,7 @@ do_reg_operation(HANDLE KeyHandle, if (Str == NULL) return FALSE; - SetupGetMultiSzFieldW (Context, 5, Str, Size, NULL); + SpInfGetMultiSzField(Context, 5, Str, Size, NULL); } if (Flags & FLG_ADDREG_APPEND) @@ -334,7 +322,7 @@ do_reg_operation(HANDLE KeyHandle, } else { - if (!SetupGetStringFieldW(Context, 5, NULL, 0, &Size)) + if (!SpInfGetStringField(Context, 5, NULL, 0, &Size)) Size = 0; if (Size) @@ -343,7 +331,7 @@ do_reg_operation(HANDLE KeyHandle, if (Str == NULL) return FALSE; - SetupGetStringFieldW(Context, 5, Str, Size, NULL); + SpInfGetStringField(Context, 5, Str, Size, NULL); } } @@ -389,7 +377,7 @@ do_reg_operation(HANDLE KeyHandle, { PUCHAR Data = NULL; - if (!SetupGetBinaryField (Context, 5, NULL, 0, &Size)) + if (!SpInfGetBinaryField(Context, 5, NULL, 0, &Size)) Size = 0; if (Size) @@ -399,7 +387,7 @@ do_reg_operation(HANDLE KeyHandle, return FALSE; DPRINT("setting binary data %wZ len %lu\n", ValueName, Size); - SetupGetBinaryField (Context, 5, Data, Size, NULL); + SpInfGetBinaryField(Context, 5, Data, Size, NULL); } NtSetValueKey (KeyHandle, @@ -435,27 +423,27 @@ registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete) HANDLE RootKeyHandle, KeyHandle; BOOLEAN Ok; - Ok = SetupFindFirstLineW(hInf, Section, NULL, &Context); + Ok = SpInfFindFirstLine(hInf, Section, NULL, &Context); if (!Ok) return TRUE; /* Don't fail if the section isn't present */ - for (;Ok; Ok = SetupFindNextLine(&Context, &Context)) + for (;Ok; Ok = SpInfFindNextLine(&Context, &Context)) { /* get root */ - if (!SetupGetStringFieldW(&Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)) + if (!SpInfGetStringField(&Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)) continue; RootKeyHandle = GetRootKeyByName(Buffer, &RootKeyName); if (!RootKeyHandle) continue; /* get key */ - if (!SetupGetStringFieldW(&Context, 2, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)) + if (!SpInfGetStringField(&Context, 2, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)) *Buffer = 0; DPRINT("KeyName: <%S\\%S>\n", RootKeyName, Buffer); /* get flags */ - if (!SetupGetIntField(&Context, 4, (PINT)&Flags)) + if (!SpInfGetIntField(&Context, 4, (PINT)&Flags)) Flags = 0; DPRINT("Flags: %lx\n", Flags); @@ -492,7 +480,7 @@ registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete) } /* get value name */ - if (SetupGetStringFieldW(&Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)) + if (SpInfGetStringField(&Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)) { RtlInitUnicodeString(&Value, Buffer); ValuePtr = &Value; @@ -531,14 +519,14 @@ ImportRegistryFile( CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2, SourcePath, FileName); - hInf = SetupOpenInfFileExW(FileNameBuffer, - NULL, - INF_STYLE_WIN4, - LocaleId, - &ErrorLine); + hInf = SpInfOpenInfFile(FileNameBuffer, + NULL, + INF_STYLE_WIN4, + LocaleId, + &ErrorLine); if (hInf == INVALID_HANDLE_VALUE) { - DPRINT1("SetupOpenInfFileEx() failed\n"); + DPRINT1("SpInfOpenInfFile() failed\n"); return FALSE; } @@ -546,7 +534,7 @@ ImportRegistryFile( if (!registry_callback(hInf, L"DelReg", FALSE)) { DPRINT1("registry_callback() failed\n"); - SetupCloseInfFile(hInf); + SpInfCloseInfFile(hInf); return FALSE; } #endif @@ -554,18 +542,18 @@ ImportRegistryFile( if (!registry_callback(hInf, L"AddReg", FALSE)) { DPRINT1("registry_callback() failed\n"); - SetupCloseInfFile(hInf); + SpInfCloseInfFile(hInf); return FALSE; } - if (!registry_callback(hInf, L"AddReg.NT" Architecture, FALSE)) + if (!registry_callback(hInf, L"AddReg.NT" INF_ARCH, FALSE)) { DPRINT1("registry_callback() failed\n"); - SetupCloseInfFile(hInf); + SpInfCloseInfFile(hInf); return FALSE; } - SetupCloseInfFile(hInf); + SpInfCloseInfFile(hInf); return TRUE; } diff --git a/base/setup/lib/settings.c b/base/setup/lib/settings.c index 93de42a31d..20a6bd4b8d 100644 --- a/base/setup/lib/settings.c +++ b/base/setup/lib/settings.c @@ -337,13 +337,13 @@ AddEntriesFromInfSection( IN PVOID Parameter OPTIONAL) { LONG TotalCount = 0; - PWCHAR KeyName; - PWCHAR KeyValue; + PCWSTR KeyName; + PCWSTR KeyValue; PVOID UserData; BOOLEAN Current; UCHAR RetVal; - if (!SetupFindFirstLineW(InfFile, SectionName, NULL, pContext)) + if (!SpInfFindFirstLine(InfFile, SectionName, NULL, pContext)) return -1; do @@ -389,7 +389,7 @@ AddEntriesFromInfSection( } // else if (RetVal == 2), skip the entry. - } while (SetupFindNextLine(pContext, pContext)); + } while (SpInfFindNextLine(pContext, pContext)); return TotalCount; } @@ -439,8 +439,8 @@ CreateComputerTypeList( { PGENERIC_LIST List; INFCONTEXT Context; - PWCHAR KeyName; - PWCHAR KeyValue; + PCWSTR KeyName; + PCWSTR KeyValue; WCHAR ComputerIdentifier[128]; WCHAR ComputerKey[32]; @@ -453,7 +453,7 @@ CreateComputerTypeList( DPRINT("Computer identifier: '%S'\n", ComputerIdentifier); /* Search for matching device identifier */ - if (!SetupFindFirstLineW(InfFile, L"Map.Computer", NULL, &Context)) + if (!SpInfFindFirstLine(InfFile, L"Map.Computer", NULL, &Context)) { /* FIXME: error message */ return NULL; @@ -487,7 +487,7 @@ CreateComputerTypeList( DPRINT("Computer key: %S\n", KeyName); RtlStringCchCopyW(ComputerKey, ARRAYSIZE(ComputerKey), KeyName); INF_FreeData(KeyName); - } while (SetupFindNextLine(&Context, &Context)); + } while (SpInfFindNextLine(&Context, &Context)); List = CreateGenericList(); if (List == NULL) @@ -675,8 +675,8 @@ CreateDisplayDriverList( { PGENERIC_LIST List; INFCONTEXT Context; - PWCHAR KeyName; - PWCHAR KeyValue; + PCWSTR KeyName; + PCWSTR KeyValue; WCHAR DisplayIdentifier[128]; WCHAR DisplayKey[32]; @@ -689,7 +689,7 @@ CreateDisplayDriverList( DPRINT("Display identifier: '%S'\n", DisplayIdentifier); /* Search for matching device identifier */ - if (!SetupFindFirstLineW(InfFile, L"Map.Display", NULL, &Context)) + if (!SpInfFindFirstLine(InfFile, L"Map.Display", NULL, &Context)) { /* FIXME: error message */ return NULL; @@ -723,7 +723,7 @@ CreateDisplayDriverList( DPRINT("Display key: %S\n", KeyName); RtlStringCchCopyW(DisplayKey, ARRAYSIZE(DisplayKey), KeyName); INF_FreeData(KeyName); - } while (SetupFindNextLine(&Context, &Context)); + } while (SpInfFindNextLine(&Context, &Context)); List = CreateGenericList(); if (List == NULL) @@ -778,8 +778,8 @@ ProcessDisplayRegistry( NTSTATUS Status; PGENERIC_LIST_ENTRY Entry; INFCONTEXT Context; - PWCHAR Buffer; - PWCHAR ServiceName; + PCWSTR Buffer; + PCWSTR ServiceName; ULONG StartValue; ULONG Width, Height, Bpp; OBJECT_ATTRIBUTES ObjectAttributes; @@ -793,11 +793,11 @@ ProcessDisplayRegistry( if (Entry == NULL) return FALSE; - if (!SetupFindFirstLineW(InfFile, L"Display", - ((PGENENTRY)GetListEntryData(Entry))->Id, - &Context)) + if (!SpInfFindFirstLine(InfFile, L"Display", + ((PGENENTRY)GetListEntryData(Entry))->Id, + &Context)) { - DPRINT1("SetupFindFirstLineW() failed\n"); + DPRINT1("SpInfFindFirstLine() failed\n"); return FALSE; } @@ -1137,7 +1137,7 @@ CreateLanguageList( { PGENERIC_LIST List; INFCONTEXT Context; - PWCHAR KeyValue; + PCWSTR KeyValue; LANG_ENTRY_PARAM LangEntryParam; @@ -1145,7 +1145,7 @@ CreateLanguageList( LangEntryParam.DefaultLanguage = DefaultLanguage; /* Get default language id */ - if (!SetupFindFirstLineW(InfFile, L"NLS", L"DefaultLanguage", &Context)) + if (!SpInfFindFirstLine(InfFile, L"NLS", L"DefaultLanguage", &Context)) return NULL; if (!INF_GetData(&Context, NULL, &KeyValue)) @@ -1188,12 +1188,12 @@ CreateKeyboardLayoutList( { PGENERIC_LIST List; INFCONTEXT Context; - PWCHAR KeyValue; + PCWSTR KeyValue; const MUI_LAYOUTS* LayoutsList; ULONG uIndex = 0; /* Get default layout id */ - if (!SetupFindFirstLineW(InfFile, L"NLS", L"DefaultLayout", &Context)) + if (!SpInfFindFirstLine(InfFile, L"NLS", L"DefaultLayout", &Context)) return NULL; if (!INF_GetData(&Context, NULL, &KeyValue)) diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c index cb48fd3fa3..34eb2283bb 100644 --- a/base/setup/lib/setuplib.c +++ b/base/setup/lib/setuplib.c @@ -32,7 +32,7 @@ CheckUnattendedSetup( HINF UnattendInf; UINT ErrorLine; INT IntValue; - PWCHAR Value; + PCWSTR Value; WCHAR UnattendInfPath[MAX_PATH]; CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2, @@ -47,22 +47,21 @@ CheckUnattendedSetup( } /* Load 'unattend.inf' from installation media */ - UnattendInf = SetupOpenInfFileExW(UnattendInfPath, - NULL, - INF_STYLE_OLDNT, - pSetupData->LanguageId, - &ErrorLine); - + UnattendInf = SpInfOpenInfFile(UnattendInfPath, + NULL, + INF_STYLE_OLDNT, + pSetupData->LanguageId, + &ErrorLine); if (UnattendInf == INVALID_HANDLE_VALUE) { - DPRINT("SetupOpenInfFileExW() failed\n"); + DPRINT("SpInfOpenInfFile() failed\n"); return; } /* Open 'Unattend' section */ - if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"Signature", &Context)) + if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context)) { - DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n"); + DPRINT("SpInfFindFirstLine() failed for section 'Unattend'\n"); goto Quit; } @@ -84,7 +83,7 @@ CheckUnattendedSetup( INF_FreeData(Value); /* Check if Unattend setup is enabled */ - if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"UnattendSetupEnabled", &Context)) + if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"UnattendSetupEnabled", &Context)) { DPRINT("Can't find key 'UnattendSetupEnabled'\n"); goto Quit; @@ -106,37 +105,37 @@ CheckUnattendedSetup( INF_FreeData(Value); /* Search for 'DestinationDiskNumber' in the 'Unattend' section */ - if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context)) + if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context)) { - DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n"); + DPRINT("SpInfFindFirstLine() failed for key 'DestinationDiskNumber'\n"); goto Quit; } - if (!SetupGetIntField(&Context, 1, &IntValue)) + if (!SpInfGetIntField(&Context, 1, &IntValue)) { - DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n"); + DPRINT("SpInfGetIntField() failed for key 'DestinationDiskNumber'\n"); goto Quit; } pSetupData->DestinationDiskNumber = (LONG)IntValue; /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */ - if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context)) + if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context)) { - DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n"); + DPRINT("SpInfFindFirstLine() failed for key 'DestinationPartitionNumber'\n"); goto Quit; } - if (!SetupGetIntField(&Context, 1, &IntValue)) + if (!SpInfGetIntField(&Context, 1, &IntValue)) { - DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n"); + DPRINT("SpInfGetIntField() failed for key 'DestinationPartitionNumber'\n"); goto Quit; } pSetupData->DestinationPartitionNumber = (LONG)IntValue; /* Search for 'InstallationDirectory' in the 'Unattend' section (optional) */ - if (SetupFindFirstLineW(UnattendInf, L"Unattend", L"InstallationDirectory", &Context)) + if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"InstallationDirectory", &Context)) { /* Get pointer 'InstallationDirectory' key */ if (!INF_GetData(&Context, NULL, &Value)) @@ -157,9 +156,9 @@ CheckUnattendedSetup( /* Search for 'MBRInstallType' in the 'Unattend' section */ pSetupData->MBRInstallType = -1; - if (SetupFindFirstLineW(UnattendInf, L"Unattend", L"MBRInstallType", &Context)) + if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"MBRInstallType", &Context)) { - if (SetupGetIntField(&Context, 1, &IntValue)) + if (SpInfGetIntField(&Context, 1, &IntValue)) { pSetupData->MBRInstallType = IntValue; } @@ -167,25 +166,25 @@ CheckUnattendedSetup( /* Search for 'FormatPartition' in the 'Unattend' section */ pSetupData->FormatPartition = 0; - if (SetupFindFirstLineW(UnattendInf, L"Unattend", L"FormatPartition", &Context)) + if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FormatPartition", &Context)) { - if (SetupGetIntField(&Context, 1, &IntValue)) + if (SpInfGetIntField(&Context, 1, &IntValue)) { pSetupData->FormatPartition = IntValue; } } pSetupData->AutoPartition = 0; - if (SetupFindFirstLineW(UnattendInf, L"Unattend", L"AutoPartition", &Context)) + if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"AutoPartition", &Context)) { - if (SetupGetIntField(&Context, 1, &IntValue)) + if (SpInfGetIntField(&Context, 1, &IntValue)) { pSetupData->AutoPartition = IntValue; } } /* Search for LocaleID in the 'Unattend' section */ - if (SetupFindFirstLineW(UnattendInf, L"Unattend", L"LocaleID", &Context)) + if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"LocaleID", &Context)) { if (INF_GetData(&Context, NULL, &Value)) { @@ -198,7 +197,7 @@ CheckUnattendedSetup( } Quit: - SetupCloseInfFile(UnattendInf); + SpInfCloseInfFile(UnattendInf); } VOID @@ -505,7 +504,7 @@ LoadSetupInf( INFCONTEXT Context; UINT ErrorLine; INT IntValue; - PWCHAR Value; + PCWSTR Value; WCHAR FileNameBuffer[MAX_PATH]; CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2, @@ -514,17 +513,16 @@ LoadSetupInf( DPRINT("SetupInf path: '%S'\n", FileNameBuffer); pSetupData->SetupInf = - SetupOpenInfFileExW(FileNameBuffer, - NULL, - /* INF_STYLE_WIN4 | */ INF_STYLE_OLDNT, - pSetupData->LanguageId, - &ErrorLine); - + SpInfOpenInfFile(FileNameBuffer, + NULL, + /* INF_STYLE_WIN4 | */ INF_STYLE_OLDNT, + pSetupData->LanguageId, + &ErrorLine); if (pSetupData->SetupInf == INVALID_HANDLE_VALUE) return ERROR_LOAD_TXTSETUPSIF; /* Open 'Version' section */ - if (!SetupFindFirstLineW(pSetupData->SetupInf, L"Version", L"Signature", &Context)) + if (!SpInfFindFirstLine(pSetupData->SetupInf, L"Version", L"Signature", &Context)) return ERROR_CORRUPT_TXTSETUPSIF; /* Get pointer 'Signature' key */ @@ -541,13 +539,13 @@ LoadSetupInf( INF_FreeData(Value); /* Open 'DiskSpaceRequirements' section */ - if (!SetupFindFirstLineW(pSetupData->SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context)) + if (!SpInfFindFirstLine(pSetupData->SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context)) return ERROR_CORRUPT_TXTSETUPSIF; pSetupData->RequiredPartitionDiskSpace = ~0; /* Get the 'FreeSysPartDiskSpace' value */ - if (!SetupGetIntField(&Context, 1, &IntValue)) + if (!SpInfGetIntField(&Context, 1, &IntValue)) return ERROR_CORRUPT_TXTSETUPSIF; pSetupData->RequiredPartitionDiskSpace = (ULONG)IntValue; @@ -559,7 +557,7 @@ LoadSetupInf( // /* Update the Setup Source paths */ - if (SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData", L"SetupSourceDevice", &Context)) + if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourceDevice", &Context)) { /* * Get optional pointer 'SetupSourceDevice' key, its presence @@ -572,7 +570,7 @@ LoadSetupInf( RtlCreateUnicodeString(&pSetupData->SourceRootPath, Value); INF_FreeData(Value); - if (!SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData", L"SetupSourcePath", &Context)) + if (!SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourcePath", &Context)) { /* The 'SetupSourcePath' value is mandatory! */ return ERROR_CORRUPT_TXTSETUPSIF; @@ -594,7 +592,7 @@ LoadSetupInf( /* Search for 'DefaultPath' in the 'SetupData' section */ pSetupData->InstallationDirectory[0] = 0; - if (SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData", L"DefaultPath", &Context)) + if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"DefaultPath", &Context)) { /* Get pointer 'DefaultPath' key */ if (!INF_GetData(&Context, NULL, &Value)) @@ -632,6 +630,10 @@ InitDestinationPaths( RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer); DPRINT("DestinationRootPath: %wZ\n", &pSetupData->DestinationRootPath); + // FIXME! Which variable to choose? + if (!InstallationDir) + InstallationDir = pSetupData->InstallationDirectory; + /** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/ /* Create 'pSetupData->DestinationArcPath' */ RtlFreeUnicodeString(&pSetupData->DestinationArcPath); @@ -776,7 +778,7 @@ FinishSetup( } /* Close the Setup INF */ - SetupCloseInfFile(pSetupData->SetupInf); + SpInfCloseInfFile(pSetupData->SetupInf); } /* @@ -802,9 +804,9 @@ UpdateRegistry( ERROR_NUMBER ErrorNumber; NTSTATUS Status; INFCONTEXT InfContext; - PWSTR Action; - PWSTR File; - PWSTR Section; + PCWSTR Action; + PCWSTR File; + PCWSTR Section; BOOLEAN Success; BOOLEAN ShouldRepairRegistry = FALSE; BOOLEAN Delete; @@ -858,13 +860,13 @@ DoUpdate: * "repair" (aka. recreate: ShouldRepairRegistry == TRUE). */ - Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible + Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible if (!Success) - Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific + Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific if (!Success) { - DPRINT1("SetupFindFirstLine() failed\n"); + DPRINT1("SpInfFindFirstLine() failed\n"); ErrorNumber = ERROR_FIND_REGISTRY; goto Cleanup; } @@ -877,7 +879,7 @@ DoUpdate: * we only update the hives. */ - Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext); + Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext); if (!Success) { /* Nothing to do for update! */ @@ -929,7 +931,7 @@ DoUpdate: ErrorNumber = ERROR_IMPORT_HIVE; goto Cleanup; } - } while (SetupFindNextLine(&InfContext, &InfContext)); + } while (SpInfFindNextLine(&InfContext, &InfContext)); if (!RepairUpdateFlag || ShouldRepairRegistry) { diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h index a885d6d09d..0686b00d58 100644 --- a/base/setup/lib/setuplib.h +++ b/base/setup/lib/setuplib.h @@ -25,6 +25,8 @@ extern HANDLE ProcessHeap; #include "errorcode.h" +#include "spapisup/fileqsup.h" +#include "spapisup/infsupp.h" #include "utils/linklist.h" #include "utils/ntverrsrc.h" // #include "utils/arcname.h" @@ -33,7 +35,6 @@ extern HANDLE ProcessHeap; #include "utils/filesup.h" #include "fsutil.h" #include "utils/genlist.h" -#include "utils/infsupp.h" #include "utils/inicache.h" #include "utils/partlist.h" #include "utils/arcname.h" diff --git a/base/setup/lib/spapisup/fileqsup.c b/base/setup/lib/spapisup/fileqsup.c new file mode 100644 index 0000000000..34da6a4580 --- /dev/null +++ b/base/setup/lib/spapisup/fileqsup.c @@ -0,0 +1,34 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Setup Library + * FILE: base/setup/lib/fileqsup.c + * PURPOSE: Interfacing with Setup* API File Queue support functions + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + */ + +/* INCLUDES *****************************************************************/ + +#include "precomp.h" +#include "fileqsup.h" + +#define NDEBUG +#include <debug.h> + +/* GLOBALS *******************************************************************/ + +/* + * These externs should be defined by the user of this library. + * They are kept there for reference and ease of usage. + */ +#if 0 + +pSpFileQueueOpen SpFileQueueOpen = NULL; +pSpFileQueueClose SpFileQueueClose = NULL; +pSpFileQueueCopy SpFileQueueCopy = NULL; +pSpFileQueueDelete SpFileQueueDelete = NULL; +pSpFileQueueRename SpFileQueueRename = NULL; +pSpFileQueueCommit SpFileQueueCommit = NULL; + +#endif + +/* EOF */ diff --git a/base/setup/usetup/filequeue.h b/base/setup/lib/spapisup/fileqsup.h similarity index 58% rename from base/setup/usetup/filequeue.h rename to base/setup/lib/spapisup/fileqsup.h index cf608377e1..c6cc3839c1 100644 --- a/base/setup/usetup/filequeue.h +++ b/base/setup/lib/spapisup/fileqsup.h @@ -1,31 +1,24 @@ -/* - * ReactOS kernel - * Copyright (C) 2002 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS text-mode setup - * FILE: base/setup/usetup/filequeue.h - * PURPOSE: File queue functions - * PROGRAMMER: + * PROJECT: ReactOS Setup Library + * FILE: base/setup/lib/fileqsup.h + * PURPOSE: Interfacing with Setup* API File Queue support functions + * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net) + * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) */ #pragma once +#include "spapisup.h" + +// FIXME: Temporary measure until all the users of this header +// (usetup...) use or define SetupAPI-conforming APIs. +#if defined(_SETUPAPI_H_) || defined(_INC_SETUPAPI) + +#include <setupapi.h> + +#else + #define SPFILENOTIFY_STARTQUEUE 0x00000001 #define SPFILENOTIFY_ENDQUEUE 0x00000002 #define SPFILENOTIFY_STARTSUBQUEUE 0x00000003 @@ -76,67 +69,68 @@ typedef UINT (CALLBACK* PSP_FILE_CALLBACK_W)( IN UINT_PTR Param1, IN UINT_PTR Param2); +#endif + /* FUNCTIONS ****************************************************************/ -HSPFILEQ -WINAPI -SetupOpenFileQueue(VOID); +// #define SetupOpenFileQueue +typedef HSPFILEQ +(WINAPI* pSpFileQueueOpen)(VOID); + +extern pSpFileQueueOpen SpFileQueueOpen; -VOID -WINAPI -SetupCloseFileQueue( +// #define SetupCloseFileQueue +typedef BOOL +(WINAPI* pSpFileQueueClose)( IN HSPFILEQ QueueHandle); -#if 0 // This is the API that is declared in setupapi.h and exported by setupapi.dll -BOOL -WINAPI -SetupQueueCopyWNew( - IN HSPFILEQ QueueHandle, - IN PCWSTR SourceRootPath, - IN PCWSTR SourcePath, - IN PCWSTR SourceFileName, - IN PCWSTR SourceDescription, - IN PCWSTR SourceTagFile, - IN PCWSTR TargetDirectory, - IN PCWSTR TargetFileName, - IN DWORD CopyStyle); -#endif +extern pSpFileQueueClose SpFileQueueClose; -/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */ -BOOL -WINAPI -SetupQueueCopyWithCab( // SetupQueueCopyW +// #define SetupQueueCopyW +typedef BOOL +(WINAPI* pSpFileQueueCopy)( IN HSPFILEQ QueueHandle, - IN PCWSTR SourceCabinet OPTIONAL, IN PCWSTR SourceRootPath, IN PCWSTR SourcePath OPTIONAL, IN PCWSTR SourceFileName, + IN PCWSTR SourceDescription OPTIONAL, + IN PCWSTR SourceCabinet OPTIONAL, + IN PCWSTR SourceTagFile OPTIONAL, IN PCWSTR TargetDirectory, - IN PCWSTR TargetFileName OPTIONAL); + IN PCWSTR TargetFileName OPTIONAL, + IN ULONG CopyStyle); + +extern pSpFileQueueCopy SpFileQueueCopy; -BOOL -WINAPI -SetupQueueDeleteW( +// #define SetupQueueDeleteW +typedef BOOL +(WINAPI* pSpFileQueueDelete)( IN HSPFILEQ QueueHandle, IN PCWSTR PathPart1, IN PCWSTR PathPart2 OPTIONAL); -BOOL -WINAPI -SetupQueueRenameW( +extern pSpFileQueueDelete SpFileQueueDelete; + +// #define SetupQueueRenameW +typedef BOOL +(WINAPI* pSpFileQueueRename)( IN HSPFILEQ QueueHandle, IN PCWSTR SourcePath, IN PCWSTR SourceFileName OPTIONAL, IN PCWSTR TargetPath OPTIONAL, IN PCWSTR TargetFileName); -BOOL -WINAPI -SetupCommitFileQueueW( +extern pSpFileQueueRename SpFileQueueRename; + +// #define SetupCommitFileQueueW +typedef BOOL +(WINAPI* pSpFileQueueCommit)( IN HWND Owner, IN HSPFILEQ QueueHandle, IN PSP_FILE_CALLBACK_W MsgHandler, IN PVOID Context OPTIONAL); +extern pSpFileQueueCommit SpFileQueueCommit; + /* EOF */ diff --git a/base/setup/lib/utils/infsupp.c b/base/setup/lib/spapisup/infsupp.c similarity index 53% rename from base/setup/lib/utils/infsupp.c rename to base/setup/lib/spapisup/infsupp.c index 265585712e..65bdbd23e6 100644 --- a/base/setup/lib/utils/infsupp.c +++ b/base/setup/lib/spapisup/infsupp.c @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Setup Library * FILE: base/setup/lib/infsupp.c - * PURPOSE: Interfacing with Setup* API .inf files support functions + * PURPOSE: Interfacing with Setup* API .INF Files support functions * PROGRAMMERS: Hervé Poussineau * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) */ @@ -15,13 +15,34 @@ #define NDEBUG #include <debug.h> +/* GLOBALS *******************************************************************/ + +/* + * These externs should be defined by the user of this library. + * They are kept there for reference and ease of usage. + */ +#if 0 + +pSpInfCloseInfFile SpInfCloseInfFile = NULL; +pSpInfFindFirstLine SpInfFindFirstLine = NULL; +pSpInfFindNextLine SpInfFindNextLine = NULL; +pSpInfGetFieldCount SpInfGetFieldCount = NULL; +pSpInfGetBinaryField SpInfGetBinaryField = NULL; +pSpInfGetIntField SpInfGetIntField = NULL; +pSpInfGetMultiSzField SpInfGetMultiSzField = NULL; +pSpInfGetStringField SpInfGetStringField = NULL; +pSpInfGetField SpInfGetField = NULL; +pSpInfOpenInfFile SpInfOpenInfFile = NULL; + +#endif + /* HELPER FUNCTIONS **********************************************************/ BOOLEAN INF_GetDataField( IN PINFCONTEXT Context, IN ULONG FieldIndex, - OUT PWCHAR *Data) + OUT PCWSTR* Data) { #if 0 @@ -31,11 +52,11 @@ INF_GetDataField( *Data = NULL; - Success = SetupGetStringFieldW(Context, - FieldIndex, - NULL, - 0, - &dwSize); + Success = SpInfGetStringField(Context, + FieldIndex, + NULL, + 0, + &dwSize); if (!Success) return FALSE; @@ -43,11 +64,11 @@ INF_GetDataField( if (!InfData) return FALSE; - Success = SetupGetStringFieldW(Context, - FieldIndex, - InfData, - dwSize, - NULL); + Success = SpInfGetStringField(Context, + FieldIndex, + InfData, + dwSize, + NULL); if (!Success) { RtlFreeHeap(ProcessHeap, 0, InfData); @@ -59,7 +80,7 @@ INF_GetDataField( #else - *Data = (PWCHAR)pSetupGetField(Context, FieldIndex); + *Data = SpInfGetField(Context, FieldIndex); return !!*Data; #endif @@ -68,11 +89,11 @@ INF_GetDataField( BOOLEAN INF_GetData( IN PINFCONTEXT Context, - OUT PWCHAR *Key, - OUT PWCHAR *Data) + OUT PCWSTR* Key, + OUT PCWSTR* Data) { BOOL Success; - PWCHAR InfData[2] = {NULL, NULL}; + PCWSTR InfData[2] = {NULL, NULL}; if (Key) *Key = NULL; @@ -82,11 +103,11 @@ INF_GetData( /* * Verify that the INF file has only one value field, in addition to its key name. - * Note that SetupGetFieldCount() does not count the key name as a field. + * Note that SpInfGetFieldCount() does not count the key name as a field. */ - if (SetupGetFieldCount(Context) != 1) + if (SpInfGetFieldCount(Context) != 1) { - DPRINT1("SetupGetFieldCount != 1\n"); + DPRINT1("SpInfGetFieldCount != 1\n"); return FALSE; } diff --git a/base/setup/lib/utils/infsupp.h b/base/setup/lib/spapisup/infsupp.h similarity index 53% rename from base/setup/lib/utils/infsupp.h rename to base/setup/lib/spapisup/infsupp.h index db6043c03f..c5d24ca6b7 100644 --- a/base/setup/lib/utils/infsupp.h +++ b/base/setup/lib/spapisup/infsupp.h @@ -2,16 +2,13 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Setup Library * FILE: base/setup/lib/infsupp.h - * PURPOSE: Interfacing with Setup* API .inf files support functions - * PROGRAMMER: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + * PURPOSE: Interfacing with Setup* API .INF Files support functions + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) */ #pragma once -/* Make setupapi.h to not define the API as exports to the DLL */ -#ifdef __REACTOS__ -#define _SETUPAPI_ -#endif +#include "spapisup.h" // FIXME: Temporary measure until all the users of this header // (usetup...) use or define SetupAPI-conforming APIs. @@ -30,65 +27,6 @@ typedef struct _INFCONTEXT UINT Line; } INFCONTEXT, *PINFCONTEXT; -// #define SetupCloseInfFile InfCloseFile -VOID -WINAPI -SetupCloseInfFile(HINF InfHandle); - -// #define SetupFindFirstLineW InfpFindFirstLineW -BOOL -WINAPI -SetupFindFirstLineW( - IN HINF InfHandle, - IN PCWSTR Section, - IN PCWSTR Key, - IN OUT PINFCONTEXT Context); - -// #define SetupFindNextLine InfFindNextLine -BOOL -WINAPI -SetupFindNextLine(PINFCONTEXT ContextIn, - PINFCONTEXT ContextOut); - -// #define SetupGetFieldCount InfGetFieldCount -LONG -WINAPI -SetupGetFieldCount(PINFCONTEXT Context); - -// #define SetupGetBinaryField InfGetBinaryField -BOOL -WINAPI -SetupGetBinaryField(PINFCONTEXT Context, - ULONG FieldIndex, - PUCHAR ReturnBuffer, - ULONG ReturnBufferSize, - PULONG RequiredSize); - -// #define SetupGetIntField InfGetIntField -BOOL -WINAPI -SetupGetIntField(PINFCONTEXT Context, - ULONG FieldIndex, - INT *IntegerValue); // PINT - -// #define SetupGetMultiSzFieldW InfGetMultiSzField -BOOL -WINAPI -SetupGetMultiSzFieldW(PINFCONTEXT Context, - ULONG FieldIndex, - PWSTR ReturnBuffer, - ULONG ReturnBufferSize, - PULONG RequiredSize); - -// #define SetupGetStringFieldW InfGetStringField -BOOL -WINAPI -SetupGetStringFieldW(PINFCONTEXT Context, - ULONG FieldIndex, - PWSTR ReturnBuffer, - ULONG ReturnBufferSize, - PULONG RequiredSize); - #endif /* Lower the MAX_INF_STRING_LENGTH value in order to avoid too much stack usage */ @@ -117,33 +55,107 @@ typedef struct _INFCONTEXT C_ASSERT(sizeof(INFCONTEXT) == 2 * sizeof(HINF) + 2 * sizeof(UINT)); -/* - * This function corresponds to an undocumented but exported SetupAPI function - * that exists since WinNT4 and is still present in Win10. - * The returned string pointer is a read-only pointer to a string in the - * maintained INF cache, and is always in UNICODE (on NT systems). - */ -PCWSTR -WINAPI -pSetupGetField(PINFCONTEXT Context, - ULONG FieldIndex); +// #define SetupCloseInfFile InfCloseFile +typedef VOID +(WINAPI* pSpInfCloseInfFile)( + IN HINF InfHandle); + +extern pSpInfCloseInfFile SpInfCloseInfFile; + +// #define SetupFindFirstLineW InfpFindFirstLineW +typedef BOOL +(WINAPI* pSpInfFindFirstLine)( + IN HINF InfHandle, + IN PCWSTR Section, + IN PCWSTR Key, + IN OUT PINFCONTEXT Context); + +extern pSpInfFindFirstLine SpInfFindFirstLine; + +// #define SetupFindNextLine InfFindNextLine +typedef BOOL +(WINAPI* pSpInfFindNextLine)( + IN PINFCONTEXT ContextIn, + OUT PINFCONTEXT ContextOut); + +extern pSpInfFindNextLine SpInfFindNextLine; + +// #define SetupGetFieldCount InfGetFieldCount +typedef ULONG +(WINAPI* pSpInfGetFieldCount)( + IN PINFCONTEXT Context); + +extern pSpInfGetFieldCount SpInfGetFieldCount; + +// #define SetupGetBinaryField InfGetBinaryField +typedef BOOL +(WINAPI* pSpInfGetBinaryField)( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT PUCHAR ReturnBuffer, + IN ULONG ReturnBufferSize, + OUT PULONG RequiredSize); + +extern pSpInfGetBinaryField SpInfGetBinaryField; + +// #define SetupGetIntField InfGetIntField +typedef BOOL +(WINAPI* pSpInfGetIntField)( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT INT *IntegerValue); // PINT + +extern pSpInfGetIntField SpInfGetIntField; + +// #define SetupGetMultiSzFieldW InfGetMultiSzField +typedef BOOL +(WINAPI* pSpInfGetMultiSzField)( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT PWSTR ReturnBuffer, + IN ULONG ReturnBufferSize, + OUT PULONG RequiredSize); + +extern pSpInfGetMultiSzField SpInfGetMultiSzField; + +// #define SetupGetStringFieldW InfGetStringField +typedef BOOL +(WINAPI* pSpInfGetStringField)( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT PWSTR ReturnBuffer, + IN ULONG ReturnBufferSize, + OUT PULONG RequiredSize); + +extern pSpInfGetStringField SpInfGetStringField; + +// #define pSetupGetField +typedef PCWSTR +(WINAPI* pSpInfGetField)( + IN PINFCONTEXT Context, + IN ULONG FieldIndex); + +extern pSpInfGetField SpInfGetField; /* A version of SetupOpenInfFileW with support for a user-provided LCID */ // #define SetupOpenInfFileExW InfpOpenInfFileW -HINF -WINAPI -SetupOpenInfFileExW( +typedef HINF +(WINAPI* pSpInfOpenInfFile)( IN PCWSTR FileName, IN PCWSTR InfClass, IN DWORD InfStyle, IN LCID LocaleId, OUT PUINT ErrorLine); +extern pSpInfOpenInfFile SpInfOpenInfFile; + /* HELPER FUNCTIONS **********************************************************/ -FORCEINLINE VOID -INF_FreeData(IN PWCHAR InfData) +FORCEINLINE +VOID +INF_FreeData( + IN PCWSTR InfData) { #if 0 if (InfData) @@ -157,12 +169,12 @@ BOOLEAN INF_GetDataField( IN PINFCONTEXT Context, IN ULONG FieldIndex, - OUT PWCHAR *Data); + OUT PCWSTR* Data); BOOLEAN INF_GetData( IN PINFCONTEXT Context, - OUT PWCHAR *Key, - OUT PWCHAR *Data); + OUT PCWSTR* Key, + OUT PCWSTR* Data); /* EOF */ diff --git a/base/setup/lib/spapisup/spapisup.h b/base/setup/lib/spapisup/spapisup.h new file mode 100644 index 0000000000..7733b78473 --- /dev/null +++ b/base/setup/lib/spapisup/spapisup.h @@ -0,0 +1,29 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Setup Library + * FILE: base/setup/lib/spapisup.h + * PURPOSE: Interfacing with Setup* API support functions + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + */ + +#pragma once + +/* Make setupapi.h to not define the API as exports to the DLL */ +#ifdef __REACTOS__ +#define _SETUPAPI_ +#endif + +/* Architecture names to be used for architecture-specific INF sections */ +#ifdef _M_IX86 +#define INF_ARCH L"x86" +#elif defined(_M_AMD64) +#define INF_ARCH L"amd64" +#elif defined(_M_IA64) +#define INF_ARCH L"ia64" +#elif defined(_M_ARM) +#define INF_ARCH L"arm" +#elif defined(_M_PPC) +#define INF_ARCH L"ppc" +#endif + +/* EOF */ diff --git a/base/setup/reactos/CMakeLists.txt b/base/setup/reactos/CMakeLists.txt index 0f08c1f252..39225e758e 100644 --- a/base/setup/reactos/CMakeLists.txt +++ b/base/setup/reactos/CMakeLists.txt @@ -7,8 +7,9 @@ include_directories( ${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers) list(APPEND SOURCE + spapisup/fileqsup.c + spapisup/infsupp.c drivepage.c - inffile.c reactos.c reactos.h) diff --git a/base/setup/reactos/spapisup/fileqsup.c b/base/setup/reactos/spapisup/fileqsup.c new file mode 100644 index 0000000000..ad31c38ee1 --- /dev/null +++ b/base/setup/reactos/spapisup/fileqsup.c @@ -0,0 +1,155 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS GUI first stage setup application + * FILE: base/setup/lib/fileqsup.c + * PURPOSE: Interfacing with Setup* API File Queue support functions + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + */ + +/* INCLUDES *****************************************************************/ + +#include "precomp.h" + +#define NDEBUG +#include <debug.h> + +/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/ + +/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */ +BOOL +WINAPI +SpFileQueueCopy_NtToWin32( + IN HSPFILEQ QueueHandle, + IN PCWSTR SourceRootPath, + IN PCWSTR SourcePath OPTIONAL, + IN PCWSTR SourceFileName, + IN PCWSTR SourceDescription OPTIONAL, + IN PCWSTR SourceCabinet OPTIONAL, + IN PCWSTR SourceTagFile OPTIONAL, + IN PCWSTR TargetDirectory, + IN PCWSTR TargetFileName OPTIONAL, + IN ULONG CopyStyle) +{ + WCHAR Win32SourceRootPath[MAX_PATH]; + WCHAR Win32TargetDirectory[MAX_PATH]; + + /* + * SpFileQueueCopy is called within setuplib with NT paths, however + * the Win32 SetupQueueCopyW API only takes Win32 paths. We therefore + * map the NT path to Win32 path and then call the Win32 API. + */ + if (!ConvertNtPathToWin32Path(Win32SourceRootPath, + _countof(Win32SourceRootPath), + SourceRootPath)) + { + return FALSE; + } + /* SourcePath, SourceFileName and SourceCabinet are appended to SourceRootPath by the SetupApi function */ + + if (!ConvertNtPathToWin32Path(Win32TargetDirectory, + _countof(Win32TargetDirectory), + TargetDirectory)) + { + return FALSE; + } + /* TargetFileName is appended to TargetDirectory by the SetupApi function */ + + /* + * Use the undocumented way of copying files from within a given cabinet file + * *ONLY IF* the files do not already exist in the same directory where + * the cabinet file resides!! + */ + return SetupQueueCopyW(QueueHandle, + Win32SourceRootPath, + SourcePath, + SourceFileName, + // Undocumented on MSDN is the fact that this parameter is mandatory *IF* one wants to take the TagFile into account! + L"foobar", + // SourceTagFile -- Special behaviour: use cabinet file present in ArchiveDir path! The API does not check for a ".cab" extension. + SourceCabinet, + Win32TargetDirectory, + TargetFileName, + // We choose to decompress the archive, so do NOT specify SP_COPY_NODECOMP ! + SP_COPY_NOOVERWRITE /* | SP_COPY_SOURCE_ABSOLUTE | SP_COPY_SOURCEPATH_ABSOLUTE */ + ); +} + +BOOL +WINAPI +SpFileQueueDelete_NtToWin32( + IN HSPFILEQ QueueHandle, + IN PCWSTR PathPart1, + IN PCWSTR PathPart2 OPTIONAL) +{ + WCHAR Win32PathPart1[MAX_PATH]; + + /* + * SpFileQueueDelete is called within setuplib with NT paths, however + * the Win32 SetupQueueDeleteW API only takes Win32 paths. We therefore + * map the NT path to Win32 path and then call the Win32 API. + */ + if (!ConvertNtPathToWin32Path(Win32PathPart1, + _countof(Win32PathPart1), + PathPart1)) + { + return FALSE; + } + /* PathPart2 is appended to PathPart1 by the SetupApi function */ + + return SetupQueueDeleteW(QueueHandle, Win32PathPart1, PathPart2); +} + +BOOL +WINAPI +SpFileQueueRename_NtToWin32( + IN HSPFILEQ QueueHandle, + IN PCWSTR SourcePath, + IN PCWSTR SourceFileName OPTIONAL, + IN PCWSTR TargetPath OPTIONAL, + IN PCWSTR TargetFileName) +{ + WCHAR Win32SourcePath[MAX_PATH]; + WCHAR Win32TargetPath[MAX_PATH]; + + /* + * SpFileQueueRename is called within setuplib with NT paths, however + * the Win32 SetupQueueRenameW API only takes Win32 paths. We therefore + * map the NT path to Win32 path and then call the Win32 API. + */ + if (!ConvertNtPathToWin32Path(Win32SourcePath, + _countof(Win32SourcePath), + SourcePath)) + { + return FALSE; + } + /* SourceFileName is appended to SourcePath by the SetupApi function */ + + if (TargetPath) + { + if (!ConvertNtPathToWin32Path(Win32TargetPath, + _countof(Win32TargetPath), + TargetPath)) + { + return FALSE; + } + } + /* TargetFileName is appended to TargetPath by the SetupApi function */ + + return SetupQueueRenameW(QueueHandle, + Win32SourcePath, + SourceFileName, + TargetPath ? Win32TargetPath : NULL, + TargetFileName); +} + + +/* GLOBALS *******************************************************************/ + +pSpFileQueueOpen SpFileQueueOpen = SetupOpenFileQueue; +pSpFileQueueClose SpFileQueueClose = SetupCloseFileQueue; +pSpFileQueueCopy SpFileQueueCopy = SpFileQueueCopy_NtToWin32; +pSpFileQueueDelete SpFileQueueDelete = SpFileQueueDelete_NtToWin32; +pSpFileQueueRename SpFileQueueRename = SpFileQueueRename_NtToWin32; +pSpFileQueueCommit SpFileQueueCommit = SetupCommitFileQueueW; + +/* EOF */ diff --git a/base/setup/reactos/inffile.c b/base/setup/reactos/spapisup/infsupp.c similarity index 61% rename from base/setup/reactos/inffile.c rename to base/setup/reactos/spapisup/infsupp.c index db25b07b08..c95aad8e6e 100644 --- a/base/setup/reactos/inffile.c +++ b/base/setup/reactos/spapisup/infsupp.c @@ -1,9 +1,9 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS text-mode setup - * FILE: base/setup/usetup/inffile.c - * PURPOSE: .inf files support functions - * PROGRAMMERS: Herv� Poussineau + * PROJECT: ReactOS GUI first stage setup application + * FILE: base/setup/lib/infsupp.c + * PURPOSE: Interfacing with Setup* API .INF Files support functions + * PROGRAMMERS: Hervé Poussineau * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) */ @@ -16,7 +16,17 @@ /* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/ -/* Functions from the INFLIB library */ +/* + * This function corresponds to an undocumented but exported SetupAPI function + * that exists since WinNT4 and is still present in Win10. + * The returned string pointer is a read-only pointer to a string in the + * maintained INF cache, and is always in UNICODE (on NT systems). + */ +PCWSTR +WINAPI +pSetupGetField( + IN PINFCONTEXT Context, + IN ULONG FieldIndex); /* SetupOpenInfFileW with support for a user-provided LCID */ HINF @@ -51,6 +61,20 @@ SetupOpenInfFileExW( } +/* GLOBALS *******************************************************************/ + +pSpInfCloseInfFile SpInfCloseInfFile = SetupCloseInfFile; +pSpInfFindFirstLine SpInfFindFirstLine = SetupFindFirstLineW; +pSpInfFindNextLine SpInfFindNextLine = SetupFindNextLine; +pSpInfGetFieldCount SpInfGetFieldCount = SetupGetFieldCount; +pSpInfGetBinaryField SpInfGetBinaryField = SetupGetBinaryField; +pSpInfGetIntField SpInfGetIntField = SetupGetIntField; +pSpInfGetMultiSzField SpInfGetMultiSzField = SetupGetMultiSzFieldW; +pSpInfGetStringField SpInfGetStringField = SetupGetStringFieldW; +pSpInfGetField SpInfGetField = pSetupGetField; +pSpInfOpenInfFile SpInfOpenInfFile = SetupOpenInfFileExW; + + /* HELPER FUNCTIONS **********************************************************/ #if 0 diff --git a/base/setup/usetup/CMakeLists.txt b/base/setup/usetup/CMakeLists.txt index 19314bfe7a..89891713ff 100644 --- a/base/setup/usetup/CMakeLists.txt +++ b/base/setup/usetup/CMakeLists.txt @@ -10,17 +10,17 @@ include_directories( ${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers) list(APPEND SOURCE - cabinet.c + spapisup/cabinet.c + spapisup/fileqsup.c + spapisup/infsupp.c chkdsk.c cmdcons.c console.c consup.c devinst.c - filequeue.c format.c fslist.c genlist.c - inffile.c keytrans.c mui.c partlist.c diff --git a/base/setup/usetup/devinst.c b/base/setup/usetup/devinst.c index 15483a31d0..2c067d72a0 100644 --- a/base/setup/usetup/devinst.c +++ b/base/setup/usetup/devinst.c @@ -53,14 +53,15 @@ InstallDriver( OBJECT_ATTRIBUTES ObjectAttributes; HANDLE hService; INFCONTEXT Context; - PWSTR Driver, ClassGuid, ImagePath, FullImagePath; + PCWSTR Driver, ClassGuid, ImagePath; + PWSTR FullImagePath; ULONG dwValue; ULONG Disposition; NTSTATUS Status; BOOLEAN deviceInstalled = FALSE; /* Check if we know the hardware */ - if (!SetupFindFirstLineW(hInf, L"HardwareIdsDatabase", HardwareId, &Context)) + if (!SpInfFindFirstLine(hInf, L"HardwareIdsDatabase", HardwareId, &Context)) return FALSE; if (!INF_GetDataField(&Context, 1, &Driver)) return FALSE; @@ -71,11 +72,11 @@ InstallDriver( /* Find associated driver name */ /* FIXME: check in other sections too! */ - if (!SetupFindFirstLineW(hInf, L"BootBusExtenders.Load", Driver, &Context) - && !SetupFindFirstLineW(hInf, L"BusExtenders.Load", Driver, &Context) - && !SetupFindFirstLineW(hInf, L"SCSI.Load", Driver, &Context) - && !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context) - && !SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver, &Context)) + if (!SpInfFindFirstLine(hInf, L"BootBusExtenders.Load", Driver, &Context) + && !SpInfFindFirstLine(hInf, L"BusExtenders.Load", Driver, &Context) + && !SpInfFindFirstLine(hInf, L"SCSI.Load", Driver, &Context) + && !SpInfFindFirstLine(hInf, L"InputDevicesSupport.Load", Driver, &Context) + && !SpInfFindFirstLine(hInf, L"Keyboard.Load", Driver, &Context)) { INF_FreeData(ClassGuid); INF_FreeData(Driver); @@ -151,7 +152,7 @@ InstallDriver( &ImagePathU, 0, REG_SZ, - ImagePath, + (PVOID)ImagePath, (wcslen(ImagePath) + 1) * sizeof(WCHAR)); INF_FreeData(ImagePath); @@ -174,7 +175,7 @@ InstallDriver( &ServiceU, 0, REG_SZ, - Driver, + (PVOID)Driver, (wcslen(Driver) + 1) * sizeof(WCHAR)); if (NT_SUCCESS(Status)) { diff --git a/base/setup/usetup/cabinet.c b/base/setup/usetup/spapisup/cabinet.c similarity index 100% rename from base/setup/usetup/cabinet.c rename to base/setup/usetup/spapisup/cabinet.c diff --git a/base/setup/usetup/cabinet.h b/base/setup/usetup/spapisup/cabinet.h similarity index 100% rename from base/setup/usetup/cabinet.h rename to base/setup/usetup/spapisup/cabinet.h diff --git a/base/setup/usetup/filequeue.c b/base/setup/usetup/spapisup/fileqsup.c similarity index 96% rename from base/setup/usetup/filequeue.c rename to base/setup/usetup/spapisup/fileqsup.c index c50203c361..75f6b36d41 100644 --- a/base/setup/usetup/filequeue.c +++ b/base/setup/usetup/spapisup/fileqsup.c @@ -16,11 +16,13 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -/* COPYRIGHT: See COPYING in the top level directory +/* + * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup - * FILE: base/setup/usetup/filequeue.c - * PURPOSE: File queue functions - * PROGRAMMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net) + * FILE: base/setup/lib/fileqsup.c + * PURPOSE: Interfacing with Setup* API File Queue support functions + * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net) + * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) */ /* INCLUDES *****************************************************************/ @@ -30,7 +32,7 @@ #define NDEBUG #include <debug.h> -/* INCLUDES *****************************************************************/ +/* DEFINITIONS **************************************************************/ typedef struct _QUEUEENTRY { @@ -210,7 +212,7 @@ SetupDeleteQueueEntry( RtlFreeHeap(ProcessHeap, 0, Entry); } -VOID +BOOL WINAPI SetupCloseFileQueue( IN HSPFILEQ QueueHandle) @@ -220,7 +222,7 @@ SetupCloseFileQueue( PQUEUEENTRY Entry; if (QueueHandle == NULL) - return; + return FALSE; QueueHeader = (PFILEQUEUEHEADER)QueueHandle; @@ -250,19 +252,24 @@ SetupCloseFileQueue( /* Delete queue header */ RtlFreeHeap(ProcessHeap, 0, QueueHeader); + + return TRUE; } /* A simplified version of SetupQueueCopyW that wraps Cabinet support around */ BOOL WINAPI -SetupQueueCopyWithCab( // SetupQueueCopyW +SetupQueueCopyWithCab( IN HSPFILEQ QueueHandle, - IN PCWSTR SourceCabinet OPTIONAL, IN PCWSTR SourceRootPath, IN PCWSTR SourcePath OPTIONAL, IN PCWSTR SourceFileName, + IN PCWSTR SourceDescription OPTIONAL, + IN PCWSTR SourceCabinet OPTIONAL, + IN PCWSTR SourceTagFile OPTIONAL, IN PCWSTR TargetDirectory, - IN PCWSTR TargetFileName OPTIONAL) + IN PCWSTR TargetFileName OPTIONAL, + IN ULONG CopyStyle) { PFILEQUEUEHEADER QueueHeader; PQUEUEENTRY Entry; @@ -868,4 +875,14 @@ SetupCommitFileQueueW( return Success; } + +/* GLOBALS *******************************************************************/ + +pSpFileQueueOpen SpFileQueueOpen = SetupOpenFileQueue; +pSpFileQueueClose SpFileQueueClose = SetupCloseFileQueue; +pSpFileQueueCopy SpFileQueueCopy = SetupQueueCopyWithCab; +pSpFileQueueDelete SpFileQueueDelete = SetupQueueDeleteW; +pSpFileQueueRename SpFileQueueRename = SetupQueueRenameW; +pSpFileQueueCommit SpFileQueueCommit = SetupCommitFileQueueW; + /* EOF */ diff --git a/base/setup/usetup/inffile.h b/base/setup/usetup/spapisup/inffile.h similarity index 86% rename from base/setup/usetup/inffile.h rename to base/setup/usetup/spapisup/inffile.h index 9d33563a88..4ee020c7b9 100644 --- a/base/setup/usetup/inffile.h +++ b/base/setup/usetup/spapisup/inffile.h @@ -20,8 +20,8 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup * FILE: base/setup/usetup/inffile.h - * PURPOSE: .inf files support functions - * PROGRAMMERS: Herv� Poussineau + * PURPOSE: Interfacing with Setup* API .INF Files support functions + * PROGRAMMERS: Hervé Poussineau * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) */ @@ -50,11 +50,11 @@ extern VOID InfSetHeap(PVOID Heap); HINF WINAPI INF_OpenBufferedFileA( - IN PSTR FileBuffer, - IN ULONG FileSize, - IN PCSTR InfClass, - IN DWORD InfStyle, - IN LCID LocaleId, + IN PSTR FileBuffer, + IN ULONG FileSize, + IN PCSTR InfClass, + IN DWORD InfStyle, + IN LCID LocaleId, OUT PUINT ErrorLine); /* EOF */ diff --git a/base/setup/usetup/inffile.c b/base/setup/usetup/spapisup/infsupp.c similarity index 74% rename from base/setup/usetup/inffile.c rename to base/setup/usetup/spapisup/infsupp.c index 47edb34a58..af18c491c1 100644 --- a/base/setup/usetup/inffile.c +++ b/base/setup/usetup/spapisup/infsupp.c @@ -19,9 +19,9 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup - * FILE: base/setup/usetup/inffile.c - * PURPOSE: .inf files support functions - * PROGRAMMERS: Herv� Poussineau + * FILE: base/setup/lib/infsupp.c + * PURPOSE: Interfacing with Setup* API .INF Files support functions + * PROGRAMMERS: Hervé Poussineau * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) */ @@ -40,7 +40,8 @@ extern VOID InfCloseFile(HINF InfHandle); // #define SetupCloseInfFile InfCloseFile VOID WINAPI -SetupCloseInfFile(HINF InfHandle) +SetupCloseInfFile( + IN HINF InfHandle) { InfCloseFile(InfHandle); } @@ -71,23 +72,25 @@ extern BOOLEAN InfFindNextLine(PINFCONTEXT ContextIn, // #define SetupFindNextLine InfFindNextLine BOOL WINAPI -SetupFindNextLine(PINFCONTEXT ContextIn, - PINFCONTEXT ContextOut) +SetupFindNextLine( + IN PINFCONTEXT ContextIn, + OUT PINFCONTEXT ContextOut) { return !!InfFindNextLine(ContextIn, ContextOut); } extern LONG InfGetFieldCount(PINFCONTEXT Context); // #define SetupGetFieldCount InfGetFieldCount -LONG +ULONG WINAPI -SetupGetFieldCount(PINFCONTEXT Context) +SetupGetFieldCount( + IN PINFCONTEXT Context) { - return InfGetFieldCount(Context); + return (ULONG)InfGetFieldCount(Context); } /* - * This function corresponds to an undocumented but exported setupapi API + * This function corresponds to an undocumented but exported SetupAPI function * that exists since WinNT4 and is still present in Win10. * The returned string pointer is a read-only pointer to a string in the * maintained INF cache, and is always in UNICODE (on NT systems). @@ -97,8 +100,9 @@ extern BOOLEAN InfGetDataField(PINFCONTEXT Context, PWCHAR *Data); PCWSTR WINAPI -pSetupGetField(PINFCONTEXT Context, - ULONG FieldIndex) +pSetupGetField( + IN PINFCONTEXT Context, + IN ULONG FieldIndex) { PWCHAR Data = NULL; if (!InfGetDataField(Context, FieldIndex, &Data)) @@ -114,11 +118,12 @@ extern BOOLEAN InfGetBinaryField(PINFCONTEXT Context, // #define SetupGetBinaryField InfGetBinaryField BOOL WINAPI -SetupGetBinaryField(PINFCONTEXT Context, - ULONG FieldIndex, - PUCHAR ReturnBuffer, - ULONG ReturnBufferSize, - PULONG RequiredSize) +SetupGetBinaryField( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT PUCHAR ReturnBuffer, + IN ULONG ReturnBufferSize, + OUT PULONG RequiredSize) { return !!InfGetBinaryField(Context, FieldIndex, @@ -133,9 +138,10 @@ extern BOOLEAN InfGetIntField(PINFCONTEXT Context, // #define SetupGetIntField InfGetIntField BOOL WINAPI -SetupGetIntField(PINFCONTEXT Context, - ULONG FieldIndex, - INT *IntegerValue) // PINT +SetupGetIntField( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT INT *IntegerValue) // PINT { return !!InfGetIntField(Context, FieldIndex, IntegerValue); } @@ -148,11 +154,12 @@ extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context, // #define SetupGetMultiSzFieldW InfGetMultiSzField BOOL WINAPI -SetupGetMultiSzFieldW(PINFCONTEXT Context, - ULONG FieldIndex, - PWSTR ReturnBuffer, - ULONG ReturnBufferSize, - PULONG RequiredSize) +SetupGetMultiSzFieldW( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT PWSTR ReturnBuffer, + IN ULONG ReturnBufferSize, + OUT PULONG RequiredSize) { return !!InfGetMultiSzField(Context, FieldIndex, @@ -169,11 +176,12 @@ extern BOOLEAN InfGetStringField(PINFCONTEXT Context, // #define SetupGetStringFieldW InfGetStringField BOOL WINAPI -SetupGetStringFieldW(PINFCONTEXT Context, - ULONG FieldIndex, - PWSTR ReturnBuffer, - ULONG ReturnBufferSize, - PULONG RequiredSize) +SetupGetStringFieldW( + IN PINFCONTEXT Context, + IN ULONG FieldIndex, + OUT PWSTR ReturnBuffer, + IN ULONG ReturnBufferSize, + OUT PULONG RequiredSize) { return !!InfGetStringField(Context, FieldIndex, @@ -182,7 +190,6 @@ SetupGetStringFieldW(PINFCONTEXT Context, RequiredSize); } - /* SetupOpenInfFileW with support for a user-provided LCID */ // #define SetupOpenInfFileExW InfpOpenInfFileW HINF @@ -212,15 +219,29 @@ SetupOpenInfFileExW( } +/* GLOBALS *******************************************************************/ + +pSpInfCloseInfFile SpInfCloseInfFile = SetupCloseInfFile; +pSpInfFindFirstLine SpInfFindFirstLine = SetupFindFirstLineW; +pSpInfFindNextLine SpInfFindNextLine = SetupFindNextLine; +pSpInfGetFieldCount SpInfGetFieldCount = SetupGetFieldCount; +pSpInfGetBinaryField SpInfGetBinaryField = SetupGetBinaryField; +pSpInfGetIntField SpInfGetIntField = SetupGetIntField; +pSpInfGetMultiSzField SpInfGetMultiSzField = SetupGetMultiSzFieldW; +pSpInfGetStringField SpInfGetStringField = SetupGetStringFieldW; +pSpInfGetField SpInfGetField = pSetupGetField; +pSpInfOpenInfFile SpInfOpenInfFile = SetupOpenInfFileExW; + + /* HELPER FUNCTIONS **********************************************************/ HINF WINAPI INF_OpenBufferedFileA( - IN PSTR FileBuffer, - IN ULONG FileSize, - IN PCSTR InfClass, - IN DWORD InfStyle, - IN LCID LocaleId, + IN PSTR FileBuffer, + IN ULONG FileSize, + IN PCSTR InfClass, + IN DWORD InfStyle, + IN LCID LocaleId, OUT PUINT ErrorLine) { HINF hInf = NULL; diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index 929a4dca9a..7fe24fcf2d 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -71,8 +71,6 @@ static PGENERIC_LIST NtOsInstallsList = NULL; // HACK: Temporary compatibility code. #if 1 - #define SetupQueueCopy SetupQueueCopyWithCab - static CABINET_CONTEXT CabinetContext; #define CabinetInitialize() (CabinetInitialize(&CabinetContext)) #define CabinetSetEventHandlers(a,b,c) (CabinetSetEventHandlers(&CabinetContext,(a),(b),(c))) @@ -3485,17 +3483,17 @@ InstallDirectoryPage(PINPUT_RECORD Ir) static BOOLEAN AddSectionToCopyQueueCab(HINF InfFile, - PWCHAR SectionName, - PWCHAR SourceCabinet, + PCWSTR SectionName, + PCWSTR SourceCabinet, PCUNICODE_STRING DestinationPath, PINPUT_RECORD Ir) { INFCONTEXT FilesContext; INFCONTEXT DirContext; - PWCHAR FileKeyName; - PWCHAR FileKeyValue; - PWCHAR DirKeyValue; - PWCHAR TargetFileName; + PCWSTR FileKeyName; + PCWSTR FileKeyValue; + PCWSTR DirKeyValue; + PCWSTR TargetFileName; WCHAR FileDstPath[MAX_PATH]; /* @@ -3505,7 +3503,7 @@ AddSectionToCopyQueueCab(HINF InfFile, */ /* Search for the SectionName section */ - if (!SetupFindFirstLineW(InfFile, SectionName, NULL, &FilesContext)) + if (!SpInfFindFirstLine(InfFile, SectionName, NULL, &FilesContext)) { MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER, SectionName); return FALSE; @@ -3531,7 +3529,7 @@ AddSectionToCopyQueueCab(HINF InfFile, DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue); /* Lookup target directory */ - if (!SetupFindFirstLineW(InfFile, L"Directories", FileKeyValue, &DirContext)) + if (!SpInfFindFirstLine(InfFile, L"Directories", FileKeyValue, &DirContext)) { /* FIXME: Handle error! */ DPRINT1("SetupFindFirstLine() failed\n"); @@ -3557,7 +3555,7 @@ AddSectionToCopyQueueCab(HINF InfFile, ULONG Length = wcslen(DirKeyValue); if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\')) Length--; - DirKeyValue[Length] = UNICODE_NULL; + *((PWSTR)DirKeyValue + Length) = UNICODE_NULL; } /* Build the full target path */ @@ -3586,22 +3584,25 @@ AddSectionToCopyQueueCab(HINF InfFile, } #endif - if (!SetupQueueCopy(USetupData.SetupFileQueue, - SourceCabinet, - USetupData.SourceRootPath.Buffer, - USetupData.SourceRootDir.Buffer, - FileKeyName, - FileDstPath, - TargetFileName)) + if (!SpFileQueueCopy((HSPFILEQ)USetupData.SetupFileQueue, + USetupData.SourceRootPath.Buffer, + USetupData.SourceRootDir.Buffer, + FileKeyName, + NULL, + SourceCabinet, + NULL, + FileDstPath, + TargetFileName, + 0 /* FIXME */)) { /* FIXME: Handle error! */ - DPRINT1("SetupQueueCopy() failed\n"); + DPRINT1("SpFileQueueCopy() failed\n"); } INF_FreeData(FileKeyName); INF_FreeData(TargetFileName); INF_FreeData(DirKeyValue); - } while (SetupFindNextLine(&FilesContext, &FilesContext)); + } while (SpInfFindNextLine(&FilesContext, &FilesContext)); return TRUE; } @@ -3609,17 +3610,17 @@ AddSectionToCopyQueueCab(HINF InfFile, static BOOLEAN AddSectionToCopyQueue(HINF InfFile, - PWCHAR SectionName, - PWCHAR SourceCabinet, + PCWSTR SectionName, + PCWSTR SourceCabinet, PCUNICODE_STRING DestinationPath, PINPUT_RECORD Ir) { INFCONTEXT FilesContext; INFCONTEXT DirContext; - PWCHAR FileKeyName; - PWCHAR FileKeyValue; - PWCHAR DirKeyValue; - PWCHAR TargetFileName; + PCWSTR FileKeyName; + PCWSTR FileKeyValue; + PCWSTR DirKeyValue; + PCWSTR TargetFileName; WCHAR CompleteOrigDirName[512]; // FIXME: MAX_PATH is not enough? WCHAR FileDstPath[MAX_PATH]; @@ -3632,7 +3633,7 @@ AddSectionToCopyQueue(HINF InfFile, */ /* Search for the SectionName section */ - if (!SetupFindFirstLineW(InfFile, SectionName, NULL, &FilesContext)) + if (!SpInfFindFirstLine(InfFile, SectionName, NULL, &FilesContext)) { MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER, SectionName); return FALSE; @@ -3669,7 +3670,7 @@ AddSectionToCopyQueue(HINF InfFile, DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue); /* Lookup target directory */ - if (!SetupFindFirstLineW(InfFile, L"Directories", FileKeyValue, &DirContext)) + if (!SpInfFindFirstLine(InfFile, L"Directories", FileKeyValue, &DirContext)) { /* FIXME: Handle error! */ DPRINT1("SetupFindFirstLine() failed\n"); @@ -3726,7 +3727,7 @@ AddSectionToCopyQueue(HINF InfFile, ULONG Length = wcslen(DirKeyValue); if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\')) Length--; - DirKeyValue[Length] = UNICODE_NULL; + *((PWSTR)DirKeyValue + Length) = UNICODE_NULL; } /* Build the full target path */ @@ -3755,22 +3756,25 @@ AddSectionToCopyQueue(HINF InfFile, } #endif - if (!SetupQueueCopy(USetupData.SetupFileQueue, - SourceCabinet, - USetupData.SourceRootPath.Buffer, - CompleteOrigDirName, - FileKeyName, - FileDstPath, - TargetFileName)) + if (!SpFileQueueCopy((HSPFILEQ)USetupData.SetupFileQueue, + USetupData.SourceRootPath.Buffer, + CompleteOrigDirName, + FileKeyName, + NULL, + SourceCabinet, + NULL, + FileDstPath, + TargetFileName, + 0 /* FIXME */)) { /* FIXME: Handle error! */ - DPRINT1("SetupQueueCopy() failed\n"); + DPRINT1("SpFileQueueCopy() failed\n"); } INF_FreeData(FileKeyName); INF_FreeData(TargetFileName); INF_FreeData(DirKeyValue); - } while (SetupFindNextLine(&FilesContext, &FilesContext)); + } while (SpInfFindNextLine(&FilesContext, &FilesContext)); return TRUE; } @@ -3778,13 +3782,13 @@ AddSectionToCopyQueue(HINF InfFile, static BOOLEAN PrepareCopyPageInfFile(HINF InfFile, - PWCHAR SourceCabinet, + PCWSTR SourceCabinet, PINPUT_RECORD Ir) { NTSTATUS Status; INFCONTEXT DirContext; PWCHAR AdditionalSectionName = NULL; - PWCHAR DirKeyValue; + PCWSTR DirKeyValue; WCHAR PathBuffer[MAX_PATH]; /* Add common files */ @@ -3829,7 +3833,7 @@ PrepareCopyPageInfFile(HINF InfFile, } /* Search for the 'Directories' section */ - if (!SetupFindFirstLineW(InfFile, L"Directories", NULL, &DirContext)) + if (!SpInfFindFirstLine(InfFile, L"Directories", NULL, &DirContext)) { if (SourceCabinet) MUIDisplayError(ERROR_CABINET_SECTION, Ir, POPUP_WAIT_ENTER, L"Directories"); @@ -3898,7 +3902,7 @@ PrepareCopyPageInfFile(HINF InfFile, } INF_FreeData(DirKeyValue); - } while (SetupFindNextLine(&DirContext, &DirContext)); + } while (SpInfFindNextLine(&DirContext, &DirContext)); return TRUE; } @@ -3925,14 +3929,14 @@ PrepareCopyPage(PINPUT_RECORD Ir) WCHAR PathBuffer[MAX_PATH]; INFCONTEXT CabinetsContext; ULONG InfFileSize; - PWCHAR KeyValue; + PCWSTR KeyValue; UINT ErrorLine; PVOID InfFileData; MUIDisplayPage(PREPARE_COPY_PAGE); /* Create the file queue */ - USetupData.SetupFileQueue = SetupOpenFileQueue(); + USetupData.SetupFileQueue = SpFileQueueOpen(); if (USetupData.SetupFileQueue == NULL) { MUIDisplayError(ERROR_COPY_QUEUE, Ir, POPUP_WAIT_ENTER); @@ -3946,7 +3950,7 @@ PrepareCopyPage(PINPUT_RECORD Ir) } /* Search for the 'Cabinets' section */ - if (!SetupFindFirstLineW(USetupData.SetupInf, L"Cabinets", NULL, &CabinetsContext)) + if (!SpInfFindFirstLine(USetupData.SetupInf, L"Cabinets", NULL, &CabinetsContext)) { return FILE_COPY_PAGE; } @@ -4005,7 +4009,7 @@ PrepareCopyPage(PINPUT_RECORD Ir) /* FIXME: show an error dialog */ return QUIT_PAGE; } - } while (SetupFindNextLine(&CabinetsContext, &CabinetsContext)); + } while (SpInfFindNextLine(&CabinetsContext, &CabinetsContext)); return FILE_COPY_PAGE; } @@ -4148,7 +4152,7 @@ FileCopyCallback(PVOID Context, * * SIDEEFFECTS * Calls SetupCommitFileQueueW - * Calls SetupCloseFileQueue + * Calls SpFileQueueClose * * RETURNS * Number of the next page. @@ -4210,13 +4214,13 @@ FileCopyPage(PINPUT_RECORD Ir) "Free Memory"); /* Do the file copying */ - SetupCommitFileQueueW(NULL, - USetupData.SetupFileQueue, - FileCopyCallback, - &CopyContext); + SpFileQueueCommit(NULL, + USetupData.SetupFileQueue, + FileCopyCallback, + &CopyContext); /* If we get here, we're done, so cleanup the queue and progress bar */ - SetupCloseFileQueue(USetupData.SetupFileQueue); + SpFileQueueClose(USetupData.SetupFileQueue); DestroyProgressBar(CopyContext.ProgressBar); DestroyProgressBar(CopyContext.MemoryBars[0]); DestroyProgressBar(CopyContext.MemoryBars[1]); diff --git a/base/setup/usetup/usetup.h b/base/setup/usetup/usetup.h index 39a5c6a168..ef2fc1e553 100644 --- a/base/setup/usetup/usetup.h +++ b/base/setup/usetup/usetup.h @@ -59,15 +59,16 @@ /* Internal Headers */ #include "consup.h" -#include "inffile.h" #include "progress.h" -#include "filequeue.h" #include "fslist.h" #include "partlist.h" -#include "cabinet.h" #include "genlist.h" #include "mui.h" +#include "spapisup/inffile.h" +#include "spapisup/cabinet.h" + + extern HANDLE ProcessHeap; extern BOOLEAN IsUnattendedSetup; extern PCWSTR SelectedLanguageId;
6 years, 1 month
1
0
0
0
01/04: [USETUP] Improvements for the File-queues code.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=44c101c9dcec40e8c87b9…
commit 44c101c9dcec40e8c87b96391501de59a53c4565 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Fri Jan 5 02:08:59 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Nov 1 18:55:35 2018 +0100 [USETUP] Improvements for the File-queues code. - Add support for delete and move/rename operations, which are needed for implementing ReactOS upgrading support. - Use cabinet contexts. - Use standard LIST_ENTRY structures for implementing the lists. - Move the path-building hack code in SetupCommitFileQueueW() that had been introduced in r66604 (97bb83f) out of the file-queues code. - Make the function prototypes compatible with win32's setupapi functions. - Fix the format of the data passed to the custom notification handler. - Adjust the file-copy callback to correctly use its arguments (setupapi-compatible). --- base/setup/usetup/filequeue.c | 797 +++++++++++++++++++++++++++++------------- base/setup/usetup/filequeue.h | 116 +++--- base/setup/usetup/usetup.c | 172 +++++++-- 3 files changed, 771 insertions(+), 314 deletions(-) diff --git a/base/setup/usetup/filequeue.c b/base/setup/usetup/filequeue.c index bb1f71218c..c50203c361 100644 --- a/base/setup/usetup/filequeue.c +++ b/base/setup/usetup/filequeue.c @@ -34,98 +34,95 @@ typedef struct _QUEUEENTRY { - struct _QUEUEENTRY *Prev; - struct _QUEUEENTRY *Next; - + LIST_ENTRY ListEntry; PWSTR SourceCabinet; /* May be NULL if the file is not in a cabinet */ PWSTR SourceRootPath; PWSTR SourcePath; - PWSTR SourceFilename; + PWSTR SourceFileName; PWSTR TargetDirectory; - PWSTR TargetFilename; + PWSTR TargetFileName; } QUEUEENTRY, *PQUEUEENTRY; - typedef struct _FILEQUEUEHEADER { - PQUEUEENTRY CopyHead; - PQUEUEENTRY CopyTail; + LIST_ENTRY DeleteQueue; // PQUEUEENTRY entries + ULONG DeleteCount; + + LIST_ENTRY RenameQueue; // PQUEUEENTRY entries + ULONG RenameCount; + + LIST_ENTRY CopyQueue; // PQUEUEENTRY entries ULONG CopyCount; + + BOOLEAN HasCurrentCabinet; + CABINET_CONTEXT CabinetContext; + CAB_SEARCH Search; + WCHAR CurrentCabinetName[MAX_PATH]; } FILEQUEUEHEADER, *PFILEQUEUEHEADER; -/* FUNCTIONS ****************************************************************/ - -static BOOLEAN HasCurrentCabinet = FALSE; -static WCHAR CurrentCabinetName[MAX_PATH]; -static CAB_SEARCH Search; - -// HACK: Temporary compatibility code. -#if 1 - static CABINET_CONTEXT CabinetContext; - #define CabinetInitialize() (CabinetInitialize(&CabinetContext)) - #define CabinetSetEventHandlers(a,b,c) (CabinetSetEventHandlers(&CabinetContext,(a),(b),(c))) - #define CabinetSetCabinetName(a) (CabinetSetCabinetName(&CabinetContext,(a))) - #define CabinetOpen() (CabinetOpen(&CabinetContext)) - #define CabinetGetCabinetName() (CabinetGetCabinetName(&CabinetContext)) - #define CabinetGetCabinetReservedArea(a) (CabinetGetCabinetReservedArea(&CabinetContext,(a))) - #define CabinetFindNextFileSequential(a,b) (CabinetFindNextFileSequential(&CabinetContext,(a),(b))) - #define CabinetFindFirst(a,b) (CabinetFindFirst(&CabinetContext,(a),(b))) - #define CabinetSetDestinationPath(a) (CabinetSetDestinationPath(&CabinetContext,(a))) - #define CabinetExtractFile(a) (CabinetExtractFile(&CabinetContext,(a))) - #define CabinetCleanup() (CabinetCleanup(&CabinetContext)) -#endif - -NTSTATUS +/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/ + +static NTSTATUS SetupExtractFile( - PWCHAR CabinetFileName, - PWCHAR SourceFileName, - PWCHAR DestinationPathName) + IN OUT PFILEQUEUEHEADER QueueHeader, + IN PCWSTR CabinetFileName, + IN PCWSTR SourceFileName, + IN PCWSTR DestinationPathName) { ULONG CabStatus; - DPRINT("SetupExtractFile(CabinetFileName %S, SourceFileName %S, DestinationPathName %S)\n", + DPRINT("SetupExtractFile(CabinetFileName: '%S', SourceFileName: '%S', DestinationPathName: '%S')\n", CabinetFileName, SourceFileName, DestinationPathName); - if (HasCurrentCabinet) + if (QueueHeader->HasCurrentCabinet) { - DPRINT("CurrentCabinetName: %S\n", CurrentCabinetName); + DPRINT("CurrentCabinetName: '%S'\n", QueueHeader->CurrentCabinetName); } - if ((HasCurrentCabinet) && (wcscmp(CabinetFileName, CurrentCabinetName) == 0)) + if (QueueHeader->HasCurrentCabinet && + (wcscmp(CabinetFileName, QueueHeader->CurrentCabinetName) == 0)) { DPRINT("Using same cabinet as last time\n"); /* Use our last location because the files should be sequential */ - CabStatus = CabinetFindNextFileSequential(SourceFileName, &Search); + CabStatus = CabinetFindNextFileSequential(&QueueHeader->CabinetContext, + SourceFileName, + &QueueHeader->Search); if (CabStatus != CAB_STATUS_SUCCESS) { DPRINT("Sequential miss on file: %S\n", SourceFileName); /* Looks like we got unlucky */ - CabStatus = CabinetFindFirst(SourceFileName, &Search); + CabStatus = CabinetFindFirst(&QueueHeader->CabinetContext, + SourceFileName, + &QueueHeader->Search); } } else { DPRINT("Using new cabinet\n"); - if (HasCurrentCabinet) + if (QueueHeader->HasCurrentCabinet) { - CabinetCleanup(); + QueueHeader->HasCurrentCabinet = FALSE; + CabinetCleanup(&QueueHeader->CabinetContext); } - wcscpy(CurrentCabinetName, CabinetFileName); + RtlStringCchCopyW(QueueHeader->CurrentCabinetName, + ARRAYSIZE(QueueHeader->CurrentCabinetName), + CabinetFileName); - CabinetInitialize(); - CabinetSetEventHandlers(NULL, NULL, NULL); - CabinetSetCabinetName(CabinetFileName); + CabinetInitialize(&QueueHeader->CabinetContext); + CabinetSetEventHandlers(&QueueHeader->CabinetContext, + NULL, NULL, NULL); + CabinetSetCabinetName(&QueueHeader->CabinetContext, CabinetFileName); - CabStatus = CabinetOpen(); + CabStatus = CabinetOpen(&QueueHeader->CabinetContext); if (CabStatus == CAB_STATUS_SUCCESS) { - DPRINT("Opened cabinet %S\n", CabinetGetCabinetName()); - HasCurrentCabinet = TRUE; + DPRINT("Opened cabinet %S\n", CabinetFileName /*CabinetGetCabinetName(&QueueHeader->CabinetContext)*/); + QueueHeader->HasCurrentCabinet = TRUE; } else { @@ -134,17 +131,20 @@ SetupExtractFile( } /* We have to start at the beginning here */ - CabStatus = CabinetFindFirst(SourceFileName, &Search); + CabStatus = CabinetFindFirst(&QueueHeader->CabinetContext, + SourceFileName, + &QueueHeader->Search); } if (CabStatus != CAB_STATUS_SUCCESS) { - DPRINT1("Unable to find '%S' in cabinet '%S'\n", SourceFileName, CabinetGetCabinetName()); + DPRINT1("Unable to find '%S' in cabinet '%S'\n", + SourceFileName, CabinetGetCabinetName(&QueueHeader->CabinetContext)); return STATUS_UNSUCCESSFUL; } - CabinetSetDestinationPath(DestinationPathName); - CabStatus = CabinetExtractFile(&Search); + CabinetSetDestinationPath(&QueueHeader->CabinetContext, DestinationPathName); + CabStatus = CabinetExtractFile(&QueueHeader->CabinetContext, &QueueHeader->Search); if (CabStatus != CAB_STATUS_SUCCESS) { DPRINT("Cannot extract file %S (%d)\n", SourceFileName, CabStatus); @@ -160,27 +160,63 @@ SetupOpenFileQueue(VOID) { PFILEQUEUEHEADER QueueHeader; - /* Allocate queue header */ - QueueHeader = (PFILEQUEUEHEADER)RtlAllocateHeap(ProcessHeap, - 0, - sizeof(FILEQUEUEHEADER)); + /* Allocate the queue header */ + QueueHeader = RtlAllocateHeap(ProcessHeap, 0, sizeof(FILEQUEUEHEADER)); if (QueueHeader == NULL) return NULL; - /* Initialize queue header */ - RtlZeroMemory(QueueHeader, - sizeof(FILEQUEUEHEADER)); + RtlZeroMemory(QueueHeader, sizeof(FILEQUEUEHEADER)); + + /* Initialize the file queues */ + InitializeListHead(&QueueHeader->DeleteQueue); + QueueHeader->DeleteCount = 0; + InitializeListHead(&QueueHeader->RenameQueue); + QueueHeader->RenameCount = 0; + InitializeListHead(&QueueHeader->CopyQueue); + QueueHeader->CopyCount = 0; + + QueueHeader->HasCurrentCabinet = FALSE; return (HSPFILEQ)QueueHeader; } +static VOID +SetupDeleteQueueEntry( + IN PQUEUEENTRY Entry) +{ + if (Entry == NULL) + return; + + /* Delete all strings */ + if (Entry->SourceCabinet != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet); + + if (Entry->SourceRootPath != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); + + if (Entry->SourcePath != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); + + if (Entry->SourceFileName != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourceFileName); + + if (Entry->TargetDirectory != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory); + + if (Entry->TargetFileName != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->TargetFileName); + + /* Delete queue entry */ + RtlFreeHeap(ProcessHeap, 0, Entry); +} VOID WINAPI SetupCloseFileQueue( - HSPFILEQ QueueHandle) + IN HSPFILEQ QueueHandle) { PFILEQUEUEHEADER QueueHeader; + PLIST_ENTRY ListEntry; PQUEUEENTRY Entry; if (QueueHandle == NULL) @@ -188,71 +224,53 @@ SetupCloseFileQueue( QueueHeader = (PFILEQUEUEHEADER)QueueHandle; - /* Delete copy queue */ - Entry = QueueHeader->CopyHead; - while (Entry != NULL) + /* Delete the delete queue */ + while (!IsListEmpty(&QueueHeader->DeleteQueue)) { - /* Delete all strings */ - if (Entry->SourceCabinet != NULL) - RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet); - - if (Entry->SourceRootPath != NULL) - RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); - - if (Entry->SourcePath != NULL) - RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); - - if (Entry->SourceFilename != NULL) - RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename); - - if (Entry->TargetDirectory != NULL) - RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory); - - if (Entry->TargetFilename != NULL) - RtlFreeHeap(ProcessHeap, 0, Entry->TargetFilename); - - /* Unlink current queue entry */ - if (Entry->Next != NULL) - { - QueueHeader->CopyHead = Entry->Next; - QueueHeader->CopyHead->Prev = NULL; - } - else - { - QueueHeader->CopyHead = NULL; - QueueHeader->CopyTail = NULL; - } + ListEntry = RemoveHeadList(&QueueHeader->DeleteQueue); + Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); + SetupDeleteQueueEntry(Entry); + } - /* Delete queue entry */ - RtlFreeHeap(ProcessHeap, 0, Entry); + /* Delete the rename queue */ + while (!IsListEmpty(&QueueHeader->RenameQueue)) + { + ListEntry = RemoveHeadList(&QueueHeader->RenameQueue); + Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); + SetupDeleteQueueEntry(Entry); + } - /* Get next queue entry */ - Entry = QueueHeader->CopyHead; + /* Delete the copy queue */ + while (!IsListEmpty(&QueueHeader->CopyQueue)) + { + ListEntry = RemoveHeadList(&QueueHeader->CopyQueue); + Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); + SetupDeleteQueueEntry(Entry); } /* Delete queue header */ RtlFreeHeap(ProcessHeap, 0, QueueHeader); } - +/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */ BOOL -SetupQueueCopy( - HSPFILEQ QueueHandle, - PCWSTR SourceCabinet, - PCWSTR SourceRootPath, - PCWSTR SourcePath, - PCWSTR SourceFilename, - PCWSTR TargetDirectory, - PCWSTR TargetFilename) +WINAPI +SetupQueueCopyWithCab( // SetupQueueCopyW + IN HSPFILEQ QueueHandle, + IN PCWSTR SourceCabinet OPTIONAL, + IN PCWSTR SourceRootPath, + IN PCWSTR SourcePath OPTIONAL, + IN PCWSTR SourceFileName, + IN PCWSTR TargetDirectory, + IN PCWSTR TargetFileName OPTIONAL) { PFILEQUEUEHEADER QueueHeader; PQUEUEENTRY Entry; ULONG Length; - /* SourceCabinet may be NULL */ if (QueueHandle == NULL || SourceRootPath == NULL || - SourceFilename == NULL || + SourceFileName == NULL || TargetDirectory == NULL) { return FALSE; @@ -260,194 +278,351 @@ SetupQueueCopy( QueueHeader = (PFILEQUEUEHEADER)QueueHandle; + DPRINT("SetupQueueCopy(Cab '%S', SrcRootPath '%S', SrcPath '%S', SrcFN '%S' --> DstPath '%S', DstFN '%S')\n", + SourceCabinet ? SourceCabinet : L"n/a", + SourceRootPath, SourcePath, SourceFileName, + TargetDirectory, TargetFileName); + /* Allocate new queue entry */ - Entry = (PQUEUEENTRY)RtlAllocateHeap(ProcessHeap, - 0, - sizeof(QUEUEENTRY)); + Entry = RtlAllocateHeap(ProcessHeap, 0, sizeof(QUEUEENTRY)); if (Entry == NULL) return FALSE; - RtlZeroMemory(Entry, - sizeof(QUEUEENTRY)); + RtlZeroMemory(Entry, sizeof(QUEUEENTRY)); /* Copy source cabinet if available */ + Entry->SourceCabinet = NULL; if (SourceCabinet != NULL) { Length = wcslen(SourceCabinet); - Entry->SourceCabinet = (WCHAR*)RtlAllocateHeap(ProcessHeap, - 0, - (Length + 1) * sizeof(WCHAR)); + Entry->SourceCabinet = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); if (Entry->SourceCabinet == NULL) { RtlFreeHeap(ProcessHeap, 0, Entry); return FALSE; } - - wcsncpy(Entry->SourceCabinet, SourceCabinet, Length); - Entry->SourceCabinet[Length] = UNICODE_NULL; - } - else - { - Entry->SourceCabinet = NULL; + RtlStringCchCopyW(Entry->SourceCabinet, Length + 1, SourceCabinet); } /* Copy source root path */ Length = wcslen(SourceRootPath); - Entry->SourceRootPath = (WCHAR*)RtlAllocateHeap(ProcessHeap, - 0, - (Length + 1) * sizeof(WCHAR)); + Entry->SourceRootPath = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); if (Entry->SourceRootPath == NULL) { if (Entry->SourceCabinet != NULL) - { RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet); - } RtlFreeHeap(ProcessHeap, 0, Entry); return FALSE; } - - wcsncpy(Entry->SourceRootPath, SourceRootPath, Length); - Entry->SourceRootPath[Length] = UNICODE_NULL; + RtlStringCchCopyW(Entry->SourceRootPath, Length + 1, SourceRootPath); /* Copy source path */ + Entry->SourcePath = NULL; if (SourcePath != NULL) { Length = wcslen(SourcePath); if ((Length > 0) && (SourcePath[Length - 1] == L'\\')) Length--; - Entry->SourcePath = (WCHAR*)RtlAllocateHeap(ProcessHeap, - 0, - (Length + 1) * sizeof(WCHAR)); + Entry->SourcePath = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); if (Entry->SourcePath == NULL) { if (Entry->SourceCabinet != NULL) - { RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet); - } RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); RtlFreeHeap(ProcessHeap, 0, Entry); return FALSE; } - - wcsncpy(Entry->SourcePath, SourcePath, Length); - Entry->SourcePath[Length] = UNICODE_NULL; + RtlStringCchCopyW(Entry->SourcePath, Length + 1, SourcePath); } /* Copy source file name */ - Length = wcslen(SourceFilename); - Entry->SourceFilename = (WCHAR*)RtlAllocateHeap(ProcessHeap, + Length = wcslen(SourceFileName); + Entry->SourceFileName = (WCHAR*)RtlAllocateHeap(ProcessHeap, 0, (Length + 1) * sizeof(WCHAR)); - if (Entry->SourceFilename == NULL) + if (Entry->SourceFileName == NULL) { + if (Entry->SourcePath != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); + + RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); + if (Entry->SourceCabinet != NULL) - { RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet); - } - RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); - RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); RtlFreeHeap(ProcessHeap, 0, Entry); return FALSE; } - - wcsncpy(Entry->SourceFilename, SourceFilename, Length); - Entry->SourceFilename[Length] = UNICODE_NULL; + RtlStringCchCopyW(Entry->SourceFileName, Length + 1, SourceFileName); /* Copy target directory */ Length = wcslen(TargetDirectory); if ((Length > 0) && (TargetDirectory[Length - 1] == L'\\')) Length--; - Entry->TargetDirectory = (WCHAR*)RtlAllocateHeap(ProcessHeap, - 0, - (Length + 1) * sizeof(WCHAR)); + Entry->TargetDirectory = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); if (Entry->TargetDirectory == NULL) { + RtlFreeHeap(ProcessHeap, 0, Entry->SourceFileName); + + if (Entry->SourcePath != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); + + RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); + if (Entry->SourceCabinet != NULL) - { RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet); - } - RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); - RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); - RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename); RtlFreeHeap(ProcessHeap, 0, Entry); return FALSE; } - - wcsncpy(Entry->TargetDirectory, TargetDirectory, Length); - Entry->TargetDirectory[Length] = UNICODE_NULL; + RtlStringCchCopyW(Entry->TargetDirectory, Length + 1, TargetDirectory); /* Copy optional target filename */ - if (TargetFilename != NULL) + Entry->TargetFileName = NULL; + if (TargetFileName != NULL) { - Length = wcslen(TargetFilename); - Entry->TargetFilename = (WCHAR*)RtlAllocateHeap(ProcessHeap, - 0, - (Length + 1) * sizeof(WCHAR)); - if (Entry->TargetFilename == NULL) + Length = wcslen(TargetFileName); + Entry->TargetFileName = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); + if (Entry->TargetFileName == NULL) { + RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory); + RtlFreeHeap(ProcessHeap, 0, Entry->SourceFileName); + + if (Entry->SourcePath != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); + + RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); + if (Entry->SourceCabinet != NULL) - { RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet); - } - RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath); - RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); - RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename); - RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory); RtlFreeHeap(ProcessHeap, 0, Entry); return FALSE; } - - wcsncpy(Entry->TargetFilename, TargetFilename, Length); - Entry->TargetFilename[Length] = UNICODE_NULL; + RtlStringCchCopyW(Entry->TargetFileName, Length + 1, TargetFileName); } /* Append queue entry */ - if (QueueHeader->CopyHead == NULL) // && QueueHeader->CopyTail == NULL) + InsertTailList(&QueueHeader->CopyQueue, &Entry->ListEntry); + ++QueueHeader->CopyCount; + + return TRUE; +} + +BOOL +WINAPI +SetupQueueDeleteW( + IN HSPFILEQ QueueHandle, + IN PCWSTR PathPart1, + IN PCWSTR PathPart2 OPTIONAL) +{ + PFILEQUEUEHEADER QueueHeader; + PQUEUEENTRY Entry; + ULONG Length; + + if (QueueHandle == NULL || PathPart1 == NULL) { - Entry->Prev = NULL; - Entry->Next = NULL; - QueueHeader->CopyHead = Entry; - QueueHeader->CopyTail = Entry; + return FALSE; } - else + + QueueHeader = (PFILEQUEUEHEADER)QueueHandle; + + DPRINT1("SetupQueueDeleteW(PathPart1 '%S', PathPart2 '%S')\n", + PathPart1, PathPart2); + + /* Allocate new queue entry */ + Entry = RtlAllocateHeap(ProcessHeap, 0, sizeof(QUEUEENTRY)); + if (Entry == NULL) + return FALSE; + + RtlZeroMemory(Entry, sizeof(QUEUEENTRY)); + + Entry->SourceCabinet = NULL; + Entry->SourceRootPath = NULL; + Entry->SourcePath = NULL; + Entry->SourceFileName = NULL; + + /* Copy first part of path */ + Length = wcslen(PathPart1); + // if ((Length > 0) && (SourcePath[Length - 1] == L'\\')) + // Length--; + Entry->TargetDirectory = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); + if (Entry->TargetDirectory == NULL) { - Entry->Prev = QueueHeader->CopyTail; - Entry->Next = NULL; - QueueHeader->CopyTail->Next = Entry; - QueueHeader->CopyTail = Entry; + RtlFreeHeap(ProcessHeap, 0, Entry); + return FALSE; + } + RtlStringCchCopyW(Entry->TargetDirectory, Length + 1, PathPart1); + + /* Copy optional second part of path */ + if (PathPart2 != NULL) + { + Length = wcslen(PathPart2); + Entry->TargetFileName = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); + if (Entry->TargetFileName == NULL) + { + RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory); + RtlFreeHeap(ProcessHeap, 0, Entry); + return FALSE; + } + RtlStringCchCopyW(Entry->TargetFileName, Length + 1, PathPart2); } - QueueHeader->CopyCount++; + /* Append the queue entry */ + InsertTailList(&QueueHeader->DeleteQueue, &Entry->ListEntry); + ++QueueHeader->DeleteCount; return TRUE; } +BOOL +WINAPI +SetupQueueRenameW( + IN HSPFILEQ QueueHandle, + IN PCWSTR SourcePath, + IN PCWSTR SourceFileName OPTIONAL, + IN PCWSTR TargetPath OPTIONAL, + IN PCWSTR TargetFileName) +{ + PFILEQUEUEHEADER QueueHeader; + PQUEUEENTRY Entry; + ULONG Length; + + if (QueueHandle == NULL || + SourcePath == NULL || + TargetFileName == NULL) + { + return FALSE; + } + + QueueHeader = (PFILEQUEUEHEADER)QueueHandle; + + DPRINT1("SetupQueueRenameW(SrcPath '%S', SrcFN '%S' --> DstPath '%S', DstFN '%S')\n", + SourcePath, SourceFileName, TargetPath, TargetFileName); + + /* Allocate a new queue entry */ + Entry = RtlAllocateHeap(ProcessHeap, 0, sizeof(QUEUEENTRY)); + if (Entry == NULL) + return FALSE; + + RtlZeroMemory(Entry, sizeof(QUEUEENTRY)); + + Entry->SourceCabinet = NULL; + Entry->SourceRootPath = NULL; + + /* Copy source path */ + Length = wcslen(SourcePath); + if ((Length > 0) && (SourcePath[Length - 1] == L'\\')) + Length--; + Entry->SourcePath = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); + if (Entry->SourcePath == NULL) + { + RtlFreeHeap(ProcessHeap, 0, Entry); + return FALSE; + } + RtlStringCchCopyW(Entry->SourcePath, Length + 1, SourcePath); + + /* Copy optional source file name */ + Entry->SourceFileName = NULL; + if (SourceFileName != NULL) + { + Length = wcslen(SourceFileName); + Entry->SourceFileName = (WCHAR*)RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); + if (Entry->SourceFileName == NULL) + { + RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); + RtlFreeHeap(ProcessHeap, 0, Entry); + return FALSE; + } + RtlStringCchCopyW(Entry->SourceFileName, Length + 1, SourceFileName); + } + + /* Copy optional target directory */ + Entry->TargetDirectory = NULL; + if (TargetPath != NULL) + { + Length = wcslen(TargetPath); + if ((Length > 0) && (TargetPath[Length - 1] == L'\\')) + Length--; + Entry->TargetDirectory = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); + if (Entry->TargetDirectory == NULL) + { + if (Entry->SourceFileName != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourceFileName); + + RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); + RtlFreeHeap(ProcessHeap, 0, Entry); + return FALSE; + } + RtlStringCchCopyW(Entry->TargetDirectory, Length + 1, TargetPath); + } + + /* Copy target filename */ + Length = wcslen(TargetFileName); + Entry->TargetFileName = RtlAllocateHeap(ProcessHeap, + 0, + (Length + 1) * sizeof(WCHAR)); + if (Entry->TargetFileName == NULL) + { + if (Entry->TargetDirectory != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory); + + if (Entry->SourceFileName != NULL) + RtlFreeHeap(ProcessHeap, 0, Entry->SourceFileName); + + RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath); + RtlFreeHeap(ProcessHeap, 0, Entry); + return FALSE; + } + RtlStringCchCopyW(Entry->TargetFileName, Length + 1, TargetFileName); + + /* Append the queue entry */ + InsertTailList(&QueueHeader->RenameQueue, &Entry->ListEntry); + ++QueueHeader->RenameCount; + + return TRUE; +} BOOL WINAPI SetupCommitFileQueueW( - HWND Owner, - HSPFILEQ QueueHandle, - PSP_FILE_CALLBACK_W MsgHandler, - PVOID Context) + IN HWND Owner, + IN HSPFILEQ QueueHandle, + IN PSP_FILE_CALLBACK_W MsgHandler, + IN PVOID Context OPTIONAL) { - WCHAR CabinetName[MAX_PATH]; + BOOL Success = TRUE; // Suppose success + NTSTATUS Status; PFILEQUEUEHEADER QueueHeader; + PLIST_ENTRY ListEntry; PQUEUEENTRY Entry; - NTSTATUS Status; - PCWSTR TargetRootPath, TargetPath; - + FILEPATHS_W FilePathInfo; + WCHAR CabinetName[MAX_PATH]; WCHAR FileSrcPath[MAX_PATH]; WCHAR FileDstPath[MAX_PATH]; - TargetRootPath = ((PCOPYCONTEXT)Context)->DestinationRootPath; - TargetPath = ((PCOPYCONTEXT)Context)->InstallPath; - if (QueueHandle == NULL) return FALSE; @@ -455,74 +630,203 @@ SetupCommitFileQueueW( MsgHandler(Context, SPFILENOTIFY_STARTQUEUE, - 0, + (UINT_PTR)Owner, 0); + + /* + * Commit the delete queue + */ + MsgHandler(Context, SPFILENOTIFY_STARTSUBQUEUE, - FILEOP_COPY, - QueueHeader->CopyCount); + FILEOP_DELETE, + QueueHeader->DeleteCount); - /* Commit copy queue */ - Entry = QueueHeader->CopyHead; - while (Entry != NULL) + ListEntry = QueueHeader->DeleteQueue.Flink; + while (ListEntry != &QueueHeader->DeleteQueue) { - /* Build the full source path */ - CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 3, - Entry->SourceRootPath, Entry->SourcePath, - Entry->SourceFilename); + Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); + ListEntry = ListEntry->Flink; /* Build the full target path */ - wcscpy(FileDstPath, TargetRootPath); - if (Entry->TargetDirectory[0] == UNICODE_NULL) - { - /* Installation path */ + CombinePaths(FileDstPath, ARRAYSIZE(FileDstPath), 2, + Entry->TargetDirectory, Entry->TargetFileName); + // RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), Entry->TargetDirectory); + // ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFileName); - /* Add the installation path */ - ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, TargetPath); - } - else if (Entry->TargetDirectory[0] == L'\\') + DPRINT1(" -----> " "Delete: '%S'\n", FileDstPath); + + FilePathInfo.Target = FileDstPath; + FilePathInfo.Source = NULL; + FilePathInfo.Win32Error = STATUS_SUCCESS; + FilePathInfo.Flags = 0; // FIXME: Unused yet... + + MsgHandler(Context, + SPFILENOTIFY_STARTDELETE, + (UINT_PTR)&FilePathInfo, + FILEOP_DELETE); + + /* Force-delete the file */ + Status = SetupDeleteFile(FileDstPath, TRUE); + if (!NT_SUCCESS(Status)) { - /* Absolute path */ - if (Entry->TargetDirectory[1] != UNICODE_NULL) - ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetDirectory); + /* An error happened */ + FilePathInfo.Win32Error = (UINT)Status; + MsgHandler(Context, + SPFILENOTIFY_DELETEERROR, + (UINT_PTR)&FilePathInfo, + 0); + Success = FALSE; } - else // if (Entry->TargetDirectory[0] != L'\\') - { - /* Path relative to the installation path */ - /* Add the installation path */ - ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 2, - TargetPath, Entry->TargetDirectory); + /* This notification is always sent, even in case of error */ + FilePathInfo.Win32Error = (UINT)Status; + MsgHandler(Context, + SPFILENOTIFY_ENDDELETE, + (UINT_PTR)&FilePathInfo, + 0); + } + + MsgHandler(Context, + SPFILENOTIFY_ENDSUBQUEUE, + FILEOP_DELETE, + 0); + + + /* + * Commit the rename queue + */ + + MsgHandler(Context, + SPFILENOTIFY_STARTSUBQUEUE, + FILEOP_RENAME, + QueueHeader->RenameCount); + + ListEntry = QueueHeader->RenameQueue.Flink; + while (ListEntry != &QueueHeader->RenameQueue) + { + Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); + ListEntry = ListEntry->Flink; + + /* Build the full source path */ + CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 2, + Entry->SourcePath, Entry->SourceFileName); + + /* Build the full target path */ + CombinePaths(FileDstPath, ARRAYSIZE(FileDstPath), 2, + Entry->TargetDirectory, Entry->TargetFileName); + // RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), Entry->TargetDirectory); + // ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFileName); + + DPRINT1(" -----> " "Rename: '%S' ==> '%S'\n", FileSrcPath, FileDstPath); + + FilePathInfo.Target = FileDstPath; + FilePathInfo.Source = FileSrcPath; + FilePathInfo.Win32Error = STATUS_SUCCESS; + FilePathInfo.Flags = 0; // FIXME: Unused yet... + + MsgHandler(Context, + SPFILENOTIFY_STARTRENAME, + (UINT_PTR)&FilePathInfo, + FILEOP_RENAME); + + /* Move or rename the file */ + Status = SetupMoveFile(FileSrcPath, FileDstPath, + MOVEFILE_REPLACE_EXISTING + | MOVEFILE_COPY_ALLOWED + | MOVEFILE_WRITE_THROUGH); + if (!NT_SUCCESS(Status)) + { + /* An error happened */ + FilePathInfo.Win32Error = (UINT)Status; + MsgHandler(Context, + SPFILENOTIFY_RENAMEERROR, + (UINT_PTR)&FilePathInfo, + 0); + Success = FALSE; } + /* This notification is always sent, even in case of error */ + FilePathInfo.Win32Error = (UINT)Status; + MsgHandler(Context, + SPFILENOTIFY_ENDRENAME, + (UINT_PTR)&FilePathInfo, + 0); + } + + MsgHandler(Context, + SPFILENOTIFY_ENDSUBQUEUE, + FILEOP_RENAME, + 0); + + + /* + * Commit the copy queue + */ + + MsgHandler(Context, + SPFILENOTIFY_STARTSUBQUEUE, + FILEOP_COPY, + QueueHeader->CopyCount); + + ListEntry = QueueHeader->CopyQueue.Flink; + while (ListEntry != &QueueHeader->CopyQueue) + { + Entry = CONTAINING_RECORD(ListEntry, QUEUEENTRY, ListEntry); + ListEntry = ListEntry->Flink; + + /* Build the full source path */ + CombinePaths(FileSrcPath, ARRAYSIZE(FileSrcPath), 3, + Entry->SourceRootPath, Entry->SourcePath, + Entry->SourceFileName); + + /* Build the full target path */ + RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), Entry->TargetDirectory); + /* * If the file is in a cabinet, use only the destination path. * Otherwise possibly use a different target name. */ if (Entry->SourceCabinet == NULL) { - if (Entry->TargetFilename != NULL) - ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFilename); + if (Entry->TargetFileName != NULL) + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->TargetFileName); else - ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->SourceFilename); + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, Entry->SourceFileName); } - /* FIXME: Do it! */ - DPRINT("Copy: '%S' ==> '%S'\n", FileSrcPath, FileDstPath); + DPRINT(" -----> " "Copy: '%S' ==> '%S'\n", FileSrcPath, FileDstPath); + + // + // Technically, here we should create the target directory, + // if it does not already exist... before calling the handler! + // + + FilePathInfo.Target = FileDstPath; + FilePathInfo.Source = FileSrcPath; // when SourceCabinet not NULL, use CabinetName ... + FilePathInfo.Win32Error = STATUS_SUCCESS; + FilePathInfo.Flags = 0; // FIXME: Unused yet... MsgHandler(Context, SPFILENOTIFY_STARTCOPY, - (UINT_PTR)Entry->SourceFilename, + (UINT_PTR)&FilePathInfo, FILEOP_COPY); if (Entry->SourceCabinet != NULL) { - /* Extract the file */ + /* + * Extract the file from the cabinet. + * The cabinet must be in Entry->SourceRootPath only! + * (ignore Entry->SourcePath). + */ CombinePaths(CabinetName, ARRAYSIZE(CabinetName), 3, Entry->SourceRootPath, Entry->SourcePath, Entry->SourceCabinet); - Status = SetupExtractFile(CabinetName, Entry->SourceFilename, FileDstPath); + Status = SetupExtractFile(QueueHeader, + CabinetName, + Entry->SourceFileName, + FileDstPath); } else { @@ -532,20 +836,21 @@ SetupCommitFileQueueW( if (!NT_SUCCESS(Status)) { + /* An error happened */ + FilePathInfo.Win32Error = (UINT)Status; MsgHandler(Context, SPFILENOTIFY_COPYERROR, - (UINT_PTR)Entry->SourceFilename, - FILEOP_COPY); - } - else - { - MsgHandler(Context, - SPFILENOTIFY_ENDCOPY, - (UINT_PTR)Entry->SourceFilename, - FILEOP_COPY); + (UINT_PTR)&FilePathInfo, + (UINT_PTR)NULL); // FIXME: Unused yet... + Success = FALSE; } - Entry = Entry->Next; + /* This notification is always sent, even in case of error */ + FilePathInfo.Win32Error = (UINT)Status; + MsgHandler(Context, + SPFILENOTIFY_ENDCOPY, + (UINT_PTR)&FilePathInfo, + 0); } MsgHandler(Context, @@ -553,12 +858,14 @@ SetupCommitFileQueueW( FILEOP_COPY, 0); + + /* All the queues have been committed */ MsgHandler(Context, SPFILENOTIFY_ENDQUEUE, - 0, + (UINT_PTR)Success, 0); - return TRUE; + return Success; } /* EOF */ diff --git a/base/setup/usetup/filequeue.h b/base/setup/usetup/filequeue.h index 1623440035..cf608377e1 100644 --- a/base/setup/usetup/filequeue.h +++ b/base/setup/usetup/filequeue.h @@ -26,55 +26,59 @@ #pragma once -#define SPFILENOTIFY_STARTQUEUE 0x1 -#define SPFILENOTIFY_ENDQUEUE 0x2 -#define SPFILENOTIFY_STARTSUBQUEUE 0x3 -#define SPFILENOTIFY_ENDSUBQUEUE 0x4 +#define SPFILENOTIFY_STARTQUEUE 0x00000001 +#define SPFILENOTIFY_ENDQUEUE 0x00000002 +#define SPFILENOTIFY_STARTSUBQUEUE 0x00000003 +#define SPFILENOTIFY_ENDSUBQUEUE 0x00000004 -#define SPFILENOTIFY_STARTCOPY 0xb -#define SPFILENOTIFY_ENDCOPY 0xc -#define SPFILENOTIFY_COPYERROR 0xd +#define SPFILENOTIFY_STARTDELETE 0x00000005 +#define SPFILENOTIFY_ENDDELETE 0x00000006 +#define SPFILENOTIFY_DELETEERROR 0x00000007 -#define FILEOP_COPY 0x0 -#define FILEOP_RENAME 0x1 -#define FILEOP_DELETE 0x2 -#define FILEOP_BACKUP 0x3 +#define SPFILENOTIFY_STARTRENAME 0x00000008 +#define SPFILENOTIFY_ENDRENAME 0x00000009 +#define SPFILENOTIFY_RENAMEERROR 0x0000000a -#define FILEOP_ABORT 0x0 -#define FILEOP_DOIT 0x1 -#define FILEOP_SKIP 0x2 -#define FILEOP_RETRY FILEOP_DOIT -#define FILEOP_NEWPATH 0x4 +#define SPFILENOTIFY_STARTCOPY 0x0000000b +#define SPFILENOTIFY_ENDCOPY 0x0000000c +#define SPFILENOTIFY_COPYERROR 0x0000000d + +#define SPFILENOTIFY_NEEDMEDIA 0x0000000e +#define SPFILENOTIFY_QUEUESCAN 0x0000000f + +#define FILEOP_COPY 0 +#define FILEOP_RENAME 1 +#define FILEOP_DELETE 2 +#define FILEOP_BACKUP 3 + +#define FILEOP_ABORT 0 +#define FILEOP_DOIT 1 +#define FILEOP_SKIP 2 +#define FILEOP_RETRY FILEOP_DOIT +#define FILEOP_NEWPATH 4 /* TYPES ********************************************************************/ typedef PVOID HSPFILEQ; +typedef struct _FILEPATHS_W +{ + PCWSTR Target; + PCWSTR Source; + UINT Win32Error; + ULONG Flags; +} FILEPATHS_W, *PFILEPATHS_W; + typedef UINT (CALLBACK* PSP_FILE_CALLBACK_W)( - PVOID Context, - UINT Notification, - UINT_PTR Param1, - UINT_PTR Param2); + IN PVOID Context, + IN UINT Notification, + IN UINT_PTR Param1, + IN UINT_PTR Param2); -typedef struct _COPYCONTEXT -{ - LPCWSTR DestinationRootPath; /* Not owned by this structure */ - LPCWSTR InstallPath; /* Not owned by this structure */ - ULONG TotalOperations; - ULONG CompletedOperations; - PPROGRESSBAR ProgressBar; - PPROGRESSBAR MemoryBars[4]; -} COPYCONTEXT, *PCOPYCONTEXT; /* FUNCTIONS ****************************************************************/ -NTSTATUS -SetupExtractFile( - PWCHAR CabinetFileName, - PWCHAR SourceFileName, - PWCHAR DestinationFileName); - HSPFILEQ WINAPI SetupOpenFileQueue(VOID); @@ -99,22 +103,40 @@ SetupQueueCopyWNew( IN DWORD CopyStyle); #endif +/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */ +BOOL +WINAPI +SetupQueueCopyWithCab( // SetupQueueCopyW + IN HSPFILEQ QueueHandle, + IN PCWSTR SourceCabinet OPTIONAL, + IN PCWSTR SourceRootPath, + IN PCWSTR SourcePath OPTIONAL, + IN PCWSTR SourceFileName, + IN PCWSTR TargetDirectory, + IN PCWSTR TargetFileName OPTIONAL); + BOOL -SetupQueueCopy( - HSPFILEQ QueueHandle, - PCWSTR SourceCabinet, - PCWSTR SourceRootPath, - PCWSTR SourcePath, - PCWSTR SourceFilename, - PCWSTR TargetDirectory, - PCWSTR TargetFilename); +WINAPI +SetupQueueDeleteW( + IN HSPFILEQ QueueHandle, + IN PCWSTR PathPart1, + IN PCWSTR PathPart2 OPTIONAL); + +BOOL +WINAPI +SetupQueueRenameW( + IN HSPFILEQ QueueHandle, + IN PCWSTR SourcePath, + IN PCWSTR SourceFileName OPTIONAL, + IN PCWSTR TargetPath OPTIONAL, + IN PCWSTR TargetFileName); BOOL WINAPI SetupCommitFileQueueW( - HWND Owner, - HSPFILEQ QueueHandle, - PSP_FILE_CALLBACK_W MsgHandler, - PVOID Context); + IN HWND Owner, + IN HSPFILEQ QueueHandle, + IN PSP_FILE_CALLBACK_W MsgHandler, + IN PVOID Context OPTIONAL); /* EOF */ diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index edd98fd654..929a4dca9a 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -71,6 +71,8 @@ static PGENERIC_LIST NtOsInstallsList = NULL; // HACK: Temporary compatibility code. #if 1 + #define SetupQueueCopy SetupQueueCopyWithCab + static CABINET_CONTEXT CabinetContext; #define CabinetInitialize() (CabinetInitialize(&CabinetContext)) #define CabinetSetEventHandlers(a,b,c) (CabinetSetEventHandlers(&CabinetContext,(a),(b),(c))) @@ -3494,6 +3496,7 @@ AddSectionToCopyQueueCab(HINF InfFile, PWCHAR FileKeyValue; PWCHAR DirKeyValue; PWCHAR TargetFileName; + WCHAR FileDstPath[MAX_PATH]; /* * This code enumerates the list of files in reactos.dff / reactos.inf @@ -3549,12 +3552,46 @@ AddSectionToCopyQueueCab(HINF InfFile, break; } +#if 1 // HACK moved! (r66604) + { + ULONG Length = wcslen(DirKeyValue); + if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\')) + Length--; + DirKeyValue[Length] = UNICODE_NULL; + } + + /* Build the full target path */ + RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), + USetupData.DestinationRootPath.Buffer); + if (DirKeyValue[0] == UNICODE_NULL) + { + /* Installation path */ + + /* Add the installation path */ + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, USetupData.InstallPath.Buffer); + } + else if (DirKeyValue[0] == L'\\') + { + /* Absolute path */ + // if (DirKeyValue[1] != UNICODE_NULL) + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, DirKeyValue); + } + else // if (DirKeyValue[0] != L'\\') + { + /* Path relative to the installation path */ + + /* Add the installation path */ + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 2, + USetupData.InstallPath.Buffer, DirKeyValue); + } +#endif + if (!SetupQueueCopy(USetupData.SetupFileQueue, SourceCabinet, USetupData.SourceRootPath.Buffer, USetupData.SourceRootDir.Buffer, FileKeyName, - DirKeyValue, + FileDstPath, TargetFileName)) { /* FIXME: Handle error! */ @@ -3584,6 +3621,7 @@ AddSectionToCopyQueue(HINF InfFile, PWCHAR DirKeyValue; PWCHAR TargetFileName; WCHAR CompleteOrigDirName[512]; // FIXME: MAX_PATH is not enough? + WCHAR FileDstPath[MAX_PATH]; if (SourceCabinet) return AddSectionToCopyQueueCab(InfFile, L"SourceFiles", SourceCabinet, DestinationPath, Ir); @@ -3683,12 +3721,46 @@ AddSectionToCopyQueue(HINF InfFile, DPRINT("RelativePath(2): '%S'\n", CompleteOrigDirName); } +#if 1 // HACK moved! (r66604) + { + ULONG Length = wcslen(DirKeyValue); + if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\')) + Length--; + DirKeyValue[Length] = UNICODE_NULL; + } + + /* Build the full target path */ + RtlStringCchCopyW(FileDstPath, ARRAYSIZE(FileDstPath), + USetupData.DestinationRootPath.Buffer); + if (DirKeyValue[0] == UNICODE_NULL) + { + /* Installation path */ + + /* Add the installation path */ + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, USetupData.InstallPath.Buffer); + } + else if (DirKeyValue[0] == L'\\') + { + /* Absolute path */ + // if (DirKeyValue[1] != UNICODE_NULL) + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 1, DirKeyValue); + } + else // if (DirKeyValue[0] != L'\\') + { + /* Path relative to the installation path */ + + /* Add the installation path */ + ConcatPaths(FileDstPath, ARRAYSIZE(FileDstPath), 2, + USetupData.InstallPath.Buffer, DirKeyValue); + } +#endif + if (!SetupQueueCopy(USetupData.SetupFileQueue, SourceCabinet, USetupData.SourceRootPath.Buffer, CompleteOrigDirName, FileKeyName, - DirKeyValue, + FileDstPath, TargetFileName)) { /* FIXME: Handle error! */ @@ -3938,9 +4010,15 @@ PrepareCopyPage(PINPUT_RECORD Ir) return FILE_COPY_PAGE; } +typedef struct _COPYCONTEXT +{ + ULONG TotalOperations; + ULONG CompletedOperations; + PPROGRESSBAR ProgressBar; + PPROGRESSBAR MemoryBars[4]; +} COPYCONTEXT, *PCOPYCONTEXT; -VOID -NTAPI +static VOID SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext, IN BOOLEAN First) { @@ -3967,7 +4045,6 @@ SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext, ProgressSetStep(CopyContext->MemoryBars[2], PerfInfo.AvailablePages); } - static UINT CALLBACK FileCopyCallback(PVOID Context, @@ -3975,26 +4052,78 @@ FileCopyCallback(PVOID Context, UINT_PTR Param1, UINT_PTR Param2) { - PCOPYCONTEXT CopyContext; - - CopyContext = (PCOPYCONTEXT)Context; + PCOPYCONTEXT CopyContext = (PCOPYCONTEXT)Context; + PFILEPATHS_W FilePathInfo; + PCWSTR SrcFileName, DstFileName; switch (Notification) { case SPFILENOTIFY_STARTSUBQUEUE: + { CopyContext->TotalOperations = (ULONG)Param2; + CopyContext->CompletedOperations = 0; ProgressSetStepCount(CopyContext->ProgressBar, CopyContext->TotalOperations); SetupUpdateMemoryInfo(CopyContext, TRUE); break; + } + case SPFILENOTIFY_STARTDELETE: + case SPFILENOTIFY_STARTRENAME: case SPFILENOTIFY_STARTCOPY: - /* Display copy message */ - CONSOLE_SetStatusText(MUIGetString(STRING_COPYING), (PWSTR)Param1); + { + FilePathInfo = (PFILEPATHS_W)Param1; + + if (Notification == SPFILENOTIFY_STARTDELETE) + { + /* Display delete message */ + ASSERT(Param2 == FILEOP_DELETE); + + DstFileName = wcsrchr(FilePathInfo->Target, L'\\'); + if (DstFileName) ++DstFileName; + else DstFileName = FilePathInfo->Target; + + CONSOLE_SetStatusText(MUIGetString(STRING_DELETING), + DstFileName); + } + else if (Notification == SPFILENOTIFY_STARTRENAME) + { + /* Display move/rename message */ + ASSERT(Param2 == FILEOP_RENAME); + + SrcFileName = wcsrchr(FilePathInfo->Source, L'\\'); + if (SrcFileName) ++SrcFileName; + else SrcFileName = FilePathInfo->Source; + + DstFileName = wcsrchr(FilePathInfo->Target, L'\\'); + if (DstFileName) ++DstFileName; + else DstFileName = FilePathInfo->Target; + + // TODO: Determine whether using STRING_RENAMING or STRING_MOVING + CONSOLE_SetStatusText(MUIGetString(STRING_MOVING), + SrcFileName, DstFileName); + } + else if (Notification == SPFILENOTIFY_STARTCOPY) + { + /* Display copy message */ + ASSERT(Param2 == FILEOP_COPY); + + SrcFileName = wcsrchr(FilePathInfo->Source, L'\\'); + if (SrcFileName) ++SrcFileName; + else SrcFileName = FilePathInfo->Source; + + CONSOLE_SetStatusText(MUIGetString(STRING_COPYING), + SrcFileName); + } + SetupUpdateMemoryInfo(CopyContext, FALSE); break; + } + case SPFILENOTIFY_ENDDELETE: + case SPFILENOTIFY_ENDRENAME: case SPFILENOTIFY_ENDCOPY: + { CopyContext->CompletedOperations++; /* SYSREG checkpoint */ @@ -4004,9 +4133,10 @@ FileCopyCallback(PVOID Context, ProgressNextStep(CopyContext->ProgressBar); SetupUpdateMemoryInfo(CopyContext, FALSE); break; + } } - return 0; + return FILEOP_DOIT; } @@ -4027,13 +4157,11 @@ static PAGE_NUMBER FileCopyPage(PINPUT_RECORD Ir) { COPYCONTEXT CopyContext; - unsigned int mem_bar_width; + UINT MemBarWidth; MUIDisplayPage(FILE_COPY_PAGE); /* Create context for the copy process */ - CopyContext.DestinationRootPath = USetupData.DestinationRootPath.Buffer; - CopyContext.InstallPath = USetupData.InstallPath.Buffer; CopyContext.TotalOperations = 0; CopyContext.CompletedOperations = 0; @@ -4048,13 +4176,13 @@ FileCopyPage(PINPUT_RECORD Ir) MUIGetString(STRING_SETUPCOPYINGFILES)); // fit memory bars to screen width, distribute them uniform - mem_bar_width = (xScreen - 26) / 5; - mem_bar_width -= mem_bar_width % 2; // make even + MemBarWidth = (xScreen - 26) / 5; + MemBarWidth -= MemBarWidth % 2; // make even /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */ /* Create the paged pool progress bar */ CopyContext.MemoryBars[0] = CreateProgressBar(13, 40, - 13 + mem_bar_width, + 13 + MemBarWidth, 43, 13, 44, @@ -4062,21 +4190,21 @@ FileCopyPage(PINPUT_RECORD Ir) "Kernel Pool"); /* Create the non paged pool progress bar */ - CopyContext.MemoryBars[1] = CreateProgressBar((xScreen / 2)- (mem_bar_width / 2), + CopyContext.MemoryBars[1] = CreateProgressBar((xScreen / 2)- (MemBarWidth / 2), 40, - (xScreen / 2) + (mem_bar_width / 2), + (xScreen / 2) + (MemBarWidth / 2), 43, - (xScreen / 2)- (mem_bar_width / 2), + (xScreen / 2)- (MemBarWidth / 2), 44, FALSE, "Kernel Cache"); /* Create the global memory progress bar */ - CopyContext.MemoryBars[2] = CreateProgressBar(xScreen - 13 - mem_bar_width, + CopyContext.MemoryBars[2] = CreateProgressBar(xScreen - 13 - MemBarWidth, 40, xScreen - 13, 43, - xScreen - 13 - mem_bar_width, + xScreen - 13 - MemBarWidth, 44, FALSE, "Free Memory");
6 years, 1 month
1
0
0
0
01/01: [UMPNPMGR] Implement PNP_DetectResourceConflict().
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ce15c8430970d9b0fcee9…
commit ce15c8430970d9b0fcee9cc664d2944c33da803e Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Thu Nov 1 14:50:08 2018 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Thu Nov 1 14:50:08 2018 +0100 [UMPNPMGR] Implement PNP_DetectResourceConflict(). --- base/services/umpnpmgr/umpnpmgr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c index 0a00d40325..486b1ad82d 100644 --- a/base/services/umpnpmgr/umpnpmgr.c +++ b/base/services/umpnpmgr/umpnpmgr.c @@ -2746,7 +2746,11 @@ PNP_DetectResourceConflict( BOOL *pbConflictDetected, DWORD ulFlags) { - UNIMPLEMENTED; + DPRINT("PNP_DetectResourceConflict()\n"); + + if (pbConflictDetected != NULL) + *pbConflictDetected = FALSE; + return CR_CALL_NOT_IMPLEMENTED; }
6 years, 1 month
1
0
0
0
← Newer
1
...
22
23
24
25
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Results per page:
10
25
50
100
200