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
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
March 2022
----- 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
20 participants
436 discussions
Start a n
N
ew thread
[reactos] 61/360: [WINESYNC] msi: Avoid using awstring in MsiGetPropertyA/W().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4748b312842a54ea5fcec…
commit 4748b312842a54ea5fcec293d26aeaebe6a30b61 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:16 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:45 2022 +0100 [WINESYNC] msi: Avoid using awstring in MsiGetPropertyA/W(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 389ad808d2ac1a443d4a4190928e665b25214c1a by Zebediah Figura <z.figura12(a)gmail.com> --- dll/win32/msi/package.c | 109 +++++++++++++------------------- modules/rostests/winetests/msi/custom.c | 6 ++ 2 files changed, 51 insertions(+), 64 deletions(-) diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c index c112b6fae2c..c3bc9dcde62 100644 --- a/dll/win32/msi/package.c +++ b/dll/win32/msi/package.c @@ -2352,84 +2352,76 @@ int msi_get_property_int( MSIDATABASE *db, LPCWSTR prop, int def ) return val; } -static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name, - awstring *szValueBuf, LPDWORD pchValueBuf ) +UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz) { + const WCHAR *value = szEmpty; MSIPACKAGE *package; - MSIRECORD *row = NULL; - UINT r = ERROR_FUNCTION_FAILED; - LPCWSTR val = NULL; - DWORD len = 0; - - TRACE("%u %s %p %p\n", handle, debugstr_w(name), - szValueBuf->str.w, pchValueBuf ); + MSIRECORD *row; + WCHAR *nameW; + int len = 0; + UINT r; if (!name) return ERROR_INVALID_PARAMETER; - package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE ); + if (!(nameW = strdupAtoW(name))) + return ERROR_OUTOFMEMORY; + + package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE); if (!package) { - LPWSTR value = NULL, buffer; + WCHAR *value = NULL, *tmp; MSIHANDLE remote; + DWORD len; - if (!(remote = msi_get_remote(handle))) + if (!(remote = msi_get_remote(hinst))) return ERROR_INVALID_HANDLE; - r = remote_GetProperty(remote, name, &value, &len); - if (r != ERROR_SUCCESS) - return r; - - /* String might contain embedded nulls. - * Native returns the correct size but truncates the string. */ - buffer = heap_alloc_zero((len + 1) * sizeof(WCHAR)); - if (!buffer) + r = remote_GetProperty(remote, nameW, &value, &len); + if (!r) { - midl_user_free(value); - return ERROR_OUTOFMEMORY; - } - strcpyW(buffer, value); - - r = msi_strcpy_to_awstring(buffer, len, szValueBuf, pchValueBuf); + /* String might contain embedded nulls. + * Native returns the correct size but truncates the string. */ + tmp = heap_alloc_zero((len + 1) * sizeof(WCHAR)); + if (!tmp) + { + midl_user_free(value); + return ERROR_OUTOFMEMORY; + } + strcpyW(tmp, value); - /* Bug required by Adobe installers */ - if (pchValueBuf && !szValueBuf->unicode && !szValueBuf->str.a) - *pchValueBuf *= sizeof(WCHAR); + r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE); - heap_free(buffer); + heap_free(tmp); + } midl_user_free(value); + heap_free(nameW); return r; } - row = msi_get_property_row( package->db, name ); + row = msi_get_property_row(package->db, nameW); if (row) - val = msi_record_get_string( row, 1, (int *)&len ); - - if (!val) - val = szEmpty; + value = msi_record_get_string(row, 1, &len); - r = msi_strcpy_to_awstring( val, len, szValueBuf, pchValueBuf ); - - if (row) - msiobj_release( &row->hdr ); - msiobj_release( &package->hdr ); + r = msi_strncpyWtoA(value, len, buf, sz, FALSE); + heap_free(nameW); + if (row) msiobj_release(&row->hdr); + msiobj_release(&package->hdr); return r; } -UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz) +UINT WINAPI MsiGetPropertyW(MSIHANDLE hinst, const WCHAR *name, WCHAR *buf, DWORD *sz) { + const WCHAR *value = szEmpty; MSIPACKAGE *package; - awstring val; - WCHAR *nameW; + MSIRECORD *row; + int len = 0; UINT r; if (!name) return ERROR_INVALID_PARAMETER; - if (!(nameW = strdupAtoW(name))) - return ERROR_OUTOFMEMORY; - package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE); if (!package) { @@ -2440,7 +2432,7 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD if (!(remote = msi_get_remote(hinst))) return ERROR_INVALID_HANDLE; - r = remote_GetProperty(remote, nameW, &value, &len); + r = remote_GetProperty(remote, name, &value, &len); if (!r) { /* String might contain embedded nulls. @@ -2453,36 +2445,25 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD } strcpyW(tmp, value); - r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE); + r = msi_strncpyW(tmp, len, buf, sz); heap_free(tmp); } midl_user_free(value); - heap_free(nameW); return r; } - val.unicode = FALSE; - val.str.a = buf; + row = msi_get_property_row(package->db, name); + if (row) + value = msi_record_get_string(row, 1, &len); - r = MSI_GetProperty(hinst, nameW, &val, sz); + r = msi_strncpyW(value, len, buf, sz); - heap_free(nameW); + if (row) msiobj_release(&row->hdr); msiobj_release(&package->hdr); return r; } -UINT WINAPI MsiGetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, - LPWSTR szValueBuf, LPDWORD pchValueBuf ) -{ - awstring val; - - val.unicode = TRUE; - val.str.w = szValueBuf; - - return MSI_GetProperty( hInstall, szName, &val, pchValueBuf ); -} - MSIHANDLE __cdecl s_remote_GetActiveDatabase(MSIHANDLE hinst) { return MsiGetActiveDatabase(hinst); diff --git a/modules/rostests/winetests/msi/custom.c b/modules/rostests/winetests/msi/custom.c index 96344ebc6eb..d240964aae7 100644 --- a/modules/rostests/winetests/msi/custom.c +++ b/modules/rostests/winetests/msi/custom.c @@ -191,6 +191,12 @@ static void test_props(MSIHANDLE hinst) ok(hinst, !strcmp(buffer, "xyz"), "got \"%s\"\n", buffer); ok(hinst, sz == 3, "got size %u\n", sz); + r = MsiGetPropertyW(hinst, booW, NULL, NULL); + ok(hinst, !r, "got %u\n", r); + + r = MsiGetPropertyW(hinst, booW, bufferW, NULL ); + ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r); + sz = 0; r = MsiGetPropertyW(hinst, booW, NULL, &sz); ok(hinst, !r, "got %u\n", r);
2 years, 7 months
1
0
0
0
[reactos] 60/360: [WINESYNC] msi: Handle the remote case directly in MsiGetPropertyA().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e12fb5036ccaec21f4781…
commit e12fb5036ccaec21f47818159b1b2f5dae7f42e7 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:16 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:45 2022 +0100 [WINESYNC] msi: Handle the remote case directly in MsiGetPropertyA(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 84d972010fcf7bc94534c7bb20890ce88381f943 by Zebediah Figura <z.figura12(a)gmail.com> --- dll/win32/msi/package.c | 54 +++++++++++++++++++++++++++------ modules/rostests/winetests/msi/custom.c | 6 ++-- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c index 58943536b46..c112b6fae2c 100644 --- a/dll/win32/msi/package.c +++ b/dll/win32/msi/package.c @@ -2417,22 +2417,58 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name, return r; } -UINT WINAPI MsiGetPropertyA( MSIHANDLE hInstall, LPCSTR szName, - LPSTR szValueBuf, LPDWORD pchValueBuf ) +UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz) { + MSIPACKAGE *package; awstring val; - LPWSTR name; + WCHAR *nameW; UINT r; - val.unicode = FALSE; - val.str.a = szValueBuf; + if (!name) + return ERROR_INVALID_PARAMETER; - name = strdupAtoW( szName ); - if (szName && !name) + if (!(nameW = strdupAtoW(name))) return ERROR_OUTOFMEMORY; - r = MSI_GetProperty( hInstall, name, &val, pchValueBuf ); - msi_free( name ); + package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE); + if (!package) + { + WCHAR *value = NULL, *tmp; + MSIHANDLE remote; + DWORD len; + + if (!(remote = msi_get_remote(hinst))) + return ERROR_INVALID_HANDLE; + + r = remote_GetProperty(remote, nameW, &value, &len); + if (!r) + { + /* String might contain embedded nulls. + * Native returns the correct size but truncates the string. */ + tmp = heap_alloc_zero((len + 1) * sizeof(WCHAR)); + if (!tmp) + { + midl_user_free(value); + return ERROR_OUTOFMEMORY; + } + strcpyW(tmp, value); + + r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE); + + heap_free(tmp); + } + midl_user_free(value); + heap_free(nameW); + return r; + } + + val.unicode = FALSE; + val.str.a = buf; + + r = MSI_GetProperty(hinst, nameW, &val, sz); + + heap_free(nameW); + msiobj_release(&package->hdr); return r; } diff --git a/modules/rostests/winetests/msi/custom.c b/modules/rostests/winetests/msi/custom.c index 723b2b5deba..96344ebc6eb 100644 --- a/modules/rostests/winetests/msi/custom.c +++ b/modules/rostests/winetests/msi/custom.c @@ -168,21 +168,21 @@ static void test_props(MSIHANDLE hinst) r = MsiGetPropertyA(hinst, "boo", buffer, &sz); ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r); ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n", buffer); - todo_wine_ok(hinst, sz == 6, "got size %u\n", sz); + ok(hinst, sz == 6, "got size %u\n", sz); sz = 1; strcpy(buffer,"x"); r = MsiGetPropertyA(hinst, "boo", buffer, &sz); ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r); ok(hinst, !buffer[0], "got \"%s\"\n", buffer); - todo_wine_ok(hinst, sz == 6, "got size %u\n", sz); + ok(hinst, sz == 6, "got size %u\n", sz); sz = 3; strcpy(buffer,"x"); r = MsiGetPropertyA(hinst, "boo", buffer, &sz); ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r); ok(hinst, !strcmp(buffer, "xy"), "got \"%s\"\n", buffer); - todo_wine_ok(hinst, sz == 6, "got size %u\n", sz); + ok(hinst, sz == 6, "got size %u\n", sz); sz = 4; strcpy(buffer,"x");
2 years, 7 months
1
0
0
0
[reactos] 59/360: [WINESYNC] msi: Avoid using awstring in MsiFormatRecordW().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0b125236c6cb7c8ec7a6d…
commit 0b125236c6cb7c8ec7a6d8ea926647c997967931 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:15 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:45 2022 +0100 [WINESYNC] msi: Avoid using awstring in MsiFormatRecordW(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 6b54a4bc2eadd0b5cbc2553e2969ff572ff042d1 by Zebediah Figura <z.figura12(a)gmail.com> --- dll/win32/msi/format.c | 12 +++--------- dll/win32/msi/install.c | 19 +++++++++++++++++++ dll/win32/msi/msipriv.h | 1 + modules/rostests/winetests/msi/custom.c | 11 +++++++++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/dll/win32/msi/format.c b/dll/win32/msi/format.c index 98ee320ce59..6165f0a5dfd 100644 --- a/dll/win32/msi/format.c +++ b/dll/win32/msi/format.c @@ -916,22 +916,16 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE hRecord, { LPWSTR value = NULL; MSIHANDLE remote; - awstring wstr; if ((remote = msi_get_remote(hInstall))) { r = remote_FormatRecord(remote, (struct wire_record *)&record->count, &value); - if (r) - { - midl_user_free(value); - return r; - } - wstr.unicode = TRUE; - wstr.str.w = szResult; - r = msi_strcpy_to_awstring(value, -1, &wstr, sz); + if (!r) + r = msi_strncpyW(value, -1, szResult, sz); midl_user_free(value); + msiobj_release(&record->hdr); return r; } } diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c index 9ade59804d7..7271763f428 100644 --- a/dll/win32/msi/install.c +++ b/dll/win32/msi/install.c @@ -191,6 +191,25 @@ UINT msi_strncpyWtoA(const WCHAR *str, int lenW, char *buf, DWORD *sz, BOOL remo return r; } +UINT msi_strncpyW(const WCHAR *str, int len, WCHAR *buf, DWORD *sz) +{ + UINT r = ERROR_SUCCESS; + + if (!sz) + return buf ? ERROR_INVALID_PARAMETER : ERROR_SUCCESS; + + if (len < 0) len = strlenW(str); + if (buf) + memcpy(buf, str, min(len + 1, *sz) * sizeof(WCHAR)); + if (buf && len >= *sz) + { + if (*sz) buf[*sz - 1] = 0; + r = ERROR_MORE_DATA; + } + *sz = len; + return r; +} + const WCHAR *msi_get_target_folder( MSIPACKAGE *package, const WCHAR *name ) { MSIFOLDER *folder = msi_get_loaded_folder( package, name ); diff --git a/dll/win32/msi/msipriv.h b/dll/win32/msi/msipriv.h index a8140bb8cdf..95f46d070a6 100644 --- a/dll/win32/msi/msipriv.h +++ b/dll/win32/msi/msipriv.h @@ -1047,6 +1047,7 @@ extern WCHAR **msi_split_string(const WCHAR *, WCHAR) DECLSPEC_HIDDEN; extern UINT msi_set_original_database_property(MSIDATABASE *, const WCHAR *) DECLSPEC_HIDDEN; extern WCHAR *msi_get_error_message(MSIDATABASE *, int) DECLSPEC_HIDDEN; extern UINT msi_strncpyWtoA(const WCHAR *str, int len, char *buf, DWORD *sz, BOOL remote) DECLSPEC_HIDDEN; +extern UINT msi_strncpyW(const WCHAR *str, int len, WCHAR *buf, DWORD *sz) DECLSPEC_HIDDEN; /* media */ diff --git a/modules/rostests/winetests/msi/custom.c b/modules/rostests/winetests/msi/custom.c index 320aa6f30e5..723b2b5deba 100644 --- a/modules/rostests/winetests/msi/custom.c +++ b/modules/rostests/winetests/msi/custom.c @@ -815,6 +815,17 @@ static void test_format_record(MSIHANDLE hinst) ok(hinst, !strcmp(buffer, "foo 123"), "got \"%s\"\n", buffer); ok(hinst, sz == 7, "got size %u\n", sz); + r = MsiFormatRecordW(hinst, rec, NULL, NULL); + ok(hinst, !r, "got %u\n", r); + + r = MsiFormatRecordW(hinst, rec, bufferW, NULL); + ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r); + + sz = 0; + r = MsiFormatRecordW(hinst, rec, NULL, &sz); + ok(hinst, !r, "got %u\n", r); + ok(hinst, sz == 7, "got size %u\n", sz); + sz = 0; bufferW[0] = 'q'; r = MsiFormatRecordW(hinst, rec, bufferW, &sz);
2 years, 7 months
1
0
0
0
[reactos] 58/360: [WINESYNC] msi: Handle the remote case directly in MsiFormatRecordA().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d5e04177e7301aeb51e34…
commit d5e04177e7301aeb51e34694be93b3fa75824951 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:15 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:45 2022 +0100 [WINESYNC] msi: Handle the remote case directly in MsiFormatRecordA(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 75aa132b521f426fa670c05774a50c87247e9834 by Zebediah Figura <z.figura12(a)gmail.com> --- dll/win32/msi/format.c | 59 +++++++++++++++++---------------- dll/win32/msi/install.c | 23 +++++++++++++ dll/win32/msi/msipriv.h | 1 + modules/rostests/winetests/msi/custom.c | 8 ++--- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/dll/win32/msi/format.c b/dll/win32/msi/format.c index 6f187581516..98ee320ce59 100644 --- a/dll/win32/msi/format.c +++ b/dll/win32/msi/format.c @@ -952,52 +952,55 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE hRecord, return r; } -UINT WINAPI MsiFormatRecordA( MSIHANDLE hInstall, MSIHANDLE hRecord, - LPSTR szResult, LPDWORD sz ) +UINT WINAPI MsiFormatRecordA(MSIHANDLE hinst, MSIHANDLE hrec, char *buf, DWORD *sz) { - UINT r; - DWORD len, save; + MSIPACKAGE *package; + MSIRECORD *rec; LPWSTR value; + DWORD len; + UINT r; - TRACE("%d %d %p %p\n", hInstall, hRecord, szResult, sz); + TRACE("%d %d %p %p\n", hinst, hrec, buf, sz); - if (!hRecord) + rec = msihandle2msiinfo(hrec, MSIHANDLETYPE_RECORD); + if (!rec) return ERROR_INVALID_HANDLE; - if (!sz) + package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE); + if (!package) { - if (szResult) - return ERROR_INVALID_PARAMETER; - else - return ERROR_SUCCESS; + LPWSTR value = NULL; + MSIHANDLE remote; + + if ((remote = msi_get_remote(hinst))) + { + r = remote_FormatRecord(remote, (struct wire_record *)&rec->count, &value); + + if (!r) + r = msi_strncpyWtoA(value, -1, buf, sz, TRUE); + + midl_user_free(value); + msiobj_release(&rec->hdr); + return r; + } } - r = MsiFormatRecordW( hInstall, hRecord, NULL, &len ); + r = MSI_FormatRecordW(package, rec, NULL, &len); if (r != ERROR_SUCCESS) return r; value = msi_alloc(++len * sizeof(WCHAR)); if (!value) - return ERROR_OUTOFMEMORY; - - r = MsiFormatRecordW( hInstall, hRecord, value, &len ); - if (r != ERROR_SUCCESS) goto done; - save = len + 1; - len = WideCharToMultiByte(CP_ACP, 0, value, len + 1, NULL, 0, NULL, NULL); - WideCharToMultiByte(CP_ACP, 0, value, len, szResult, *sz, NULL, NULL); - - if (szResult && len > *sz) - { - if (*sz) szResult[*sz - 1] = '\0'; - r = ERROR_MORE_DATA; - } + r = MSI_FormatRecordW(package, rec, value, &len); + if (!r) + r = msi_strncpyWtoA(value, len, buf, sz, FALSE); - *sz = save - 1; - -done: msi_free(value); +done: + msiobj_release(&rec->hdr); + if (package) msiobj_release(&package->hdr); return r; } diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c index 382f20b7aa0..9ade59804d7 100644 --- a/dll/win32/msi/install.c +++ b/dll/win32/msi/install.c @@ -168,6 +168,29 @@ UINT msi_strcpy_to_awstring( const WCHAR *str, int len, awstring *awbuf, DWORD * return r; } +UINT msi_strncpyWtoA(const WCHAR *str, int lenW, char *buf, DWORD *sz, BOOL remote) +{ + UINT r = ERROR_SUCCESS; + DWORD lenA; + + if (!sz) + return buf ? ERROR_INVALID_PARAMETER : ERROR_SUCCESS; + + if (lenW < 0) lenW = strlenW(str); + lenA = WideCharToMultiByte(CP_ACP, 0, str, lenW + 1, NULL, 0, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, str, lenW + 1, buf, *sz, NULL, NULL); + lenA--; + if (buf && lenA >= *sz) + { + if (*sz) buf[*sz - 1] = 0; + r = ERROR_MORE_DATA; + } + if (remote && lenA >= *sz) + lenA *= 2; + *sz = lenA; + return r; +} + const WCHAR *msi_get_target_folder( MSIPACKAGE *package, const WCHAR *name ) { MSIFOLDER *folder = msi_get_loaded_folder( package, name ); diff --git a/dll/win32/msi/msipriv.h b/dll/win32/msi/msipriv.h index ca4c5cfc083..a8140bb8cdf 100644 --- a/dll/win32/msi/msipriv.h +++ b/dll/win32/msi/msipriv.h @@ -1046,6 +1046,7 @@ extern WCHAR *msi_font_version_from_file(const WCHAR *) DECLSPEC_HIDDEN; extern WCHAR **msi_split_string(const WCHAR *, WCHAR) DECLSPEC_HIDDEN; extern UINT msi_set_original_database_property(MSIDATABASE *, const WCHAR *) DECLSPEC_HIDDEN; extern WCHAR *msi_get_error_message(MSIDATABASE *, int) DECLSPEC_HIDDEN; +extern UINT msi_strncpyWtoA(const WCHAR *str, int len, char *buf, DWORD *sz, BOOL remote) DECLSPEC_HIDDEN; /* media */ diff --git a/modules/rostests/winetests/msi/custom.c b/modules/rostests/winetests/msi/custom.c index 04946d907d3..320aa6f30e5 100644 --- a/modules/rostests/winetests/msi/custom.c +++ b/modules/rostests/winetests/msi/custom.c @@ -785,28 +785,28 @@ static void test_format_record(MSIHANDLE hinst) sz = 0; r = MsiFormatRecordA(hinst, rec, NULL, &sz); ok(hinst, !r, "got %u\n", r); - todo_wine_ok(hinst, sz == 14, "got size %u\n", sz); + ok(hinst, sz == 14, "got size %u\n", sz); sz = 0; strcpy(buffer,"q"); r = MsiFormatRecordA(hinst, rec, buffer, &sz); ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r); ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n", buffer); - todo_wine_ok(hinst, sz == 14, "got size %u\n", sz); + ok(hinst, sz == 14, "got size %u\n", sz); sz = 1; strcpy(buffer,"x"); r = MsiFormatRecordA(hinst, rec, buffer, &sz); ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r); ok(hinst, !buffer[0], "got \"%s\"\n", buffer); - todo_wine_ok(hinst, sz == 14, "got size %u\n", sz); + ok(hinst, sz == 14, "got size %u\n", sz); sz = 7; strcpy(buffer,"x"); r = MsiFormatRecordA(hinst, rec, buffer, &sz); ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r); ok(hinst, !strcmp(buffer, "foo 12"), "got \"%s\"\n", buffer); - todo_wine_ok(hinst, sz == 14, "got size %u\n", sz); + ok(hinst, sz == 14, "got size %u\n", sz); sz = 8; strcpy(buffer,"x");
2 years, 7 months
1
0
0
0
[reactos] 57/360: [WINESYNC] msi/tests: More accurately calculate estimated size.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56c14436f41cb975ee18e…
commit 56c14436f41cb975ee18ee99181e5615287a9280 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:14 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:44 2022 +0100 [WINESYNC] msi/tests: More accurately calculate estimated size. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 40b211b6c2d61effba333cb64fb30289d3a18ee1 by Zebediah Figura <z.figura12(a)gmail.com> --- modules/rostests/winetests/msi/action.c | 113 ++++++++------------------------ 1 file changed, 26 insertions(+), 87 deletions(-) diff --git a/modules/rostests/winetests/msi/action.c b/modules/rostests/winetests/msi/action.c index 8e72ff4e36e..849975d997e 100644 --- a/modules/rostests/winetests/msi/action.c +++ b/modules/rostests/winetests/msi/action.c @@ -2321,45 +2321,6 @@ static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, DWORD lin ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val); } -static void check_reg_dword4(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2, DWORD expected3, - DWORD expected4, DWORD line) -{ - DWORD val, size, type; - LONG res; - - size = sizeof(DWORD); - res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size); - - if (res != ERROR_SUCCESS || type != REG_DWORD) - { - ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n"); - return; - } - - ok_(__FILE__, line)(val == expected1 || val == expected2 || val == expected3 || val == expected4, - "Expected %d, %d, %d or %d, got %d\n", expected1, expected2, expected3, expected4, val); -} - -static void check_reg_dword5(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2, DWORD expected3, - DWORD expected4, DWORD expected5, DWORD line) -{ - DWORD val, size, type; - LONG res; - - size = sizeof(DWORD); - res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size); - - if (res != ERROR_SUCCESS || type != REG_DWORD) - { - ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n"); - return; - } - - ok_(__FILE__, line)(val == expected1 || val == expected2 || val == expected3 || val == expected4 || - val == expected5, - "Expected %d, %d, %d, %d or %d, got %d\n", expected1, expected2, expected3, expected4, expected5, val); -} - #define CHECK_REG_STR(prodkey, name, expected) \ check_reg_str(prodkey, name, expected, TRUE, __LINE__); @@ -2387,24 +2348,6 @@ static void check_reg_dword5(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD e RegDeleteValueA(prodkey, name); \ } while(0) -#define CHECK_REG_DWORD2(prodkey, name, expected1, expected2) \ - check_reg_dword2(prodkey, name, expected1, expected2, __LINE__); - -#define CHECK_DEL_REG_DWORD2(prodkey, name, expected1, expected2) \ - do { \ - check_reg_dword2(prodkey, name, expected1, expected2, __LINE__); \ - RegDeleteValueA(prodkey, name); \ - } while(0) - -#define CHECK_REG_DWORD4(prodkey, name, expected1, expected2, expected3, expected4) \ - check_reg_dword4(prodkey, name, expected1, expected2, expected3, expected4, __LINE__); - -#define CHECK_DEL_REG_DWORD5(prodkey, name, expected1, expected2, expected3, expected4 ,expected5) \ - do { \ - check_reg_dword5(prodkey, name, expected1, expected2, expected3, expected4, expected5, __LINE__); \ - RegDeleteValueA(prodkey, name); \ - } while(0) - static void get_date_str(LPSTR date) { SYSTEMTIME systime; @@ -2414,6 +2357,22 @@ static void get_date_str(LPSTR date) sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay); } +/* EstimatedSize is the size in KiB of .msi + installed files, rounded up to page size. */ +static DWORD get_estimated_size(void) +{ + SYSTEM_INFO si; + HANDLE file; + DWORD size; + + GetSystemInfo(&si); + + file = CreateFileA(msifile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); + size = ((GetFileSize(file, NULL) + si.dwPageSize - 1) / si.dwPageSize + 1); + size = size * si.dwPageSize / 1024; + CloseHandle(file); + return size; +} + static void test_register_product(void) { UINT r; @@ -2505,9 +2464,7 @@ static void test_register_product(void) CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1); CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1); todo_wine - { - CHECK_DEL_REG_DWORD5(hkey, "EstimatedSize", 12, -12, 4, 10, 24); - } + CHECK_DEL_REG_DWORD(hkey, "EstimatedSize", get_estimated_size()); delete_key(hkey, "", access); RegCloseKey(hkey); @@ -2547,9 +2504,7 @@ static void test_register_product(void) CHECK_DEL_REG_DWORD(props, "VersionMinor", 1); CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1); todo_wine - { - CHECK_DEL_REG_DWORD5(props, "EstimatedSize", 12, -12, 4, 10, 24); - } + CHECK_DEL_REG_DWORD(props, "EstimatedSize", get_estimated_size()); delete_key(props, "", access); RegCloseKey(props); @@ -2616,9 +2571,7 @@ static void test_register_product(void) CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1); CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1); todo_wine - { - CHECK_DEL_REG_DWORD5(hkey, "EstimatedSize", 12, -12, 4, 10, 24); - } + CHECK_DEL_REG_DWORD(hkey, "EstimatedSize", get_estimated_size()); delete_key(hkey, "", access); RegCloseKey(hkey); @@ -2658,9 +2611,7 @@ static void test_register_product(void) CHECK_DEL_REG_DWORD(props, "VersionMinor", 1); CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1); todo_wine - { - CHECK_DEL_REG_DWORD5(props, "EstimatedSize", 12, -12, 4, 10, 24); - } + CHECK_DEL_REG_DWORD(props, "EstimatedSize", get_estimated_size()); delete_key(props, "", access); RegCloseKey(props); @@ -3525,9 +3476,7 @@ static void test_publish(void) CHECK_REG_DWORD(prodkey, "VersionMinor", 1); CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1); todo_wine - { - CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24); - } + CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size()); RegCloseKey(prodkey); @@ -3631,9 +3580,7 @@ static void test_publish(void) CHECK_REG_DWORD(prodkey, "VersionMinor", 1); CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1); todo_wine - { - CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24); - } + CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size()); RegCloseKey(prodkey); @@ -3714,9 +3661,7 @@ static void test_publish(void) CHECK_REG_DWORD(prodkey, "VersionMinor", 1); CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1); todo_wine - { - CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24); - } + CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size()); RegCloseKey(prodkey); @@ -3774,9 +3719,7 @@ static void test_publish(void) CHECK_REG_DWORD(prodkey, "VersionMinor", 1); CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1); todo_wine - { - CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24); - } + CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size()); RegCloseKey(prodkey); @@ -3834,9 +3777,7 @@ static void test_publish(void) CHECK_REG_DWORD(prodkey, "VersionMinor", 1); CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1); todo_wine - { - CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -20, 10, 24); - } + CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size()); RegCloseKey(prodkey); @@ -3917,9 +3858,7 @@ static void test_publish(void) CHECK_REG_DWORD(prodkey, "VersionMinor", 1); CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1); todo_wine - { - CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24); - } + CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size()); RegCloseKey(prodkey);
2 years, 7 months
1
0
0
0
[reactos] 56/360: [WINESYNC] msi/tests: Add the custom action DLL in create_database_wordcount().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b016bb6bccb7faf463d1d…
commit b016bb6bccb7faf463d1d9c8152f80735028b275 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:14 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:44 2022 +0100 [WINESYNC] msi/tests: Add the custom action DLL in create_database_wordcount(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id bf0b9b97e08879637750f721fc96ca766e6ff61a by Zebediah Figura <z.figura12(a)gmail.com> --- modules/rostests/winetests/msi/install.c | 142 +++++++++++++++---------------- modules/rostests/winetests/msi/msi.c | 2 +- 2 files changed, 69 insertions(+), 75 deletions(-) diff --git a/modules/rostests/winetests/msi/install.c b/modules/rostests/winetests/msi/install.c index a2b95d1d2c6..f0e4857fe19 100644 --- a/modules/rostests/winetests/msi/install.c +++ b/modules/rostests/winetests/msi/install.c @@ -2551,6 +2551,73 @@ static void write_msi_summary_info(MSIHANDLE db, INT version, INT wordcount, MsiCloseHandle(summary); } +static char *load_resource(const char *name) +{ + static char path[MAX_PATH]; + DWORD written; + HANDLE file; + HRSRC res; + void *ptr; + + GetTempFileNameA(".", name, 0, path); + + file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", path, GetLastError()); + + res = FindResourceA(NULL, name, "TESTDLL"); + ok( res != 0, "couldn't find resource\n" ); + ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res )); + WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL ); + ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" ); + CloseHandle( file ); + + return path; +} + +static INT CALLBACK ok_callback(void *context, UINT message_type, MSIHANDLE record) +{ + if (message_type == INSTALLMESSAGE_USER) + { + char file[200]; + char msg[2000]; + DWORD len; + + len = sizeof(file); + MsiRecordGetStringA(record, 2, file, &len); + len = sizeof(msg); + MsiRecordGetStringA(record, 5, msg, &len); + + todo_wine_if(MsiRecordGetInteger(record, 1)) + ok_(file, MsiRecordGetInteger(record, 3)) (MsiRecordGetInteger(record, 4), "%s", msg); + + return 1; + } + return 0; +} + +static void add_custom_dll(MSIHANDLE hdb) +{ + MSIHANDLE record; + UINT res; + + if (!customdll) + customdll = load_resource("custom.dll"); + + MsiSetExternalUIRecord(ok_callback, INSTALLLOGMODE_USER, NULL, NULL); + + res = run_query(hdb, 0, "CREATE TABLE `Binary` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL PRIMARY KEY `Name`)"); + ok(res == ERROR_SUCCESS, "failed to create Binary table: %u\n", res); + + record = MsiCreateRecord(1); + res = MsiRecordSetStreamA(record, 1, customdll); + ok(res == ERROR_SUCCESS, "failed to add %s to stream: %u\n", customdll, res); + + res = run_query(hdb, record, "INSERT INTO `Binary` (`Name`, `Data`) VALUES ('custom.dll', ?)"); + ok(res == ERROR_SUCCESS, "failed to insert into Binary table: %u\n", res); + + MsiCloseHandle(record); +} + void create_database_wordcount(const CHAR *name, const msi_table *tables, int num_tables, INT version, INT wordcount, const char *template, const char *packagecode) { @@ -2580,6 +2647,7 @@ void create_database_wordcount(const CHAR *name, const msi_table *tables, int nu } write_msi_summary_info(db, version, wordcount, template, packagecode); + add_custom_dll(db); r = MsiDatabaseCommit(db); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); @@ -2634,29 +2702,6 @@ static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access ) return RegDeleteKeyA( key, subkey ); } -static char *load_resource(const char *name) -{ - static char path[MAX_PATH]; - DWORD written; - HANDLE file; - HRSRC res; - void *ptr; - - GetTempFileNameA(".", name, 0, path); - - file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); - ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", path, GetLastError()); - - res = FindResourceA(NULL, name, "TESTDLL"); - ok( res != 0, "couldn't find resource\n" ); - ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res )); - WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL ); - ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" ); - CloseHandle( file ); - - return path; -} - static void test_MsiInstallProduct(void) { UINT r; @@ -4082,52 +4127,6 @@ error: DeleteFileA("augustus"); } -static void add_custom_dll(void) -{ - MSIHANDLE hdb = 0, record; - UINT res; - - res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb); - ok(res == ERROR_SUCCESS, "failed to open db: %u\n", res); - - res = run_query(hdb, 0, "CREATE TABLE `Binary` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL PRIMARY KEY `Name`)"); - ok(res == ERROR_SUCCESS, "failed to create Binary table: %u\n", res); - - record = MsiCreateRecord(1); - res = MsiRecordSetStreamA(record, 1, customdll); - ok(res == ERROR_SUCCESS, "failed to add %s to stream: %u\n", customdll, res); - - res = run_query(hdb, record, "INSERT INTO `Binary` (`Name`, `Data`) VALUES ('custom.dll', ?)"); - ok(res == ERROR_SUCCESS, "failed to insert into Binary table: %u\n", res); - - res = MsiDatabaseCommit(hdb); - ok(res == ERROR_SUCCESS, "failed to commit database: %u\n", res); - - MsiCloseHandle(record); - MsiCloseHandle(hdb); -} - -static INT CALLBACK ok_callback(void *context, UINT message_type, MSIHANDLE record) -{ - if (message_type == INSTALLMESSAGE_USER) - { - char file[200]; - char msg[2000]; - DWORD len; - - len = sizeof(file); - MsiRecordGetStringA(record, 2, file, &len); - len = sizeof(msg); - MsiRecordGetStringA(record, 5, msg, &len); - - todo_wine_if(MsiRecordGetInteger(record, 1)) - ok_(file, MsiRecordGetInteger(record, 3)) (MsiRecordGetInteger(record, 4), "%s", msg); - - return 1; - } - return 0; -} - static void test_customaction1(void) { MSIHANDLE hdb, record; @@ -4135,7 +4134,6 @@ static void test_customaction1(void) create_test_files(); create_database(msifile, ca1_tables, sizeof(ca1_tables) / sizeof(msi_table)); - add_custom_dll(); /* create a test table */ MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb); @@ -6106,7 +6104,6 @@ static void test_deferred_action(void) sprintf(buffer, "TESTPATH=\"%s\"", file); create_database(msifile, da_tables, sizeof(da_tables) / sizeof(da_tables[0])); - add_custom_dll(); MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); @@ -6234,9 +6231,6 @@ START_TEST(install) lstrcatA(log_file, "\\msitest.log"); MsiEnableLogA(INSTALLLOGMODE_FATALEXIT, log_file, 0); - customdll = load_resource("custom.dll"); - MsiSetExternalUIRecord(ok_callback, INSTALLLOGMODE_USER, NULL, NULL); - if (pSRSetRestorePointA) /* test has side-effects on win2k3 that cause failures in following tests */ test_MsiInstallProduct(); test_MsiSetComponentState(); diff --git a/modules/rostests/winetests/msi/msi.c b/modules/rostests/winetests/msi/msi.c index 527a89960a5..a91b1e38c91 100644 --- a/modules/rostests/winetests/msi/msi.c +++ b/modules/rostests/winetests/msi/msi.c @@ -14459,6 +14459,7 @@ START_TEST(msi) test_getcomponentpath(); test_MsiGetFileHash(); test_MsiSetInternalUI(); + test_MsiSetExternalUI(); if (!pConvertSidToStringSidA) win_skip("ConvertSidToStringSidA not implemented\n"); @@ -14491,7 +14492,6 @@ START_TEST(msi) test_MsiConfigureProductEx(); test_MsiSetFeatureAttributes(); test_MsiGetFeatureInfo(); - test_MsiSetExternalUI(); test_lastusedsource(); test_setpropertyfolder(); test_sourcedir_props();
2 years, 7 months
1
0
0
0
[reactos] 55/360: [WINESYNC] msi/tests: Add a header for some common functions.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0e769060745451f79070c…
commit 0e769060745451f79070c38f8e74091ae7f44f46 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:13 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:44 2022 +0100 [WINESYNC] msi/tests: Add a header for some common functions. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ab522d694d5ffe08a410320988100b1a0fb2f077 by Zebediah Figura <z.figura12(a)gmail.com> --- modules/rostests/winetests/msi/action.c | 469 +-------------------------- modules/rostests/winetests/msi/install.c | 72 ++--- modules/rostests/winetests/msi/msi.c | 527 ++----------------------------- modules/rostests/winetests/msi/utils.h | 60 ++++ 4 files changed, 117 insertions(+), 1011 deletions(-) diff --git a/modules/rostests/winetests/msi/action.c b/modules/rostests/winetests/msi/action.c index 31cc9819b0c..8e72ff4e36e 100644 --- a/modules/rostests/winetests/msi/action.c +++ b/modules/rostests/winetests/msi/action.c @@ -34,6 +34,7 @@ #include <winsvc.h> #include "wine/test.h" +#include "utils.h" static UINT (WINAPI *pMsiQueryComponentStateA) (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE *); @@ -46,9 +47,7 @@ static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA) static UINT (WINAPI *pMsiQueryFeatureStateExA) (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE *); -static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL); static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR *); -static BOOL (WINAPI *pOpenProcessToken)(HANDLE, DWORD, PHANDLE); static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); @@ -60,11 +59,6 @@ static BOOL is_wow64; static const BOOL is_64bit = sizeof(void *) > sizeof(int); static const char *msifile = "msitest.msi"; -static CHAR CURR_DIR[MAX_PATH]; -static CHAR PROG_FILES_DIR[MAX_PATH]; -static CHAR COMMON_FILES_DIR[MAX_PATH]; -static CHAR APP_DATA_DIR[MAX_PATH]; -static CHAR WINDOWS_DIR[MAX_PATH]; /* msi database data */ @@ -1679,15 +1673,6 @@ static const char rep_install_exec_seq_dat[] = "PublishProduct\t\t5200\n" "InstallFinalize\t\t6000\n"; -typedef struct _msi_table -{ - const char *filename; - const char *data; - unsigned int size; -} msi_table; - -#define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)} - static const msi_table env_tables[] = { ADD_TABLE(component), @@ -2152,110 +2137,6 @@ cleanup: /* make the max size large so there is only one cab file */ #define MEDIA_SIZE 0x7FFFFFFF -#define FOLDER_THRESHOLD 900000 - -/* the FCI callbacks */ - -static void * CDECL mem_alloc(ULONG cb) -{ - return HeapAlloc(GetProcessHeap(), 0, cb); -} - -static void CDECL mem_free(void *memory) -{ - HeapFree(GetProcessHeap(), 0, memory); -} - -static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv) -{ - sprintf(pccab->szCab, pv, pccab->iCab); - return TRUE; -} - -static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv) -{ - return 0; -} - -static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile, - BOOL fContinuation, void *pv) -{ - return 0; -} - -static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv) -{ - HANDLE handle; - DWORD dwAccess = 0; - DWORD dwShareMode = 0; - DWORD dwCreateDisposition = OPEN_EXISTING; - - dwAccess = GENERIC_READ | GENERIC_WRITE; - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - - if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES) - dwCreateDisposition = OPEN_EXISTING; - else - dwCreateDisposition = CREATE_NEW; - - handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL, - dwCreateDisposition, 0, NULL); - - ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile); - - return (INT_PTR)handle; -} - -static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - DWORD dwRead; - BOOL res; - - res = ReadFile(handle, memory, cb, &dwRead, NULL); - ok(res, "Failed to ReadFile\n"); - - return dwRead; -} - -static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - DWORD dwWritten; - BOOL res; - - res = WriteFile(handle, memory, cb, &dwWritten, NULL); - ok(res, "Failed to WriteFile\n"); - - return dwWritten; -} - -static int CDECL fci_close(INT_PTR hf, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - ok(CloseHandle(handle), "Failed to CloseHandle\n"); - - return 0; -} - -static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - DWORD ret; - - ret = SetFilePointer(handle, dist, NULL, seektype); - ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n"); - - return ret; -} - -static int CDECL fci_delete(char *pszFile, int *err, void *pv) -{ - BOOL ret = DeleteFileA(pszFile); - ok(ret, "Failed to DeleteFile %s\n", pszFile); - - return 0; -} static void init_functionpointers(void) { @@ -2274,9 +2155,7 @@ static void init_functionpointers(void) GET_PROC(hmsi, MsiGetComponentPathExA); GET_PROC(hmsi, MsiQueryFeatureStateExA); - GET_PROC(hadvapi32, CheckTokenMembership); GET_PROC(hadvapi32, ConvertSidToStringSidA); - GET_PROC(hadvapi32, OpenProcessToken); GET_PROC(hadvapi32, RegDeleteKeyExA) GET_PROC(hkernel32, IsWow64Process) @@ -2287,44 +2166,6 @@ static void init_functionpointers(void) #undef GET_PROC } -static BOOL is_process_limited(void) -{ - SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group = NULL; - BOOL IsInGroup; - HANDLE token; - - if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; - - if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || - !pCheckTokenMembership(NULL, Group, &IsInGroup)) - { - trace("Could not check if the current user is an administrator\n"); - FreeSid(Group); - return FALSE; - } - FreeSid(Group); - - if (!IsInGroup) - { - /* Only administrators have enough privileges for these tests */ - return TRUE; - } - - if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) - { - BOOL ret; - TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; - DWORD size; - - ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size); - CloseHandle(token); - return (ret && type == TokenElevationTypeLimited); - } - return FALSE; -} - static char *get_user_sid(void) { HANDLE token; @@ -2349,185 +2190,6 @@ static char *get_user_sid(void) return usersid; } -static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv) -{ - LPSTR tempname; - - tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH); - GetTempFileNameA(".", "xx", 0, tempname); - - if (tempname && (strlen(tempname) < (unsigned)cbTempName)) - { - lstrcpyA(pszTempName, tempname); - HeapFree(GetProcessHeap(), 0, tempname); - return TRUE; - } - - HeapFree(GetProcessHeap(), 0, tempname); - - return FALSE; -} - -static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime, - USHORT *pattribs, int *err, void *pv) -{ - BY_HANDLE_FILE_INFORMATION finfo; - FILETIME filetime; - HANDLE handle; - DWORD attrs; - BOOL res; - - handle = CreateFileA(pszName, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - - ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName); - - res = GetFileInformationByHandle(handle, &finfo); - ok(res, "Expected GetFileInformationByHandle to succeed\n"); - - FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime); - FileTimeToDosDateTime(&filetime, pdate, ptime); - - attrs = GetFileAttributesA(pszName); - ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n"); - - return (INT_PTR)handle; -} - -static BOOL add_file(HFCI hfci, const char *file, TCOMP compress) -{ - char path[MAX_PATH]; - char filename[MAX_PATH]; - - lstrcpyA(path, CURR_DIR); - lstrcatA(path, "\\"); - lstrcatA(path, file); - - lstrcpyA(filename, file); - - return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet, - progress, get_open_info, compress); -} - -static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size) -{ - ZeroMemory(pCabParams, sizeof(CCAB)); - - pCabParams->cb = max_size; - pCabParams->cbFolderThresh = FOLDER_THRESHOLD; - pCabParams->setID = 0xbeef; - pCabParams->iCab = 1; - lstrcpyA(pCabParams->szCabPath, CURR_DIR); - lstrcatA(pCabParams->szCabPath, "\\"); - lstrcpyA(pCabParams->szCab, name); -} - -static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files) -{ - CCAB cabParams; - LPCSTR ptr; - HFCI hfci; - ERF erf; - BOOL res; - - set_cab_parameters(&cabParams, name, max_size); - - hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open, - fci_read, fci_write, fci_close, fci_seek, fci_delete, - get_temp_file, &cabParams, NULL); - - ok(hfci != NULL, "Failed to create an FCI context\n"); - - ptr = files; - while (*ptr) - { - res = add_file(hfci, ptr, tcompTYPE_MSZIP); - ok(res, "Failed to add file: %s\n", ptr); - ptr += lstrlenA(ptr) + 1; - } - - res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress); - ok(res, "Failed to flush the cabinet\n"); - - res = FCIDestroy(hfci); - ok(res, "Failed to destroy the cabinet\n"); -} - -static BOOL get_user_dirs(void) -{ - HKEY hkey; - DWORD type, size; - - if (RegOpenKeyA(HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey)) - return FALSE; - - size = MAX_PATH; - if (RegQueryValueExA(hkey, "AppData", 0, &type, (LPBYTE)APP_DATA_DIR, &size)) - { - RegCloseKey(hkey); - return FALSE; - } - - RegCloseKey(hkey); - return TRUE; -} - -static BOOL get_system_dirs(void) -{ - HKEY hkey; - DWORD type, size; - - if (RegOpenKeyA(HKEY_LOCAL_MACHINE, - "Software\\Microsoft\\Windows\\CurrentVersion", &hkey)) - return FALSE; - - size = MAX_PATH; - if (RegQueryValueExA(hkey, "ProgramFilesDir (x86)", 0, &type, (LPBYTE)PROG_FILES_DIR, &size) && - RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR, &size)) - { - RegCloseKey(hkey); - return FALSE; - } - - size = MAX_PATH; - if (RegQueryValueExA(hkey, "CommonFilesDir (x86)", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size) && - RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size)) - { - RegCloseKey(hkey); - return FALSE; - } - - RegCloseKey(hkey); - - if (!GetWindowsDirectoryA(WINDOWS_DIR, MAX_PATH)) - return FALSE; - - return TRUE; -} - -static void create_file_data(LPCSTR name, LPCSTR data, DWORD size) -{ - HANDLE file; - DWORD written; - - file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - if (file == INVALID_HANDLE_VALUE) - return; - - WriteFile(file, data, strlen(data), &written, NULL); - - if (size) - { - SetFilePointer(file, size, NULL, FILE_BEGIN); - SetEndOfFile(file); - } - - CloseHandle(file); -} - -#define create_file(name, size) create_file_data(name, name, size) - static void create_test_files(void) { CreateDirectoryA("msitest", NULL); @@ -2549,20 +2211,6 @@ static void create_test_files(void) DeleteFileA("five.txt"); } -static BOOL delete_pf(const CHAR *rel_path, BOOL is_file) -{ - CHAR path[MAX_PATH]; - - lstrcpyA(path, PROG_FILES_DIR); - lstrcatA(path, "\\"); - lstrcatA(path, rel_path); - - if (is_file) - return DeleteFileA(path); - else - return RemoveDirectoryA(path); -} - static void delete_test_files(void) { DeleteFileA("msitest.msi"); @@ -2578,89 +2226,6 @@ static void delete_test_files(void) RemoveDirectoryA("msitest"); } -static void write_file(const CHAR *filename, const char *data, int data_size) -{ - DWORD size; - HANDLE hf = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - WriteFile(hf, data, data_size, &size, NULL); - CloseHandle(hf); -} - -static void write_msi_summary_info(MSIHANDLE db, INT version, INT wordcount, const char *template) -{ - MSIHANDLE summary; - UINT r; - - r = MsiGetSummaryInformationA(db, NULL, 5, &summary); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, template); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL, - "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}"); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, version, NULL, NULL); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, wordcount, NULL, NULL); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST"); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - /* write the summary changes back to the stream */ - r = MsiSummaryInfoPersist(summary); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - MsiCloseHandle(summary); -} - -#define create_database(name, tables, num_tables) \ - create_database_wordcount(name, tables, num_tables, 100, 0, ";1033"); - -#define create_database_template(name, tables, num_tables, version, template) \ - create_database_wordcount(name, tables, num_tables, version, 0, template); - -static void create_database_wordcount(const CHAR *name, const msi_table *tables, - int num_tables, INT version, INT wordcount, - const char *template) -{ - MSIHANDLE db; - UINT r; - WCHAR *nameW; - int j, len; - - len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 ); - if (!(nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return; - MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, len ); - - r = MsiOpenDatabaseW(nameW, MSIDBOPEN_CREATE, &db); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - /* import the tables into the database */ - for (j = 0; j < num_tables; j++) - { - const msi_table *table = &tables[j]; - - write_file(table->filename, table->data, (table->size - 1) * sizeof(char)); - - r = MsiDatabaseImportA(db, CURR_DIR, table->filename); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - DeleteFileA(table->filename); - } - - write_msi_summary_info(db, version, wordcount, template); - - r = MsiDatabaseCommit(db); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - MsiCloseHandle(db); - HeapFree( GetProcessHeap(), 0, nameW ); -} - static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status) { RESTOREPOINTINFOA spec; @@ -2689,22 +2254,6 @@ static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access ) return RegDeleteKeyA( key, subkey ); } -static BOOL file_exists(LPCSTR file) -{ - return GetFileAttributesA(file) != INVALID_FILE_ATTRIBUTES; -} - -static BOOL pf_exists(LPCSTR file) -{ - CHAR path[MAX_PATH]; - - lstrcpyA(path, PROG_FILES_DIR); - lstrcatA(path, "\\"); - lstrcatA(path, file); - - return file_exists(path); -} - static void delete_pfmsitest_files(void) { SHFILEOPSTRUCTA shfl; @@ -4615,22 +4164,6 @@ error: RemoveDirectoryA("msitest"); } -static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file) -{ - CHAR path[MAX_PATH]; - - lstrcpyA(path, PROG_FILES_DIR); - lstrcatA(path, "\\"); - lstrcatA(path, file); - - if (is_file) - create_file_data(path, data, 500); - else - CreateDirectoryA(path, NULL); -} - -#define create_pf(file, is_file) create_pf_data(file, file, is_file) - static void test_remove_files(void) { UINT r; diff --git a/modules/rostests/winetests/msi/install.c b/modules/rostests/winetests/msi/install.c index ac2c8371e3e..a2b95d1d2c6 100644 --- a/modules/rostests/winetests/msi/install.c +++ b/modules/rostests/winetests/msi/install.c @@ -35,6 +35,7 @@ #include <shellapi.h> #include "wine/test.h" +#include "utils.h" static UINT (WINAPI *pMsiQueryComponentStateA) (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*); @@ -43,9 +44,7 @@ static UINT (WINAPI *pMsiSourceListEnumSourcesA) static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA) (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD); -static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL); static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); -static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE ); static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(void **); @@ -65,12 +64,12 @@ static const char *mstfile = "winetest.mst"; static const WCHAR msifileW[] = {'m','s','i','t','e','s','t','.','m','s','i',0}; static const WCHAR msifile2W[] = {'w','i','n','e','t','e','s','t','2','.','m','s','i',0}; -static CHAR CURR_DIR[MAX_PATH]; -static CHAR PROG_FILES_DIR[MAX_PATH]; -static CHAR PROG_FILES_DIR_NATIVE[MAX_PATH]; -static CHAR COMMON_FILES_DIR[MAX_PATH]; -static CHAR APP_DATA_DIR[MAX_PATH]; -static CHAR WINDOWS_DIR[MAX_PATH]; +char CURR_DIR[MAX_PATH]; +char PROG_FILES_DIR[MAX_PATH]; +char PROG_FILES_DIR_NATIVE[MAX_PATH]; +char COMMON_FILES_DIR[MAX_PATH]; +char APP_DATA_DIR[MAX_PATH]; +char WINDOWS_DIR[MAX_PATH]; static const char *customdll; @@ -1348,15 +1347,6 @@ static const CHAR x64_directory_dat[] = "ProgramFiles64Folder\tTARGETDIR\t.\n" "TARGETDIR\t\tSourceDir"; -typedef struct _msi_table -{ - const CHAR *filename; - const CHAR *data; - int size; -} msi_table; - -#define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)} - static const msi_table tables[] = { ADD_TABLE(component), @@ -2084,8 +2074,7 @@ static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, voi DWORD dwCreateDisposition = OPEN_EXISTING; dwAccess = GENERIC_READ | GENERIC_WRITE; - /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */ - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES) dwCreateDisposition = OPEN_EXISTING; @@ -2166,9 +2155,7 @@ static void init_functionpointers(void) GET_PROC(hmsi, MsiSourceListEnumSourcesA); GET_PROC(hmsi, MsiGetComponentPathExA); - GET_PROC(hadvapi32, CheckTokenMembership); GET_PROC(hadvapi32, ConvertSidToStringSidA); - GET_PROC(hadvapi32, OpenProcessToken); GET_PROC(hadvapi32, RegDeleteKeyExA) GET_PROC(hkernel32, IsWow64Process) GET_PROC(hkernel32, Wow64DisableWow64FsRedirection); @@ -2181,18 +2168,16 @@ static void init_functionpointers(void) #undef GET_PROC } -static BOOL is_process_limited(void) +BOOL is_process_limited(void) { SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; PSID Group = NULL; BOOL IsInGroup; HANDLE token; - if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; - if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || - !pCheckTokenMembership(NULL, Group, &IsInGroup)) + !CheckTokenMembership(NULL, Group, &IsInGroup)) { trace("Could not check if the current user is an administrator\n"); FreeSid(Group); @@ -2206,7 +2191,7 @@ static BOOL is_process_limited(void) return TRUE; } - if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) { BOOL ret; TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; @@ -2303,7 +2288,7 @@ static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_siz lstrcpyA(pCabParams->szCab, name); } -static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files) +void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files) { CCAB cabParams; LPCSTR ptr; @@ -2334,7 +2319,7 @@ static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files) ok(res, "Failed to destroy the cabinet\n"); } -static BOOL get_user_dirs(void) +BOOL get_user_dirs(void) { HKEY hkey; DWORD type, size; @@ -2353,7 +2338,7 @@ static BOOL get_user_dirs(void) return TRUE; } -static BOOL get_system_dirs(void) +BOOL get_system_dirs(void) { HKEY hkey; DWORD type, size; @@ -2390,7 +2375,7 @@ static BOOL get_system_dirs(void) return TRUE; } -static void create_file_data(LPCSTR name, LPCSTR data, DWORD size) +void create_file_data(LPCSTR name, LPCSTR data, DWORD size) { HANDLE file; DWORD written; @@ -2410,8 +2395,6 @@ static void create_file_data(LPCSTR name, LPCSTR data, DWORD size) CloseHandle(file); } -#define create_file(name, size) create_file_data(name, name, size) - static void create_test_files(void) { CreateDirectoryA("msitest", NULL); @@ -2432,7 +2415,7 @@ static void create_test_files(void) DeleteFileA("five.txt"); } -static BOOL delete_pf(const CHAR *rel_path, BOOL is_file) +BOOL delete_pf(const CHAR *rel_path, BOOL is_file) { CHAR path[MAX_PATH]; @@ -2568,17 +2551,8 @@ static void write_msi_summary_info(MSIHANDLE db, INT version, INT wordcount, MsiCloseHandle(summary); } -#define create_database(name, tables, num_tables) \ - create_database_wordcount(name, tables, num_tables, 100, 0, ";1033", \ - "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}"); - -#define create_database_template(name, tables, num_tables, version, template) \ - create_database_wordcount(name, tables, num_tables, version, 0, template, \ - "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}"); - -static void create_database_wordcount(const CHAR *name, const msi_table *tables, - int num_tables, INT version, INT wordcount, - const char *template, const char *packagecode) +void create_database_wordcount(const CHAR *name, const msi_table *tables, int num_tables, + INT version, INT wordcount, const char *template, const char *packagecode) { MSIHANDLE db; UINT r; @@ -3018,7 +2992,7 @@ static void create_cc_test_files(void) DeleteFileA("caesar"); } -static void delete_cab_files(void) +void delete_cab_files(void) { SHFILEOPSTRUCTA shfl; CHAR path[MAX_PATH+10]; @@ -3536,12 +3510,12 @@ error: RemoveDirectoryA("msitest"); } -static BOOL file_exists(LPCSTR file) +BOOL file_exists(const char *file) { return GetFileAttributesA(file) != INVALID_FILE_ATTRIBUTES; } -static BOOL pf_exists(LPCSTR file) +BOOL pf_exists(const char *file) { CHAR path[MAX_PATH]; @@ -3574,7 +3548,7 @@ static void delete_pfmsitest_files(void) RemoveDirectoryA(path); } -static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query) +UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query) { MSIHANDLE hview = 0; UINT r; @@ -3976,7 +3950,7 @@ error: RemoveDirectoryA("msitest"); } -static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file) +void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file) { CHAR path[MAX_PATH]; diff --git a/modules/rostests/winetests/msi/msi.c b/modules/rostests/winetests/msi/msi.c index fcb7d66eaae..527a89960a5 100644 --- a/modules/rostests/winetests/msi/msi.c +++ b/modules/rostests/winetests/msi/msi.c @@ -32,19 +32,13 @@ #include <objidl.h> #include "wine/test.h" +#include "utils.h" static BOOL is_wow64; static const char msifile[] = "winetest.msi"; static const WCHAR msifileW[] = {'w','i','n','e','t','e','s','t','.','m','s','i',0}; -static char CURR_DIR[MAX_PATH]; -static char PROG_FILES_DIR[MAX_PATH]; -static char PROG_FILES_DIR_NATIVE[MAX_PATH]; -static char COMMON_FILES_DIR[MAX_PATH]; -static char WINDOWS_DIR[MAX_PATH]; -static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL); static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); -static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE ); static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); @@ -110,328 +104,19 @@ static void init_functionpointers(void) GET_PROC(hmsi, MsiEnumComponentsExA) GET_PROC(hmsi, MsiSourceListGetInfoA) - GET_PROC(hadvapi32, CheckTokenMembership); GET_PROC(hadvapi32, ConvertSidToStringSidA) - GET_PROC(hadvapi32, OpenProcessToken); GET_PROC(hadvapi32, RegDeleteKeyExA) GET_PROC(hkernel32, IsWow64Process) #undef GET_PROC } -static BOOL get_system_dirs(void) -{ - HKEY hkey; - DWORD type, size; - - if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey)) - return FALSE; - - size = MAX_PATH; - if (RegQueryValueExA(hkey, "ProgramFilesDir (x86)", 0, &type, (LPBYTE)PROG_FILES_DIR, &size) && - RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR, &size)) - { - RegCloseKey(hkey); - return FALSE; - } - size = MAX_PATH; - if (RegQueryValueExA(hkey, "CommonFilesDir (x86)", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size) && - RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size)) - { - RegCloseKey(hkey); - return FALSE; - } - size = MAX_PATH; - if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR_NATIVE, &size)) - { - RegCloseKey(hkey); - return FALSE; - } - RegCloseKey(hkey); - if (!GetWindowsDirectoryA(WINDOWS_DIR, MAX_PATH)) return FALSE; - return TRUE; -} - -static BOOL file_exists(const char *file) -{ - return GetFileAttributesA(file) != INVALID_FILE_ATTRIBUTES; -} - -static BOOL pf_exists(const char *file) -{ - char path[MAX_PATH]; - - lstrcpyA(path, PROG_FILES_DIR); - lstrcatA(path, "\\"); - lstrcatA(path, file); - return file_exists(path); -} - -static BOOL delete_pf(const char *rel_path, BOOL is_file) -{ - char path[MAX_PATH]; - - lstrcpyA(path, PROG_FILES_DIR); - lstrcatA(path, "\\"); - lstrcatA(path, rel_path); - - if (is_file) - return DeleteFileA(path); - else - return RemoveDirectoryA(path); -} - -static BOOL is_process_limited(void) -{ - SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group = NULL; - BOOL IsInGroup; - HANDLE token; - - if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE; - - if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || - !pCheckTokenMembership(NULL, Group, &IsInGroup)) - { - trace("Could not check if the current user is an administrator\n"); - FreeSid(Group); - return FALSE; - } - FreeSid(Group); - - if (!IsInGroup) - { - /* Only administrators have enough privileges for these tests */ - return TRUE; - } - - if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) - { - BOOL ret; - TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; - DWORD size; - - ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size); - CloseHandle(token); - return (ret && type == TokenElevationTypeLimited); - } - return FALSE; -} - /* cabinet definitions */ /* make the max size large so there is only one cab file */ #define MEDIA_SIZE 0x7FFFFFFF #define FOLDER_THRESHOLD 900000 -/* the FCI callbacks */ - -static void * CDECL mem_alloc(ULONG cb) -{ - return HeapAlloc(GetProcessHeap(), 0, cb); -} - -static void CDECL mem_free(void *memory) -{ - HeapFree(GetProcessHeap(), 0, memory); -} - -static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv) -{ - sprintf(pccab->szCab, pv, pccab->iCab); - return TRUE; -} - -static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv) -{ - return 0; -} - -static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile, - BOOL fContinuation, void *pv) -{ - return 0; -} - -static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv) -{ - HANDLE handle; - DWORD dwAccess = 0; - DWORD dwShareMode = 0; - DWORD dwCreateDisposition = OPEN_EXISTING; - - dwAccess = GENERIC_READ | GENERIC_WRITE; - /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */ - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - - if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES) - dwCreateDisposition = OPEN_EXISTING; - else - dwCreateDisposition = CREATE_NEW; - - handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL, - dwCreateDisposition, 0, NULL); - - ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile); - - return (INT_PTR)handle; -} - -static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - DWORD dwRead; - BOOL res; - - res = ReadFile(handle, memory, cb, &dwRead, NULL); - ok(res, "Failed to ReadFile\n"); - - return dwRead; -} - -static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - DWORD dwWritten; - BOOL res; - - res = WriteFile(handle, memory, cb, &dwWritten, NULL); - ok(res, "Failed to WriteFile\n"); - - return dwWritten; -} - -static int CDECL fci_close(INT_PTR hf, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - ok(CloseHandle(handle), "Failed to CloseHandle\n"); - - return 0; -} - -static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv) -{ - HANDLE handle = (HANDLE)hf; - DWORD ret; - - ret = SetFilePointer(handle, dist, NULL, seektype); - ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n"); - - return ret; -} - -static int CDECL fci_delete(char *pszFile, int *err, void *pv) -{ - BOOL ret = DeleteFileA(pszFile); - ok(ret, "Failed to DeleteFile %s\n", pszFile); - - return 0; -} - -static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv) -{ - LPSTR tempname; - - tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH); - GetTempFileNameA(".", "xx", 0, tempname); - - if (tempname && (strlen(tempname) < (unsigned)cbTempName)) - { - lstrcpyA(pszTempName, tempname); - HeapFree(GetProcessHeap(), 0, tempname); - return TRUE; - } - - HeapFree(GetProcessHeap(), 0, tempname); - - return FALSE; -} - -static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime, - USHORT *pattribs, int *err, void *pv) -{ - BY_HANDLE_FILE_INFORMATION finfo; - FILETIME filetime; - HANDLE handle; - DWORD attrs; - BOOL res; - - handle = CreateFileA(pszName, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName); - - res = GetFileInformationByHandle(handle, &finfo); - ok(res, "Expected GetFileInformationByHandle to succeed\n"); - - FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime); - FileTimeToDosDateTime(&filetime, pdate, ptime); - - attrs = GetFileAttributesA(pszName); - ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n"); - - return (INT_PTR)handle; -} - -static BOOL add_file(HFCI hfci, const char *file, TCOMP compress) -{ - char path[MAX_PATH]; - char filename[MAX_PATH]; - - lstrcpyA(path, CURR_DIR); - lstrcatA(path, "\\"); - lstrcatA(path, file); - - lstrcpyA(filename, file); - - return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet, - progress, get_open_info, compress); -} - -static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size) -{ - ZeroMemory(pCabParams, sizeof(CCAB)); - - pCabParams->cb = max_size; - pCabParams->cbFolderThresh = FOLDER_THRESHOLD; - pCabParams->setID = 0xbeef; - pCabParams->iCab = 1; - lstrcpyA(pCabParams->szCabPath, CURR_DIR); - lstrcatA(pCabParams->szCabPath, "\\"); - lstrcpyA(pCabParams->szCab, name); -} - -static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files) -{ - CCAB cabParams; - LPCSTR ptr; - HFCI hfci; - ERF erf; - BOOL res; - - set_cab_parameters(&cabParams, name, max_size); - - hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open, - fci_read, fci_write, fci_close, fci_seek, fci_delete, - get_temp_file, &cabParams, NULL); - - ok(hfci != NULL, "Failed to create an FCI context\n"); - - ptr = files; - while (*ptr) - { - res = add_file(hfci, ptr, tcompTYPE_MSZIP); - ok(res, "Failed to add file: %s\n", ptr); - ptr += lstrlenA(ptr) + 1; - } - - res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress); - ok(res, "Failed to flush the cabinet\n"); - - res = FCIDestroy(hfci); - ok(res, "Failed to destroy the cabinet\n"); -} - static BOOL add_cabinet_storage(LPCSTR db, LPCSTR cabinet) { WCHAR dbW[MAX_PATH], cabinetW[MAX_PATH]; @@ -469,24 +154,6 @@ static BOOL add_cabinet_storage(LPCSTR db, LPCSTR cabinet) return TRUE; } -static void delete_cab_files(void) -{ - SHFILEOPSTRUCTA shfl; - CHAR path[MAX_PATH+10]; - - lstrcpyA(path, CURR_DIR); - lstrcatA(path, "\\*.cab"); - path[strlen(path) + 1] = '\0'; - - shfl.hwnd = NULL; - shfl.wFunc = FO_DELETE; - shfl.pFrom = path; - shfl.pTo = NULL; - shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT; - - SHFileOperationA(&shfl); -} - /* msi database data */ static const char directory_dat[] = @@ -908,15 +575,6 @@ static const char cl_install_exec_seq_dat[] = "InstallValidate\t\t1400\n" "InstallFinalize\t\t5000\n"; -typedef struct _msi_table -{ - const CHAR *filename; - const CHAR *data; - int size; -} msi_table; - -#define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)} - static const msi_table tables[] = { ADD_TABLE(directory), @@ -1043,107 +701,6 @@ static const msi_table cl_tables[] = ADD_TABLE(property) }; -static void write_file(const CHAR *filename, const char *data, int data_size) -{ - DWORD size; - - HANDLE hf = CreateFileA(filename, GENERIC_WRITE, 0, NULL, - CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - WriteFile(hf, data, data_size, &size, NULL); - CloseHandle(hf); -} - -static void write_msi_summary_info(MSIHANDLE db, INT version, INT wordcount, const char *template) -{ - MSIHANDLE summary; - UINT r; - - r = MsiGetSummaryInformationA(db, NULL, 5, &summary); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, template); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL, - "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}"); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, version, NULL, NULL); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, wordcount, NULL, NULL); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST"); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - /* write the summary changes back to the stream */ - r = MsiSummaryInfoPersist(summary); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - MsiCloseHandle(summary); -} - -#define create_database(name, tables, num_tables) \ - create_database_wordcount(name, tables, num_tables, 100, 0, ";1033"); - -#define create_database_template(name, tables, num_tables, version, template) \ - create_database_wordcount(name, tables, num_tables, version, 0, template); - -static void create_database_wordcount(const CHAR *name, const msi_table *tables, - int num_tables, INT version, INT wordcount, - const char *template) -{ - MSIHANDLE db; - UINT r; - WCHAR *nameW; - int j, len; - - len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 ); - if (!(nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return; - MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, len ); - - r = MsiOpenDatabaseW(nameW, MSIDBOPEN_CREATE, &db); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - /* import the tables into the database */ - for (j = 0; j < num_tables; j++) - { - const msi_table *table = &tables[j]; - - write_file(table->filename, table->data, (table->size - 1) * sizeof(char)); - - r = MsiDatabaseImportA(db, CURR_DIR, table->filename); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - DeleteFileA(table->filename); - } - - write_msi_summary_info(db, version, wordcount, template); - - r = MsiDatabaseCommit(db); - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - - MsiCloseHandle(db); - HeapFree( GetProcessHeap(), 0, nameW ); -} - -static UINT run_query(MSIHANDLE hdb, const char *query) -{ - MSIHANDLE hview = 0; - UINT r; - - r = MsiDatabaseOpenViewA(hdb, query, &hview); - if (r != ERROR_SUCCESS) - return r; - - r = MsiViewExecute(hview, 0); - if (r == ERROR_SUCCESS) - r = MsiViewClose(hview); - MsiCloseHandle(hview); - return r; -} - static UINT set_summary_info(MSIHANDLE hdb, LPSTR prodcode) { UINT res; @@ -1207,7 +764,7 @@ static MSIHANDLE create_package_db(LPSTR prodcode) set_summary_info(hdb, prodcode); - res = run_query(hdb, + res = run_query(hdb, 0, "CREATE TABLE `Directory` ( " "`Directory` CHAR(255) NOT NULL, " "`Directory_Parent` CHAR(255), " @@ -1215,7 +772,7 @@ static MSIHANDLE create_package_db(LPSTR prodcode) "PRIMARY KEY `Directory`)"); ok(res == ERROR_SUCCESS , "Failed to create directory table\n"); - res = run_query(hdb, + res = run_query(hdb, 0, "CREATE TABLE `Property` ( " "`Property` CHAR(72) NOT NULL, " "`Value` CHAR(255) " @@ -1225,7 +782,7 @@ static MSIHANDLE create_package_db(LPSTR prodcode) sprintf(query, "INSERT INTO `Property` " "(`Property`, `Value`) " "VALUES( 'ProductCode', '%s' )", prodcode); - res = run_query(hdb, query); + res = run_query(hdb, 0, query); ok(res == ERROR_SUCCESS , "Failed\n"); res = MsiDatabaseCommit(hdb); @@ -1428,39 +985,21 @@ static void test_getcomponentpath(void) ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n"); } -static void create_file(LPCSTR name, LPCSTR data, DWORD size) -{ - HANDLE file; - DWORD written; - - file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name); - WriteFile(file, data, strlen(data), &written, NULL); - - if (size) - { - SetFilePointer(file, size, NULL, FILE_BEGIN); - SetEndOfFile(file); - } - - CloseHandle(file); -} - static void create_test_files(void) { CreateDirectoryA("msitest", NULL); - create_file("msitest\\one.txt", "msitest\\one.txt", 100); + create_file("msitest\\one.txt", 100); CreateDirectoryA("msitest\\first", NULL); - create_file("msitest\\first\\two.txt", "msitest\\first\\two.txt", 100); + create_file("msitest\\first\\two.txt", 100); CreateDirectoryA("msitest\\second", NULL); - create_file("msitest\\second\\three.txt", "msitest\\second\\three.txt", 100); + create_file("msitest\\second\\three.txt", 100); - create_file("four.txt", "four.txt", 100); - create_file("five.txt", "five.txt", 100); + create_file("four.txt", 100); + create_file("five.txt", 100); create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0"); - create_file("msitest\\filename", "msitest\\filename", 100); - create_file("msitest\\service.exe", "msitest\\service.exe", 100); + create_file("msitest\\filename", 100); + create_file("msitest\\service.exe", 100); DeleteFileA("four.txt"); DeleteFileA("five.txt"); @@ -1559,7 +1098,7 @@ static void test_MsiGetFileHash(void) { int ret; - create_file(name, hash_data[i].data, hash_data[i].size); + create_file_data(name, hash_data[i].data, hash_data[i].size); memset(&hash, 0, sizeof(MSIFILEHASHINFO)); hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO); @@ -3030,7 +2569,7 @@ static void test_MsiGetComponentPath(void) ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path); ok(size == 10, "Expected 10, got %d\n", size); - create_file("C:\\imapath", "C:\\imapath", 11); + create_file("C:\\imapath", 11); /* file exists */ path[0] = 'a'; @@ -3134,7 +2673,7 @@ static void test_MsiGetComponentPath(void) ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path); ok(size == 10, "Expected 10, got %d\n", size); - create_file("C:\\imapath", "C:\\imapath", 11); + create_file("C:\\imapath", 11); /* file exists */ path[0] = 0; @@ -3244,7 +2783,7 @@ static void test_MsiGetComponentPath(void) ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path); ok(size == 10, "Expected 10, got %d\n", size); - create_file("C:\\imapath", "C:\\imapath", 11); + create_file("C:\\imapath", 11); /* file exists */ path[0] = 0; @@ -3326,7 +2865,7 @@ static void test_MsiGetComponentPath(void) ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path); ok(size == 10, "Expected 10, got %d\n", size); - create_file("C:\\imapath", "C:\\imapath", 11); + create_file("C:\\imapath", 11); /* file exists */ path[0] = 0; @@ -3403,7 +2942,7 @@ static void test_MsiGetComponentPath(void) ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path); ok(size == 10, "Expected 10, got %d\n", size); - create_file("C:\\imapath", "C:\\imapath", 11); + create_file("C:\\imapath", 11); /* file exists */ path[0] = 0; @@ -3537,7 +3076,7 @@ static void test_MsiGetComponentPathEx(void) ok( !lstrcmpA( path, "c:\\testcomponentpath"), "got %s\n", path ); ok( size == 20, "got %u\n", size ); - create_file( "c:\\testcomponentpath", "c:\\testcomponentpath", 21 ); + create_file( "c:\\testcomponentpath", 21 ); /* file exists */ path[0] = 0; @@ -3600,7 +3139,7 @@ static void test_MsiGetComponentPathEx(void) ok( !lstrcmpA( path, "c:\\testcomponentpath"), "got %s\n", path ); ok( size == 20, "got %u\n", size ); - create_file( "c:\\testcomponentpath", "c:\\testcomponentpath", 21 ); + create_file( "c:\\testcomponentpath", 21 ); /* file exists */ path[0] = 0; @@ -3676,7 +3215,7 @@ static void test_MsiGetComponentPathEx(void) ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path ); ok( size == 20, "got %u\n", size ); - create_file( "c:\\testcomponentpath", "C:\\testcomponentpath", 21 ); + create_file( "c:\\testcomponentpath", 21 ); /* file exists */ path[0] = 0; @@ -3731,7 +3270,7 @@ static void test_MsiGetComponentPathEx(void) ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path ); ok( size == 20, "got %u\n", size ); - create_file( "c:\\testcomponentpath", "c:\\testcomponentpath", 21 ); + create_file( "c:\\testcomponentpath", 21 ); /* file exists */ path[0] = 0; @@ -3773,7 +3312,7 @@ static void test_MsiProvideComponent(void) } create_test_files(); - create_file("msitest\\sourcedir.txt", "msitest\\sourcedir.txt", 1000); + create_file("msitest\\sourcedir.txt", 1000); create_database(msifile, sd_tables, sizeof(sd_tables) / sizeof(msi_table)); MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); @@ -3957,7 +3496,7 @@ static void test_MsiProvideQualifiedComponentEx(void) lstrcatA( path, "\\msitest" ); CreateDirectoryA( path, NULL ); lstrcatA( path, "\\test.txt" ); - create_file( path, "test", 100 ); + create_file_data( path, "test", 100 ); res = RegSetValueExA( hkey5, prod_squashed, 0, REG_SZ, (const BYTE *)path, lstrlenA(path) + 1 ); ok( res == ERROR_SUCCESS, "got %d\n", res ); @@ -4600,7 +4139,7 @@ static void test_MsiGetFileVersion(void) ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r); - create_file("ver.txt", "ver.txt", 20); + create_file("ver.txt", 20); /* file exists, no version information */ r = MsiGetFileVersionA("ver.txt", NULL, NULL, NULL, NULL); @@ -13544,7 +13083,7 @@ static void test_MsiGetFileSignatureInformation(void) hr = MsiGetFileSignatureInformationA( "signature.bin", 0, &cert, NULL, &len ); todo_wine ok(hr == CRYPT_E_FILE_ERROR, "expected CRYPT_E_FILE_ERROR got 0x%08x\n", hr); - create_file( "signature.bin", "signature", sizeof("signature") ); + create_file_data( "signature.bin", "signature", sizeof("signature") ); hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, NULL ); ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr); @@ -13909,9 +13448,9 @@ static void test_MsiConfigureProductEx(void) } CreateDirectoryA("msitest", NULL); - create_file("msitest\\hydrogen", "hydrogen", 500); - create_file("msitest\\helium", "helium", 500); - create_file("msitest\\lithium", "lithium", 500); + create_file_data("msitest\\hydrogen", "hydrogen", 500); + create_file_data("msitest\\helium", "helium", 500); + create_file_data("msitest\\lithium", "lithium", 500); create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table)); @@ -14452,7 +13991,7 @@ static void test_lastusedsource(void) } CreateDirectoryA("msitest", NULL); - create_file("maximus", "maximus", 500); + create_file("maximus", 500); create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0"); DeleteFileA("maximus"); @@ -14576,7 +14115,7 @@ static void test_setpropertyfolder(void) lstrcatA(path, "\\msitest\\added"); CreateDirectoryA("msitest", NULL); - create_file("msitest\\maximus", "msitest\\maximus", 500); + create_file("msitest\\maximus", 500); create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table)); @@ -14620,7 +14159,7 @@ static void test_sourcedir_props(void) } create_test_files(); - create_file("msitest\\sourcedir.txt", "msitest\\sourcedir.txt", 1000); + create_file("msitest\\sourcedir.txt", 1000); create_database(msifile, sd_tables, sizeof(sd_tables) / sizeof(msi_table)); MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL); @@ -14685,8 +14224,8 @@ static void test_concurrentinstall(void) CreateDirectoryA("msitest", NULL); CreateDirectoryA("msitest\\msitest", NULL); - create_file("msitest\\maximus", "msitest\\maximus", 500); - create_file("msitest\\msitest\\augustus", "msitest\\msitest\\augustus", 500); + create_file("msitest\\maximus", 500); + create_file("msitest\\msitest\\augustus", 500); create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table)); diff --git a/modules/rostests/winetests/msi/utils.h b/modules/rostests/winetests/msi/utils.h new file mode 100644 index 00000000000..f16e2d5ff56 --- /dev/null +++ b/modules/rostests/winetests/msi/utils.h @@ -0,0 +1,60 @@ +/* + * Copyright 2018 Zebediah Figura + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +char PROG_FILES_DIR[MAX_PATH]; +char PROG_FILES_DIR_NATIVE[MAX_PATH]; +char COMMON_FILES_DIR[MAX_PATH]; +char APP_DATA_DIR[MAX_PATH]; +char WINDOWS_DIR[MAX_PATH]; +char CURR_DIR[MAX_PATH]; + +BOOL get_system_dirs(void); +BOOL get_user_dirs(void); + +typedef struct _msi_table +{ + const char *filename; + const char *data; + int size; +} msi_table; + +#define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)} + +/* in install.c */ +void create_database_wordcount(const char *name, const msi_table *tables, int num_tables, + int version, int wordcount, const char *template, const char *packagecode); + +#define create_database(name, tables, num_tables) \ + create_database_wordcount(name, tables, num_tables, 100, 0, ";1033", \ + "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}"); + +#define create_database_template(name, tables, num_tables, version, template) \ + create_database_wordcount(name, tables, num_tables, version, 0, template, \ + "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}"); + +void create_cab_file(const char *name, DWORD max_size, const char *files); +void create_file_data(const char *name, const char *data, DWORD size); +#define create_file(name, size) create_file_data(name, name, size) +void create_pf_data(const char *file, const char *data, BOOL is_file); +#define create_pf(file, is_file) create_pf_data(file, file, is_file) +void delete_cab_files(void); +BOOL delete_pf(const char *rel_path, BOOL is_file); +BOOL file_exists(const char *file); +BOOL pf_exists(const char *file); +BOOL is_process_limited(void); +UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query);
2 years, 7 months
1
0
0
0
[reactos] 54/360: [WINESYNC] msi: Avoid leaking custom action data.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0bca61ed833df837a8eed…
commit 0bca61ed833df837a8eed981881f4cc892e85f40 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:13 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:44 2022 +0100 [WINESYNC] msi: Avoid leaking custom action data. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id f4bcd95fa78172a3a07c5f065adf4287fe69af02 by Zebediah Figura <z.figura12(a)gmail.com> --- dll/win32/msi/custom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c index 34486f949a9..3e96aee62c0 100644 --- a/dll/win32/msi/custom.c +++ b/dll/win32/msi/custom.c @@ -610,6 +610,7 @@ static DWORD WINAPI DllThread( LPVOID arg ) info = find_action_by_guid(guid); ret = GetBinaryTypeW(info->source, &arch); + release_custom_action_data(info); if (sizeof(void *) == 8 && ret && arch == SCS_32BIT_BINARY) GetSystemWow64DirectoryW(buffer, MAX_PATH - sizeof(msiexecW)/sizeof(WCHAR));
2 years, 7 months
1
0
0
0
[reactos] 53/360: [WINESYNC] msi: Disable WoW redirection when installing a 64-bit package.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e940ff11f7c381f712a6…
commit 8e940ff11f7c381f712a67f835dea7dc98bf5826 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:12 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:44 2022 +0100 [WINESYNC] msi: Disable WoW redirection when installing a 64-bit package. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 540c48b91175b11c7b8646d0a036b20c46425080 by Zebediah Figura <z.figura12(a)gmail.com> --- dll/win32/msi/action.c | 8 +++ modules/rostests/winetests/msi/install.c | 101 +++++++++++++++++++++++++++++-- 2 files changed, 104 insertions(+), 5 deletions(-) diff --git a/dll/win32/msi/action.c b/dll/win32/msi/action.c index f58a53d4558..dbd08e57db4 100644 --- a/dll/win32/msi/action.c +++ b/dll/win32/msi/action.c @@ -7873,8 +7873,12 @@ StandardActions[] = static UINT ACTION_HandleStandardAction(MSIPACKAGE *package, LPCWSTR action) { UINT rc = ERROR_FUNCTION_NOT_CALLED; + void *cookie; UINT i; + if (is_wow64 && package->platform == PLATFORM_X64) + Wow64DisableWow64FsRedirection(&cookie); + i = 0; while (StandardActions[i].action != NULL) { @@ -7909,6 +7913,10 @@ static UINT ACTION_HandleStandardAction(MSIPACKAGE *package, LPCWSTR action) } i++; } + + if (is_wow64 && package->platform == PLATFORM_X64) + Wow64RevertWow64FsRedirection(cookie); + return rc; } diff --git a/modules/rostests/winetests/msi/install.c b/modules/rostests/winetests/msi/install.c index 5c83d303fa2..ac2c8371e3e 100644 --- a/modules/rostests/winetests/msi/install.c +++ b/modules/rostests/winetests/msi/install.c @@ -48,6 +48,8 @@ static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE ); static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); +static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(void **); +static BOOL (WINAPI *pWow64RevertWow64FsRedirection)(void *); static HMODULE hsrclient = 0; static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD); @@ -1334,6 +1336,18 @@ static const char da_install_exec_seq_dat[] = "immediate\t\t800\n" "InstallFinalize\t\t1100\n"; +static const CHAR x64_directory_dat[] = + "Directory\tDirectory_Parent\tDefaultDir\n" + "s72\tS72\tl255\n" + "Directory\tDirectory\n" + "CABOUTDIR\tMSITESTDIR\tcabout\n" + "CHANGEDDIR\tMSITESTDIR\tchanged:second\n" + "FIRSTDIR\tMSITESTDIR\tfirst\n" + "MSITESTDIR\tProgramFiles64Folder\tmsitest\n" + "NEWDIR\tCABOUTDIR\tnew\n" + "ProgramFiles64Folder\tTARGETDIR\t.\n" + "TARGETDIR\t\tSourceDir"; + typedef struct _msi_table { const CHAR *filename; @@ -2015,6 +2029,18 @@ static const msi_table da_tables[] = ADD_TABLE(da_custom_action), }; +static const msi_table x64_tables[] = +{ + ADD_TABLE(media), + ADD_TABLE(x64_directory), + ADD_TABLE(file), + ADD_TABLE(component), + ADD_TABLE(feature), + ADD_TABLE(feature_comp), + ADD_TABLE(property), + ADD_TABLE(install_exec_seq), +}; + /* cabinet definitions */ /* make the max size large so there is only one cab file */ @@ -2145,6 +2171,8 @@ static void init_functionpointers(void) GET_PROC(hadvapi32, OpenProcessToken); GET_PROC(hadvapi32, RegDeleteKeyExA) GET_PROC(hkernel32, IsWow64Process) + GET_PROC(hkernel32, Wow64DisableWow64FsRedirection); + GET_PROC(hkernel32, Wow64RevertWow64FsRedirection); hsrclient = LoadLibraryA("srclient.dll"); GET_PROC(hsrclient, SRRemoveRestorePoint); @@ -2330,7 +2358,8 @@ static BOOL get_system_dirs(void) HKEY hkey; DWORD type, size; - if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey)) + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", + 0, KEY_QUERY_VALUE | KEY_WOW64_64KEY, &hkey)) return FALSE; size = MAX_PATH; @@ -5693,16 +5722,16 @@ static void test_package_validation(void) r = MsiInstallProductA(msifile, NULL); ok(r == ERROR_INSTALL_PACKAGE_INVALID, "Expected ERROR_INSTALL_PACKAGE_INVALID, got %u\n", r); - ok(!delete_pf_native("msitest\\maximus", TRUE), "file exists\n"); - ok(!delete_pf_native("msitest", FALSE), "directory exists\n"); + ok(!delete_pf("msitest\\maximus", TRUE), "file exists\n"); + ok(!delete_pf("msitest", FALSE), "directory exists\n"); DeleteFileA(msifile); create_database_template(msifile, pv_tables, sizeof(pv_tables)/sizeof(msi_table), 200, "x64;0"); r = MsiInstallProductA(msifile, NULL); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - ok(delete_pf_native("msitest\\maximus", TRUE), "file exists\n"); - ok(delete_pf_native("msitest", FALSE), "directory exists\n"); + ok(delete_pf("msitest\\maximus", TRUE), "file exists\n"); + ok(delete_pf("msitest", FALSE), "directory exists\n"); } else { @@ -6124,6 +6153,67 @@ error: DeleteFileA(msifile); } +static void test_wow64(void) +{ + void *cookie; + UINT r; + + if (!is_wow64) + { + skip("test must be run on WoW64\n"); + return; + } + + if (is_process_limited()) + { + skip("process is limited\n"); + return; + } + + create_test_files(); + create_database_template(msifile, x64_tables, sizeof(x64_tables)/sizeof(msi_table), 200, "x64;0"); + r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } + + pWow64DisableWow64FsRedirection(&cookie); + + ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\first", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\filename", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); + ok(!delete_pf("msitest", FALSE), "Directory created\n"); + + ok(delete_pf_native("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); + ok(delete_pf_native("msitest\\cabout\\new", FALSE), "Directory not created\n"); + ok(delete_pf_native("msitest\\cabout\\four.txt", TRUE), "File not installed\n"); + ok(delete_pf_native("msitest\\cabout", FALSE), "Directory not created\n"); + ok(delete_pf_native("msitest\\changed\\three.txt", TRUE), "File not installed\n"); + ok(delete_pf_native("msitest\\changed", FALSE), "Directory not created\n"); + ok(delete_pf_native("msitest\\first\\two.txt", TRUE), "File not installed\n"); + ok(delete_pf_native("msitest\\first", FALSE), "Directory not created\n"); + ok(delete_pf_native("msitest\\one.txt", TRUE), "File not installed\n"); + ok(delete_pf_native("msitest\\filename", TRUE), "File not installed\n"); + ok(delete_pf_native("msitest\\service.exe", TRUE), "File not installed\n"); + ok(delete_pf_native("msitest", FALSE), "Directory not created\n"); + + pWow64RevertWow64FsRedirection(cookie); + +error: + delete_test_files(); + DeleteFileA(msifile); +} + START_TEST(install) { DWORD len; @@ -6217,6 +6307,7 @@ START_TEST(install) test_remove_upgrade_code(); test_feature_tree(); test_deferred_action(); + test_wow64(); DeleteFileA(customdll);
2 years, 7 months
1
0
0
0
[reactos] 52/360: [WINESYNC] msi: Check return value of GetBinaryType().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8baf528d3fad6eb1f10a6…
commit 8baf528d3fad6eb1f10a6101571efb96f7540aab Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sat Mar 12 15:12:12 2022 +0100 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun Mar 20 19:27:43 2022 +0100 [WINESYNC] msi: Check return value of GetBinaryType(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id deb4f970009d6fd85a61d3183877e67e1ccf66fe by Zebediah Figura <z.figura12(a)gmail.com> --- dll/win32/msi/custom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c index 71f02bb2745..34486f949a9 100644 --- a/dll/win32/msi/custom.c +++ b/dll/win32/msi/custom.c @@ -586,6 +586,7 @@ static DWORD WINAPI DllThread( LPVOID arg ) void *cookie; BOOL wow64; DWORD arch; + BOOL ret; DWORD rc; TRACE("custom action (%x) started\n", GetCurrentThreadId() ); @@ -608,9 +609,9 @@ static DWORD WINAPI DllThread( LPVOID arg ) } info = find_action_by_guid(guid); - GetBinaryTypeW(info->source, &arch); + ret = GetBinaryTypeW(info->source, &arch); - if (sizeof(void *) == 8 && arch == SCS_32BIT_BINARY) + if (sizeof(void *) == 8 && ret && arch == SCS_32BIT_BINARY) GetSystemWow64DirectoryW(buffer, MAX_PATH - sizeof(msiexecW)/sizeof(WCHAR)); else GetSystemDirectoryW(buffer, MAX_PATH - sizeof(msiexecW)/sizeof(WCHAR));
2 years, 7 months
1
0
0
0
← Newer
1
...
32
33
34
35
36
37
38
...
44
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200