X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=programs%2Fimagex-win32.c;h=0fe04399e8fc4b603faad77bb2ca563ede25a733;hb=db9a61d62db87df4228ad3e6f3fcef1f5a4e14bc;hp=18581ed0d2603bd94442c18d2814372d7008b4cb;hpb=650997e4865a090b6856c7ca34b02f42994e8e29;p=wimlib diff --git a/programs/imagex-win32.c b/programs/imagex-win32.c index 18581ed0..0fe04399 100644 --- a/programs/imagex-win32.c +++ b/programs/imagex-win32.c @@ -14,7 +14,8 @@ #include #include -/* Replacement for glob() in Windows native builds. */ +/* Replacement for glob() in Windows native builds that operates on wide + * characters. */ int win32_wglob(const wchar_t *pattern, int flags, int (*errfunc)(const wchar_t *epath, int eerrno), @@ -119,7 +120,7 @@ globfree(glob_t *pglob) } static bool -win32_modify_privilege(const char *privilege, bool enable) +win32_modify_privilege(const wchar_t *privilege, bool enable) { HANDLE hToken; LUID luid; @@ -129,13 +130,10 @@ win32_modify_privilege(const char *privilege, bool enable) if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) - { goto out; - } - if (!LookupPrivilegeValue(NULL, privilege, &luid)) { + if (!LookupPrivilegeValueW(NULL, privilege, &luid)) goto out; - } newState.PrivilegeCount = 1; newState.Privileges[0].Luid = luid; @@ -194,6 +192,7 @@ win32_release_restore_privileges() win32_modify_restore_privileges(false); } +/* Convert a string from the "current Windows codepage" to UTF-16LE. */ wchar_t * win32_mbs_to_wcs(const char *mbs, size_t mbs_nbytes, size_t *num_wchars_ret) { @@ -245,6 +244,8 @@ is_path_separator(wchar_t c) return c == L'/' || c == L'\\'; } +/* basename() (modifying, trailing-slash stripping version) for wide-character + * strings. */ wchar_t * win32_wbasename(wchar_t *path) {