From b71dcee6b2168a2436555a0560a24a1ffac86575 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 30 Apr 2016 23:41:04 +0200 Subject: [PATCH] Added patch to improve wmic cmd line parser and add support for path command. --- patches/patchinstall.sh | 16 ++ ...-line-parser-and-add-support-for-pat.patch | 138 ++++++++++++++++++ patches/wmic-Query_Path/definition | 1 + 3 files changed, 155 insertions(+) create mode 100644 patches/wmic-Query_Path/0001-wmic-Improve-cmd-line-parser-and-add-support-for-pat.patch create mode 100644 patches/wmic-Query_Path/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 66716a89..78060b28 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -383,6 +383,7 @@ patch_enable_all () enable_winmm_mciSendCommandA="$1" enable_winspool_drv_SetPrinterW="$1" enable_wintrust_WinVerifyTrust="$1" + enable_wmic_Query_Path="$1" enable_wpcap_Dynamic_Linking="$1" enable_wpcap_Several_Fixes="$1" enable_ws2_32_APC_Performance="$1" @@ -1317,6 +1318,9 @@ patch_enable () wintrust-WinVerifyTrust) enable_wintrust_WinVerifyTrust="$2" ;; + wmic-Query_Path) + enable_wmic_Query_Path="$2" + ;; wpcap-Dynamic_Linking) enable_wpcap_Dynamic_Linking="$2" ;; @@ -7512,6 +7516,18 @@ if test "$enable_wintrust_WinVerifyTrust" -eq 1; then ) >> "$patchlist" fi +# Patchset wmic-Query_Path +# | +# | Modified files: +# | * programs/wmic/main.c, programs/wmic/wmic.h, programs/wmic/wmic.rc +# | +if test "$enable_wmic_Query_Path" -eq 1; then + patch_apply wmic-Query_Path/0001-wmic-Improve-cmd-line-parser-and-add-support-for-pat.patch + ( + echo '+ { "Michael Müller", "wmic: Improve cmd line parser and add support for path command.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wpcap-Several_Fixes # | # | Modified files: diff --git a/patches/wmic-Query_Path/0001-wmic-Improve-cmd-line-parser-and-add-support-for-pat.patch b/patches/wmic-Query_Path/0001-wmic-Improve-cmd-line-parser-and-add-support-for-pat.patch new file mode 100644 index 00000000..0baa84e8 --- /dev/null +++ b/patches/wmic-Query_Path/0001-wmic-Improve-cmd-line-parser-and-add-support-for-pat.patch @@ -0,0 +1,138 @@ +From a672d372862991d9dbccdcff1b342b3965fd5e30 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Wed, 27 Apr 2016 00:41:08 +0200 +Subject: wmic: Improve cmd line parser and add support for path command. + +--- + programs/wmic/main.c | 74 ++++++++++++++++++++++++++++++++++++++++++--------- + programs/wmic/wmic.h | 1 + + programs/wmic/wmic.rc | 1 + + 3 files changed, 64 insertions(+), 12 deletions(-) + +diff --git a/programs/wmic/main.c b/programs/wmic/main.c +index 5aee4c1..46c360f 100644 +--- a/programs/wmic/main.c ++++ b/programs/wmic/main.c +@@ -162,7 +162,7 @@ static int output_message( int msg ) + return output_string( fmtW, buffer ); + } + +-static int query_prop( const WCHAR *alias, const WCHAR *propname ) ++static int query_prop( const WCHAR *class, const WCHAR *propname ) + { + static const WCHAR select_allW[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0}; + static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0}; +@@ -175,18 +175,12 @@ static int query_prop( const WCHAR *alias, const WCHAR *propname ) + IEnumWbemClassObject *result = NULL; + LONG flags = WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY; + BSTR path = NULL, wql = NULL, query = NULL; +- const WCHAR *class; + WCHAR *prop = NULL; + BOOL first = TRUE; + int len, ret = -1; + +- WINE_TRACE("%s, %s\n", debugstr_w(alias), debugstr_w(propname)); ++ WINE_TRACE("%s, %s\n", debugstr_w(class), debugstr_w(propname)); + +- if (!(class = find_class( alias ))) +- { +- output_message( STRING_ALIAS_NOT_FOUND ); +- return -1; +- } + CoInitialize( NULL ); + CoInitializeSecurity( NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, + RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL ); +@@ -253,11 +247,67 @@ done: + int wmain(int argc, WCHAR *argv[]) + { + static const WCHAR getW[] = {'g','e','t',0}; ++ static const WCHAR quitW[] = {'q','u','i','t',0}; ++ static const WCHAR exitW[] = {'e','x','i','t',0}; ++ static const WCHAR pathW[] = {'p','a','t','h',0}; ++ static const WCHAR classW[] = {'c','l','a','s','s',0}; ++ static const WCHAR contextW[] = {'c','o','n','t','e','x','t',0}; ++ ++ const WCHAR *class; ++ const WCHAR *value; ++ int i; ++ ++ if (argc == 1) ++ goto not_supported; + +- if (argc != 4 || strcmpiW( argv[2], getW )) ++ for (i = 1; i < argc && argv[i][0] == '/'; i++) ++ WINE_FIXME("command line switch %s not supported\n", debugstr_w(argv[i])); ++ ++ if (i >= argc) ++ goto not_supported; ++ ++ if (!strcmpiW( argv[i], quitW ) || ++ !strcmpiW( argv[i], exitW )) ++ { ++ return 0; ++ } ++ else if (!strcmpiW( argv[i], classW) || ++ !strcmpiW( argv[i], contextW)) + { +- output_message( STRING_CMDLINE_NOT_SUPPORTED ); +- return -1; ++ WINE_FIXME("command %s not supported\n", debugstr_w(argv[i])); ++ goto not_supported; + } +- return query_prop( argv[1], argv[3] ); ++ else if (!strcmpiW( argv[i], pathW)) ++ { ++ if (++i >= argc) ++ { ++ output_message( STRING_INVALID_PATH ); ++ return 1; ++ } ++ class = argv[i]; ++ } ++ else ++ { ++ class = find_class( argv[i] ); ++ if (!class) ++ { ++ output_message( STRING_ALIAS_NOT_FOUND ); ++ return 1; ++ } ++ } ++ ++ if (++i >= argc) ++ goto not_supported; ++ ++ if (!strcmpiW( argv[i], getW)) ++ { ++ if (++i >= argc) ++ goto not_supported; ++ value = argv[i]; ++ return query_prop( class, value ); ++ } ++ ++not_supported: ++ output_message( STRING_CMDLINE_NOT_SUPPORTED ); ++ return 1; + } +diff --git a/programs/wmic/wmic.h b/programs/wmic/wmic.h +index ee56d8e..2727270 100644 +--- a/programs/wmic/wmic.h ++++ b/programs/wmic/wmic.h +@@ -21,3 +21,4 @@ + #define STRING_CMDLINE_NOT_SUPPORTED 101 + #define STRING_ALIAS_NOT_FOUND 102 + #define STRING_INVALID_QUERY 103 ++#define STRING_INVALID_PATH 104 +diff --git a/programs/wmic/wmic.rc b/programs/wmic/wmic.rc +index 54384fb..a530682 100644 +--- a/programs/wmic/wmic.rc ++++ b/programs/wmic/wmic.rc +@@ -27,4 +27,5 @@ STRINGTABLE + STRING_CMDLINE_NOT_SUPPORTED, "Error: Command line not supported\n" + STRING_ALIAS_NOT_FOUND, "Error: Alias not found\n" + STRING_INVALID_QUERY, "Error: Invalid query\n" ++ STRING_INVALID_PATH, "Invalid syntax for PATH\n" + } +-- +2.8.0 + diff --git a/patches/wmic-Query_Path/definition b/patches/wmic-Query_Path/definition new file mode 100644 index 00000000..122d6094 --- /dev/null +++ b/patches/wmic-Query_Path/definition @@ -0,0 +1 @@ +Fixes: Improve wmic cmd line parser and add support for path command