winehq.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
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
March 2019
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1097 discussions
Start a n
N
ew thread
Nikolay Sivov : propsys: Add support for VT_CLSID in PropVariantCompareEx( ).
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: 0a508e49d6d9229e6ed31b2ee375eaf2f41adfc5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0a508e49d6d9229e6ed31b2e…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Fri Mar 15 13:56:42 2019 +0300 propsys: Add support for VT_CLSID in PropVariantCompareEx(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/propsys/propvar.c | 9 ++++++++- dlls/propsys/tests/propsys.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c index c56a737..1b2cb15 100644 --- a/dlls/propsys/propvar.c +++ b/dlls/propsys/propvar.c @@ -807,6 +807,9 @@ static BOOL isemptyornull(const PROPVARIANT *propvar) } return i == propvar->u.parray->cDims; } + if (propvar->vt == VT_CLSID) + return !propvar->u.puuid; + /* FIXME: vectors, byrefs, errors? */ return FALSE; } @@ -893,8 +896,12 @@ INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2 else res = lstrcmpA(propvar1->u.pszVal, propvar2_converted->u.pszVal); break; + case VT_CLSID: + res = memcmp(propvar1->u.puuid, propvar2->u.puuid, sizeof(*propvar1->u.puuid)); + if (res) res = res > 0 ? 1 : -1; + break; default: - FIXME("vartype %d not handled\n", propvar1->vt); + FIXME("vartype %#x not handled\n", propvar1->vt); res = -1; break; } diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index c47729e..fab2d5e 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -660,6 +660,7 @@ static void test_PropVariantToStringAlloc(void) static void test_PropVariantCompare(void) { PROPVARIANT empty, null, emptyarray, i2_0, i2_2, i4_large, i4_largeneg, i4_2, str_2, str_02, str_b; + PROPVARIANT clsid_null, clsid, clsid2; INT res; static const WCHAR str_2W[] = {'2', 0}; static const WCHAR str_02W[] = {'0', '2', 0}; @@ -704,6 +705,12 @@ static void test_PropVariantCompare(void) str_02.u.bstrVal = SysAllocString(str_02W); str_b.vt = VT_BSTR; str_b.u.bstrVal = SysAllocString(str_bW); + clsid_null.vt = VT_CLSID; + clsid_null.u.puuid = NULL; + clsid.vt = VT_CLSID; + clsid.u.puuid = (GUID *)&dummy_guid; + clsid2.vt = VT_CLSID; + clsid2.u.puuid = (GUID *)&GUID_NULL; res = PropVariantCompareEx(&empty, &empty, 0, 0); ok(res == 0, "res=%i\n", res); @@ -772,6 +779,34 @@ static void test_PropVariantCompare(void) res = PropVariantCompareEx(&i4_large, &str_b, 0, 0); todo_wine ok(res == -5 /* ??? */, "res=%i\n", res); + /* VT_CLSID */ + res = PropVariantCompareEx(&clsid_null, &clsid_null, 0, 0); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid_null, &clsid_null, 0, PVCF_TREATEMPTYASGREATERTHAN); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid, 0, 0); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid2, 0, 0); + ok(res == 1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid2, &clsid, 0, 0); + ok(res == -1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid_null, &clsid, 0, 0); + ok(res == -1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid_null, 0, 0); + ok(res == 1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid_null, &clsid, 0, PVCF_TREATEMPTYASGREATERTHAN); + ok(res == 1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid_null, 0, PVCF_TREATEMPTYASGREATERTHAN); + ok(res == -1, "res=%i\n", res); + SysFreeString(str_2.u.bstrVal); SysFreeString(str_02.u.bstrVal); SysFreeString(str_b.u.bstrVal);
1
0
0
0
Erich E. Hoover : msidb: Add support for wildcard (full database) export.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: 63e03de9c7f093a536b48f999768b861aa5a60d9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=63e03de9c7f093a536b48f99…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:04:04 2019 +0100 msidb: Add support for wildcard (full database) export. msidb allows a full database export with the special "*" database name. Note: It does not support true wildcards, just this special indication that you wish to export all the tables in the database. Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/msidb/main.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/programs/msidb/main.c b/programs/msidb/main.c index 3916e0d..4bd065a 100644 --- a/programs/msidb/main.c +++ b/programs/msidb/main.c @@ -439,7 +439,7 @@ static int import_table( struct msidb_state *state, const WCHAR *table_name ) WCHAR table_path[MAX_PATH]; UINT ret; - snprintfW( table_path, sizeof(table_path)/sizeof(WCHAR), format, table_name ); + snprintfW( table_path, ARRAY_SIZE(table_path), format, table_name ); ret = MsiDatabaseImportW( state->database_handle, state->table_folder, table_path ); if (ret != ERROR_SUCCESS) { @@ -469,7 +469,7 @@ static int export_table( struct msidb_state *state, const WCHAR *table_name ) WCHAR table_path[MAX_PATH]; UINT ret; - snprintfW( table_path, sizeof(table_path)/sizeof(WCHAR), format, table_name ); + snprintfW( table_path, ARRAY_SIZE(table_path), format, table_name ); ret = MsiDatabaseExportW( state->database_handle, table_name, state->table_folder, table_path ); if (ret != ERROR_SUCCESS) { @@ -479,12 +479,90 @@ static int export_table( struct msidb_state *state, const WCHAR *table_name ) return 1; } +static int export_all_tables( struct msidb_state *state ) +{ + static const WCHAR summary_information[] = + {'_','S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0}; + static const WCHAR query_command[] = + {'S','E','L','E','C','T',' ','N','a','m','e',' ','F','R','O','M',' ','_','T','a','b','l','e','s',0}; + MSIHANDLE view = 0; + UINT ret; + + ret = MsiDatabaseOpenViewW( state->database_handle, query_command, &view ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to open _Tables table.\n" ); + goto cleanup; + } + ret = MsiViewExecute( view, 0 ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to query list from _Tables table.\n" ); + goto cleanup; + } + while( 1 ) + { + MSIHANDLE record = 0; + WCHAR table[256]; + DWORD size; + + ret = MsiViewFetch( view, &record ); + if (ret == ERROR_NO_MORE_ITEMS) + break; + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to query row from _Tables table.\n" ); + goto cleanup; + } + size = ARRAY_SIZE(table); + ret = MsiRecordGetStringW( record, 1, table, &size ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to retrieve name string.\n" ); + goto cleanup; + } + if (!export_table( state, table )) + { + ret = ERROR_FUNCTION_FAILED; + goto cleanup; + } + ret = MsiCloseHandle( record ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to close record handle.\n" ); + goto cleanup; + } + } + ret = ERROR_SUCCESS; + /* the _SummaryInformation table is not listed in _Tables */ + if (!export_table( state, summary_information )) + { + ret = ERROR_FUNCTION_FAILED; + goto cleanup; + } + +cleanup: + if (view && MsiViewClose( view ) != ERROR_SUCCESS) + { + ERR( "Failed to close _Streams table.\n" ); + return 0; + } + return (ret == ERROR_SUCCESS); +} + static int export_tables( struct msidb_state *state ) { + const WCHAR wildcard[] = { '*',0 }; struct msidb_listentry *data; LIST_FOR_EACH_ENTRY( data, &state->table_list, struct msidb_listentry, entry ) { + if (strcmpW( data->name, wildcard ) == 0) + { + if (!export_all_tables( state )) + return 0; /* failed, do not commit changes */ + continue; + } if (!export_table( state, data->name )) return 0; /* failed, do not commit changes */ }
1
0
0
0
Erich E. Hoover : msidb: Add support for exporting with short (DOS) filenames.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: 2820738b290bba49927f579b01af74827f73e2ce URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2820738b290bba49927f579b…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:04:03 2019 +0100 msidb: Add support for exporting with short (DOS) filenames. msidb's "-s" flag modifies the database export to use short (DOS) filenames instead of full table names. This flag is convenient because it uses the same filenames that the import (-i) option expects. For example, the InstallExecuteSequence table gets imported (or exported with this flag) as InstallE.idt where the normal export option uses InstallExecuteSequence.idt. Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/msidb/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/programs/msidb/main.c b/programs/msidb/main.c index 1cb16df..3916e0d 100644 --- a/programs/msidb/main.c +++ b/programs/msidb/main.c @@ -48,6 +48,7 @@ struct msidb_state BOOL create_database; BOOL import_tables; BOOL export_tables; + BOOL short_filenames; struct list add_stream_list; struct list extract_stream_list; struct list kill_stream_list; @@ -92,6 +93,7 @@ static void show_usage( void ) " -f folder Folder in which to open/save the tables.\n" " -i Import tables into database.\n" " -k file.cab Kill (remove) stream/cabinet file from _Streams table.\n" + " -s Export with short filenames (eight character max).\n" " -x file.cab Extract stream/cabinet file from _Streams table.\n" ); } @@ -163,6 +165,9 @@ static int process_argument( struct msidb_state *state, int i, int argc, WCHAR * state->kill_streams = TRUE; list_append( &state->kill_stream_list, argv[i + 1] ); return 2; + case 's': + state->short_filenames = TRUE; + return 1; case 'x': if (i + 1 >= argc) return 0; state->extract_streams = TRUE; @@ -458,7 +463,9 @@ static int import_tables( struct msidb_state *state ) static int export_table( struct msidb_state *state, const WCHAR *table_name ) { - const WCHAR format[] = { '%','s','.','i','d','t',0 }; + const WCHAR format_dos[] = { '%','.','8','s','.','i','d','t',0 }; /* truncate to 8 characters */ + const WCHAR format_full[] = { '%','s','.','i','d','t',0 }; + const WCHAR *format = (state->short_filenames ? format_dos : format_full); WCHAR table_path[MAX_PATH]; UINT ret;
1
0
0
0
Erich E. Hoover : msidb: Add support for exporting database tables.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: e7cc147f9e05543cecf9af01a62559e7c0d2c443 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e7cc147f9e05543cecf9af01…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:04:02 2019 +0100 msidb: Add support for exporting database tables. msidb allows developers to export tables from a database with the "-e" mode flag followed by a list of tables. For example, this call would export three tables to the current directory: msidb -d package.msi -f . -e ActionText Component InstallExecuteSequence Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/msidb/main.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/programs/msidb/main.c b/programs/msidb/main.c index ee79b5c..1cb16df 100644 --- a/programs/msidb/main.c +++ b/programs/msidb/main.c @@ -47,6 +47,7 @@ struct msidb_state BOOL kill_streams; BOOL create_database; BOOL import_tables; + BOOL export_tables; struct list add_stream_list; struct list extract_stream_list; struct list kill_stream_list; @@ -87,6 +88,7 @@ static void show_usage( void ) " -a file.cab Add stream/cabinet file to _Streams table.\n" " -c Create database file (instead of opening existing file).\n" " -d package.msi Path to the database file.\n" + " -e Export tables from database.\n" " -f folder Folder in which to open/save the tables.\n" " -i Import tables into database.\n" " -k file.cab Kill (remove) stream/cabinet file from _Streams table.\n" @@ -108,10 +110,10 @@ static int valid_state( struct msidb_state *state ) show_usage(); return 0; } - if (!state->create_database && !state->import_tables && !state->add_streams - && !state->kill_streams && !state->extract_streams) + if (!state->create_database && !state->import_tables && !state->export_tables + && !state->add_streams&& !state->kill_streams && !state->extract_streams) { - ERR( "No mode flag specified (-a, -c, -i, -k, -x).\n" ); + ERR( "No mode flag specified (-a, -c, -e, -i, -k, -x).\n" ); show_usage(); return 0; } @@ -146,6 +148,9 @@ static int process_argument( struct msidb_state *state, int i, int argc, WCHAR * if (i + 1 >= argc) return 0; state->database_file = argv[i + 1]; return 2; + case 'e': + state->export_tables = TRUE; + return 1; case 'f': if (i + 1 >= argc) return 0; state->table_folder = argv[i + 1]; @@ -451,6 +456,34 @@ static int import_tables( struct msidb_state *state ) return 1; } +static int export_table( struct msidb_state *state, const WCHAR *table_name ) +{ + const WCHAR format[] = { '%','s','.','i','d','t',0 }; + WCHAR table_path[MAX_PATH]; + UINT ret; + + snprintfW( table_path, sizeof(table_path)/sizeof(WCHAR), format, table_name ); + ret = MsiDatabaseExportW( state->database_handle, table_name, state->table_folder, table_path ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to export table '%s', error %d.\n", wine_dbgstr_w(table_name), ret ); + return 0; + } + return 1; +} + +static int export_tables( struct msidb_state *state ) +{ + struct msidb_listentry *data; + + LIST_FOR_EACH_ENTRY( data, &state->table_list, struct msidb_listentry, entry ) + { + if (!export_table( state, data->name )) + return 0; /* failed, do not commit changes */ + } + return 1; +} + int wmain( int argc, WCHAR *argv[] ) { struct msidb_state state; @@ -479,6 +512,8 @@ int wmain( int argc, WCHAR *argv[] ) } if (state.add_streams && !add_streams( &state )) goto cleanup; /* failed, do not commit changes */ + if (state.export_tables && !export_tables( &state )) + goto cleanup; /* failed, do not commit changes */ if (state.extract_streams && !extract_streams( &state )) goto cleanup; /* failed, do not commit changes */ if (state.import_tables && !import_tables( &state ))
1
0
0
0
Erich E. Hoover : msidb: Add support for extracting stream/ cabinet files from MSI databases.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: d4a362dda718543df6cf3d6c24b2a3b0f81928e4 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d4a362dda718543df6cf3d6c…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:04:01 2019 +0100 msidb: Add support for extracting stream/cabinet files from MSI databases. msidb allows developers to extract "streams" (cabinet files) from a database with the "-x" mode flag followed by the filename for the stream in the database, example: msidb -d package.msi -x cabinet.cab Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/msidb/main.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 4 deletions(-) diff --git a/programs/msidb/main.c b/programs/msidb/main.c index e2e4e77..ee79b5c 100644 --- a/programs/msidb/main.c +++ b/programs/msidb/main.c @@ -43,10 +43,12 @@ struct msidb_state WCHAR *table_folder; MSIHANDLE database_handle; BOOL add_streams; + BOOL extract_streams; BOOL kill_streams; BOOL create_database; BOOL import_tables; struct list add_stream_list; + struct list extract_stream_list; struct list kill_stream_list; struct list table_list; }; @@ -88,6 +90,7 @@ static void show_usage( void ) " -f folder Folder in which to open/save the tables.\n" " -i Import tables into database.\n" " -k file.cab Kill (remove) stream/cabinet file from _Streams table.\n" + " -x file.cab Extract stream/cabinet file from _Streams table.\n" ); } @@ -98,20 +101,22 @@ static int valid_state( struct msidb_state *state ) FIXME( "GUI operation is not currently supported.\n" ); return 0; } - if (state->table_folder == NULL && !state->add_streams && !state->kill_streams) + if (state->table_folder == NULL && !state->add_streams && !state->kill_streams + && !state->extract_streams) { ERR( "No table folder specified (-f option).\n" ); show_usage(); return 0; } if (!state->create_database && !state->import_tables && !state->add_streams - && !state->kill_streams) + && !state->kill_streams && !state->extract_streams) { - ERR( "No mode flag specified (-a, -c, -i, -k).\n" ); + ERR( "No mode flag specified (-a, -c, -i, -k, -x).\n" ); show_usage(); return 0; } - if (list_empty( &state->table_list ) && !state->add_streams && !state->kill_streams) + if (list_empty( &state->table_list ) && !state->add_streams && !state->kill_streams + && !state->extract_streams) { ERR( "No tables specified.\n" ); return 0; @@ -153,6 +158,11 @@ static int process_argument( struct msidb_state *state, int i, int argc, WCHAR * state->kill_streams = TRUE; list_append( &state->kill_stream_list, argv[i + 1] ); return 2; + case 'x': + if (i + 1 >= argc) return 0; + state->extract_streams = TRUE; + list_append( &state->extract_stream_list, argv[i + 1] ); + return 2; default: break; } @@ -322,6 +332,97 @@ static int kill_streams( struct msidb_state *state ) return 1; } +static int extract_stream( struct msidb_state *state, const WCHAR *stream_filename ) +{ + static const WCHAR select_command[] = + {'S','E','L','E','C','T',' ','D','a','t','a',' ','F','R','O','M',' ','_','S','t','r','e','a','m','s',' ', + 'W','H','E','R','E',' ','N','a','m','e',' ','=',' ','?',0}; + HANDLE file = INVALID_HANDLE_VALUE; + MSIHANDLE view = 0, record = 0; + DWORD read_size, write_size; + char buffer[1024]; + UINT ret; + + file = CreateFileW( stream_filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL ); + if (file == INVALID_HANDLE_VALUE) + { + ret = ERROR_FILE_NOT_FOUND; + ERR( "Failed to open destination file %s.\n", wine_dbgstr_w(stream_filename) ); + goto cleanup; + } + ret = MsiDatabaseOpenViewW( state->database_handle, select_command, &view ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to open _Streams table.\n" ); + goto cleanup; + } + record = MsiCreateRecord( 1 ); + if (record == 0) + { + ERR( "Failed to create MSI record.\n" ); + ret = ERROR_OUTOFMEMORY; + goto cleanup; + } + ret = MsiRecordSetStringW( record, 1, stream_filename ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to add stream filename to MSI record.\n" ); + goto cleanup; + } + ret = MsiViewExecute( view, record ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to query stream from _Streams table.\n" ); + goto cleanup; + } + MsiCloseHandle( record ); + record = 0; + ret = MsiViewFetch( view, &record ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to query row from _Streams table.\n" ); + goto cleanup; + } + read_size = sizeof(buffer); + while (read_size == sizeof(buffer)) + { + ret = MsiRecordReadStream( record, 1, buffer, &read_size ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to read stream from _Streams table.\n" ); + goto cleanup; + } + if (!WriteFile( file, buffer, read_size, &write_size, NULL ) || read_size != write_size) + { + ret = ERROR_WRITE_FAULT; + ERR( "Failed to write stream to destination file.\n" ); + goto cleanup; + } + } + +cleanup: + if (record) + MsiCloseHandle( record ); + if (view) + MsiViewClose( view ); + if (file != INVALID_HANDLE_VALUE) + CloseHandle( file ); + return (ret == ERROR_SUCCESS); +} + +static int extract_streams( struct msidb_state *state ) +{ + struct msidb_listentry *data; + + LIST_FOR_EACH_ENTRY( data, &state->extract_stream_list, struct msidb_listentry, entry ) + { + if (!extract_stream( state, data->name )) + return 0; /* failed, do not commit changes */ + } + return 1; +} + static int import_table( struct msidb_state *state, const WCHAR *table_name ) { const WCHAR format[] = { '%','.','8','s','.','i','d','t',0 }; /* truncate to 8 characters */ @@ -358,6 +459,7 @@ int wmain( int argc, WCHAR *argv[] ) memset( &state, 0x0, sizeof(state) ); list_init( &state.add_stream_list ); + list_init( &state.extract_stream_list ); list_init( &state.kill_stream_list ); list_init( &state.table_list ); /* process and validate all the command line flags */ @@ -377,6 +479,8 @@ int wmain( int argc, WCHAR *argv[] ) } if (state.add_streams && !add_streams( &state )) goto cleanup; /* failed, do not commit changes */ + if (state.extract_streams && !extract_streams( &state )) + goto cleanup; /* failed, do not commit changes */ if (state.import_tables && !import_tables( &state )) goto cleanup; /* failed, do not commit changes */ if (state.kill_streams && !kill_streams( &state )) @@ -386,6 +490,7 @@ int wmain( int argc, WCHAR *argv[] ) cleanup: close_database( &state, ret == 0 ); list_free( &state.add_stream_list ); + list_free( &state.extract_stream_list ); list_free( &state.kill_stream_list ); list_free( &state.table_list ); return ret;
1
0
0
0
Erich E. Hoover : msidb: Add support for removing stream/ cabinet files from MSI databases.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: 0cf6cd00ce15b3a8dc5ef08aa79cdbe61e2b996d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0cf6cd00ce15b3a8dc5ef08a…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:04:00 2019 +0100 msidb: Add support for removing stream/cabinet files from MSI databases. msidb allows developers to remove "streams" (cabinet files) from a database with the "-k" mode flag followed by the filename for the stream in the database, example: msidb -d package.msi -k cabinet.cab Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/msidb/main.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/programs/msidb/main.c b/programs/msidb/main.c index d837299..e2e4e77 100644 --- a/programs/msidb/main.c +++ b/programs/msidb/main.c @@ -43,9 +43,11 @@ struct msidb_state WCHAR *table_folder; MSIHANDLE database_handle; BOOL add_streams; + BOOL kill_streams; BOOL create_database; BOOL import_tables; struct list add_stream_list; + struct list kill_stream_list; struct list table_list; }; @@ -85,6 +87,7 @@ static void show_usage( void ) " -d package.msi Path to the database file.\n" " -f folder Folder in which to open/save the tables.\n" " -i Import tables into database.\n" + " -k file.cab Kill (remove) stream/cabinet file from _Streams table.\n" ); } @@ -95,19 +98,20 @@ static int valid_state( struct msidb_state *state ) FIXME( "GUI operation is not currently supported.\n" ); return 0; } - if (state->table_folder == NULL && !state->add_streams) + if (state->table_folder == NULL && !state->add_streams && !state->kill_streams) { ERR( "No table folder specified (-f option).\n" ); show_usage(); return 0; } - if (!state->create_database && !state->import_tables && !state->add_streams) + if (!state->create_database && !state->import_tables && !state->add_streams + && !state->kill_streams) { - ERR( "No mode flag specified (-a, -c, -i).\n" ); + ERR( "No mode flag specified (-a, -c, -i, -k).\n" ); show_usage(); return 0; } - if (list_empty( &state->table_list ) && !state->add_streams) + if (list_empty( &state->table_list ) && !state->add_streams && !state->kill_streams) { ERR( "No tables specified.\n" ); return 0; @@ -144,6 +148,11 @@ static int process_argument( struct msidb_state *state, int i, int argc, WCHAR * case 'i': state->import_tables = TRUE; return 1; + case 'k': + if (i + 1 >= argc) return 0; + state->kill_streams = TRUE; + list_append( &state->kill_stream_list, argv[i + 1] ); + return 2; default: break; } @@ -199,11 +208,13 @@ static const WCHAR *basenameW( const WCHAR *filename ) static int add_stream( struct msidb_state *state, const WCHAR *stream_filename ) { - static const char insert_command[] = "INSERT INTO _Streams (Name, Data) VALUES (?, ?)"; + static const WCHAR insert_command[] = + {'I','N','S','E','R','T',' ','I','N','T','O',' ','_','S','t','r','e','a','m','s',' ', + '(','N','a','m','e',',',' ','D','a','t','a',')',' ','V','A','L','U','E','S',' ','(','?',',',' ','?',')',0}; MSIHANDLE view = 0, record = 0; UINT ret; - ret = MsiDatabaseOpenViewA( state->database_handle, insert_command, &view ); + ret = MsiDatabaseOpenViewW( state->database_handle, insert_command, &view ); if (ret != ERROR_SUCCESS) { ERR( "Failed to open _Streams table.\n" ); @@ -256,6 +267,61 @@ static int add_streams( struct msidb_state *state ) return 1; } +static int kill_stream( struct msidb_state *state, const WCHAR *stream_filename ) +{ + static const WCHAR delete_command[] = + {'D','E','L','E','T','E',' ','F','R','O','M',' ','_','S','t','r','e','a','m','s',' ', + 'W','H','E','R','E',' ','N','a','m','e',' ','=',' ','?',0}; + MSIHANDLE view = 0, record = 0; + UINT ret; + + ret = MsiDatabaseOpenViewW( state->database_handle, delete_command, &view ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to open _Streams table.\n" ); + goto cleanup; + } + record = MsiCreateRecord( 1 ); + if (record == 0) + { + ERR( "Failed to create MSI record.\n" ); + ret = ERROR_OUTOFMEMORY; + goto cleanup; + } + ret = MsiRecordSetStringW( record, 1, stream_filename ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to add stream filename to MSI record.\n" ); + goto cleanup; + } + ret = MsiViewExecute( view, record ); + if (ret != ERROR_SUCCESS) + { + ERR( "Failed to delete stream from _Streams table.\n" ); + goto cleanup; + } + +cleanup: + if (record) + MsiCloseHandle( record ); + if (view) + MsiViewClose( view ); + + return (ret == ERROR_SUCCESS); +} + +static int kill_streams( struct msidb_state *state ) +{ + struct msidb_listentry *data; + + LIST_FOR_EACH_ENTRY( data, &state->kill_stream_list, struct msidb_listentry, entry ) + { + if (!kill_stream( state, data->name )) + return 0; /* failed, do not commit changes */ + } + return 1; +} + static int import_table( struct msidb_state *state, const WCHAR *table_name ) { const WCHAR format[] = { '%','.','8','s','.','i','d','t',0 }; /* truncate to 8 characters */ @@ -292,6 +358,7 @@ int wmain( int argc, WCHAR *argv[] ) memset( &state, 0x0, sizeof(state) ); list_init( &state.add_stream_list ); + list_init( &state.kill_stream_list ); list_init( &state.table_list ); /* process and validate all the command line flags */ for (i = 1; n && i < argc; i += n) @@ -312,11 +379,14 @@ int wmain( int argc, WCHAR *argv[] ) goto cleanup; /* failed, do not commit changes */ if (state.import_tables && !import_tables( &state )) goto cleanup; /* failed, do not commit changes */ + if (state.kill_streams && !kill_streams( &state )) + goto cleanup; /* failed, do not commit changes */ ret = 0; cleanup: close_database( &state, ret == 0 ); list_free( &state.add_stream_list ); + list_free( &state.kill_stream_list ); list_free( &state.table_list ); return ret; }
1
0
0
0
Erich E. Hoover : msi: Add support for exporting binary streams (Binary/ Icon tables).
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: f1d8218169715fcb64d4c6d81be7ead9d8bbf6ed URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f1d8218169715fcb64d4c6d8…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:03:59 2019 +0100 msi: Add support for exporting binary streams (Binary/Icon tables). The Binary and Icon tables store their data in a different format from other tables, one column of the data is stored as a "stream" instead of a normal text field. With this patch those tables can now be exported properly by the MSI export functionality. Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/database.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index f302610..4537ed5 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -961,8 +961,68 @@ static UINT msi_export_field( HANDLE handle, MSIRECORD *row, UINT field ) return ret ? ERROR_SUCCESS : ERROR_FUNCTION_FAILED; } -static UINT msi_export_record( HANDLE handle, MSIRECORD *row, UINT start ) +static UINT msi_export_stream( const WCHAR *folder, const WCHAR *table, MSIRECORD *row, UINT field, UINT start ) { + static const WCHAR fmt[] = {'%','s','\\','%','s',0}; + WCHAR stream[MAX_STREAM_NAME_LEN + 1], *path; + DWORD sz, read_size, write_size; + char buffer[1024]; + HANDLE file; + UINT len, r; + + sz = ARRAY_SIZE( stream ); + r = MSI_RecordGetStringW( row, start, stream, &sz ); + if (r != ERROR_SUCCESS) + return r; + + len = (sz + strlenW( folder ) + strlenW( table ) + ARRAY_SIZE( fmt ) + 1) * sizeof(WCHAR); + if (!(path = msi_alloc( len ))) + return ERROR_OUTOFMEMORY; + + len = sprintfW( path, fmt, folder, table ); + if (!CreateDirectoryW( path, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS) + { + msi_free( path ); + return ERROR_FUNCTION_FAILED; + } + + path[len++] = '\\'; + strcpyW( path + len, stream ); + file = CreateFileW( path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); + msi_free( path ); + if (file == INVALID_HANDLE_VALUE) + return ERROR_FUNCTION_FAILED; + + read_size = sizeof(buffer); + while (read_size == sizeof(buffer)) + { + r = MSI_RecordReadStream( row, field, buffer, &read_size ); + if (r != ERROR_SUCCESS) + { + CloseHandle( file ); + return r; + } + if (!WriteFile( file, buffer, read_size, &write_size, NULL ) || read_size != write_size) + { + CloseHandle( file ); + return ERROR_WRITE_FAULT; + } + } + CloseHandle( file ); + return r; +} + +struct row_export_info +{ + HANDLE handle; + const WCHAR *folder; + const WCHAR *table; +}; + +static UINT msi_export_record( struct row_export_info *row_export_info, MSIRECORD *row, UINT start ) +{ + HANDLE handle = row_export_info->handle; UINT i, count, r = ERROR_SUCCESS; const char *sep; DWORD sz; @@ -971,7 +1031,18 @@ static UINT msi_export_record( HANDLE handle, MSIRECORD *row, UINT start ) for (i = start; i <= count; i++) { r = msi_export_field( handle, row, i ); - if (r != ERROR_SUCCESS) + if (r == ERROR_INVALID_PARAMETER) + { + r = msi_export_stream( row_export_info->folder, row_export_info->table, row, i, start ); + if (r != ERROR_SUCCESS) + return r; + + /* exporting a binary stream, repeat the "Name" field */ + r = msi_export_field( handle, row, start ); + if (r != ERROR_SUCCESS) + return r; + } + else if (r != ERROR_SUCCESS) return r; sep = (i < count) ? "\t" : "\r\n"; @@ -1062,11 +1133,13 @@ static UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table, LPCWSTR folder, r = MSI_OpenQuery( db, &view, query, table ); if (r == ERROR_SUCCESS) { + struct row_export_info row_export_info = { handle, folder, table }; + /* write out row 1, the column names */ r = MSI_ViewGetColumnInfo(view, MSICOLINFO_NAMES, &rec); if (r == ERROR_SUCCESS) { - msi_export_record( handle, rec, 1 ); + msi_export_record( &row_export_info, rec, 1 ); msiobj_release( &rec->hdr ); } @@ -1074,7 +1147,7 @@ static UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table, LPCWSTR folder, r = MSI_ViewGetColumnInfo(view, MSICOLINFO_TYPES, &rec); if (r == ERROR_SUCCESS) { - msi_export_record( handle, rec, 1 ); + msi_export_record( &row_export_info, rec, 1 ); msiobj_release( &rec->hdr ); } @@ -1083,12 +1156,12 @@ static UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table, LPCWSTR folder, if (r == ERROR_SUCCESS) { MSI_RecordSetStringW( rec, 0, table ); - msi_export_record( handle, rec, 0 ); + msi_export_record( &row_export_info, rec, 0 ); msiobj_release( &rec->hdr ); } /* write out row 4 onwards, the data */ - r = MSI_IterateRecords( view, 0, msi_export_row, handle ); + r = MSI_IterateRecords( view, 0, msi_export_row, &row_export_info ); msiobj_release( &view->hdr ); }
1
0
0
0
Erich E. Hoover : msi: Break out field exporting into a separate routine.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: b08d9998635137475dae335f8b45c909274d3001 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b08d9998635137475dae335f…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:03:58 2019 +0100 msi: Break out field exporting into a separate routine. msi_export_record is a lot more complicated than necessary, this patch splits out the field export part of that functionality as msi_export_field. This also needs to be separate for exporting binary stream data (next patch). Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/database.c | 74 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 589dce5..f302610 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -918,50 +918,66 @@ end: return r; } -static UINT msi_export_record( HANDLE handle, MSIRECORD *row, UINT start ) +static UINT msi_export_field( HANDLE handle, MSIRECORD *row, UINT field ) { - UINT i, count, len, r = ERROR_SUCCESS; - const char *sep; char *buffer; - DWORD sz; + BOOL ret; + DWORD sz = 0x100; + UINT r; - len = 0x100; - buffer = msi_alloc( len ); - if ( !buffer ) + buffer = msi_alloc( sz ); + if (!buffer) return ERROR_OUTOFMEMORY; - count = MSI_RecordGetFieldCount( row ); - for ( i=start; i<=count; i++ ) + r = MSI_RecordGetStringA( row, field, buffer, &sz ); + if (r == ERROR_MORE_DATA) { - sz = len; - r = MSI_RecordGetStringA( row, i, buffer, &sz ); - if (r == ERROR_MORE_DATA) + char *tmp; + + sz++; /* leave room for NULL terminator */ + tmp = msi_realloc( buffer, sz ); + if (!tmp) { - char *p = msi_realloc( buffer, sz + 1 ); - if (!p) - break; - len = sz + 1; - buffer = p; + msi_free( buffer ); + return ERROR_OUTOFMEMORY; } - sz = len; - r = MSI_RecordGetStringA( row, i, buffer, &sz ); - if (r != ERROR_SUCCESS) - break; + buffer = tmp; - if (!WriteFile( handle, buffer, sz, &sz, NULL )) + r = MSI_RecordGetStringA( row, field, buffer, &sz ); + if (r != ERROR_SUCCESS) { - r = ERROR_FUNCTION_FAILED; - break; + msi_free( buffer ); + return r; } + } + else if (r != ERROR_SUCCESS) + { + msi_free( buffer ); + return r; + } + + ret = WriteFile( handle, buffer, sz, &sz, NULL ); + msi_free( buffer ); + return ret ? ERROR_SUCCESS : ERROR_FUNCTION_FAILED; +} + +static UINT msi_export_record( HANDLE handle, MSIRECORD *row, UINT start ) +{ + UINT i, count, r = ERROR_SUCCESS; + const char *sep; + DWORD sz; + + count = MSI_RecordGetFieldCount( row ); + for (i = start; i <= count; i++) + { + r = msi_export_field( handle, row, i ); + if (r != ERROR_SUCCESS) + return r; sep = (i < count) ? "\t" : "\r\n"; if (!WriteFile( handle, sep, strlen(sep), &sz, NULL )) - { - r = ERROR_FUNCTION_FAILED; - break; - } + return ERROR_FUNCTION_FAILED; } - msi_free( buffer ); return r; }
1
0
0
0
Erich E. Hoover : msi: Add support for exporting the _SummaryInformation table.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: 79fd42fc1ae0747f509fce05cedf9e56c9f928bc URL:
https://source.winehq.org/git/wine.git/?a=commit;h=79fd42fc1ae0747f509fce05…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:03:57 2019 +0100 msi: Add support for exporting the _SummaryInformation table. The _SummaryInformation table stores a lot of important information about an MSI database. This patch adds the ability to export that table since, like _ForceCodepage, it is stored in a different format than the other tables. Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/database.c | 29 +++++++++++--- dlls/msi/msipriv.h | 1 + dlls/msi/suminfo.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 6 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index b8ec393..589dce5 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -974,24 +974,35 @@ static UINT msi_export_forcecodepage( HANDLE handle, UINT codepage ) { static const char fmt[] = "\r\n\r\n%u\t_ForceCodepage\r\n"; char data[sizeof(fmt) + 10]; - DWORD sz; - - sprintf( data, fmt, codepage ); + DWORD sz = sprintf( data, fmt, codepage ); - sz = lstrlenA(data) + 1; if (!WriteFile(handle, data, sz, &sz, NULL)) return ERROR_FUNCTION_FAILED; return ERROR_SUCCESS; } -static UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table, - LPCWSTR folder, LPCWSTR file ) +static UINT msi_export_summaryinformation( MSIDATABASE *db, HANDLE handle ) +{ + static const char header[] = "PropertyId\tValue\r\n" + "i2\tl255\r\n" + "_SummaryInformation\tPropertyId\r\n"; + DWORD sz = ARRAY_SIZE(header) - 1; + + if (!WriteFile(handle, header, sz, &sz, NULL)) + return ERROR_WRITE_FAULT; + + return msi_export_suminfo( db, handle ); +} + +static UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table, LPCWSTR folder, LPCWSTR file ) { static const WCHAR query[] = { 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','%','s',0 }; static const WCHAR forcecodepage[] = { '_','F','o','r','c','e','C','o','d','e','p','a','g','e',0 }; + static const WCHAR summaryinformation[] = { + '_','S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0 }; MSIRECORD *rec = NULL; MSIQUERY *view = NULL; LPWSTR filename; @@ -1026,6 +1037,12 @@ static UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table, goto done; } + if (!strcmpW( table, summaryinformation )) + { + r = msi_export_summaryinformation( db, handle ); + goto done; + } + r = MSI_OpenQuery( db, &view, query, table ); if (r == ERROR_SUCCESS) { diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 4b2b65a..39219a6 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -961,6 +961,7 @@ extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty ) DECL extern INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty ) DECLSPEC_HIDDEN; extern LPWSTR msi_get_suminfo_product( IStorage *stg ) DECLSPEC_HIDDEN; extern UINT msi_add_suminfo( MSIDATABASE *db, LPWSTR **records, int num_records, int num_columns ) DECLSPEC_HIDDEN; +extern UINT msi_export_suminfo( MSIDATABASE *db, HANDLE handle ) DECLSPEC_HIDDEN; extern UINT msi_load_suminfo_properties( MSIPACKAGE *package ) DECLSPEC_HIDDEN; /* undocumented functions */ diff --git a/dlls/msi/suminfo.c b/dlls/msi/suminfo.c index 98f6330..c812ae0 100644 --- a/dlls/msi/suminfo.c +++ b/dlls/msi/suminfo.c @@ -23,6 +23,7 @@ #define COBJMACROS #define NONAMELESSUNION +#include "stdio.h" #include "windef.h" #include "winbase.h" #include "winreg.h" @@ -1096,6 +1097,114 @@ end: return r; } +static UINT save_prop( MSISUMMARYINFO *si, HANDLE handle, UINT row ) +{ + static const char fmt_systemtime[] = "%04u/%02u/%02u %02u:%02u:%02u"; + char data[36]; /* largest string: YYYY/MM/DD hh:mm:ss */ + static const char fmt_begin[] = "%u\t"; + static const char data_end[] = "\r\n"; + static const char fmt_int[] = "%u"; + UINT r, data_type, len; + SYSTEMTIME system_time; + FILETIME file_time; + INT int_value; + awstring str; + DWORD sz; + + str.unicode = FALSE; + str.str.a = NULL; + len = 0; + r = get_prop( si, row, &data_type, &int_value, &file_time, &str, &len ); + if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA) + return r; + if (data_type == VT_EMPTY) + return ERROR_SUCCESS; /* property not set */ + sz = sprintf( data, fmt_begin, row ); + if (!WriteFile( handle, data, sz, &sz, NULL )) + return ERROR_WRITE_FAULT; + + switch( data_type ) + { + case VT_I2: + case VT_I4: + sz = sprintf( data, fmt_int, int_value ); + if (!WriteFile( handle, data, sz, &sz, NULL )) + return ERROR_WRITE_FAULT; + break; + case VT_LPSTR: + len++; + if (!(str.str.a = msi_alloc( len ))) + return ERROR_OUTOFMEMORY; + r = get_prop( si, row, NULL, NULL, NULL, &str, &len ); + if (r != ERROR_SUCCESS) + { + msi_free( str.str.a ); + return r; + } + sz = len; + if (!WriteFile( handle, str.str.a, sz, &sz, NULL )) + { + msi_free( str.str.a ); + return ERROR_WRITE_FAULT; + } + msi_free( str.str.a ); + break; + case VT_FILETIME: + if (!FileTimeToSystemTime( &file_time, &system_time )) + return ERROR_FUNCTION_FAILED; + sz = sprintf( data, fmt_systemtime, system_time.wYear, system_time.wMonth, + system_time.wDay, system_time.wHour, system_time.wMinute, + system_time.wSecond ); + if (!WriteFile( handle, data, sz, &sz, NULL )) + return ERROR_WRITE_FAULT; + break; + case VT_EMPTY: + /* cannot reach here, property not set */ + break; + default: + FIXME( "Unknown property variant type\n" ); + return ERROR_FUNCTION_FAILED; + } + + sz = ARRAY_SIZE(data_end) - 1; + if (!WriteFile( handle, data_end, sz, &sz, NULL )) + return ERROR_WRITE_FAULT; + + return ERROR_SUCCESS; +} + +UINT msi_export_suminfo( MSIDATABASE *db, HANDLE handle ) +{ + UINT i, r, num_rows; + MSISUMMARYINFO *si; + + r = msi_get_suminfo( db->storage, 0, &si ); + if (r != ERROR_SUCCESS) + r = msi_get_db_suminfo( db, 0, &si ); + if (r != ERROR_SUCCESS) + return r; + + num_rows = get_property_count( si->property ); + if (!num_rows) + { + msiobj_release( &si->hdr ); + return ERROR_FUNCTION_FAILED; + } + + for (i = 0; i < num_rows; i++) + { + r = save_prop( si, handle, i ); + if (r != ERROR_SUCCESS) + { + msiobj_release( &si->hdr ); + return r; + } + } + + msiobj_release( &si->hdr ); + return ERROR_SUCCESS; +} + UINT WINAPI MsiSummaryInfoPersist( MSIHANDLE handle ) { MSISUMMARYINFO *si;
1
0
0
0
Erich E. Hoover : msi: Add support for deleting streams from an MSI database.
by Alexandre Julliard
15 Mar '19
15 Mar '19
Module: wine Branch: master Commit: 51d5242a5fa07a76077f2318fbbff968d760389d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=51d5242a5fa07a76077f2318…
Author: Erich E. Hoover <erich.e.hoover(a)gmail.com> Date: Fri Mar 15 10:03:56 2019 +0100 msi: Add support for deleting streams from an MSI database. msidb allows developers to remove "streams" (cabinet files) from a database with the "-k" mode flag. To support that feature we need MSIMODIFY_DELETE support in the underlying MSI implementation. Signed-off-by: Erich E. Hoover <erich.e.hoover(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/streams.c | 29 +++++++++++++++++--- dlls/msi/tests/db.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index cfce816..777eb98 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -218,8 +218,28 @@ static UINT STREAMS_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row static UINT STREAMS_delete_row(struct tagMSIVIEW *view, UINT row) { - FIXME("(%p %d): stub!\n", view, row); - return ERROR_SUCCESS; + MSIDATABASE *db = ((MSISTREAMSVIEW *)view)->db; + UINT i, num_rows = db->num_streams - 1; + const WCHAR *name; + WCHAR *encname; + HRESULT hr; + + TRACE("(%p %d)\n", view, row); + + if (!db->num_streams || row > num_rows) + return ERROR_FUNCTION_FAILED; + + name = msi_string_lookup( db->strings, db->streams[row].str_index, NULL ); + if (!(encname = encode_streamname( FALSE, name ))) return ERROR_OUTOFMEMORY; + IStream_Release( db->streams[row].stream ); + + for (i = row; i < num_rows; i++) + db->streams[i] = db->streams[i + 1]; + db->num_streams = num_rows; + + hr = IStorage_DestroyElement( db->storage, encname ); + msi_free( encname ); + return FAILED( hr ) ? ERROR_FUNCTION_FAILED : ERROR_SUCCESS; } static UINT STREAMS_execute(struct tagMSIVIEW *view, MSIRECORD *record) @@ -317,12 +337,15 @@ static UINT STREAMS_modify(struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRE r = streams_modify_update(view, rec); break; + case MSIMODIFY_DELETE: + r = STREAMS_delete_row(view, row - 1); + break; + case MSIMODIFY_VALIDATE_NEW: case MSIMODIFY_INSERT_TEMPORARY: case MSIMODIFY_REFRESH: case MSIMODIFY_REPLACE: case MSIMODIFY_MERGE: - case MSIMODIFY_DELETE: case MSIMODIFY_VALIDATE: case MSIMODIFY_VALIDATE_FIELD: case MSIMODIFY_VALIDATE_DELETE: diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 0382e54..9fbf43e 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -1779,6 +1779,84 @@ static void test_streamtable(void) MsiCloseHandle( view ); MsiCloseHandle( hdb ); DeleteFileA(msifile); + + /* insert a file into the _Streams table */ + r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATEDIRECT, &hdb); + ok(r == ERROR_SUCCESS, "Failed to create database\n"); + ok( hdb, "failed to create db\n"); + create_file( "test.txt" ); + rec = MsiCreateRecord( 2 ); + MsiRecordSetStringA( rec, 1, "data" ); + r = MsiRecordSetStreamA( rec, 2, "test.txt" ); + ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r); + DeleteFileA("test.txt"); + r = MsiDatabaseOpenViewA( hdb, + "INSERT INTO `_Streams` ( `Name`, `Data` ) VALUES ( ?, ? )", &view ); + ok( r == ERROR_SUCCESS, "Failed to open database view: %d\n", r); + r = MsiViewExecute( view, rec ); + ok( r == ERROR_SUCCESS, "Failed to execute view: %d\n", r); + MsiCloseHandle( rec ); + MsiViewClose( view ); + MsiCloseHandle( view ); + r = MsiDatabaseCommit( hdb ); + ok( r == ERROR_SUCCESS , "Failed to commit database\n" ); + + /* open a handle to the "data" stream */ + r = MsiDatabaseOpenViewA( hdb, + "SELECT `Name`, `Data` FROM `_Streams` WHERE `Name` = 'data'", &view ); + ok( r == ERROR_SUCCESS, "Failed to open database view: %d\n", r); + r = MsiViewExecute( view, 0 ); + ok( r == ERROR_SUCCESS, "Failed to execute view: %d\n", r); + r = MsiViewFetch( view, &rec ); + ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + MsiViewClose( view ); + MsiCloseHandle( view ); + /* read the stream while it still exists (normal case) */ + size = MAX_PATH; + r = MsiRecordGetStringA( rec, 1, file, &size ); + ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r); + ok( !lstrcmpA(file, "data"), "Expected 'data', got %s\n", file); + size = MAX_PATH; + memset(buf, 0, MAX_PATH); + r = MsiRecordReadStream( rec, 2, buf, &size ); + ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r); + ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\\n', got '%s' (%d)\n", buf, size); + MsiCloseHandle( rec ); + + /* open a handle to the "data" stream (and keep it open during removal) */ + r = MsiDatabaseOpenViewA( hdb, + "SELECT `Name`, `Data` FROM `_Streams` WHERE `Name` = 'data'", &view ); + ok( r == ERROR_SUCCESS, "Failed to open database view: %d\n", r); + r = MsiViewExecute( view, 0 ); + ok( r == ERROR_SUCCESS, "Failed to execute view: %d\n", r); + r = MsiViewFetch( view, &rec ); + ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + MsiViewClose( view ); + MsiCloseHandle( view ); + + /* remove the stream */ + r = MsiDatabaseOpenViewA( hdb, + "DELETE FROM `_Streams` WHERE `Name` = 'data'", &view ); + ok( r == ERROR_SUCCESS, "Failed to open database view: %d\n", r); + r = MsiViewExecute( view, 0 ); + ok( r == ERROR_SUCCESS, "Failed to execute view: %d\n", r); + MsiViewClose( view ); + MsiCloseHandle( view ); + + /* attempt to read the stream that no longer exists (abnormal case) */ + size = MAX_PATH; + r = MsiRecordGetStringA( rec, 1, file, &size ); + ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r); + ok( !lstrcmpA(file, "data"), "Expected 'data', got %s\n", file); + size = MAX_PATH; + memset(buf, 0, MAX_PATH); + r = MsiRecordReadStream( rec, 2, buf, &size ); + ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r); + todo_wine ok( size == 0, "Expected empty buffer, got %d bytes\n", size); + MsiCloseHandle( rec ); + + MsiCloseHandle( hdb ); + DeleteFileA(msifile); } static void test_binary(void)
1
0
0
0
← Newer
1
...
41
42
43
44
45
46
47
...
110
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Results per page:
10
25
50
100
200