[PATCH v2 2/2] wusa: Add additional expressions.

Mohamad Al-Jaf mohamadaljaf at gmail.com
Tue Feb 22 17:35:42 CST 2022


Signed-off-by: Mohamad Al-Jaf <mohamadaljaf at gmail.com>
---
v2: Use const for dirs.
---
 programs/wusa/main.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/programs/wusa/main.c b/programs/wusa/main.c
index de8387cd575..da0e18e73de 100644
--- a/programs/wusa/main.c
+++ b/programs/wusa/main.c
@@ -242,6 +242,17 @@ static INT_PTR CDECL cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION
     }
 }
 
+static DWORD copy_filename( const WCHAR *name, WCHAR *buffer, DWORD len )
+{
+    UINT ret = lstrlenW( name ) + 1;
+    if (buffer && len >= ret)
+    {
+        lstrcpyW( buffer, name );
+        ret--;
+    }
+    return ret;
+}
+
 static BOOL extract_cabinet(const WCHAR *filename, const WCHAR *destination)
 {
     char *filenameA = NULL;
@@ -478,6 +489,17 @@ static BOOL strbuf_append(struct strbuf *buf, const WCHAR *str, DWORD len)
 
 static WCHAR *lookup_expression(struct assembly_entry *assembly, const WCHAR *key)
 {
+    const WCHAR common_dir[] = L"C:\\Program Files\\Common Files";
+    const WCHAR common_x86_dir[] = L"C:\\Program Files (x86)\\Common Files";
+    const WCHAR data_dir[] = L"C:\\ProgramData";
+    const WCHAR drivers_dir[] = L"C:\\windows\\system32\\drivers";
+    const WCHAR files_dir[] = L"C:\\Program Files";
+    const WCHAR files_x86_dir[] = L"C:\\Program Files (x86)";
+    const WCHAR fonts_dir[] = L"C:\\windows\\Fonts";
+    const WCHAR inf_dir[] = L"C:\\windows\\inf";
+    const WCHAR wbem_dir[] = L"C:\\windows\\system32\\wbem";
+
+    const WCHAR *dir = NULL;
     WCHAR path[MAX_PATH];
 
     if (!wcsicmp(key, L"runtime.system32"))
@@ -498,6 +520,22 @@ static WCHAR *lookup_expression(struct assembly_entry *assembly, const WCHAR *ke
         return strdupW(path);
     }
 
+    if (!wcsicmp(key, L"runtime.commonFiles"))            dir = common_dir;
+    else if (!wcsicmp(key, L"runtime.commonFilesX86"))    dir = common_x86_dir;
+    else if (!wcsicmp(key, L"runtime.programData"))       dir = data_dir;
+    else if (!wcsicmp(key, L"runtime.drivers"))           dir = drivers_dir;
+    else if (!wcsicmp(key, L"runtime.programFiles"))      dir = files_dir;
+    else if (!wcsicmp(key, L"runtime.programFilesX86"))   dir = files_x86_dir;
+    else if (!wcsicmp(key, L"runtime.fonts"))             dir = fonts_dir;
+    else if (!wcsicmp(key, L"runtime.inf"))               dir = inf_dir;
+    else if (!wcsicmp(key, L"runtime.wbem"))              dir = wbem_dir;
+
+    if (dir)
+    {
+        copy_filename(dir, path, ARRAY_SIZE(path));
+        return strdupW(path);
+    }
+
     FIXME("Unknown expression %s\n", debugstr_w(key));
     return NULL;
 }
-- 
2.35.1




More information about the wine-devel mailing list