Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 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
November 2020
- 73 participants
- 650 discussions
27 Nov '20
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcrt/dir.c | 9 ++++----
dlls/msvcrt/file.c | 8 +++----
dlls/msvcrt/math.c | 9 ++++----
dlls/msvcrt/msvcrt.h | 26 ---------------------
dlls/msvcrt/printf.h | 2 +-
dlls/msvcrt/string.c | 53 ++++++++++++++++++++++---------------------
dlls/msvcrt/time.c | 4 ++--
dlls/msvcrt/wcs.c | 36 ++++++++++++++---------------
include/msvcrt/math.h | 4 ++++
9 files changed, 66 insertions(+), 85 deletions(-)
1
0
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcrt/tests/dir.c | 104 +++++++++------------------
dlls/msvcrt/tests/environ.c | 7 +-
dlls/msvcrt/tests/file.c | 8 +--
dlls/msvcrt/tests/locale.c | 8 +--
dlls/msvcrt/tests/printf.c | 140 ++++++++++++++----------------------
dlls/msvcrt/tests/scanf.c | 15 ++--
dlls/msvcrt/tests/string.c | 57 +++++++--------
dlls/msvcrt/tests/time.c | 10 +--
8 files changed, 125 insertions(+), 224 deletions(-)
1
0
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcrt/dir.c | 8 +++---
dlls/msvcrt/errno.c | 6 ++--
dlls/msvcrt/exit.c | 28 ++++++-------------
dlls/msvcrt/file.c | 24 ++++++----------
dlls/msvcrt/locale.c | 65 ++++++-------------------------------------
dlls/msvcrt/mbcs.c | 2 +-
dlls/msvcrt/printf.h | 3 +-
dlls/msvcrt/process.c | 23 ++++++---------
dlls/msvcrt/string.c | 6 ++--
dlls/msvcrt/time.c | 37 +++++++-----------------
dlls/msvcrt/wcs.c | 15 ++++------
11 files changed, 61 insertions(+), 156 deletions(-)
1
0
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcrt/console.c | 38 ++--
dlls/msvcrt/ctype.c | 2 +-
dlls/msvcrt/data.c | 62 +++---
dlls/msvcrt/dir.c | 88 ++++-----
dlls/msvcrt/environ.c | 34 ++--
dlls/msvcrt/errno.c | 18 +-
dlls/msvcrt/exit.c | 22 +--
dlls/msvcrt/file.c | 156 +++++++--------
dlls/msvcrt/heap.c | 16 +-
dlls/msvcrt/locale.c | 170 ++++++++---------
dlls/msvcrt/mbcs.c | 32 ++--
dlls/msvcrt/msvcrt.h | 133 +++++++------
dlls/msvcrt/printf.h | 16 +-
dlls/msvcrt/process.c | 190 +++++++++----------
dlls/msvcrt/scanf.c | 58 +++---
dlls/msvcrt/scanf.h | 28 +--
dlls/msvcrt/string.c | 46 ++---
dlls/msvcrt/time.c | 50 ++---
dlls/msvcrt/wcs.c | 432 +++++++++++++++++++++---------------------
19 files changed, 795 insertions(+), 796 deletions(-)
1
0
[resend PATCH v2 1/4] ntdll: Introduce ldr_data_section and per-module locks.
by Paul Gofman 27 Nov '20
by Paul Gofman 27 Nov '20
27 Nov '20
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
dlls/ntdll/loader.c | 371 ++++++++++++++++++++++++++++++++++----------
1 file changed, 293 insertions(+), 78 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index ff5a175027c..2ccc3b1d30e 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -132,6 +132,7 @@ typedef struct _wine_modref
int alloc_deps;
int nDeps;
struct _wine_modref **deps;
+ RTL_CRITICAL_SECTION module_section;
} WINE_MODREF;
static UINT tls_module_count; /* number of modules with TLS directory */
@@ -147,6 +148,30 @@ static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
};
static RTL_CRITICAL_SECTION loader_section = { &critsect_debug, -1, 0, 0, 0, 0 };
+/* ldr_data_section allows for read only access to module linked lists in PEB and
+ * the underlying structures without taking loader lock. The relations between
+ * ldr_data_section, loader_section and module_section from WINE_MODREF are:
+ * - modification to the module linked lists is done with both ldr_data_ and loader_
+ * sections locked;
+ * - read only access to loader linked lists is allowed with either loader_ or ldr_data_
+ * section locked;
+ * - the WINE_MODREF pointer (and the underlying module mapping) should stay valid
+ * while any of three locks is held; if loader_ or ldr_data_ section is held module_section
+ * can be unlocked and locked again without the risk of loosing the module reference;
+ * - query or modification if WINE_MODREF must be done with module_section locked, except for
+ * reading the fields initialized on module reference creation which don't change after
+ * (those can be accessed whenever module reference is valid);
+ * - the order of locking is: loader_section, ldr_data_section, module_section;
+ * - thread should not have any module_section locked when requesting loader_ or ldr_data_ lock. */
+static CRITICAL_SECTION ldr_data_section;
+static CRITICAL_SECTION_DEBUG ldr_data_section_debug =
+{
+ 0, 0, &ldr_data_section,
+ { &ldr_data_section_debug.ProcessLocksList, &ldr_data_section_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": ldr_data_section") }
+};
+static CRITICAL_SECTION ldr_data_section = { &ldr_data_section_debug, -1, 0, 0, 0, 0 };
+
static CRITICAL_SECTION dlldir_section;
static CRITICAL_SECTION_DEBUG dlldir_critsect_debug =
{
@@ -176,11 +201,23 @@ static WINE_MODREF *last_failed_modref;
static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext,
DWORD flags, WINE_MODREF** pwm );
static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved );
-static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
+static FARPROC find_ordinal_export( WINE_MODREF **wm, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, DWORD ordinal, LPCWSTR load_path );
-static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
+static FARPROC find_named_export( WINE_MODREF **wm, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, const char *name, int hint, LPCWSTR load_path );
+static void lock_ldr_data( BOOL lock_always )
+{
+ if (lock_always || !RtlIsCriticalSectionLockedByThread( &loader_section ))
+ RtlEnterCriticalSection( &ldr_data_section );
+}
+
+static void unlock_ldr_data( BOOL unlock_always )
+{
+ if (unlock_always || !RtlIsCriticalSectionLockedByThread( &loader_section ))
+ RtlLeaveCriticalSection( &ldr_data_section );
+}
+
/* convert PE image VirtualAddress to Real Address */
static inline void *get_rva( HMODULE module, DWORD va )
{
@@ -462,27 +499,65 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module )
}
}
+
+/*************************************************************************
+ * lock_modref
+ *
+ * Locks module reference.
+ */
+static void lock_modref( WINE_MODREF *modref )
+{
+ RtlEnterCriticalSection( &modref->module_section );
+}
+
+
+/*************************************************************************
+ * unlock_modref
+ *
+ * Unlocks module reference.
+ */
+static void unlock_modref( WINE_MODREF *modref )
+{
+ assert(modref && RtlIsCriticalSectionLockedByThread( &modref->module_section ));
+ RtlLeaveCriticalSection( &modref->module_section );
+}
+
+
/*************************************************************************
* get_modref
*
* Looks for the referenced HMODULE in the current process
- * The loader_section must be locked while calling this function.
*/
static WINE_MODREF *get_modref( HMODULE hmod )
{
PLIST_ENTRY mark, entry;
PLDR_DATA_TABLE_ENTRY mod;
+ WINE_MODREF *ret = NULL;
+
+ lock_ldr_data( FALSE );
- if (cached_modref && cached_modref->ldr.DllBase == hmod) return cached_modref;
+ if (cached_modref && cached_modref->ldr.DllBase == hmod)
+ {
+ ret = cached_modref;
+ goto done;
+ }
mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList;
for (entry = mark->Flink; entry != mark; entry = entry->Flink)
{
mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InMemoryOrderLinks);
if (mod->DllBase == hmod)
- return cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ {
+ ret = cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ break;
+ }
}
- return NULL;
+
+done:
+ if (ret)
+ lock_modref(ret);
+ unlock_ldr_data( FALSE );
+ return ret;
}
@@ -490,17 +565,22 @@ static WINE_MODREF *get_modref( HMODULE hmod )
* find_basename_module
*
* Find a module from its base name.
- * The loader_section must be locked while calling this function
*/
static WINE_MODREF *find_basename_module( LPCWSTR name )
{
PLIST_ENTRY mark, entry;
UNICODE_STRING name_str;
+ WINE_MODREF *ret = NULL;
RtlInitUnicodeString( &name_str, name );
+ lock_ldr_data( FALSE );
+
if (cached_modref && RtlEqualUnicodeString( &name_str, &cached_modref->ldr.BaseDllName, TRUE ))
- return cached_modref;
+ {
+ ret = cached_modref;
+ goto done;
+ }
mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList;
for (entry = mark->Flink; entry != mark; entry = entry->Flink)
@@ -508,11 +588,16 @@ static WINE_MODREF *find_basename_module( LPCWSTR name )
LDR_DATA_TABLE_ENTRY *mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
if (RtlEqualUnicodeString( &name_str, &mod->BaseDllName, TRUE ))
{
- cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
- return cached_modref;
+ ret = cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ break;
}
}
- return NULL;
+
+done:
+ if (ret)
+ lock_modref(ret);
+ unlock_ldr_data( FALSE );
+ return ret;
}
@@ -520,31 +605,39 @@ static WINE_MODREF *find_basename_module( LPCWSTR name )
* find_fullname_module
*
* Find a module from its full path name.
- * The loader_section must be locked while calling this function
*/
static WINE_MODREF *find_fullname_module( const UNICODE_STRING *nt_name )
{
PLIST_ENTRY mark, entry;
UNICODE_STRING name = *nt_name;
+ WINE_MODREF *ret = NULL;
if (name.Length <= 4 * sizeof(WCHAR)) return NULL;
name.Length -= 4 * sizeof(WCHAR); /* for \??\ prefix */
name.Buffer += 4;
- if (cached_modref && RtlEqualUnicodeString( &name, &cached_modref->ldr.FullDllName, TRUE ))
- return cached_modref;
+ lock_ldr_data( FALSE );
+ if (cached_modref && RtlEqualUnicodeString( &name, &cached_modref->ldr.FullDllName, TRUE ))
+ {
+ ret = cached_modref;
+ goto done;
+ }
mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList;
for (entry = mark->Flink; entry != mark; entry = entry->Flink)
{
LDR_DATA_TABLE_ENTRY *mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
if (RtlEqualUnicodeString( &name, &mod->FullDllName, TRUE ))
{
- cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
- return cached_modref;
+ ret = cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ break;
}
}
- return NULL;
+done:
+ if (ret)
+ lock_modref(ret);
+ unlock_ldr_data( FALSE );
+ return ret;
}
@@ -552,13 +645,19 @@ static WINE_MODREF *find_fullname_module( const UNICODE_STRING *nt_name )
* find_fileid_module
*
* Find a module from its file id.
- * The loader_section must be locked while calling this function
*/
static WINE_MODREF *find_fileid_module( const struct file_id *id )
{
LIST_ENTRY *mark, *entry;
+ WINE_MODREF *ret = NULL;
- if (cached_modref && !memcmp( &cached_modref->id, id, sizeof(*id) )) return cached_modref;
+ lock_ldr_data( FALSE );
+
+ if (cached_modref && !memcmp( &cached_modref->id, id, sizeof(*id) ))
+ {
+ ret = cached_modref;
+ goto done;
+ }
mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList;
for (entry = mark->Flink; entry != mark; entry = entry->Flink)
@@ -568,11 +667,15 @@ static WINE_MODREF *find_fileid_module( const struct file_id *id )
if (!memcmp( &wm->id, id, sizeof(*id) ))
{
- cached_modref = wm;
- return wm;
+ ret = cached_modref = wm;
+ break;
}
}
- return NULL;
+done:
+ if (ret)
+ lock_modref(ret);
+ unlock_ldr_data( FALSE );
+ return ret;
}
@@ -603,29 +706,39 @@ static WINE_MODREF **grow_module_deps( WINE_MODREF *wm, int count )
* Find the final function pointer for a forwarded function.
* The loader_section must be locked while calling this function.
*/
-static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWSTR load_path )
+static FARPROC find_forwarded_export( WINE_MODREF **wm_imp, const char *forward, LPCWSTR load_path )
{
+ HMODULE module = (*wm_imp)->ldr.DllBase;
const IMAGE_EXPORT_DIRECTORY *exports;
DWORD exp_size;
WINE_MODREF *wm;
- WCHAR buffer[32], *mod_name = buffer;
+ SIZE_T modname_size;
+ WCHAR *mod_name;
+ void *buffer;
const char *end = strrchr(forward, '.');
FARPROC proc = NULL;
+ char *name;
if (!end) return NULL;
- if ((end - forward) * sizeof(WCHAR) > sizeof(buffer) - sizeof(dllW))
- {
- if (!(mod_name = RtlAllocateHeap( GetProcessHeap(), 0, (end - forward + sizeof(dllW)) * sizeof(WCHAR) )))
- return NULL;
- }
+
+ modname_size = (end - forward + sizeof(dllW)) * sizeof(WCHAR);
+ if (!(mod_name = buffer = RtlAllocateHeap( GetProcessHeap(), 0, modname_size + strlen( end + 1 ) + 1 )))
+ return NULL;
+ name = (char *)buffer + modname_size;
+
ascii_to_unicode( mod_name, forward, end - forward );
mod_name[end - forward] = 0;
if (!wcschr( mod_name, '.' ))
memcpy( mod_name + (end - forward), dllW, sizeof(dllW) );
+ strcpy( name, end + 1 );
+
+ TRACE( "loading %s for '%s' used by '%s'\n", debugstr_w(mod_name), forward,
+ debugstr_w((*wm_imp)->ldr.FullDllName.Buffer) );
+ unlock_modref( *wm_imp );
if (!(wm = find_basename_module( mod_name )))
{
- TRACE( "delay loading %s for '%s'\n", debugstr_w(mod_name), forward );
+ TRACE( "delay loading %s.\n", debugstr_w(mod_name) );
if (load_dll( load_path, mod_name, dllW, 0, &wm ) == STATUS_SUCCESS &&
!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{
@@ -636,37 +749,36 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
}
else if (process_attach( wm, NULL ) != STATUS_SUCCESS)
{
- LdrUnloadDll( wm->ldr.DllBase );
+ void *dllbase = wm->ldr.DllBase;
+
+ unlock_modref( wm );
wm = NULL;
+ LdrUnloadDll( dllbase );
}
}
-
if (!wm)
{
- if (mod_name != buffer) RtlFreeHeap( GetProcessHeap(), 0, mod_name );
- ERR( "module not found for forward '%s' used by %s\n",
- forward, debugstr_w(get_modref(module)->ldr.FullDllName.Buffer) );
- return NULL;
+ ERR( "module not found, mod_name %s, path %s.\n", debugstr_w(mod_name), debugstr_w(load_path) );
+ goto done;
}
}
if ((exports = RtlImageDirectoryEntryToData( wm->ldr.DllBase, TRUE,
IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
{
- const char *name = end + 1;
if (*name == '#') /* ordinal */
- proc = find_ordinal_export( wm->ldr.DllBase, exports, exp_size, atoi(name+1), load_path );
+ proc = find_ordinal_export( &wm, exports, exp_size, atoi(name+1), load_path );
else
- proc = find_named_export( wm->ldr.DllBase, exports, exp_size, name, -1, load_path );
+ proc = find_named_export( &wm, exports, exp_size, name, -1, load_path );
}
+ if (wm)
+ unlock_modref(wm);
+
if (!proc)
- {
- ERR("function not found for forward '%s' used by %s."
- " If you are using builtin %s, try using the native one instead.\n",
- forward, debugstr_w(get_modref(module)->ldr.FullDllName.Buffer),
- debugstr_w(get_modref(module)->ldr.BaseDllName.Buffer) );
- }
- if (mod_name != buffer) RtlFreeHeap( GetProcessHeap(), 0, mod_name );
+ ERR( "function not found for forward '%s.%s'.", debugstr_w(mod_name), debugstr_a(name) );
+done:
+ RtlFreeHeap( GetProcessHeap(), 0, buffer );
+ *wm_imp = get_modref( module );
return proc;
}
@@ -676,11 +788,11 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
*
* Find an exported function by ordinal.
* The exports base must have been subtracted from the ordinal already.
- * The loader_section must be locked while calling this function.
*/
-static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
+static FARPROC find_ordinal_export( WINE_MODREF **wm, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, DWORD ordinal, LPCWSTR load_path )
{
+ HMODULE module = (*wm)->ldr.DllBase;
FARPROC proc;
const DWORD *functions = get_rva( module, exports->AddressOfFunctions );
@@ -696,16 +808,18 @@ static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY
/* if the address falls into the export dir, it's a forward */
if (((const char *)proc >= (const char *)exports) &&
((const char *)proc < (const char *)exports + exp_size))
- return find_forwarded_export( module, (const char *)proc, load_path );
+ return find_forwarded_export( wm, (const char *)proc, load_path );
if (TRACE_ON(snoop))
{
- const WCHAR *user = current_modref ? current_modref->ldr.BaseDllName.Buffer : NULL;
+ const WCHAR *user = RtlIsCriticalSectionLockedByThread( &loader_section ) && current_modref
+ ? current_modref->ldr.BaseDllName.Buffer : NULL;
proc = SNOOP_GetProcAddress( module, exports, exp_size, proc, ordinal, user );
}
if (TRACE_ON(relay))
{
- const WCHAR *user = current_modref ? current_modref->ldr.BaseDllName.Buffer : NULL;
+ const WCHAR *user = RtlIsCriticalSectionLockedByThread( &loader_section ) && current_modref
+ ? current_modref->ldr.BaseDllName.Buffer : NULL;
proc = RELAY_GetProcAddress( module, exports, exp_size, proc, ordinal, user );
}
return proc;
@@ -716,11 +830,11 @@ static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY
* find_named_export
*
* Find an exported function by name.
- * The loader_section must be locked while calling this function.
*/
-static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
+static FARPROC find_named_export( WINE_MODREF **wm, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, const char *name, int hint, LPCWSTR load_path )
{
+ HMODULE module = (*wm)->ldr.DllBase;
const WORD *ordinals = get_rva( module, exports->AddressOfNameOrdinals );
const DWORD *names = get_rva( module, exports->AddressOfNames );
int min = 0, max = exports->NumberOfNames - 1;
@@ -730,7 +844,7 @@ static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *
{
char *ename = get_rva( module, names[hint] );
if (!strcmp( ename, name ))
- return find_ordinal_export( module, exports, exp_size, ordinals[hint], load_path );
+ return find_ordinal_export( wm, exports, exp_size, ordinals[hint], load_path );
}
/* then do a binary search */
@@ -739,7 +853,7 @@ static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *
int res, pos = (min + max) / 2;
char *ename = get_rva( module, names[pos] );
if (!(res = strcmp( ename, name )))
- return find_ordinal_export( module, exports, exp_size, ordinals[pos], load_path );
+ return find_ordinal_export( wm, exports, exp_size, ordinals[pos], load_path );
if (res > 0) max = pos - 1;
else min = pos + 1;
}
@@ -754,8 +868,9 @@ static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *
* Import the dll specified by the given import descriptor.
* The loader_section must be locked while calling this function.
*/
-static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LPCWSTR load_path, WINE_MODREF **pwm )
+static BOOL import_dll( WINE_MODREF *wm, const IMAGE_IMPORT_DESCRIPTOR *descr, LPCWSTR load_path, WINE_MODREF **pwm )
{
+ HMODULE module = wm->ldr.DllBase;
NTSTATUS status;
WINE_MODREF *wmImp;
HMODULE imp_mod;
@@ -783,6 +898,8 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
return TRUE;
}
+ unlock_modref( wm );
+
while (len && name[len-1] == ' ') len--; /* remove trailing spaces */
if (len * sizeof(WCHAR) < sizeof(buffer))
@@ -794,7 +911,11 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
else /* need to allocate a larger buffer */
{
WCHAR *ptr = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
- if (!ptr) return FALSE;
+ if (!ptr)
+ {
+ lock_modref( wm );
+ return FALSE;
+ }
ascii_to_unicode( ptr, name, len );
ptr[len] = 0;
status = load_dll( load_path, ptr, dllW, 0, &wmImp );
@@ -809,6 +930,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
else
ERR("Loading library %s (which is needed by %s) failed (error %x).\n",
name, debugstr_w(current_modref->ldr.FullDllName.Buffer), status);
+ lock_modref( wm );
return FALSE;
}
@@ -855,8 +977,9 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
{
int ordinal = IMAGE_ORDINAL(import_list->u1.Ordinal);
- thunk_list->u1.Function = (ULONG_PTR)find_ordinal_export( imp_mod, exports, exp_size,
+ thunk_list->u1.Function = (ULONG_PTR)find_ordinal_export( &wmImp, exports, exp_size,
ordinal - exports->Base, load_path );
+ assert( wmImp );
if (!thunk_list->u1.Function)
{
thunk_list->u1.Function = allocate_stub( name, IntToPtr(ordinal) );
@@ -870,9 +993,10 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
{
IMAGE_IMPORT_BY_NAME *pe_name;
pe_name = get_rva( module, (DWORD)import_list->u1.AddressOfData );
- thunk_list->u1.Function = (ULONG_PTR)find_named_export( imp_mod, exports, exp_size,
+ thunk_list->u1.Function = (ULONG_PTR)find_named_export( &wmImp, exports, exp_size,
(const char*)pe_name->Name,
pe_name->Hint, load_path );
+ assert( wmImp );
if (!thunk_list->u1.Function)
{
thunk_list->u1.Function = allocate_stub( name, (const char*)pe_name->Name );
@@ -891,6 +1015,7 @@ done:
/* restore old protection of the import address table */
NtProtectVirtualMemory( NtCurrentProcess(), &protect_base, &protect_size, protect_old, &protect_old );
*pwm = wmImp;
+ lock_modref(wm);
return TRUE;
}
@@ -1082,12 +1207,16 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void *
prev = current_modref;
current_modref = wm;
- if (!(status = load_dll( load_path, mscoreeW, NULL, 0, &imp ))) wm->deps[0] = imp;
+ unlock_modref( wm );
+ if (!(status = load_dll( load_path, mscoreeW, NULL, 0, &imp )))
+ wm->deps[0] = imp;
+
current_modref = prev;
if (status)
{
ERR( "mscoree.dll not found, IL-only binary %s cannot be loaded\n",
debugstr_w(wm->ldr.BaseDllName.Buffer) );
+ lock_modref( wm );
return status;
}
@@ -1097,8 +1226,12 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void *
IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
{
const char *name = (wm->ldr.Flags & LDR_IMAGE_IS_DLL) ? "_CorDllMain" : "_CorExeMain";
- proc = find_named_export( imp->ldr.DllBase, exports, exp_size, name, -1, load_path );
+ proc = find_named_export( &imp, exports, exp_size, name, -1, load_path );
+ assert( imp );
}
+ unlock_modref( imp );
+ lock_modref( wm );
+
if (!proc) return STATUS_PROCEDURE_NOT_FOUND;
*entry = proc;
return STATUS_SUCCESS;
@@ -1148,12 +1281,13 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
{
dep = wm->nDeps++;
- if (!import_dll( wm->ldr.DllBase, &imports[i], load_path, &imp ))
+ if (!import_dll( wm, &imports[i], load_path, &imp ))
{
imp = NULL;
status = STATUS_DLL_NOT_FOUND;
}
wm->deps[dep] = imp;
+ unlock_modref( imp );
}
current_modref = prev;
if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie );
@@ -1181,6 +1315,8 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
wm->ldr.Flags = LDR_DONT_RESOLVE_REFS | (builtin ? LDR_WINE_INTERNAL : 0);
wm->ldr.TlsIndex = -1;
wm->ldr.LoadCount = 1;
+ RtlInitializeCriticalSection( &wm->module_section );
+ wm->module_section.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": module_section");
if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, nt_name->Length - 3 * sizeof(WCHAR) )))
{
@@ -1202,11 +1338,14 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
wm->ldr.EntryPoint = (char *)hModule + nt->OptionalHeader.AddressOfEntryPoint;
}
+ lock_ldr_data( TRUE );
InsertTailList(&NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList,
&wm->ldr.InLoadOrderLinks);
InsertTailList(&NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList,
&wm->ldr.InMemoryOrderLinks);
/* wait until init is called for inserting into InInitializationOrderModuleList */
+ lock_modref( wm );
+ unlock_ldr_data( TRUE );
if (!(nt->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT))
{
@@ -1405,19 +1544,28 @@ static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved )
if (lpReserved) wm->ldr.LoadCount = -1; /* pin it if imported by the main exe */
if (wm->ldr.ActivationContext) RtlActivateActivationContext( 0, wm->ldr.ActivationContext, &cookie );
+ unlock_modref( wm );
/* Recursively attach all DLLs this one depends on */
for ( i = 0; i < wm->nDeps; i++ )
{
if (!wm->deps[i]) continue;
- if ((status = process_attach( wm->deps[i], lpReserved )) != STATUS_SUCCESS) break;
+
+ lock_modref( wm->deps[i] );
+ status = process_attach( wm->deps[i], lpReserved );
+ unlock_modref( wm->deps[i] );
+ if (status != STATUS_SUCCESS) break;
}
if (!wm->ldr.InInitializationOrderLinks.Flink)
+ {
+ lock_ldr_data( TRUE );
InsertTailList(&NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList,
&wm->ldr.InInitializationOrderLinks);
+ unlock_ldr_data( TRUE );
+ }
/* Call DLL entry point */
- if (status == STATUS_SUCCESS)
+ if (!status)
{
WINE_MODREF *prev = current_modref;
current_modref = wm;
@@ -1426,6 +1574,7 @@ static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved )
status = MODULE_InitDLL( wm, DLL_PROCESS_ATTACH, lpReserved );
if (status == STATUS_SUCCESS)
{
+ lock_modref( wm );
wm->ldr.Flags |= LDR_PROCESS_ATTACHED;
}
else
@@ -1439,6 +1588,8 @@ static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved )
}
current_modref = prev;
}
+ if (status)
+ lock_modref( wm );
if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie );
/* Remove recursion flag */
@@ -1465,12 +1616,16 @@ static void attach_implicitly_loaded_dlls( LPVOID reserved )
for (entry = mark->Flink; entry != mark; entry = entry->Flink)
{
LDR_DATA_TABLE_ENTRY *mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
+ WINE_MODREF *wm;
if (!(mod->Flags & LDR_IMAGE_IS_DLL)) continue;
if (mod->Flags & (LDR_LOAD_IN_PROGRESS | LDR_PROCESS_ATTACHED)) continue;
TRACE( "found implicitly loaded %s, attaching to it\n",
debugstr_w(mod->BaseDllName.Buffer));
- process_attach( CONTAINING_RECORD(mod, WINE_MODREF, ldr), reserved );
+ wm = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ lock_modref( wm );
+ process_attach( wm, reserved );
+ unlock_modref( wm );
break; /* restart the search from the start */
}
if (entry == mark) break; /* nothing found */
@@ -1488,6 +1643,7 @@ static void process_detach(void)
{
PLIST_ENTRY mark, entry;
PLDR_DATA_TABLE_ENTRY mod;
+ WINE_MODREF *wm;
mark = &NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList;
do
@@ -1502,10 +1658,12 @@ static void process_detach(void)
if ( mod->LoadCount && !process_detaching )
continue;
+ wm = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ lock_modref( wm );
/* Call detach notification */
mod->Flags &= ~LDR_PROCESS_ATTACHED;
- MODULE_InitDLL( CONTAINING_RECORD(mod, WINE_MODREF, ldr),
- DLL_PROCESS_DETACH, ULongToPtr(process_detaching) );
+ unlock_modref( wm );
+ MODULE_InitDLL( wm, DLL_PROCESS_DETACH, ULongToPtr(process_detaching) );
call_ldr_notifications( LDR_DLL_NOTIFICATION_REASON_UNLOADED, mod );
/* Restart at head of WINE_MODREF list, as entries might have
@@ -1557,6 +1715,7 @@ NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE hModule)
ret = STATUS_DLL_NOT_FOUND;
else
wm->ldr.Flags |= LDR_NO_DLL_CALLS;
+ unlock_modref( wm );
RtlLeaveCriticalSection( &loader_section );
@@ -1721,17 +1880,18 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
IMAGE_EXPORT_DIRECTORY *exports;
DWORD exp_size;
NTSTATUS ret = STATUS_PROCEDURE_NOT_FOUND;
+ WINE_MODREF *modref;
RtlEnterCriticalSection( &loader_section );
/* check if the module itself is invalid to return the proper error */
- if (!get_modref( module )) ret = STATUS_DLL_NOT_FOUND;
+ if (!(modref = get_modref( module ))) ret = STATUS_DLL_NOT_FOUND;
else if ((exports = RtlImageDirectoryEntryToData( module, TRUE,
IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
{
LPCWSTR load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
- void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, load_path )
- : find_ordinal_export( module, exports, exp_size, ord - exports->Base, load_path );
+ void *proc = name ? find_named_export( &modref, exports, exp_size, name->Buffer, -1, load_path )
+ : find_ordinal_export( &modref, exports, exp_size, ord - exports->Base, load_path );
if (proc)
{
*address = proc;
@@ -1739,6 +1899,9 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
}
}
+ if (modref)
+ unlock_modref( modref );
+
RtlLeaveCriticalSection( &loader_section );
return ret;
}
@@ -1911,8 +2074,11 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name,
if (status != STATUS_SUCCESS)
{
/* the module has only be inserted in the load & memory order lists */
+ unlock_modref( wm );
+ lock_ldr_data( TRUE );
RemoveEntryList(&wm->ldr.InLoadOrderLinks);
RemoveEntryList(&wm->ldr.InMemoryOrderLinks);
+ unlock_ldr_data( TRUE );
/* FIXME: there are several more dangling references
* left. Including dlls loaded by this dll before the
@@ -2656,6 +2822,8 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
main_exe = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, &nt_name );
+ if (main_exe)
+ unlock_modref( main_exe );
switch (nts)
{
@@ -2714,6 +2882,7 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
{
/* stub-only dll, try native */
TRACE( "%s pre-attach returned FALSE, preferring native\n", debugstr_us(&nt_name) );
+ unlock_modref( *pwm );
LdrUnloadDll( (*pwm)->ldr.DllBase );
nts = STATUS_DLL_NOT_FOUND;
/* map the dll again if it was unmapped */
@@ -2773,6 +2942,7 @@ NTSTATUS __cdecl __wine_init_unix_lib( HMODULE module, DWORD reason, const void
if ((wm = get_modref( module )))
{
NTSTATUS (CDECL *init_func)( HMODULE, DWORD, const void *, void * ) = wm->unix_entry;
+ unlock_modref( wm );
if (init_func) ret = init_func( module, reason, ptr_in, ptr_out );
}
else ret = STATUS_INVALID_HANDLE;
@@ -2801,11 +2971,20 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
nts = process_attach( wm, NULL );
if (nts != STATUS_SUCCESS)
{
+ unlock_modref( wm );
LdrUnloadDll(wm->ldr.DllBase);
wm = NULL;
}
}
- *hModule = (wm) ? wm->ldr.DllBase : NULL;
+ if (wm)
+ {
+ *hModule = wm->ldr.DllBase;
+ unlock_modref( wm );
+ }
+ else
+ {
+ *hModule = NULL;
+ }
RtlLeaveCriticalSection( &loader_section );
return nts;
@@ -2830,7 +3009,11 @@ NTSTATUS WINAPI LdrGetDllHandle( LPCWSTR load_path, ULONG flags, const UNICODE_S
status = find_dll_file( load_path, name->Buffer, dllW, &nt_name, &wm, &module, &image_info, &id );
- if (wm) *base = wm->ldr.DllBase;
+ if (wm)
+ {
+ *base = wm->ldr.DllBase;
+ unlock_modref( wm );
+ }
else
{
if (status == STATUS_SUCCESS) NtUnmapViewOfSection( NtCurrentProcess(), module );
@@ -2863,6 +3046,7 @@ NTSTATUS WINAPI LdrAddRefDll( ULONG flags, HMODULE module )
else
if (wm->ldr.LoadCount != -1) wm->ldr.LoadCount++;
TRACE( "(%s) ldr.LoadCount: %d\n", debugstr_w(wm->ldr.BaseDllName.Buffer), wm->ldr.LoadCount );
+ unlock_modref( wm );
}
else ret = STATUS_INVALID_PARAMETER;
@@ -3239,6 +3423,7 @@ void WINAPI LdrShutdownThread(void)
RtlEnterCriticalSection( &loader_section );
wm = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
+ unlock_modref( wm );
mark = &NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList;
for (entry = mark->Blink; entry != mark; entry = entry->Blink)
@@ -3283,6 +3468,7 @@ static void free_modref( WINE_MODREF *wm )
RemoveEntryList(&wm->ldr.InMemoryOrderLinks);
if (wm->ldr.InInitializationOrderLinks.Flink)
RemoveEntryList(&wm->ldr.InInitializationOrderLinks);
+ if (cached_modref == wm) cached_modref = NULL;
TRACE(" unloading %s\n", debugstr_w(wm->ldr.FullDllName.Buffer));
if (!TRACE_ON(module))
@@ -3297,11 +3483,15 @@ static void free_modref( WINE_MODREF *wm )
}
SERVER_END_REQ;
+ unlock_modref( wm );
+
+ wm->module_section.DebugInfo->Spare[0] = 0;
+ RtlDeleteCriticalSection( &wm->module_section );
+
free_tls_slot( &wm->ldr );
RtlReleaseActivationContext( wm->ldr.ActivationContext );
unix_funcs->unload_builtin_dll( wm->ldr.DllBase );
NtUnmapViewOfSection( NtCurrentProcess(), wm->ldr.DllBase );
- if (cached_modref == wm) cached_modref = NULL;
RtlFreeUnicodeString( &wm->ldr.FullDllName );
RtlFreeHeap( GetProcessHeap(), 0, wm->deps );
RtlFreeHeap( GetProcessHeap(), 0, wm );
@@ -3321,13 +3511,18 @@ static void MODULE_FlushModrefs(void)
LDR_DATA_TABLE_ENTRY *mod;
WINE_MODREF*wm;
+ lock_ldr_data( TRUE );
mark = &NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList;
for (entry = mark->Blink; entry != mark; entry = prev)
{
mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InInitializationOrderLinks);
wm = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ lock_modref( wm );
prev = entry->Blink;
- if (!mod->LoadCount) free_modref( wm );
+ if (!mod->LoadCount)
+ free_modref( wm );
+ else
+ unlock_modref( wm );
}
/* check load order list too for modules that haven't been initialized yet */
@@ -3336,9 +3531,14 @@ static void MODULE_FlushModrefs(void)
{
mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
wm = CONTAINING_RECORD(mod, WINE_MODREF, ldr);
+ lock_modref( wm );
prev = entry->Blink;
- if (!mod->LoadCount) free_modref( wm );
+ if (!mod->LoadCount)
+ free_modref( wm );
+ else
+ unlock_modref( wm );
}
+ unlock_ldr_data( TRUE );
}
/***********************************************************************
@@ -3365,7 +3565,11 @@ static void MODULE_DecRefCount( WINE_MODREF *wm )
for ( i = 0; i < wm->nDeps; i++ )
if ( wm->deps[i] )
+ {
+ lock_modref( wm->deps[i] );
MODULE_DecRefCount( wm->deps[i] );
+ unlock_modref( wm->deps[i] );
+ }
wm->ldr.Flags &= ~LDR_UNLOAD_IN_PROGRESS;
@@ -3396,8 +3600,8 @@ NTSTATUS WINAPI LdrUnloadDll( HMODULE hModule )
/* Recursively decrement reference counts */
MODULE_DecRefCount( wm );
-
/* Call process detach notifications */
+ unlock_modref( wm );
if ( free_lib_count <= 1 )
{
process_detach();
@@ -3516,6 +3720,8 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
imports_fixup_done = TRUE;
}
+ unlock_modref( wm );
+
RtlAcquirePebLock();
InsertHeadList( &tls_links, &NtCurrentTeb()->TlsLinks );
RtlReleasePebLock();
@@ -3539,7 +3745,10 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
for (i = 0; i < wm->nDeps; i++)
{
if (!wm->deps[i]) continue;
- if ((status = process_attach( wm->deps[i], context )) != STATUS_SUCCESS)
+ lock_modref( wm->deps[i] );
+ status = process_attach( wm->deps[i], context );
+ unlock_modref( wm->deps[i] );
+ if (status)
{
if (last_failed_modref)
ERR( "%s failed to initialize, aborting\n",
@@ -4051,12 +4260,15 @@ static NTSTATUS process_init(void)
&meminfo, sizeof(meminfo), NULL );
status = build_builtin_module( params->DllPath.Buffer, &nt_name, meminfo.AllocationBase, 0, &wm );
assert( !status );
+ unlock_modref( wm );
if ((status = load_dll( params->DllPath.Buffer, kernel32W, NULL, 0, &wm )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
NtTerminateProcess( GetCurrentProcess(), status );
}
+ unlock_modref( wm );
+
RtlInitAnsiString( &func_name, "BaseThreadInitThunk" );
if ((status = LdrGetProcedureAddress( wm->ldr.DllBase, &func_name,
0, (void **)&pBaseThreadInitThunk )) != STATUS_SUCCESS)
@@ -4070,6 +4282,8 @@ static NTSTATUS process_init(void)
if (!(status = load_dll( params->DllPath.Buffer, params->ImagePathName.Buffer, NULL,
DONT_RESOLVE_DLL_REFERENCES, &wm )))
{
+ unlock_modref( wm );
+
peb->ImageBaseAddress = wm->ldr.DllBase;
TRACE( "main exe loaded %s at %p\n", debugstr_us(¶ms->ImagePathName), peb->ImageBaseAddress );
if (wm->ldr.Flags & LDR_IMAGE_IS_DLL)
@@ -4128,7 +4342,8 @@ static NTSTATUS process_init(void)
}
#endif
- /* the main exe needs to be the first in the load order list */
+ /* the main exe needs to be the first in the load order list.
+ * ldr_data_section locking is redundant here. */
RemoveEntryList( &wm->ldr.InLoadOrderLinks );
InsertHeadList( &peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderLinks );
RemoveEntryList( &wm->ldr.InMemoryOrderLinks );
--
2.28.0
2
4
27 Nov '20
is_identifier_char also triggers on logical operators like "or".
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50179
Signed-off-by: Robert Wilhelm <robert.wilhelm(a)gmx.net>
---
dlls/vbscript/lex.c | 2 +-
dlls/vbscript/tests/lang.vbs | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
index e98ed98e194..357cad7158c 100644
--- a/dlls/vbscript/lex.c
+++ b/dlls/vbscript/lex.c
@@ -315,7 +315,7 @@ static int parse_hex_literal(parser_ctx_t *ctx,
LONG *ret)
while((d = hex_to_int(*++ctx->ptr)) != -1)
l = l*16 + d;
- if(begin + 9 /* max digits+1 */ < ctx->ptr || (*ctx->ptr != '&' &&
is_identifier_char(*ctx->ptr))) {
+ if(begin + 9 /* max digits+1 */ < ctx->ptr) {
FIXME("invalid literal\n");
return 0;
}
diff --git a/dlls/vbscript/tests/lang.vbs
b/dlls/vbscript/tests/lang.vbs
index 419a4349896..a716cdbc65f 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -60,6 +60,7 @@ Call ok(&hfffe = -2, "&hfffe <> -2")
Call ok(&hffff& = 65535, "&hffff& <> -1")
Call ok(&hfffe& = 65534, "&hfffe& <> -2")
Call ok(&hffffffff& = -1, "&hffffffff& <> -1")
+Call ok((&h01or&h02)=3,"&h01or&h02 <> 3")
W = 5
Call ok(W = 5, "W = " & W & " expected " & 5)
--
2.28.0
2
1
Check for completion (handles/APC) before pumping any messages, and
again after each message is dispatched, returning as soon as the wait
condition is satisfied. This matches windows behavior and obsoletes
the previous "100 message" workaround for WM_PAINT.
Only report timeout before/during sleep, not while actively working.
The previous code had a narrow race (particularly for timeout=0):
if GetTickCount incremented between start_time and the loop body
it could WAIT_TIMEOUT even if the handles were already signaled.
No test; I couldn't think of a way to provoke this consistently.
NOTE: this means CoWaitForMultipleHandles does not time out while
there are still queued messages, and will livelock (and never time out)
if dispatching of messages continuously posts additional messages.
It will exit (successfully) if the handles eventually become signaled.
The latter is the only case tested, since I don't know how to write
a successful test for "this will livelock and hang the process".
But windows does do the same.
Notify IMessageFilter::MessagePending only for messages that wake
CoWait from MsgWait (sleeping on an empty queue), but not for
messages already posted before it sleeps.
Add tests for IMessageFilter::MessagePending -> PENDINGMSG_CANCELCALL
One of these is todo_wine, as was the existing MessageFilter test.
The bug is the same: windows does not call MessagePending for DDE/RPC
messages, but wine (still) does. I'm not sure what the right structure
is to fix this, but it's a separate (and preexisting) issue.
---
dlls/combase/combase.c | 169 +++++++++++++++++++------------------
dlls/ole32/tests/compobj.c | 164 +++++++++++++++++++++++++++++++++++
2 files changed, 251 insertions(+), 82 deletions(-)
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c
index 72ff6cc31f9..5fafbd51cfe 100644
--- a/dlls/combase/combase.c
+++ b/dlls/combase/combase.c
@@ -1891,11 +1891,12 @@ static BOOL com_peek_message(struct apartment *apt, MSG *msg)
HRESULT WINAPI CoWaitForMultipleHandles(DWORD flags, DWORD timeout, ULONG handle_count, HANDLE *handles,
DWORD *index)
{
- BOOL check_apc = !!(flags & COWAIT_ALERTABLE), post_quit = FALSE, message_loop;
+ BOOL post_quit = FALSE, message_loop;
DWORD start_time, wait_flags = 0;
struct tlsdata *tlsdata;
struct apartment *apt;
UINT exit_code;
+ DWORD res;
HRESULT hr;
TRACE("%#x, %#x, %u, %p, %p\n", flags, timeout, handle_count, handles, index);
@@ -1924,113 +1925,117 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD flags, DWORD timeout, ULONG handle
start_time = GetTickCount();
- while (TRUE)
+ if (message_loop)
{
- DWORD now = GetTickCount(), res;
-
- if (now - start_time > timeout)
+ while (TRUE)
{
- hr = RPC_S_CALLPENDING;
- break;
- }
+ MSG msg;
- if (message_loop)
- {
TRACE("waiting for rpc completion or window message\n");
- res = WAIT_TIMEOUT;
+ res = WaitForMultipleObjectsEx(handle_count, handles,
+ !!(flags & COWAIT_WAITALL), 0, !!(flags & COWAIT_ALERTABLE));
- if (check_apc)
+ if (res != WAIT_TIMEOUT)
{
- res = WaitForMultipleObjectsEx(handle_count, handles, !!(flags & COWAIT_WAITALL), 0, TRUE);
- check_apc = FALSE;
+ break;
}
- if (res == WAIT_TIMEOUT)
- res = MsgWaitForMultipleObjectsEx(handle_count, handles,
- timeout == INFINITE ? INFINITE : start_time + timeout - now,
- QS_SENDMESSAGE | QS_ALLPOSTMESSAGE | QS_PAINT, wait_flags);
-
- if (res == WAIT_OBJECT_0 + handle_count) /* messages available */
+ if (!apt->win)
{
- int msg_count = 0;
- MSG msg;
-
- /* call message filter */
+ /* If window is NULL on apartment, peek at messages so that it will not trigger
+ * MsgWaitForMultipleObjects next time. */
+ PeekMessageW(NULL, NULL, 0, 0, PM_QS_POSTMESSAGE | PM_NOREMOVE | PM_NOYIELD);
+ }
- if (apt->filter)
+ if (com_peek_message(apt, &msg))
+ {
+ if (msg.message == WM_QUIT)
{
- PENDINGTYPE pendingtype = tlsdata->pending_call_count_server ? PENDINGTYPE_NESTED : PENDINGTYPE_TOPLEVEL;
- DWORD be_handled = IMessageFilter_MessagePending(apt->filter, 0 /* FIXME */, now - start_time, pendingtype);
-
- TRACE("IMessageFilter_MessagePending returned %d\n", be_handled);
-
- switch (be_handled)
- {
- case PENDINGMSG_CANCELCALL:
- WARN("call canceled\n");
- hr = RPC_E_CALL_CANCELED;
- break;
- case PENDINGMSG_WAITNOPROCESS:
- case PENDINGMSG_WAITDEFPROCESS:
- default:
- /* FIXME: MSDN is very vague about the difference
- * between WAITNOPROCESS and WAITDEFPROCESS - there
- * appears to be none, so it is possibly a left-over
- * from the 16-bit world. */
- break;
- }
+ TRACE("Received WM_QUIT message\n");
+ post_quit = TRUE;
+ exit_code = msg.wParam;
}
-
- if (!apt->win)
+ else
{
- /* If window is NULL on apartment, peek at messages so that it will not trigger
- * MsgWaitForMultipleObjects next time. */
- PeekMessageW(NULL, NULL, 0, 0, PM_QS_POSTMESSAGE | PM_NOREMOVE | PM_NOYIELD);
+ TRACE("Received message whilst waiting for RPC: 0x%04x\n", msg.message);
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
}
+ }
+ else
+ {
+ DWORD now = GetTickCount();
+ if (now - start_time > timeout)
+ {
+ /* res really is WAIT_TIMEOUT (not just from the dwMilliseconds=0 polling of handles) */
+ break;
+ }
+
+ /* not done, no messages pending, sleep for the remaining time (or until something happens) */
+ res = MsgWaitForMultipleObjectsEx(handle_count, handles,
+ timeout == INFINITE ? INFINITE : start_time + timeout - now,
+ QS_SENDMESSAGE | QS_ALLPOSTMESSAGE | QS_PAINT, wait_flags);
- /* Some apps (e.g. Visio 2010) don't handle WM_PAINT properly and loop forever,
- * so after processing 100 messages we go back to checking the wait handles */
- while (msg_count++ < 100 && com_peek_message(apt, &msg))
+ if (res == WAIT_OBJECT_0 + handle_count) /* messages available */
{
- if (msg.message == WM_QUIT)
- {
- TRACE("Received WM_QUIT message\n");
- post_quit = TRUE;
- exit_code = msg.wParam;
- }
- else
+ /* call message filter */
+
+ if (apt->filter)
{
- TRACE("Received message whilst waiting for RPC: 0x%04x\n", msg.message);
- TranslateMessage(&msg);
- DispatchMessageW(&msg);
+ PENDINGTYPE pendingtype = tlsdata->pending_call_count_server ? PENDINGTYPE_NESTED : PENDINGTYPE_TOPLEVEL;
+ DWORD be_handled = IMessageFilter_MessagePending(apt->filter, 0 /* FIXME */, now - start_time, pendingtype);
+
+ TRACE("IMessageFilter_MessagePending returned %d\n", be_handled);
+
+ switch (be_handled)
+ {
+ case PENDINGMSG_CANCELCALL:
+ WARN("call canceled\n");
+ hr = RPC_E_CALL_CANCELED;
+ goto done;
+ break;
+ case PENDINGMSG_WAITNOPROCESS:
+ case PENDINGMSG_WAITDEFPROCESS:
+ default:
+ /* FIXME: MSDN is very vague about the difference
+ * between WAITNOPROCESS and WAITDEFPROCESS - there
+ * appears to be none, so it is possibly a left-over
+ * from the 16-bit world. */
+ break;
+ }
}
}
- continue;
+ else
+ {
+ break;
+ }
}
}
- else
- {
- TRACE("Waiting for rpc completion\n");
+ }
+ else
+ {
+ TRACE("Waiting for rpc completion\n");
- res = WaitForMultipleObjectsEx(handle_count, handles, !!(flags & COWAIT_WAITALL),
- (timeout == INFINITE) ? INFINITE : start_time + timeout - now, !!(flags & COWAIT_ALERTABLE));
- }
+ res = WaitForMultipleObjectsEx(handle_count, handles, !!(flags & COWAIT_WAITALL),
+ timeout, !!(flags & COWAIT_ALERTABLE));
+ }
- switch (res)
- {
- case WAIT_TIMEOUT:
- hr = RPC_S_CALLPENDING;
- break;
- case WAIT_FAILED:
- hr = HRESULT_FROM_WIN32(GetLastError());
- break;
- default:
- *index = res;
- break;
- }
+ switch (res)
+ {
+ case WAIT_TIMEOUT:
+ hr = RPC_S_CALLPENDING;
+ break;
+ case WAIT_FAILED:
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ break;
+ default:
+ hr = S_OK;
+ *index = res;
break;
}
+
+done:
if (post_quit) PostQuitMessage(exit_code);
TRACE("-- 0x%08x\n", hr);
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index 5d44cd5a0ba..93039f89529 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -975,6 +975,16 @@ static DWORD WINAPI MessageFilter_MessagePending(
return PENDINGMSG_WAITNOPROCESS;
}
+static DWORD WINAPI MessageFilter_MessagePending_cancel(
+ IMessageFilter *iface,
+ HTASK threadIDCallee,
+ DWORD dwTickCount,
+ DWORD dwPendingType)
+{
+ trace("MessagePending(cancel)\n");
+ return PENDINGMSG_CANCELCALL;
+}
+
static const IMessageFilterVtbl MessageFilter_Vtbl =
{
MessageFilter_QueryInterface,
@@ -987,6 +997,18 @@ static const IMessageFilterVtbl MessageFilter_Vtbl =
static IMessageFilter MessageFilter = { &MessageFilter_Vtbl };
+static const IMessageFilterVtbl MessageFilter_Vtbl_cancel =
+{
+ MessageFilter_QueryInterface,
+ MessageFilter_AddRef,
+ MessageFilter_Release,
+ MessageFilter_HandleInComingCall,
+ MessageFilter_RetryRejectedCall,
+ MessageFilter_MessagePending_cancel
+};
+
+static IMessageFilter MessageFilter_cancel = { &MessageFilter_Vtbl_cancel };
+
static void test_CoRegisterMessageFilter(void)
{
HRESULT hr;
@@ -2611,6 +2633,22 @@ static DWORD CALLBACK post_message_thread(LPVOID arg)
return 0;
}
+static DWORD CALLBACK post_input_later_thread(LPVOID arg)
+{
+ HWND hWnd = arg;
+ Sleep(50);
+ PostMessageA(hWnd, WM_CHAR, VK_ESCAPE, 0);
+ return 0;
+}
+
+static DWORD CALLBACK post_dde_later_thread(LPVOID arg)
+{
+ HWND hWnd = arg;
+ Sleep(50);
+ PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
+ return 0;
+}
+
static const char cls_name[] = "cowait_test_class";
static UINT cowait_msgs[100], cowait_msgs_first, cowait_msgs_last;
@@ -2668,6 +2706,18 @@ static LRESULT CALLBACK cowait_window_proc(HWND hwnd, UINT msg, WPARAM wparam, L
cowait_msgs[cowait_msgs_last++] = msg;
if(msg == WM_DDE_FIRST)
return 6;
+ if(msg == WM_DDE_EXECUTE && lparam)
+ {
+ const char* command = (const char *)GlobalLock((HGLOBAL)lparam);
+ if(strcmp(command,"[apc]") == 0)
+ QueueUserAPC(apc_test_proc, GetCurrentThread(), 0);
+ else if(strcmp(command,"[postmessage]") == 0)
+ PostMessageA(hwnd,msg,wparam,lparam); /* post the same message again (trigges livelock) */
+ else if(strcmp(command,"[semaphore]") == 0)
+ ReleaseSemaphore(GetPropA(hwnd,"semaphore"), 1, NULL);
+ GlobalUnlock((HGLOBAL)lparam);
+ return 0;
+ }
return DefWindowProcA(hwnd, msg, wparam, lparam);
}
@@ -2749,6 +2799,27 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
success = PeekMessageA(&msg, NULL, uMSG, uMSG, PM_REMOVE);
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
+ hr = CoRegisterMessageFilter(&MessageFilter_cancel, NULL);
+ ok(hr == S_OK, "CoRegisterMessageFilter failed: %08x\n", hr);
+
+ /* a message which arrives during the wait calls IMessageFilter::PendingMessage,
+ * which can cancel the wait (without pumping the message) */
+ thread = CreateThread(NULL, 0, post_input_later_thread, hWnd, 0, &tid);
+ hr = CoWaitForMultipleHandles(0, 200, 2, handles, &index);
+ ok(hr == RPC_E_CALL_CANCELED, "expected RPC_E_CALL_CANCELED, got 0x%08x\n", hr);
+ success = PeekMessageA(&msg, hWnd, WM_CHAR, WM_CHAR, PM_REMOVE);
+ ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
+ CloseHandle(thread);
+
+ /* DDE/RPC messages shouldn't go to IMessageFilter::PendingMessage */
+ thread = CreateThread(NULL, 0, post_dde_later_thread, hWnd, 0, &tid);
+ hr = CoWaitForMultipleHandles(0, 200, 2, handles, &index);
+ todo_wine ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
+ CloseHandle(thread);
+
+ hr = CoRegisterMessageFilter(NULL, NULL);
+ ok(hr == S_OK, "CoRegisterMessageFilter failed: %08x\n", hr);
+
DestroyWindow(hWnd);
CoUninitialize();
@@ -2788,6 +2859,15 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
return 0;
}
+static HGLOBAL globalalloc_string(const char *s) {
+ UINT len = strlen(s);
+ HGLOBAL ret = GlobalAlloc(GMEM_FIXED,len+1);
+ void *ptr = GlobalLock(ret);
+ strcpy(ptr,s);
+ GlobalUnlock(ret);
+ return ret;
+}
+
static void test_CoWaitForMultipleHandles(void)
{
HANDLE handles[2], thread;
@@ -2797,6 +2877,10 @@ static void test_CoWaitForMultipleHandles(void)
HRESULT hr;
HWND hWnd;
MSG msg;
+ HGLOBAL execute_apc = globalalloc_string("[apc]");
+ HGLOBAL execute_postmessage = globalalloc_string("[postmessage]");
+ HGLOBAL execute_semaphore = globalalloc_string("[semaphore]");
+ DWORD start_time;
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ok(hr == S_OK, "CoInitializeEx failed with error 0x%08x\n", hr);
@@ -2819,6 +2903,8 @@ static void test_CoWaitForMultipleHandles(void)
handles[1] = CreateSemaphoreA(NULL, 1, 1, NULL);
ok(handles[1] != 0, "CreateSemaphoreA failed %u\n", GetLastError());
+ SetPropA(hWnd,"semaphore",handles[0]);
+
/* test without flags */
PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
@@ -2867,6 +2953,31 @@ static void test_CoWaitForMultipleHandles(void)
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
+ /* test CoWaitForMultipleHandles stops pumping messages as soon as its handles are signaled */
+ index = 0xdeadbeef;
+ PostMessageA(hWnd, WM_DDE_EXECUTE, 0, (LPARAM)execute_semaphore);
+ PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
+ hr = CoWaitForMultipleHandles(0, 50, 1, handles, &index);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+ ok(index == 0, "expected index 0, got %u\n", index);
+ cowait_msgs_expect_queued(hWnd,WM_DDE_FIRST); /* WM_DDE_EXECUTE already pumped*/
+ success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_LAST, PM_REMOVE);
+ ok(!success, "CoWaitForMultipleHandles didn't pump enough messages\n");
+
+ /* test CoWaitForMultipleHandles will keep pumping even beyond timeout if the queue
+ * still has messages (e.g. pumping messages just posts more mesages),
+ * but will still exit if the handles handles become signaled */
+ index = 0xdeadbeef;
+ PostMessageA(hWnd, WM_DDE_EXECUTE, 0, (LPARAM)execute_postmessage);
+ start_time = GetTickCount();
+ thread = CreateThread(NULL, 0, release_semaphore_thread, handles[0], 0, &tid);
+ hr = CoWaitForMultipleHandles(0, 50, 1, handles, &index);
+ ok(GetTickCount() - start_time >= 200, "CoWaitForMultipleHandles exited too soon\n");
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+ cowait_msgs_expect_queued(hWnd,WM_DDE_EXECUTE); /* each pumped execute_postmessage added one more back */
+ success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_LAST, PM_REMOVE);
+ ok(!success, "CoWaitForMultipleHandles didn't pump enough messages\n");
+
/* test PostMessageA/SendMessageA from a different thread */
index = 0xdeadbeef;
@@ -2914,6 +3025,45 @@ static void test_CoWaitForMultipleHandles(void)
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
+ ReleaseSemaphore(handles[0], 1, NULL);
+
+ /* COWAIT_ALL will get time out even if the handles became signaled while it waits
+ * in MsgWaitForMultipleObjects(...,MWIO_WAITALL), as it demands a posted message too */
+ index = 0xdeadbeef;
+ thread = CreateThread(NULL, 0, release_semaphore_thread, handles[1], 0, &tid);
+ hr = CoWaitForMultipleHandles(COWAIT_WAITALL, 500, 2, handles, &index);
+ ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
+ /* but will succeed (without any further wait time) if the handles are avilable right away
+ * i.e. that it checks the handles first before calling MsgWaitForMultipleObjects */
+ hr = CoWaitForMultipleHandles(COWAIT_WAITALL, 0, 2, handles, &index);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+ ok(index == 0, "expected index 0, got %u\n", index);
+
+ ReleaseSemaphore(handles[1], 1, NULL);
+
+ /* COWAIT_ALL will pump message which are already in the queue,
+ * (but no longer QS_ALLPOSTMESSAGE), before blocking in MsgWaitForMultipleObjectsEx */
+ index = 0xdeadbeef;
+ PostMessageA(hWnd, WM_DDE_EXECUTE, 0, (LPARAM)execute_semaphore);
+ PeekMessageA(&msg, hWnd, 0, 0, PM_NOREMOVE); // clear QS_ALLPOSTMESSAGE
+ hr = CoWaitForMultipleHandles(COWAIT_WAITALL, 50, 1, handles, &index);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+ ok(index == 0, "expected index 0, got %u\n", index);
+ success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
+ ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
+
+ ReleaseSemaphore(handles[1], 1, NULL);
+
+ /* test early completion (rather than blocking in MsgWaitForMultipleObjectsEx again)
+ * if pumping a message results in all handles becoming signaled) */
+ index = 0xdeadbeef;
+ PostMessageA(hWnd, WM_DDE_EXECUTE, 0, (LPARAM)execute_semaphore);
+ hr = CoWaitForMultipleHandles(COWAIT_WAITALL, 50, 2, handles, &index);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+ ok(index == 0, "expected index 0, got %u\n", index);
+ success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
+ ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n");
+
ReleaseSemaphore(handles[0], 1, NULL);
ReleaseSemaphore(handles[1], 1, NULL);
@@ -2953,6 +3103,16 @@ static void test_CoWaitForMultipleHandles(void)
success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE);
ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n");
+ index = 0xdeadbeef;
+ PostMessageA(hWnd, WM_DDE_EXECUTE, 0, (LPARAM)execute_apc);
+ PostMessageA(hWnd, WM_DDE_FIRST, 0, 0);
+ hr = CoWaitForMultipleHandles(COWAIT_ALERTABLE, 50, 1, handles, &index);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+ ok(index == WAIT_IO_COMPLETION, "expected index WAIT_IO_COMPLETION, got %u\n", index);
+ cowait_msgs_expect_queued(hWnd,WM_DDE_FIRST); /* WM_DDE_EXECUTE already pumped*/
+ success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_LAST, PM_REMOVE);
+ ok(!success, "CoWaitForMultipleHandles didn't pump enough messages\n");
+
/* test with COWAIT_INPUTAVAILABLE (semaphores are still locked) */
index = 0xdeadbeef;
@@ -3165,6 +3325,10 @@ static void test_CoWaitForMultipleHandles(void)
CoUninitialize();
+ RemovePropA(hWnd,"semaphore");
+ GlobalFree(execute_apc);
+ GlobalFree(execute_postmessage);
+ GlobalFree(execute_semaphore);
CloseHandle(handles[0]);
CloseHandle(handles[1]);
DestroyWindow(hWnd);
2
1
27 Nov '20
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
I couldn't resist adding some spaces.
And while I was at it I added some more cleanups to those lines.
As the cleanups where manual I've validated that I get the same object
file as with just the automated changes.
dlls/ole32/filemoniker.c | 45 +++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c
index e5978169ca1..acd4723d8d5 100644
--- a/dlls/ole32/filemoniker.c
+++ b/dlls/ole32/filemoniker.c
@@ -657,8 +657,6 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
{
HRESULT res;
LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0;
- static const WCHAR twoPoint[]={'.','.',0};
- static const WCHAR bkSlash[]={'\\',0};
IBindCtx *bind=0;
int i=0,j=0,lastIdx1=0,lastIdx2=0;
DWORD mkSys, order;
@@ -687,17 +685,15 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1;
lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1;
- if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && wcscmp(strDec1[0],twoPoint)==0))
+ if ((lastIdx1 == -1 && lastIdx2 > -1) || (lastIdx1 == 1 && !wcscmp(strDec1[0], L"..")))
res = MK_E_SYNTAX;
else{
- if(wcscmp(strDec1[lastIdx1],bkSlash)==0)
+ if (!wcscmp(strDec1[lastIdx1], L"\\"))
lastIdx1--;
/* for each "..\" in the left of str2 remove the right element from str1 */
- for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (wcscmp(strDec2[i],twoPoint)==0) ); i+=2){
-
+ for (i = 0; lastIdx1 >= 0 && strDec2[i] && !wcscmp(strDec2[i], L".."); i += 2)
lastIdx1-=2;
- }
/* the length of the composed path string is increased by the sum of the two paths' lengths */
newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
@@ -707,8 +703,8 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
for(*newStr=0,j=0;j<=lastIdx1;j++)
lstrcatW(newStr,strDec1[j]);
- if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || wcscmp(strDec2[i],bkSlash)!=0)
- lstrcatW(newStr,bkSlash);
+ if ((!strDec2[i] && lastIdx1 > -1 && lastIdx2>-1) || wcscmp(strDec2[i], L"\\"))
+ lstrcatW(newStr, L"\\");
for(j=i;j<=lastIdx2;j++)
lstrcatW(newStr,strDec2[j]);
@@ -1016,7 +1012,6 @@ failed:
*/
int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
{
- static const WCHAR bSlash[] = {'\\',0};
LPOLESTR word;
int i=0,j,tabIndex=0, ret=0;
LPOLESTR *strgtable ;
@@ -1040,7 +1035,8 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
while(str[i]!=0){
- if(str[i]==bSlash[0]){
+ if (str[i] == L'\\')
+ {
strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
@@ -1050,14 +1046,14 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
goto lend;
}
- lstrcpyW(strgtable[tabIndex++],bSlash);
+ lstrcpyW(strgtable[tabIndex++], L"\\");
i++;
}
else {
- for(j=0; str[i]!=0 && str[i]!=bSlash[0] ; i++,j++)
+ for (j = 0; str[i] && str[i] != L'\\'; i++, j++)
word[j]=str[i];
word[j]=0;
@@ -1103,7 +1099,6 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
HRESULT res;
LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0;
DWORD len1=0,len2=0,sameIdx=0,j=0;
- static const WCHAR back[] ={'.','.','\\',0};
TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
@@ -1150,7 +1145,7 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
if (len2>0 && !(len1==1 && len2==1 && sameIdx==0))
for(j=sameIdx;(tabStr1[j] != NULL); j++)
if (*tabStr1[j]!='\\')
- lstrcatW(relPath,back);
+ lstrcatW(relPath, L"..\\");
/* add items of the second path (similar items with the first path are not included) to the relativePath */
for(j=sameIdx;tabStr2[j]!=NULL;j++)
@@ -1340,8 +1335,6 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
int nb=0,i;
int sizeStr=lstrlenW(lpszPathName);
LPOLESTR *tabStr=0;
- static const WCHAR twoPoint[]={'.','.',0};
- static const WCHAR bkSlash[]={'\\',0};
BOOL addBkSlash;
TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
@@ -1364,18 +1357,20 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
if (nb > 0 ){
addBkSlash = TRUE;
- if (wcscmp(tabStr[0],twoPoint)!=0)
+ if (wcscmp(tabStr[0], L".."))
addBkSlash = FALSE;
else
for(i=0;i<nb;i++){
- if ( (wcscmp(tabStr[i],twoPoint)!=0) && (wcscmp(tabStr[i],bkSlash)!=0) ){
+ if (wcscmp(tabStr[i], L"..") && wcscmp(tabStr[i], L"\\"))
+ {
addBkSlash = FALSE;
break;
}
else
- if (wcscmp(tabStr[i],bkSlash)==0 && i<nb-1 && wcscmp(tabStr[i+1],bkSlash)==0){
+ if (!wcscmp(tabStr[i], L"\\") && i < nb - 1 && !wcscmp(tabStr[i+1], L"\\"))
+ {
*tabStr[i]=0;
sizeStr--;
addBkSlash = FALSE;
@@ -1383,7 +1378,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
}
}
- if (wcscmp(tabStr[nb-1],bkSlash)==0)
+ if (!wcscmp(tabStr[nb-1], L"\\"))
addBkSlash = FALSE;
This->filePathName=HeapReAlloc(GetProcessHeap(),0,This->filePathName,(sizeStr+1)*sizeof(WCHAR));
@@ -1394,7 +1389,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
lstrcatW(This->filePathName,tabStr[i]);
if (addBkSlash)
- lstrcatW(This->filePathName,bkSlash);
+ lstrcatW(This->filePathName, L"\\");
}
free_stringtable(tabStr);
@@ -1447,11 +1442,10 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
LPDWORD pchEaten, IMoniker **ppmk)
{
LPCWSTR end;
- static const WCHAR wszSeparators[] = {':','\\','/','!',0};
for (end = szDisplayName + lstrlenW(szDisplayName);
end && (end != szDisplayName);
- end = memrpbrkW(szDisplayName, end - szDisplayName, wszSeparators))
+ end = memrpbrkW(szDisplayName, end - szDisplayName, L":\\/!"))
{
HRESULT hr;
IRunningObjectTable *rot;
@@ -1538,7 +1532,6 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
{
FileMonikerImpl* newFileMoniker;
HRESULT hr;
- static const WCHAR wszEmpty[] = { 0 };
TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
@@ -1551,7 +1544,7 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
if (!newFileMoniker)
return E_OUTOFMEMORY;
- hr = FileMonikerImpl_Construct(newFileMoniker, wszEmpty);
+ hr = FileMonikerImpl_Construct(newFileMoniker, L"");
if (SUCCEEDED(hr))
hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface, riid, ppv);
--
2.26.2
2
1
27 Nov '20
From: Michael Stefaniuc <mstefani(a)winehq.org>
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/ole32/filemoniker.c | 45 +++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c
index e5978169ca1..d8c401c8978 100644
--- a/dlls/ole32/filemoniker.c
+++ b/dlls/ole32/filemoniker.c
@@ -657,8 +657,6 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
{
HRESULT res;
LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0;
- static const WCHAR twoPoint[]={'.','.',0};
- static const WCHAR bkSlash[]={'\\',0};
IBindCtx *bind=0;
int i=0,j=0,lastIdx1=0,lastIdx2=0;
DWORD mkSys, order;
@@ -687,17 +685,15 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1;
lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1;
- if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && wcscmp(strDec1[0],twoPoint)==0))
+ if ((lastIdx1 == -1 && lastIdx2 > -1) || (lastIdx1 == 1 && !wcscmp(strDec1[0], L"..")))
res = MK_E_SYNTAX;
else{
- if(wcscmp(strDec1[lastIdx1],bkSlash)==0)
+ if (!wcscmp(strDec1[lastIdx1], L"\\"))
lastIdx1--;
/* for each "..\" in the left of str2 remove the right element from str1 */
- for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (wcscmp(strDec2[i],twoPoint)==0) ); i+=2){
-
+ for (i = 0; lastIdx1 >= 0 && strDec2[i] && !wcscmp(strDec2[i], L".."); i += 2)
lastIdx1-=2;
- }
/* the length of the composed path string is increased by the sum of the two paths' lengths */
newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
@@ -707,8 +703,8 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
for(*newStr=0,j=0;j<=lastIdx1;j++)
lstrcatW(newStr,strDec1[j]);
- if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || wcscmp(strDec2[i],bkSlash)!=0)
- lstrcatW(newStr,bkSlash);
+ if ((!strDec2[i] && lastIdx1 > -1 && lastIdx2 > -1) || wcscmp(strDec2[i], L"\\"))
+ lstrcatW(newStr, L"\\");
for(j=i;j<=lastIdx2;j++)
lstrcatW(newStr,strDec2[j]);
@@ -1016,7 +1012,6 @@ failed:
*/
int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
{
- static const WCHAR bSlash[] = {'\\',0};
LPOLESTR word;
int i=0,j,tabIndex=0, ret=0;
LPOLESTR *strgtable ;
@@ -1040,7 +1035,8 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
while(str[i]!=0){
- if(str[i]==bSlash[0]){
+ if (str[i] == L'\\')
+ {
strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
@@ -1050,14 +1046,14 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
goto lend;
}
- lstrcpyW(strgtable[tabIndex++],bSlash);
+ lstrcpyW(strgtable[tabIndex++], L"\\");
i++;
}
else {
- for(j=0; str[i]!=0 && str[i]!=bSlash[0] ; i++,j++)
+ for (j = 0; str[i] && str[i] != L'\\'; i++, j++)
word[j]=str[i];
word[j]=0;
@@ -1103,7 +1099,6 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
HRESULT res;
LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0;
DWORD len1=0,len2=0,sameIdx=0,j=0;
- static const WCHAR back[] ={'.','.','\\',0};
TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
@@ -1150,7 +1145,7 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
if (len2>0 && !(len1==1 && len2==1 && sameIdx==0))
for(j=sameIdx;(tabStr1[j] != NULL); j++)
if (*tabStr1[j]!='\\')
- lstrcatW(relPath,back);
+ lstrcatW(relPath, L"..\\");
/* add items of the second path (similar items with the first path are not included) to the relativePath */
for(j=sameIdx;tabStr2[j]!=NULL;j++)
@@ -1340,8 +1335,6 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
int nb=0,i;
int sizeStr=lstrlenW(lpszPathName);
LPOLESTR *tabStr=0;
- static const WCHAR twoPoint[]={'.','.',0};
- static const WCHAR bkSlash[]={'\\',0};
BOOL addBkSlash;
TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
@@ -1364,18 +1357,20 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
if (nb > 0 ){
addBkSlash = TRUE;
- if (wcscmp(tabStr[0],twoPoint)!=0)
+ if (wcscmp(tabStr[0], L".."))
addBkSlash = FALSE;
else
for(i=0;i<nb;i++){
- if ( (wcscmp(tabStr[i],twoPoint)!=0) && (wcscmp(tabStr[i],bkSlash)!=0) ){
+ if (wcscmp(tabStr[i], L"..") && wcscmp(tabStr[i], L"\\"))
+ {
addBkSlash = FALSE;
break;
}
else
- if (wcscmp(tabStr[i],bkSlash)==0 && i<nb-1 && wcscmp(tabStr[i+1],bkSlash)==0){
+ if (!wcscmp(tabStr[i], L"\\") && i < nb - 1 && !wcscmp(tabStr[i+1], L"\\"))
+ {
*tabStr[i]=0;
sizeStr--;
addBkSlash = FALSE;
@@ -1383,7 +1378,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
}
}
- if (wcscmp(tabStr[nb-1],bkSlash)==0)
+ if (!wcscmp(tabStr[nb-1], L"\\"))
addBkSlash = FALSE;
This->filePathName=HeapReAlloc(GetProcessHeap(),0,This->filePathName,(sizeStr+1)*sizeof(WCHAR));
@@ -1394,7 +1389,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
lstrcatW(This->filePathName,tabStr[i]);
if (addBkSlash)
- lstrcatW(This->filePathName,bkSlash);
+ lstrcatW(This->filePathName, L"\\");
}
free_stringtable(tabStr);
@@ -1447,11 +1442,10 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
LPDWORD pchEaten, IMoniker **ppmk)
{
LPCWSTR end;
- static const WCHAR wszSeparators[] = {':','\\','/','!',0};
for (end = szDisplayName + lstrlenW(szDisplayName);
end && (end != szDisplayName);
- end = memrpbrkW(szDisplayName, end - szDisplayName, wszSeparators))
+ end = memrpbrkW(szDisplayName, end - szDisplayName, L":\\/!"))
{
HRESULT hr;
IRunningObjectTable *rot;
@@ -1538,7 +1532,6 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
{
FileMonikerImpl* newFileMoniker;
HRESULT hr;
- static const WCHAR wszEmpty[] = { 0 };
TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
@@ -1551,7 +1544,7 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
if (!newFileMoniker)
return E_OUTOFMEMORY;
- hr = FileMonikerImpl_Construct(newFileMoniker, wszEmpty);
+ hr = FileMonikerImpl_Construct(newFileMoniker, L"");
if (SUCCEEDED(hr))
hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface, riid, ppv);
--
2.23.0
1
0
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/ole32/classmoniker.c | 2 +-
dlls/ole32/clipboard.c | 6 ++---
dlls/ole32/comcat.c | 8 +++---
dlls/ole32/compobj.c | 37 +++++++++-----------------
dlls/ole32/datacache.c | 6 ++---
dlls/ole32/defaulthandler.c | 3 +--
dlls/ole32/itemmoniker.c | 3 +--
dlls/ole32/moniker.c | 6 ++---
dlls/ole32/ole2.c | 53 +++++++++++--------------------------
dlls/ole32/stg_prop.c | 6 ++---
dlls/ole32/storage32.c | 51 ++++++++++++-----------------------
11 files changed, 60 insertions(+), 121 deletions(-)
diff --git a/dlls/ole32/classmoniker.c b/dlls/ole32/classmoniker.c
index 86d954a9c99..662baa3cd39 100644
--- a/dlls/ole32/classmoniker.c
+++ b/dlls/ole32/classmoniker.c
@@ -519,7 +519,7 @@ static HRESULT WINAPI ClassMoniker_GetDisplayName(IMoniker* iface,
LPOLESTR *ppszDisplayName)
{
ClassMoniker *This = impl_from_IMoniker(iface);
- static const WCHAR wszClsidPrefix[] = {'c','l','s','i','d',':',0};
+ static const WCHAR wszClsidPrefix[] = L"clsid:";
TRACE("(%p, %p, %p)\n", pbc, pmkToLeft, ppszDisplayName);
diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index 01cfda831f5..a28dcef9eee 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -198,7 +198,7 @@ static inline HRESULT get_ole_clipbrd(ole_clipbrd **clipbrd)
/*
* Name of our registered OLE clipboard window class
*/
-static const WCHAR clipbrd_wndclass[] = {'C','L','I','P','B','R','D','W','N','D','C','L','A','S','S',0};
+static const WCHAR clipbrd_wndclass[] = L"CLIPBRDWNDCLASS";
UINT ownerlink_clipboard_format = 0;
UINT filename_clipboard_format = 0;
@@ -619,7 +619,6 @@ static HRESULT render_embed_source_hack(IDataObject *data, LPFORMATETC fmt)
if (mfp)
{
- OLECHAR name[]={ 2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
IStream *pStream = 0;
void *mfBits;
PresentationDataHeader pdh;
@@ -644,7 +643,8 @@ static HRESULT render_embed_source_hack(IDataObject *data, LPFORMATETC fmt)
pdh.dwObjectExtentY = mfp->yExt;
pdh.dwSize = nSize;
- hr = IStorage_CreateStream(std.u.pstg, name, STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, 0, &pStream);
+ hr = IStorage_CreateStream(std.u.pstg, L"\2OlePres000",
+ STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, 0, &pStream);
hr = IStream_Write(pStream, &pdh, sizeof(PresentationDataHeader), NULL);
diff --git a/dlls/ole32/comcat.c b/dlls/ole32/comcat.c
index e258f8835b0..0b97b00d908 100644
--- a/dlls/ole32/comcat.c
+++ b/dlls/ole32/comcat.c
@@ -129,7 +129,7 @@ static HRESULT COMCAT_UnRegisterClassCategories(
ULONG cCategories,
const CATID *rgcatid)
{
- WCHAR keyname[68] = { 'C', 'L', 'S', 'I', 'D', '\\' };
+ WCHAR keyname[68] = L"CLSID\\";
HRESULT res;
HKEY type_key;
@@ -501,9 +501,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc(
LCID lcid,
PWCHAR *ppszDesc)
{
- WCHAR keyname[60] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
- 't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
- 'r', 'i', 'e', 's', '\\', 0 };
+ WCHAR keyname[60] = L"Component Categories\\";
HKEY key;
HRESULT res;
@@ -584,7 +582,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories(
ULONG cRequired,
CATID *rgcatidReq)
{
- WCHAR keyname[45] = { 'C', 'L', 'S', 'I', 'D', '\\', 0 };
+ WCHAR keyname[45] = L"CLSID\\";
HRESULT res;
struct class_categories *categories;
HKEY key;
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index c37a8ac6098..51db61414dc 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -245,10 +245,6 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES
return status;
}
-static const WCHAR classes_rootW[] =
- {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e',
- '\\','S','o','f','t','w','a','r','e','\\','C','l','a','s','s','e','s',0};
-
static HKEY classes_root_hkey;
/* create the special HKEY_CLASSES_ROOT key */
@@ -264,7 +260,7 @@ static HKEY create_classes_root_hkey(DWORD access)
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
- RtlInitUnicodeString( &name, classes_rootW );
+ RtlInitUnicodeString( &name, L"\\Registry\\Machine\\Software\\Classes" );
if (create_key( &hkey, access, &attr )) return 0;
TRACE( "%s -> %p\n", debugstr_w(attr.ObjectName->Buffer), hkey );
@@ -292,9 +288,8 @@ static inline HKEY get_classes_root_hkey( HKEY hkey, REGSAM access )
ret = create_classes_root_hkey(MAXIMUM_ALLOWED | (access & KEY_WOW64_64KEY));
if (force_wow32 && ret && ret == classes_root_hkey)
{
- static const WCHAR wow6432nodeW[] = {'W','o','w','6','4','3','2','N','o','d','e',0};
access &= ~KEY_WOW64_32KEY;
- if (create_classes_key(classes_root_hkey, wow6432nodeW, access, &hkey))
+ if (create_classes_key(classes_root_hkey, L"Wow6432Node", access, &hkey))
return 0;
ret = hkey;
}
@@ -530,13 +525,12 @@ HRESULT WINAPI CoInitialize(LPVOID lpReserved)
/* open HKCR\\CLSID\\{string form of clsid}\\{keyname} key */
HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *subkey)
{
- static const WCHAR wszCLSIDSlash[] = {'C','L','S','I','D','\\',0};
- WCHAR path[CHARS_IN_GUID + ARRAY_SIZE(wszCLSIDSlash) - 1];
+ WCHAR path[CHARS_IN_GUID + ARRAY_SIZE(L"CLSID\\") - 1];
LONG res;
HKEY key;
- lstrcpyW(path, wszCLSIDSlash);
- StringFromGUID2(clsid, path + lstrlenW(wszCLSIDSlash), CHARS_IN_GUID);
+ lstrcpyW(path, L"CLSID\\");
+ StringFromGUID2(clsid, path + lstrlenW(L"CLSID\\"), CHARS_IN_GUID);
res = open_classes_key(HKEY_CLASSES_ROOT, path, keyname ? KEY_READ : access, &key);
if (res == ERROR_FILE_NOT_FOUND)
return REGDB_E_CLASSNOTREG;
@@ -707,8 +701,6 @@ HRESULT WINAPI CoSetState(IUnknown * pv)
*/
HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
{
- static const WCHAR wszAutoTreatAs[] = {'A','u','t','o','T','r','e','a','t','A','s',0};
- static const WCHAR wszTreatAs[] = {'T','r','e','a','t','A','s',0};
HKEY hkey = NULL;
WCHAR szClsidNew[CHARS_IN_GUID];
HRESULT res = S_OK;
@@ -722,10 +714,10 @@ HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
if (IsEqualGUID( clsidOld, clsidNew ))
{
- if (!RegQueryValueW(hkey, wszAutoTreatAs, auto_treat_as, &auto_treat_as_size) &&
+ if (!RegQueryValueW(hkey, L"AutoTreatAs", auto_treat_as, &auto_treat_as_size) &&
CLSIDFromString(auto_treat_as, &id) == S_OK)
{
- if (RegSetValueW(hkey, wszTreatAs, REG_SZ, auto_treat_as, sizeof(auto_treat_as)))
+ if (RegSetValueW(hkey, L"TreatAs", REG_SZ, auto_treat_as, sizeof(auto_treat_as)))
{
res = REGDB_E_WRITEREGDB;
goto done;
@@ -733,7 +725,7 @@ HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
}
else
{
- if(RegDeleteKeyW(hkey, wszTreatAs))
+ if (RegDeleteKeyW(hkey, L"TreatAs"))
res = REGDB_E_WRITEREGDB;
goto done;
}
@@ -741,7 +733,7 @@ HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
else
{
if(IsEqualGUID(clsidNew, &CLSID_NULL)){
- RegDeleteKeyW(hkey, wszTreatAs);
+ RegDeleteKeyW(hkey, L"TreatAs");
}else{
if(!StringFromGUID2(clsidNew, szClsidNew, ARRAY_SIZE(szClsidNew))){
WARN("StringFromGUID2 failed\n");
@@ -749,7 +741,7 @@ HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
goto done;
}
- if(RegSetValueW(hkey, wszTreatAs, REG_SZ, szClsidNew, sizeof(szClsidNew)) != ERROR_SUCCESS){
+ if (RegSetValueW(hkey, L"TreatAs", REG_SZ, szClsidNew, sizeof(szClsidNew)) != ERROR_SUCCESS){
WARN("RegSetValue failed\n");
res = REGDB_E_WRITEREGDB;
goto done;
@@ -892,12 +884,11 @@ static BOOL get_object_dll_path(const struct class_reg_data *regdata, WCHAR *dst
}
else
{
- static const WCHAR dllW[] = {'.','d','l','l',0};
ULONG_PTR cookie;
*dst = 0;
ActivateActCtx(regdata->u.actctx.hactctx, &cookie);
- ret = SearchPathW(NULL, regdata->u.actctx.module_name, dllW, dstlen, dst, NULL);
+ ret = SearchPathW(NULL, regdata->u.actctx.module_name, L".dll", dstlen, dst, NULL);
DeactivateActCtx(0, cookie);
return *dst != 0;
}
@@ -905,11 +896,10 @@ static BOOL get_object_dll_path(const struct class_reg_data *regdata, WCHAR *dst
HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
- static const WCHAR wszInprocHandler32[] = {'I','n','p','r','o','c','H','a','n','d','l','e','r','3','2',0};
HKEY hkey;
HRESULT hres;
- hres = COM_OpenKeyForCLSID(rclsid, wszInprocHandler32, KEY_READ, &hkey);
+ hres = COM_OpenKeyForCLSID(rclsid, L"InprocHandler32", KEY_READ, &hkey);
if (SUCCEEDED(hres))
{
struct class_reg_data regdata;
@@ -920,8 +910,7 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
if (get_object_dll_path(®data, dllpath, ARRAY_SIZE(dllpath)))
{
- static const WCHAR wszOle32[] = {'o','l','e','3','2','.','d','l','l',0};
- if (!wcsicmp(dllpath, wszOle32))
+ if (!wcsicmp(dllpath, L"ole32.dll"))
{
RegCloseKey(hkey);
return HandlerCF_Create(rclsid, riid, ppv);
diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index 4e4f264860a..a536f829515 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -530,8 +530,6 @@ static HRESULT write_clipformat(IStream *stream, CLIPFORMAT clipformat)
return hr;
}
-static const WCHAR CONTENTS[] = {'C','O','N','T','E','N','T','S',0};
-
static HRESULT open_pres_stream( IStorage *stg, int stream_number, IStream **stm )
{
WCHAR pres[] = {2,'O','l','e','P','r','e','s',
@@ -541,7 +539,7 @@ static HRESULT open_pres_stream( IStorage *stg, int stream_number, IStream **stm
const WCHAR *name = pres;
if (stream_number == STREAM_NUMBER_NOT_SET) return E_FAIL;
- if (stream_number == STREAM_NUMBER_CONTENTS) name = CONTENTS;
+ if (stream_number == STREAM_NUMBER_CONTENTS) name = L"CONTENTS";
return IStorage_OpenStream( stg, name, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm );
}
@@ -1089,7 +1087,7 @@ static HRESULT create_stream(DataCacheEntry *cache_entry, IStorage *storage,
const WCHAR *name;
if (contents)
- name = CONTENTS;
+ name = L"CONTENTS";
else
name = pres;
diff --git a/dlls/ole32/defaulthandler.c b/dlls/ole32/defaulthandler.c
index c1045c15466..81ffa1e6dbc 100644
--- a/dlls/ole32/defaulthandler.c
+++ b/dlls/ole32/defaulthandler.c
@@ -1758,7 +1758,6 @@ static HRESULT WINAPI DefaultHandler_IPersistStorage_IsDirty(
* BYTE data[] - moniker data for a link
*/
-static const WCHAR OleStream[] = {1,'O','l','e',0};
typedef struct
{
DWORD version;
@@ -1774,7 +1773,7 @@ static HRESULT load_ole_stream(DefaultHandler *This, IStorage *storage)
IStream *stream;
HRESULT hr;
- hr = IStorage_OpenStream(storage, OleStream, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
+ hr = IStorage_OpenStream(storage, L"\1Ole", NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
if(SUCCEEDED(hr))
{
diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c
index dee4fc0bf2d..786d183d598 100644
--- a/dlls/ole32/itemmoniker.c
+++ b/dlls/ole32/itemmoniker.c
@@ -1055,7 +1055,6 @@ failed:
HRESULT WINAPI ItemMoniker_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
- static const WCHAR emptyW[] = { 0 };
IMoniker *moniker;
HRESULT hr;
@@ -1066,7 +1065,7 @@ HRESULT WINAPI ItemMoniker_CreateInstance(IClassFactory *iface, IUnknown *outer,
if (outer)
return CLASS_E_NOAGGREGATION;
- if (FAILED(hr = CreateItemMoniker(emptyW, emptyW, &moniker)))
+ if (FAILED(hr = CreateItemMoniker(L"", L"", &moniker)))
return hr;
hr = IMoniker_QueryInterface(moniker, riid, ppv);
diff --git a/dlls/ole32/moniker.c b/dlls/ole32/moniker.c
index 251c3c47849..be78eb90cf3 100644
--- a/dlls/ole32/moniker.c
+++ b/dlls/ole32/moniker.c
@@ -915,8 +915,6 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
LONG sizeProgId, ret;
LPOLESTR *pathDec=0,absFile=0,progId=0;
LPWSTR extension;
- static const WCHAR bkslashW[] = {'\\',0};
- static const WCHAR dotW[] = {'.',0};
TRACE("%s, %p\n", debugstr_w(filePathName), pclsid);
@@ -962,7 +960,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
absFile=pathDec[nbElm-1];
/* failed if the path represents a directory and not an absolute file name*/
- if (!wcscmp(absFile, bkslashW)) {
+ if (!wcscmp(absFile, L"\\")) {
CoTaskMemFree(pathDec);
return MK_E_INVALIDEXTENSION;
}
@@ -973,7 +971,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
for(i = length-1; (i >= 0) && *(extension = &absFile[i]) != '.'; i--)
/* nothing */;
- if (!extension || !wcscmp(extension, dotW)) {
+ if (!extension || !wcscmp(extension, L".")) {
CoTaskMemFree(pathDec);
return MK_E_INVALIDEXTENSION;
}
diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c
index 4464ba07144..f2224ad5b6a 100644
--- a/dlls/ole32/ole2.c
+++ b/dlls/ole32/ole2.c
@@ -101,24 +101,18 @@ static LONG OLE_moduleLockCount = 0;
/*
* Name of our registered window class.
*/
-static const WCHAR OLEDD_DRAGTRACKERCLASS[] =
- {'W','i','n','e','D','r','a','g','D','r','o','p','T','r','a','c','k','e','r','3','2',0};
+static const WCHAR OLEDD_DRAGTRACKERCLASS[] = L"WineDragDropTracker32";
/*
* Name of menu descriptor property.
*/
-static const WCHAR prop_olemenuW[] =
- {'P','R','O','P','_','O','L','E','M','e','n','u','D','e','s','c','r','i','p','t','o','r',0};
+static const WCHAR prop_olemenuW[] = L"PROP_OLEMenuDescriptor";
/* property to store IDropTarget pointer */
-static const WCHAR prop_oledroptarget[] =
- {'O','l','e','D','r','o','p','T','a','r','g','e','t','I','n','t','e','r','f','a','c','e',0};
+static const WCHAR prop_oledroptarget[] = L"OleDropTargetInterface";
/* property to store Marshalled IDropTarget pointer */
-static const WCHAR prop_marshalleddroptarget[] =
- {'W','i','n','e','M','a','r','s','h','a','l','l','e','d','D','r','o','p','T','a','r','g','e','t',0};
-
-static const WCHAR emptyW[] = { 0 };
+static const WCHAR prop_marshalleddroptarget[] = L"WineMarshalledDropTarget";
/******************************************************************************
* These are the prototypes of miscellaneous utility methods
@@ -669,7 +663,6 @@ HRESULT WINAPI RevokeDragDrop(HWND hwnd)
*/
HRESULT WINAPI OleRegGetUserType(REFCLSID clsid, DWORD form, LPOLESTR *usertype)
{
- static const WCHAR auxusertypeW[] = {'A','u','x','U','s','e','r','T','y','p','e','\\','%','d',0};
DWORD valuetype, valuelen;
WCHAR auxkeynameW[16];
HKEY usertypekey;
@@ -695,10 +688,10 @@ HRESULT WINAPI OleRegGetUserType(REFCLSID clsid, DWORD form, LPOLESTR *usertype)
{
HKEY auxkey;
- swprintf(auxkeynameW, ARRAY_SIZE(auxkeynameW), auxusertypeW, form);
+ swprintf(auxkeynameW, ARRAY_SIZE(auxkeynameW), L"AuxUserType\\%d", form);
if (COM_OpenKeyForCLSID(clsid, auxkeynameW, KEY_READ, &auxkey) == S_OK)
{
- if (!RegQueryValueExW(auxkey, emptyW, NULL, &valuetype, NULL, &valuelen) && valuelen)
+ if (!RegQueryValueExW(auxkey, L"", NULL, &valuetype, NULL, &valuelen) && valuelen)
{
RegCloseKey(usertypekey);
usertypekey = auxkey;
@@ -709,7 +702,7 @@ HRESULT WINAPI OleRegGetUserType(REFCLSID clsid, DWORD form, LPOLESTR *usertype)
}
valuelen = 0;
- if (RegQueryValueExW(usertypekey, emptyW, NULL, &valuetype, NULL, &valuelen))
+ if (RegQueryValueExW(usertypekey, L"", NULL, &valuetype, NULL, &valuelen))
{
RegCloseKey(usertypekey);
return REGDB_E_READREGDB;
@@ -722,12 +715,7 @@ HRESULT WINAPI OleRegGetUserType(REFCLSID clsid, DWORD form, LPOLESTR *usertype)
return E_OUTOFMEMORY;
}
- ret = RegQueryValueExW(usertypekey,
- emptyW,
- NULL,
- &valuetype,
- (LPBYTE)*usertype,
- &valuelen);
+ ret = RegQueryValueExW(usertypekey, L"", NULL, &valuetype, (BYTE *)*usertype, &valuelen);
RegCloseKey(usertypekey);
if (ret != ERROR_SUCCESS)
{
@@ -748,7 +736,6 @@ HRESULT WINAPI DoDragDrop (
DWORD dwOKEffect, /* [in] effects allowed by the source */
DWORD *pdwEffect) /* [out] ptr to effects of the source */
{
- static const WCHAR trackerW[] = {'T','r','a','c','k','e','r','W','i','n','d','o','w',0};
TrackerWindowInfo trackerInfo;
HWND hwndTrackWindow;
MSG msg;
@@ -772,7 +759,7 @@ HRESULT WINAPI DoDragDrop (
trackerInfo.curTargetHWND = 0;
trackerInfo.curDragTarget = 0;
- hwndTrackWindow = CreateWindowW(OLEDD_DRAGTRACKERCLASS, trackerW,
+ hwndTrackWindow = CreateWindowW(OLEDD_DRAGTRACKERCLASS, L"TrackerWindow",
WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0,
&trackerInfo);
@@ -856,8 +843,6 @@ HRESULT WINAPI OleRegGetMiscStatus(
DWORD dwAspect,
DWORD* pdwStatus)
{
- static const WCHAR miscstatusW[] = {'M','i','s','c','S','t','a','t','u','s',0};
- static const WCHAR dfmtW[] = {'%','d',0};
WCHAR keyName[16];
HKEY miscStatusKey;
HKEY aspectKey;
@@ -872,7 +857,7 @@ HRESULT WINAPI OleRegGetMiscStatus(
if (actctx_get_miscstatus(clsid, dwAspect, pdwStatus)) return S_OK;
- hr = COM_OpenKeyForCLSID(clsid, miscstatusW, KEY_READ, &miscStatusKey);
+ hr = COM_OpenKeyForCLSID(clsid, L"MiscStatus", KEY_READ, &miscStatusKey);
if (FAILED(hr))
/* missing key is not a failure */
return hr == REGDB_E_KEYMISSING ? S_OK : hr;
@@ -882,7 +867,7 @@ HRESULT WINAPI OleRegGetMiscStatus(
/*
* Open the key specific to the requested aspect.
*/
- swprintf(keyName, ARRAY_SIZE(keyName), dfmtW, dwAspect);
+ swprintf(keyName, ARRAY_SIZE(keyName), L"%d", dwAspect);
result = open_classes_key(miscStatusKey, keyName, KEY_READ, &aspectKey);
if (result == ERROR_SUCCESS)
@@ -1117,11 +1102,10 @@ HRESULT WINAPI OleRegEnumVerbs (REFCLSID clsid, LPENUMOLEVERB* ppenum)
LONG res;
HKEY hkeyVerb;
DWORD dwSubKeys;
- static const WCHAR wszVerb[] = {'V','e','r','b',0};
TRACE("(%s, %p)\n", debugstr_guid(clsid), ppenum);
- res = COM_OpenKeyForCLSID(clsid, wszVerb, KEY_READ, &hkeyVerb);
+ res = COM_OpenKeyForCLSID(clsid, L"Verb", KEY_READ, &hkeyVerb);
if (FAILED(res))
{
if (res == REGDB_E_CLASSNOTREG)
@@ -2402,12 +2386,7 @@ static void OLEUTL_ReadRegistryDWORDValue(
DWORD dwKeyType;
LONG lres;
- lres = RegQueryValueExW(regKey,
- emptyW,
- NULL,
- &dwKeyType,
- (LPBYTE)buffer,
- &cbData);
+ lres = RegQueryValueExW(regKey, L"", NULL, &dwKeyType, (BYTE *)buffer, &cbData);
if (lres==ERROR_SUCCESS)
{
@@ -2573,13 +2552,12 @@ HRESULT WINAPI OleCreate(
*/
HRESULT WINAPI OleGetAutoConvert(REFCLSID clsidOld, LPCLSID pClsidNew)
{
- static const WCHAR wszAutoConvertTo[] = {'A','u','t','o','C','o','n','v','e','r','t','T','o',0};
HKEY hkey = NULL;
WCHAR buf[CHARS_IN_GUID];
LONG len;
HRESULT res = S_OK;
- res = COM_OpenKeyForCLSID(clsidOld, wszAutoConvertTo, KEY_READ, &hkey);
+ res = COM_OpenKeyForCLSID(clsidOld, L"AutoConvertTo", KEY_READ, &hkey);
if (FAILED(res))
goto done;
@@ -2600,7 +2578,6 @@ done:
*/
HRESULT WINAPI OleSetAutoConvert(REFCLSID clsidOld, REFCLSID clsidNew)
{
- static const WCHAR wszAutoConvertTo[] = {'A','u','t','o','C','o','n','v','e','r','t','T','o',0};
HKEY hkey = NULL;
WCHAR szClsidNew[CHARS_IN_GUID];
HRESULT res = S_OK;
@@ -2611,7 +2588,7 @@ HRESULT WINAPI OleSetAutoConvert(REFCLSID clsidOld, REFCLSID clsidNew)
if (FAILED(res))
goto done;
StringFromGUID2(clsidNew, szClsidNew, CHARS_IN_GUID);
- if (RegSetValueW(hkey, wszAutoConvertTo, REG_SZ, szClsidNew, (lstrlenW(szClsidNew)+1) * sizeof(WCHAR)))
+ if (RegSetValueW(hkey, L"AutoConvertTo", REG_SZ, szClsidNew, (lstrlenW(szClsidNew)+1) * sizeof(WCHAR)))
{
res = REGDB_E_WRITEREGDB;
goto done;
diff --git a/dlls/ole32/stg_prop.c b/dlls/ole32/stg_prop.c
index 27794c739ee..7b1cd801cf1 100644
--- a/dlls/ole32/stg_prop.c
+++ b/dlls/ole32/stg_prop.c
@@ -2991,10 +2991,8 @@ static const IPropertyStorageVtbl IPropertyStorage_Vtbl =
/***********************************************************************
* Format ID <-> name conversion
*/
-static const WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
- 'I','n','f','o','r','m','a','t','i','o','n',0 };
-static const WCHAR szDocSummaryInfo[] = { 5,'D','o','c','u','m','e','n','t',
- 'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0 };
+static const WCHAR szSummaryInfo[] = L"\5SummaryInformation";
+static const WCHAR szDocSummaryInfo[] = L"\5DocumentSummaryInformation";
#define BITS_PER_BYTE 8
#define CHARMASK 0x1f
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 58fb055993f..3d372af83f5 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -4761,14 +4761,13 @@ static HRESULT StorageImpl_Refresh(StorageImpl *This, BOOL new_object, BOOL crea
*/
if (create)
{
- static const WCHAR rootentryW[] = {'R','o','o','t',' ','E','n','t','r','y',0};
DirEntry rootEntry;
/*
* Initialize the directory table
*/
memset(&rootEntry, 0, sizeof(rootEntry));
- lstrcpyW(rootEntry.name, rootentryW);
- rootEntry.sizeOfNameString = sizeof(rootentryW);
+ lstrcpyW(rootEntry.name, L"Root Entry");
+ rootEntry.sizeOfNameString = sizeof(L"Root Entry");
rootEntry.stgType = STGTY_ROOT;
rootEntry.leftChild = DIRENTRY_NULL;
rootEntry.rightChild = DIRENTRY_NULL;
@@ -8533,7 +8532,6 @@ static HRESULT create_storagefile(
if (pwcsName == 0)
{
WCHAR tempPath[MAX_PATH];
- static const WCHAR prefix[] = { 'S', 'T', 'O', 0 };
memset(tempPath, 0, sizeof(tempPath));
memset(tempFileName, 0, sizeof(tempFileName));
@@ -8541,7 +8539,7 @@ static HRESULT create_storagefile(
if ((GetTempPathW(MAX_PATH, tempPath)) == 0 )
tempPath[0] = '.';
- if (GetTempFileNameW(tempPath, prefix, 0, tempFileName) != 0)
+ if (GetTempFileNameW(tempPath, L"STO", 0, tempFileName) != 0)
pwcsName = tempFileName;
else
{
@@ -9205,12 +9203,11 @@ HRESULT WINAPI OleSaveToStream(IPersistStream *pPStm,IStream *pStm)
*/
HRESULT STORAGE_CreateOleStream(IStorage *storage, DWORD flags)
{
- static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
static const DWORD version_magic = 0x02000001;
IStream *stream;
HRESULT hr;
- hr = IStorage_CreateStream(storage, stream_1oleW, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
+ hr = IStorage_CreateStream(storage, L"\1Ole", STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
if (hr == S_OK)
{
struct empty_1ole_stream {
@@ -9310,7 +9307,6 @@ static HRESULT STORAGE_WriteCompObj( LPSTORAGE pstg, CLSID *clsid,
{
IStream *pstm;
HRESULT r = S_OK;
- static const WCHAR szwStreamName[] = {1, 'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
static const BYTE unknown1[12] =
{ 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
@@ -9324,7 +9320,7 @@ static HRESULT STORAGE_WriteCompObj( LPSTORAGE pstg, CLSID *clsid,
debugstr_w(szProgIDName));
/* Create a CompObj stream */
- r = IStorage_CreateStream(pstg, szwStreamName,
+ r = IStorage_CreateStream(pstg, L"\1CompObj",
STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm );
if( FAILED (r) )
return r;
@@ -9399,7 +9395,6 @@ HRESULT WINAPI ReadFmtUserTypeStg (LPSTORAGE pstg, CLIPFORMAT* pcf, LPOLESTR* lp
{
HRESULT r;
IStream *stm = 0;
- static const WCHAR szCompObj[] = { 1, 'C','o','m','p','O','b','j', 0 };
unsigned char unknown1[12];
unsigned char unknown2[16];
DWORD count;
@@ -9408,8 +9403,7 @@ HRESULT WINAPI ReadFmtUserTypeStg (LPSTORAGE pstg, CLIPFORMAT* pcf, LPOLESTR* lp
TRACE("(%p,%p,%p)\n", pstg, pcf, lplpszUserType);
- r = IStorage_OpenStream( pstg, szCompObj, NULL,
- STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm );
+ r = IStorage_OpenStream( pstg, L"\1CompObj", NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm );
if( FAILED ( r ) )
{
WARN("Failed to open stream r = %08x\n", r);
@@ -9922,11 +9916,10 @@ static void OLECONVERT_GetOLE20FromOLE10(LPSTORAGE pDestStorage, const BYTE *pBu
IStorage *pTempStorage;
DWORD dwNumOfBytesWritten;
WCHAR wstrTempDir[MAX_PATH], wstrTempFile[MAX_PATH];
- static const WCHAR wstrPrefix[] = {'s', 'i', 's', 0};
/* Create a temp File */
GetTempPathW(MAX_PATH, wstrTempDir);
- GetTempFileNameW(wstrTempDir, wstrPrefix, 0, wstrTempFile);
+ GetTempFileNameW(wstrTempDir, L"sis", 0, wstrTempFile);
hFile = CreateFileW(wstrTempFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if(hFile != INVALID_HANDLE_VALUE)
@@ -9972,13 +9965,12 @@ static DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
DWORD nDataLength = 0;
IStorage *pTempStorage;
WCHAR wstrTempDir[MAX_PATH], wstrTempFile[MAX_PATH];
- static const WCHAR wstrPrefix[] = {'s', 'i', 's', 0};
*pData = NULL;
/* Create temp Storage */
GetTempPathW(MAX_PATH, wstrTempDir);
- GetTempFileNameW(wstrTempDir, wstrPrefix, 0, wstrTempFile);
+ GetTempFileNameW(wstrTempDir, L"sis", 0, wstrTempFile);
hRes = StgCreateDocfile(wstrTempFile, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pTempStorage);
if(hRes == S_OK)
@@ -10029,7 +10021,6 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
IStream *pStream;
HRESULT hStorageRes, hRes = S_OK;
OLECONVERT_ISTORAGE_COMPOBJ IStorageCompObj;
- static const WCHAR wstrStreamName[] = {1,'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
WCHAR bufferW[OLESTREAM_MAX_STR_LEN];
static const BYTE pCompObjUnknown1[] = {0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
@@ -10042,7 +10033,7 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
/* Create a CompObj stream if it doesn't exist */
- hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName,
+ hStorageRes = IStorage_CreateStream(pStorage, L"\1CompObj",
STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
if(hStorageRes == S_OK)
{
@@ -10130,7 +10121,6 @@ static void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX,
{
HRESULT hRes;
IStream *pStream;
- static const WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
static const BYTE pOlePresStreamHeader[] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
@@ -10148,7 +10138,7 @@ static void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX,
};
/* Create the OlePres000 Stream */
- hRes = IStorage_CreateStream(pStorage, wstrStreamName,
+ hRes = IStorage_CreateStream(pStorage, L"\2OlePres000",
STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
if(hRes == S_OK)
@@ -10214,10 +10204,9 @@ static void OLECONVERT_CreateOle10NativeStream(LPSTORAGE pStorage, const BYTE *p
{
HRESULT hRes;
IStream *pStream;
- static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
/* Create the Ole10Native Stream */
- hRes = IStorage_CreateStream(pStorage, wstrStreamName,
+ hRes = IStorage_CreateStream(pStorage, L"\1Ole10Native",
STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
if(hRes == S_OK)
@@ -10255,10 +10244,9 @@ static HRESULT OLECONVERT_GetOLE10ProgID(LPSTORAGE pStorage, char *strProgID, DW
IStream *pStream;
LARGE_INTEGER iSeekPos;
OLECONVERT_ISTORAGE_COMPOBJ CompObj;
- static const WCHAR wstrStreamName[] = {1,'C', 'o', 'm', 'p', 'O', 'b', 'j', 0};
/* Open the CompObj Stream */
- hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
+ hRes = IStorage_OpenStream(pStorage, L"\1CompObj", NULL,
STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
if(hRes == S_OK)
{
@@ -10325,7 +10313,6 @@ static void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM
HRESULT hRes;
IStream *pStream;
- static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
/* Initialize Default data for OLESTREAM */
pOleStreamData[0].dwOleID = OLESTREAM_ID;
@@ -10338,7 +10325,7 @@ static void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM
pOleStreamData[1].pData = NULL;
/* Open Ole10Native Stream */
- hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
+ hRes = IStorage_OpenStream(pStorage, L"\1Ole10Native", NULL,
STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
if(hRes == S_OK)
{
@@ -10378,7 +10365,6 @@ static void OLECONVERT_GetOle20PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM
HRESULT hRes;
IStream *pStream;
OLECONVERT_ISTORAGE_OLEPRES olePress;
- static const WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
/* Initialize Default data for OLESTREAM */
pOleStreamData[0].dwOleID = OLESTREAM_ID;
@@ -10397,7 +10383,7 @@ static void OLECONVERT_GetOle20PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM
/* Open OlePress000 stream */
- hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
+ hRes = IStorage_OpenStream(pStorage, L"\2OlePres000", NULL,
STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream );
if(hRes == S_OK)
{
@@ -10555,7 +10541,6 @@ HRESULT WINAPI OleConvertIStorageToOLESTREAM (
HRESULT hRes = S_OK;
IStream *pStream;
OLECONVERT_OLESTREAM_DATA pOleStreamData[2];
- static const WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
TRACE("%p %p\n", pstg, pOleStream);
@@ -10574,7 +10559,7 @@ HRESULT WINAPI OleConvertIStorageToOLESTREAM (
if(hRes == S_OK)
{
/* Was it originally Ole10 */
- hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
+ hRes = IStorage_OpenStream(pstg, L"\1Ole10Native", 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
if(hRes == S_OK)
{
IStream_Release(pStream);
@@ -10615,7 +10600,6 @@ enum stream_1ole_flags {
*/
HRESULT WINAPI GetConvertStg(IStorage *stg)
{
- static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
static const DWORD version_magic = 0x02000001;
DWORD header[2];
IStream *stream;
@@ -10625,7 +10609,7 @@ HRESULT WINAPI GetConvertStg(IStorage *stg)
if (!stg) return E_INVALIDARG;
- hr = IStorage_OpenStream(stg, stream_1oleW, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
+ hr = IStorage_OpenStream(stg, L"\1Ole", NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
if (FAILED(hr)) return hr;
hr = IStream_Read(stream, header, sizeof(header), NULL);
@@ -10646,7 +10630,6 @@ HRESULT WINAPI GetConvertStg(IStorage *stg)
*/
HRESULT WINAPI SetConvertStg(IStorage *storage, BOOL convert)
{
- static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
DWORD flags = convert ? OleStream_Convert : 0;
IStream *stream;
DWORD header[2];
@@ -10654,7 +10637,7 @@ HRESULT WINAPI SetConvertStg(IStorage *storage, BOOL convert)
TRACE("(%p, %d)\n", storage, convert);
- hr = IStorage_OpenStream(storage, stream_1oleW, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
+ hr = IStorage_OpenStream(storage, L"\1Ole", NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
if (FAILED(hr))
{
if (hr != STG_E_FILENOTFOUND)
--
2.26.2
2
1