mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
Added patch for combase HSTRING objects.
This commit is contained in:
parent
ec9701cec2
commit
150dc70e53
@ -37,13 +37,14 @@ Wine. All those differences are also documented on the
|
||||
Included bug fixes and improvements
|
||||
===================================
|
||||
|
||||
**Bugfixes and features included in the next upcoming release [5]:**
|
||||
**Bugfixes and features included in the next upcoming release [6]:**
|
||||
|
||||
* Add support for GetPropValue to PulseAudio backend
|
||||
* Fix condition mask handling in RtlVerifyVersionInfo ([Wine Bug #36143](https://bugs.winehq.org/show_bug.cgi?id=36143))
|
||||
* Fix possible segfault in pulse_rd_loop of PulseAudio backend
|
||||
* Set last error when GetRawInputDeviceList fails ([Wine Bug #37667](https://bugs.winehq.org/show_bug.cgi?id=37667))
|
||||
* Support for StrCatChainW
|
||||
* Support for combase HSTRING objects
|
||||
|
||||
|
||||
**Bugs fixed in Wine Staging 1.7.32 [108]:**
|
||||
|
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -5,6 +5,7 @@ wine-compholio (1.7.33) UNRELEASED; urgency=low
|
||||
* Added patch to fix possible segfault in pulse_rd_loop of PulseAudio backend.
|
||||
* Added patch to implement support for GetPropValue to PulseAudio backend.
|
||||
* Added patch to implement shlwapi.StrCatChainW.
|
||||
* Added patch for combase HSTRING objects.
|
||||
* Removed patch to fix copy and paste errors in ws2_32 tests (accepted upstream).
|
||||
* Removed patch to fix ordering of IP addresses by metric if two addresses have the same metric (accepted upstream).
|
||||
* Removed patch to reset data->pWintrustData->u.pFile->hFile after closing handle (accepted upstream).
|
||||
|
@ -24,6 +24,7 @@ PATCHLIST := \
|
||||
Pipelight.ok \
|
||||
Staging.ok \
|
||||
atl-IOCS_Property.ok \
|
||||
combase-HSTRING.ok \
|
||||
comctl32-LoadIconMetric.ok \
|
||||
configure-Absolute_RPATH.ok \
|
||||
d3d9-Surface_Refcount.ok \
|
||||
@ -270,6 +271,26 @@ atl-IOCS_Property.ok:
|
||||
echo '+ { "Qian Hong", "atl: Don'\''t use GWLP_USERDATA to store IOCS to avoid conflict with Apps.", 1 },'; \
|
||||
) > atl-IOCS_Property.ok
|
||||
|
||||
# Patchset combase-HSTRING
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * configure.ac, dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec,
|
||||
# | dlls/combase/Makefile.in, dlls/combase/combase.spec, dlls/combase/string.c, dlls/combase/tests/Makefile.in,
|
||||
# | dlls/combase/tests/string.c, include/Makefile.in, include/hstring.h, include/winstring.h, tools/make_specfiles
|
||||
# |
|
||||
.INTERMEDIATE: combase-HSTRING.ok
|
||||
combase-HSTRING.ok:
|
||||
$(call APPLY_FILE,combase-HSTRING/0001-include-Add-hstring.h-and-winstring.h.patch)
|
||||
$(call APPLY_FILE,combase-HSTRING/0002-combase-Implement-creation-and-deletion-of-HSTRING-o.patch)
|
||||
$(call APPLY_FILE,combase-HSTRING/0003-combase-Implement-functions-for-accessing-HSTRING-ob.patch)
|
||||
$(call APPLY_FILE,combase-HSTRING/0004-combase-Implement-functions-for-HSTRING_BUFFER.patch)
|
||||
@( \
|
||||
echo '+ { "Martin Storsjo", "include: Add hstring.h and winstring.h.", 1 },'; \
|
||||
echo '+ { "Martin Storsjo", "combase: Implement creation and deletion of HSTRING objects.", 1 },'; \
|
||||
echo '+ { "Martin Storsjo", "combase: Implement functions for accessing HSTRING objects.", 1 },'; \
|
||||
echo '+ { "Martin Storsjo", "combase: Implement functions for HSTRING_BUFFER.", 1 },'; \
|
||||
) > combase-HSTRING.ok
|
||||
|
||||
# Patchset comctl32-LoadIconMetric
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
|
@ -0,0 +1,133 @@
|
||||
From d857022a2a68015c586c93bfbd34d8dc81588363 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Tue, 9 Dec 2014 10:36:47 +0200
|
||||
Subject: include: Add hstring.h and winstring.h.
|
||||
|
||||
---
|
||||
include/Makefile.in | 2 ++
|
||||
include/hstring.h | 39 +++++++++++++++++++++++++++++++++++++++
|
||||
include/winstring.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 87 insertions(+)
|
||||
create mode 100644 include/hstring.h
|
||||
create mode 100644 include/winstring.h
|
||||
|
||||
diff --git a/include/Makefile.in b/include/Makefile.in
|
||||
index 5b1f3ab..4a9806b 100644
|
||||
--- a/include/Makefile.in
|
||||
+++ b/include/Makefile.in
|
||||
@@ -341,6 +341,7 @@ SRCDIR_INCLUDES = \
|
||||
htmlhelp.h \
|
||||
http.h \
|
||||
httprequestid.h \
|
||||
+ hstring.h \
|
||||
i_cryptasn1tls.h \
|
||||
icm.h \
|
||||
icmpapi.h \
|
||||
@@ -618,6 +619,7 @@ SRCDIR_INCLUDES = \
|
||||
winsock.h \
|
||||
winsock2.h \
|
||||
winspool.h \
|
||||
+ winstring.h \
|
||||
winsvc.h \
|
||||
wintab.h \
|
||||
wintabx.h \
|
||||
diff --git a/include/hstring.h b/include/hstring.h
|
||||
new file mode 100644
|
||||
index 0000000..d65e375
|
||||
--- /dev/null
|
||||
+++ b/include/hstring.h
|
||||
@@ -0,0 +1,39 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2014 Martin Storsjo
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
+ */
|
||||
+
|
||||
+#ifndef __WINE_HSTRING_H
|
||||
+#define __WINE_HSTRING_H
|
||||
+
|
||||
+#include <windef.h>
|
||||
+
|
||||
+DECLARE_HANDLE(HSTRING);
|
||||
+DECLARE_HANDLE(HSTRING_BUFFER);
|
||||
+
|
||||
+typedef struct HSTRING_HEADER
|
||||
+{
|
||||
+ union {
|
||||
+ PVOID Reserved1;
|
||||
+#ifdef _WIN64
|
||||
+ char Reserved2[24];
|
||||
+#else
|
||||
+ char Reserved2[20];
|
||||
+#endif
|
||||
+ } Reserved;
|
||||
+} HSTRING_HEADER;
|
||||
+
|
||||
+#endif /* __WINE_HSTRING_H */
|
||||
diff --git a/include/winstring.h b/include/winstring.h
|
||||
new file mode 100644
|
||||
index 0000000..4db3f4c
|
||||
--- /dev/null
|
||||
+++ b/include/winstring.h
|
||||
@@ -0,0 +1,46 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2014 Martin Storsjo
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
+ */
|
||||
+
|
||||
+#ifndef __WINE_WINSTRING_H
|
||||
+#define __WINE_WINSTRING_H
|
||||
+
|
||||
+#include <hstring.h>
|
||||
+
|
||||
+HRESULT WINAPI WindowsCompareStringOrdinal(HSTRING str1, HSTRING str2, INT32 *order);
|
||||
+HRESULT WINAPI WindowsConcatString(HSTRING str1, HSTRING str2, HSTRING *out);
|
||||
+HRESULT WINAPI WindowsCreateString(LPCWSTR ptr, UINT32 len, HSTRING *out);
|
||||
+HRESULT WINAPI WindowsCreateStringReference(LPCWSTR ptr, UINT32 len,
|
||||
+ HSTRING_HEADER *header, HSTRING *out);
|
||||
+HRESULT WINAPI WindowsDeleteString(HSTRING str);
|
||||
+HRESULT WINAPI WindowsDeleteStringBuffer(HSTRING_BUFFER buf);
|
||||
+HRESULT WINAPI WindowsDuplicateString(HSTRING str, HSTRING *out);
|
||||
+UINT32 WINAPI WindowsGetStringLen(HSTRING str);
|
||||
+LPCWSTR WINAPI WindowsGetStringRawBuffer(HSTRING str, UINT32 *len);
|
||||
+BOOL WINAPI WindowsIsStringEmpty(HSTRING str);
|
||||
+HRESULT WINAPI WindowsPreallocateStringBuffer(UINT32 len, WCHAR **outptr, HSTRING_BUFFER *out);
|
||||
+HRESULT WINAPI WindowsPromoteStringBuffer(HSTRING_BUFFER buf, HSTRING *out);
|
||||
+HRESULT WINAPI WindowsReplaceString(HSTRING haystack, HSTRING needle, HSTRING replacement,
|
||||
+ HSTRING *out);
|
||||
+HRESULT WINAPI WindowsStringHasEmbeddedNull(HSTRING str, BOOL *out);
|
||||
+HRESULT WINAPI WindowsSubstring(HSTRING str, UINT32 pos, HSTRING *out);
|
||||
+HRESULT WINAPI WindowsSubstringWithSpecifiedLength(HSTRING str, UINT32 pos,
|
||||
+ UINT32 len, HSTRING *out);
|
||||
+HRESULT WINAPI WindowsTrimStringEnd(HSTRING str, HSTRING charstr, HSTRING *out);
|
||||
+HRESULT WINAPI WindowsTrimStringStart(HSTRING str, HSTRING charstr, HSTRING *out);
|
||||
+
|
||||
+#endif /* __WINE_WINSTRING_H */
|
||||
--
|
||||
2.1.3
|
||||
|
@ -0,0 +1,390 @@
|
||||
From 0eaebb31a43736c90862d24f979c5a4dbe976d7d Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Tue, 9 Dec 2014 10:36:48 +0200
|
||||
Subject: combase: Implement creation and deletion of HSTRING objects.
|
||||
|
||||
---
|
||||
configure.ac | 1 +
|
||||
.../api-ms-win-core-winrt-string-l1-1-0.spec | 8 +-
|
||||
dlls/combase/Makefile.in | 3 +-
|
||||
dlls/combase/combase.spec | 8 +-
|
||||
dlls/combase/string.c | 143 +++++++++++++++++++++
|
||||
dlls/combase/tests/Makefile.in | 4 +
|
||||
dlls/combase/tests/string.c | 128 ++++++++++++++++++
|
||||
tools/make_specfiles | 1 +
|
||||
8 files changed, 287 insertions(+), 9 deletions(-)
|
||||
create mode 100644 dlls/combase/string.c
|
||||
create mode 100644 dlls/combase/tests/Makefile.in
|
||||
create mode 100644 dlls/combase/tests/string.c
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 400ee61..e214189 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -2758,6 +2758,7 @@ WINE_CONFIG_DLL(cards,,[implib])
|
||||
WINE_CONFIG_DLL(cfgmgr32,,[implib])
|
||||
WINE_CONFIG_DLL(clusapi,,[implib])
|
||||
WINE_CONFIG_DLL(combase)
|
||||
+WINE_CONFIG_TEST(dlls/combase/tests)
|
||||
WINE_CONFIG_DLL(comcat)
|
||||
WINE_CONFIG_TEST(dlls/comcat/tests)
|
||||
WINE_CONFIG_DLL(comctl32,,[implib,po])
|
||||
diff --git a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
index bc9035c..7658867 100644
|
||||
--- a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
+++ b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
@@ -8,11 +8,11 @@
|
||||
@ stub HSTRING_UserUnmarshal64
|
||||
@ stub WindowsCompareStringOrdinal
|
||||
@ stub WindowsConcatString
|
||||
-@ stub WindowsCreateString
|
||||
-@ stub WindowsCreateStringReference
|
||||
-@ stub WindowsDeleteString
|
||||
+@ stdcall WindowsCreateString(ptr long ptr) combase.WindowsCreateString
|
||||
+@ stdcall WindowsCreateStringReference(wstr long ptr ptr) combase.WindowsCreateStringReference
|
||||
+@ stdcall WindowsDeleteString(ptr) combase.WindowsDeleteString
|
||||
@ stub WindowsDeleteStringBuffer
|
||||
-@ stub WindowsDuplicateString
|
||||
+@ stdcall WindowsDuplicateString(ptr ptr) combase.WindowsDuplicateString
|
||||
@ stub WindowsGetStringLen
|
||||
@ stub WindowsGetStringRawBuffer
|
||||
@ stub WindowsInspectString
|
||||
diff --git a/dlls/combase/Makefile.in b/dlls/combase/Makefile.in
|
||||
index 79d22a1..c5ab8d2 100644
|
||||
--- a/dlls/combase/Makefile.in
|
||||
+++ b/dlls/combase/Makefile.in
|
||||
@@ -2,4 +2,5 @@ MODULE = combase.dll
|
||||
IMPORTS = ole32
|
||||
|
||||
C_SRCS = \
|
||||
- roapi.c
|
||||
+ roapi.c \
|
||||
+ string.c
|
||||
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
|
||||
index 652eff6..f399d25 100644
|
||||
--- a/dlls/combase/combase.spec
|
||||
+++ b/dlls/combase/combase.spec
|
||||
@@ -289,11 +289,11 @@
|
||||
@ stub WdtpInterfacePointer_UserUnmarshal64
|
||||
@ stub WindowsCompareStringOrdinal
|
||||
@ stub WindowsConcatString
|
||||
-@ stub WindowsCreateString
|
||||
-@ stub WindowsCreateStringReference
|
||||
-@ stub WindowsDeleteString
|
||||
+@ stdcall WindowsCreateString(ptr long ptr)
|
||||
+@ stdcall WindowsCreateStringReference(wstr long ptr ptr)
|
||||
+@ stdcall WindowsDeleteString(ptr)
|
||||
@ stub WindowsDeleteStringBuffer
|
||||
-@ stub WindowsDuplicateString
|
||||
+@ stdcall WindowsDuplicateString(ptr ptr)
|
||||
@ stub WindowsGetStringLen
|
||||
@ stub WindowsGetStringRawBuffer
|
||||
@ stub WindowsInspectString
|
||||
diff --git a/dlls/combase/string.c b/dlls/combase/string.c
|
||||
new file mode 100644
|
||||
index 0000000..ee2f5c0
|
||||
--- /dev/null
|
||||
+++ b/dlls/combase/string.c
|
||||
@@ -0,0 +1,143 @@
|
||||
+/*
|
||||
+ * Copyright 2014 Martin Storsjo
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
+ */
|
||||
+
|
||||
+#include "winerror.h"
|
||||
+#include "hstring.h"
|
||||
+#include "windows.h"
|
||||
+#include "wine/debug.h"
|
||||
+#include <string.h>
|
||||
+
|
||||
+WINE_DEFAULT_DEBUG_CHANNEL(combase);
|
||||
+
|
||||
+struct hstring_private
|
||||
+{
|
||||
+ LPWSTR buffer;
|
||||
+ UINT32 length;
|
||||
+ BOOL reference;
|
||||
+ LONG refcount;
|
||||
+};
|
||||
+
|
||||
+C_ASSERT(sizeof(struct hstring_private) <= sizeof(HSTRING_HEADER));
|
||||
+
|
||||
+static inline struct hstring_private *impl_from_HSTRING(HSTRING string)
|
||||
+{
|
||||
+ return (struct hstring_private *)string;
|
||||
+}
|
||||
+
|
||||
+static inline struct hstring_private *impl_from_HSTRING_HEADER(HSTRING_HEADER *header)
|
||||
+{
|
||||
+ return (struct hstring_private *)header;
|
||||
+}
|
||||
+
|
||||
+static BOOL alloc_string(UINT32 len, HSTRING *out)
|
||||
+{
|
||||
+ struct hstring_private *priv;
|
||||
+ priv = HeapAlloc(GetProcessHeap(), 0, sizeof(*priv) + (len + 1) * sizeof(*priv->buffer));
|
||||
+ if (!priv)
|
||||
+ return FALSE;
|
||||
+ priv->buffer = (LPWSTR)(priv + 1);
|
||||
+ priv->length = len;
|
||||
+ priv->reference = FALSE;
|
||||
+ priv->refcount = 1;
|
||||
+ priv->buffer[len] = '\0';
|
||||
+ *out = (HSTRING)priv;
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsCreateString (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsCreateString(LPCWSTR ptr, UINT32 len,
|
||||
+ HSTRING *out)
|
||||
+{
|
||||
+ struct hstring_private *priv;
|
||||
+ if (out == NULL)
|
||||
+ return E_INVALIDARG;
|
||||
+ if (ptr == NULL && len > 0)
|
||||
+ return E_POINTER;
|
||||
+ if (len == 0)
|
||||
+ {
|
||||
+ *out = NULL;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+ if (!alloc_string(len, out))
|
||||
+ return E_OUTOFMEMORY;
|
||||
+ priv = impl_from_HSTRING(*out);
|
||||
+ memcpy(priv->buffer, ptr, len * sizeof(*priv->buffer));
|
||||
+ return S_OK;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsCreateStringReference (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsCreateStringReference(LPCWSTR ptr, UINT32 len,
|
||||
+ HSTRING_HEADER *header, HSTRING *out)
|
||||
+{
|
||||
+ struct hstring_private *priv = impl_from_HSTRING_HEADER(header);
|
||||
+ if (out == NULL || header == NULL)
|
||||
+ return E_INVALIDARG;
|
||||
+ if (ptr == NULL && len > 0)
|
||||
+ return E_POINTER;
|
||||
+ if (ptr[len] != '\0')
|
||||
+ return E_INVALIDARG;
|
||||
+ if (len == 0)
|
||||
+ {
|
||||
+ *out = NULL;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+ priv->buffer = (LPWSTR)ptr;
|
||||
+ priv->length = len;
|
||||
+ priv->reference = TRUE;
|
||||
+ *out = (HSTRING)header;
|
||||
+ return S_OK;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsDeleteString (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsDeleteString(HSTRING str)
|
||||
+{
|
||||
+ struct hstring_private *priv = impl_from_HSTRING(str);
|
||||
+ if (str == NULL)
|
||||
+ return S_OK;
|
||||
+ if (priv->reference)
|
||||
+ return S_OK;
|
||||
+ if (InterlockedDecrement(&priv->refcount) == 0)
|
||||
+ HeapFree(GetProcessHeap(), 0, priv);
|
||||
+ return S_OK;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsDuplicateString (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsDuplicateString(HSTRING str, HSTRING *out)
|
||||
+{
|
||||
+ struct hstring_private *priv = impl_from_HSTRING(str);
|
||||
+ if (out == NULL)
|
||||
+ return E_INVALIDARG;
|
||||
+ if (str == NULL)
|
||||
+ {
|
||||
+ *out = NULL;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+ if (priv->reference)
|
||||
+ return WindowsCreateString(priv->buffer, priv->length, out);
|
||||
+ InterlockedIncrement(&priv->refcount);
|
||||
+ *out = str;
|
||||
+ return S_OK;
|
||||
+}
|
||||
diff --git a/dlls/combase/tests/Makefile.in b/dlls/combase/tests/Makefile.in
|
||||
new file mode 100644
|
||||
index 0000000..3e7ecab
|
||||
--- /dev/null
|
||||
+++ b/dlls/combase/tests/Makefile.in
|
||||
@@ -0,0 +1,4 @@
|
||||
+TESTDLL = combase.dll
|
||||
+
|
||||
+C_SRCS = \
|
||||
+ string.c
|
||||
diff --git a/dlls/combase/tests/string.c b/dlls/combase/tests/string.c
|
||||
new file mode 100644
|
||||
index 0000000..01a63f7
|
||||
--- /dev/null
|
||||
+++ b/dlls/combase/tests/string.c
|
||||
@@ -0,0 +1,128 @@
|
||||
+/*
|
||||
+ * Unit tests for Windows String functions
|
||||
+ *
|
||||
+ * Copyright (c) 2014 Martin Storsjo
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
+ */
|
||||
+
|
||||
+#include <stdarg.h>
|
||||
+
|
||||
+#include "windef.h"
|
||||
+#include "winbase.h"
|
||||
+#include "winerror.h"
|
||||
+#include "winstring.h"
|
||||
+
|
||||
+#include "wine/test.h"
|
||||
+
|
||||
+static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
|
||||
+static HRESULT (WINAPI *pWindowsCreateStringReference)(LPCWSTR, UINT32, HSTRING_HEADER *, HSTRING *);
|
||||
+static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
|
||||
+static HRESULT (WINAPI *pWindowsDuplicateString)(HSTRING, HSTRING *);
|
||||
+
|
||||
+#define SET(x) p##x = (void*)GetProcAddress(hmod, #x)
|
||||
+
|
||||
+static BOOL init_functions(void)
|
||||
+{
|
||||
+ HMODULE hmod = LoadLibraryA("combase.dll");
|
||||
+ if (!hmod)
|
||||
+ {
|
||||
+ win_skip("Failed to load combase.dll, skipping tests\n");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ SET(WindowsCreateString);
|
||||
+ SET(WindowsCreateStringReference);
|
||||
+ SET(WindowsDeleteString);
|
||||
+ SET(WindowsDuplicateString);
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+#undef SET
|
||||
+
|
||||
+
|
||||
+static const WCHAR input_string[] = { 'a', 'b', 'c', 'd', 'e', 'f', '\0' };
|
||||
+static const WCHAR input_empty_string[] = { '\0' };
|
||||
+
|
||||
+static void test_create_delete(void)
|
||||
+{
|
||||
+ HSTRING str;
|
||||
+ HSTRING_HEADER header;
|
||||
+
|
||||
+ /* Test normal creation of a string */
|
||||
+ ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+ /* Test error handling in WindowsCreateString */
|
||||
+ ok(pWindowsCreateString(input_string, 6, NULL) == E_INVALIDARG, "Incorrect error handling\n");
|
||||
+ ok(pWindowsCreateString(NULL, 6, &str) == E_POINTER, "Incorrect error handling\n");
|
||||
+
|
||||
+ /* Test handling of a NULL string */
|
||||
+ ok(pWindowsDeleteString(NULL) == S_OK, "Failed to delete null string\n");
|
||||
+
|
||||
+ /* Test creation of a string reference */
|
||||
+ ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
|
||||
+
|
||||
+ /* Test error handling in WindowsCreateStringReference */
|
||||
+ /* Strings to CreateStringReference must be null terminated with the correct
|
||||
+ * length. According to MSDN this should be E_INVALIDARG, but it returns
|
||||
+ * 0x80000017 in practice. */
|
||||
+ ok(FAILED(pWindowsCreateStringReference(input_string, 5, &header, &str)), "Incorrect error handling\n");
|
||||
+ ok(pWindowsCreateStringReference(input_string, 6, NULL, &str) == E_INVALIDARG, "Incorrect error handling\n");
|
||||
+ ok(pWindowsCreateStringReference(input_string, 6, &header, NULL) == E_INVALIDARG, "Incorrect error handling\n");
|
||||
+ ok(pWindowsCreateStringReference(NULL, 6, &header, &str) == E_POINTER, "Incorrect error handling\n");
|
||||
+
|
||||
+ /* Test creating a string without a null-termination at the specified length */
|
||||
+ ok(pWindowsCreateString(input_string, 3, &str) == S_OK, "Failed to create string\n");
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+
|
||||
+ /* Test an empty string */
|
||||
+ ok(pWindowsCreateString(input_empty_string, 0, &str) == S_OK, "Failed to create string\n");
|
||||
+ ok(str == NULL, "Empty string not a null string\n");
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+
|
||||
+ ok(pWindowsCreateStringReference(input_empty_string, 0, &header, &str) == S_OK, "Failed to create string\n");
|
||||
+ ok(str == NULL, "Empty string not a null string\n");
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+}
|
||||
+
|
||||
+static void test_duplicate(void)
|
||||
+{
|
||||
+ HSTRING str, str2;
|
||||
+ HSTRING_HEADER header;
|
||||
+ ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
|
||||
+ ok(pWindowsDuplicateString(str, NULL) == E_INVALIDARG, "Incorrect error handling\n");
|
||||
+ ok(pWindowsDuplicateString(str, &str2) == S_OK, "Failed to duplicate string\n");
|
||||
+ ok(str == str2, "Duplicated string created new string\n");
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+ ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
|
||||
+
|
||||
+ ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
|
||||
+ ok(pWindowsDuplicateString(str, &str2) == S_OK, "Failed to duplicate string\n");
|
||||
+ ok(str != str2, "Duplicated string ref didn't create new string\n");
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+ ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
|
||||
+
|
||||
+ ok(pWindowsDuplicateString(NULL, &str2) == S_OK, "Failed to duplicate NULL string\n");
|
||||
+ ok(str2 == NULL, "Duplicated string created new string\n");
|
||||
+ ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
|
||||
+}
|
||||
+
|
||||
+START_TEST(string)
|
||||
+{
|
||||
+ if (!init_functions())
|
||||
+ return;
|
||||
+ test_create_delete();
|
||||
+ test_duplicate();
|
||||
+}
|
||||
diff --git a/tools/make_specfiles b/tools/make_specfiles
|
||||
index 6e2f3d7..794d00c 100755
|
||||
--- a/tools/make_specfiles
|
||||
+++ b/tools/make_specfiles
|
||||
@@ -207,6 +207,7 @@ my @dll_groups =
|
||||
[
|
||||
"combase",
|
||||
"api-ms-win-core-winrt-l1-1-0",
|
||||
+ "api-ms-win-core-winrt-string-l1-1-0",
|
||||
],
|
||||
);
|
||||
|
||||
--
|
||||
2.1.3
|
||||
|
@ -0,0 +1,257 @@
|
||||
From 64e2fd6cfd71aa4e1358086e8ee961a7c44e32e0 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Tue, 9 Dec 2014 10:36:49 +0200
|
||||
Subject: combase: Implement functions for accessing HSTRING objects.
|
||||
|
||||
---
|
||||
.../api-ms-win-core-winrt-string-l1-1-0.spec | 8 +--
|
||||
dlls/combase/combase.spec | 8 +--
|
||||
dlls/combase/string.c | 66 ++++++++++++++++++++++
|
||||
dlls/combase/tests/string.c | 65 ++++++++++++++++++++-
|
||||
4 files changed, 138 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
index 7658867..cb6bb5e 100644
|
||||
--- a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
+++ b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
@@ -13,14 +13,14 @@
|
||||
@ stdcall WindowsDeleteString(ptr) combase.WindowsDeleteString
|
||||
@ stub WindowsDeleteStringBuffer
|
||||
@ stdcall WindowsDuplicateString(ptr ptr) combase.WindowsDuplicateString
|
||||
-@ stub WindowsGetStringLen
|
||||
-@ stub WindowsGetStringRawBuffer
|
||||
+@ stdcall WindowsGetStringLen(ptr) combase.WindowsGetStringLen
|
||||
+@ stdcall WindowsGetStringRawBuffer(ptr ptr) combase.WindowsGetStringRawBuffer
|
||||
@ stub WindowsInspectString
|
||||
-@ stub WindowsIsStringEmpty
|
||||
+@ stdcall WindowsIsStringEmpty(ptr) combase.WindowsIsStringEmpty
|
||||
@ stub WindowsPreallocateStringBuffer
|
||||
@ stub WindowsPromoteStringBuffer
|
||||
@ stub WindowsReplaceString
|
||||
-@ stub WindowsStringHasEmbeddedNull
|
||||
+@ stdcall WindowsStringHasEmbeddedNull(ptr ptr) combase.WindowsStringHasEmbeddedNull
|
||||
@ stub WindowsSubstring
|
||||
@ stub WindowsSubstringWithSpecifiedLength
|
||||
@ stub WindowsTrimStringEnd
|
||||
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
|
||||
index f399d25..e0136f0 100644
|
||||
--- a/dlls/combase/combase.spec
|
||||
+++ b/dlls/combase/combase.spec
|
||||
@@ -294,14 +294,14 @@
|
||||
@ stdcall WindowsDeleteString(ptr)
|
||||
@ stub WindowsDeleteStringBuffer
|
||||
@ stdcall WindowsDuplicateString(ptr ptr)
|
||||
-@ stub WindowsGetStringLen
|
||||
-@ stub WindowsGetStringRawBuffer
|
||||
+@ stdcall WindowsGetStringLen(ptr)
|
||||
+@ stdcall WindowsGetStringRawBuffer(ptr ptr)
|
||||
@ stub WindowsInspectString
|
||||
-@ stub WindowsIsStringEmpty
|
||||
+@ stdcall WindowsIsStringEmpty(ptr)
|
||||
@ stub WindowsPreallocateStringBuffer
|
||||
@ stub WindowsPromoteStringBuffer
|
||||
@ stub WindowsReplaceString
|
||||
-@ stub WindowsStringHasEmbeddedNull
|
||||
+@ stdcall WindowsStringHasEmbeddedNull(ptr ptr)
|
||||
@ stub WindowsSubstring
|
||||
@ stub WindowsSubstringWithSpecifiedLength
|
||||
@ stub WindowsTrimStringEnd
|
||||
diff --git a/dlls/combase/string.c b/dlls/combase/string.c
|
||||
index ee2f5c0..a451ed8 100644
|
||||
--- a/dlls/combase/string.c
|
||||
+++ b/dlls/combase/string.c
|
||||
@@ -141,3 +141,69 @@ HRESULT WINAPI WindowsDuplicateString(HSTRING str, HSTRING *out)
|
||||
*out = str;
|
||||
return S_OK;
|
||||
}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsGetStringLen (combase.@)
|
||||
+ */
|
||||
+UINT32 WINAPI WindowsGetStringLen(HSTRING str)
|
||||
+{
|
||||
+ struct hstring_private *priv = impl_from_HSTRING(str);
|
||||
+ if (str == NULL)
|
||||
+ return 0;
|
||||
+ return priv->length;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsGetStringRawBuffer (combase.@)
|
||||
+ */
|
||||
+LPCWSTR WINAPI WindowsGetStringRawBuffer(HSTRING str, UINT32 *len)
|
||||
+{
|
||||
+ static const WCHAR empty[] = { 0 };
|
||||
+ struct hstring_private *priv = impl_from_HSTRING(str);
|
||||
+ if (str == NULL)
|
||||
+ {
|
||||
+ if (len)
|
||||
+ *len = 0;
|
||||
+ return empty;
|
||||
+ }
|
||||
+ if (len)
|
||||
+ *len = priv->length;
|
||||
+ return priv->buffer;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsStringHasEmbeddedNull (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsStringHasEmbeddedNull(HSTRING str, BOOL *out)
|
||||
+{
|
||||
+ UINT32 i;
|
||||
+ struct hstring_private *priv = impl_from_HSTRING(str);
|
||||
+ if (out == NULL)
|
||||
+ return E_INVALIDARG;
|
||||
+ if (str == NULL)
|
||||
+ {
|
||||
+ *out = FALSE;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+ for (i = 0; i < priv->length; i++)
|
||||
+ {
|
||||
+ if (priv->buffer[i] == '\0')
|
||||
+ {
|
||||
+ *out = TRUE;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+ }
|
||||
+ *out = FALSE;
|
||||
+ return S_OK;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsIsStringEmpty (combase.@)
|
||||
+ */
|
||||
+BOOL WINAPI WindowsIsStringEmpty(HSTRING str)
|
||||
+{
|
||||
+ struct hstring_private *priv = impl_from_HSTRING(str);
|
||||
+ if (str == NULL)
|
||||
+ return TRUE;
|
||||
+ return priv->length == 0;
|
||||
+}
|
||||
diff --git a/dlls/combase/tests/string.c b/dlls/combase/tests/string.c
|
||||
index 01a63f7..ec5e517 100644
|
||||
--- a/dlls/combase/tests/string.c
|
||||
+++ b/dlls/combase/tests/string.c
|
||||
@@ -31,6 +31,10 @@ static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
|
||||
static HRESULT (WINAPI *pWindowsCreateStringReference)(LPCWSTR, UINT32, HSTRING_HEADER *, HSTRING *);
|
||||
static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
|
||||
static HRESULT (WINAPI *pWindowsDuplicateString)(HSTRING, HSTRING *);
|
||||
+static UINT32 (WINAPI *pWindowsGetStringLen)(HSTRING);
|
||||
+static LPCWSTR (WINAPI *pWindowsGetStringRawBuffer)(HSTRING, UINT32 *);
|
||||
+static BOOL (WINAPI *pWindowsIsStringEmpty)(HSTRING);
|
||||
+static HRESULT (WINAPI *pWindowsStringHasEmbeddedNull)(HSTRING, BOOL *);
|
||||
|
||||
#define SET(x) p##x = (void*)GetProcAddress(hmod, #x)
|
||||
|
||||
@@ -46,14 +50,42 @@ static BOOL init_functions(void)
|
||||
SET(WindowsCreateStringReference);
|
||||
SET(WindowsDeleteString);
|
||||
SET(WindowsDuplicateString);
|
||||
+ SET(WindowsGetStringLen);
|
||||
+ SET(WindowsGetStringRawBuffer);
|
||||
+ SET(WindowsIsStringEmpty);
|
||||
+ SET(WindowsStringHasEmbeddedNull);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#undef SET
|
||||
|
||||
|
||||
-static const WCHAR input_string[] = { 'a', 'b', 'c', 'd', 'e', 'f', '\0' };
|
||||
+#define check_string(str, content, length, has_null) _check_string(__LINE__, str, content, length, has_null)
|
||||
+static void _check_string(int line, HSTRING str, LPCWSTR content, UINT32 length, BOOL has_null)
|
||||
+{
|
||||
+ BOOL out_null;
|
||||
+ BOOL empty = length == 0;
|
||||
+ UINT32 out_length;
|
||||
+ LPCWSTR ptr;
|
||||
+
|
||||
+ ok_(__FILE__, line)(pWindowsIsStringEmpty(str) == empty, "WindowsIsStringEmpty failed\n");
|
||||
+ ok_(__FILE__, line)(pWindowsStringHasEmbeddedNull(str, &out_null) == S_OK, "pWindowsStringHasEmbeddedNull failed\n");
|
||||
+ ok_(__FILE__, line)(out_null == has_null, "WindowsStringHasEmbeddedNull failed\n");
|
||||
+ ok_(__FILE__, line)(pWindowsGetStringLen(str) == length, "WindowsGetStringLen failed\n");
|
||||
+ ptr = pWindowsGetStringRawBuffer(str, &out_length);
|
||||
+ /* WindowsGetStringRawBuffer should return a non-null, null terminated empty string
|
||||
+ * even if str is NULL. */
|
||||
+ ok_(__FILE__, line)(ptr != NULL, "WindowsGetStringRawBuffer returned null\n");
|
||||
+ ok_(__FILE__, line)(out_length == length, "WindowsGetStringRawBuffer returned incorrect length\n");
|
||||
+ ptr = pWindowsGetStringRawBuffer(str, NULL);
|
||||
+ ok_(__FILE__, line)(ptr != NULL, "WindowsGetStringRawBuffer returned null\n");
|
||||
+ ok_(__FILE__, line)(ptr[length] == '\0', "WindowsGetStringRawBuffer doesn't return a null terminated buffer\n");
|
||||
+ ok_(__FILE__, line)(memcmp(ptr, content, sizeof(*content) * length) == 0, "Incorrect string content\n");
|
||||
+}
|
||||
+
|
||||
+static const WCHAR input_string[] = { 'a', 'b', 'c', 'd', 'e', 'f', '\0', '\0' };
|
||||
static const WCHAR input_empty_string[] = { '\0' };
|
||||
+static const WCHAR input_embed_null[] = { 'a', '\0', 'c', '\0', 'e', 'f', '\0' };
|
||||
|
||||
static void test_create_delete(void)
|
||||
{
|
||||
@@ -62,6 +94,7 @@ static void test_create_delete(void)
|
||||
|
||||
/* Test normal creation of a string */
|
||||
ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
|
||||
+ check_string(str, input_string, 6, FALSE);
|
||||
ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
/* Test error handling in WindowsCreateString */
|
||||
ok(pWindowsCreateString(input_string, 6, NULL) == E_INVALIDARG, "Incorrect error handling\n");
|
||||
@@ -72,6 +105,7 @@ static void test_create_delete(void)
|
||||
|
||||
/* Test creation of a string reference */
|
||||
ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
|
||||
+ check_string(str, input_string, 6, FALSE);
|
||||
ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
|
||||
|
||||
/* Test error handling in WindowsCreateStringReference */
|
||||
@@ -85,6 +119,7 @@ static void test_create_delete(void)
|
||||
|
||||
/* Test creating a string without a null-termination at the specified length */
|
||||
ok(pWindowsCreateString(input_string, 3, &str) == S_OK, "Failed to create string\n");
|
||||
+ check_string(str, input_string, 3, FALSE);
|
||||
ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
|
||||
/* Test an empty string */
|
||||
@@ -119,10 +154,38 @@ static void test_duplicate(void)
|
||||
ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
|
||||
}
|
||||
|
||||
+static void test_access(void)
|
||||
+{
|
||||
+ HSTRING str;
|
||||
+ HSTRING_HEADER header;
|
||||
+
|
||||
+ /* Test handling of a NULL string */
|
||||
+ check_string(NULL, NULL, 0, FALSE);
|
||||
+
|
||||
+ /* Test strings with embedded null chars */
|
||||
+ ok(pWindowsCreateString(input_embed_null, 6, &str) == S_OK, "Failed to create string\n");
|
||||
+ check_string(str, input_embed_null, 6, TRUE);
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+
|
||||
+ ok(pWindowsCreateStringReference(input_embed_null, 6, &header, &str) == S_OK, "Failed to create string ref\n");
|
||||
+ check_string(str, input_embed_null, 6, TRUE);
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
|
||||
+
|
||||
+ /* Test normal creation of a string with trailing null */
|
||||
+ ok(pWindowsCreateString(input_string, 7, &str) == S_OK, "Failed to create string\n");
|
||||
+ check_string(str, input_string, 7, TRUE);
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+
|
||||
+ ok(pWindowsCreateStringReference(input_string, 7, &header, &str) == S_OK, "Failed to create string ref\n");
|
||||
+ check_string(str, input_string, 7, TRUE);
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
|
||||
+}
|
||||
+
|
||||
START_TEST(string)
|
||||
{
|
||||
if (!init_functions())
|
||||
return;
|
||||
test_create_delete();
|
||||
test_duplicate();
|
||||
+ test_access();
|
||||
}
|
||||
--
|
||||
2.1.3
|
||||
|
@ -0,0 +1,245 @@
|
||||
From 012a71baa669e6ead66a1d5f94c8ee81d8cfce58 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Tue, 9 Dec 2014 10:36:50 +0200
|
||||
Subject: combase: Implement functions for HSTRING_BUFFER.
|
||||
|
||||
---
|
||||
.../api-ms-win-core-winrt-string-l1-1-0.spec | 6 +--
|
||||
dlls/combase/combase.spec | 6 +--
|
||||
dlls/combase/string.c | 60 +++++++++++++++++++++-
|
||||
dlls/combase/tests/string.c | 56 ++++++++++++++++++++
|
||||
4 files changed, 121 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
index cb6bb5e..2361a1d 100644
|
||||
--- a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
+++ b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
|
||||
@@ -11,14 +11,14 @@
|
||||
@ stdcall WindowsCreateString(ptr long ptr) combase.WindowsCreateString
|
||||
@ stdcall WindowsCreateStringReference(wstr long ptr ptr) combase.WindowsCreateStringReference
|
||||
@ stdcall WindowsDeleteString(ptr) combase.WindowsDeleteString
|
||||
-@ stub WindowsDeleteStringBuffer
|
||||
+@ stdcall WindowsDeleteStringBuffer(ptr) combase.WindowsDeleteStringBuffer
|
||||
@ stdcall WindowsDuplicateString(ptr ptr) combase.WindowsDuplicateString
|
||||
@ stdcall WindowsGetStringLen(ptr) combase.WindowsGetStringLen
|
||||
@ stdcall WindowsGetStringRawBuffer(ptr ptr) combase.WindowsGetStringRawBuffer
|
||||
@ stub WindowsInspectString
|
||||
@ stdcall WindowsIsStringEmpty(ptr) combase.WindowsIsStringEmpty
|
||||
-@ stub WindowsPreallocateStringBuffer
|
||||
-@ stub WindowsPromoteStringBuffer
|
||||
+@ stdcall WindowsPreallocateStringBuffer(long ptr ptr) combase.WindowsPreallocateStringBuffer
|
||||
+@ stdcall WindowsPromoteStringBuffer(ptr ptr) combase.WindowsPromoteStringBuffer
|
||||
@ stub WindowsReplaceString
|
||||
@ stdcall WindowsStringHasEmbeddedNull(ptr ptr) combase.WindowsStringHasEmbeddedNull
|
||||
@ stub WindowsSubstring
|
||||
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
|
||||
index e0136f0..ac095ce 100644
|
||||
--- a/dlls/combase/combase.spec
|
||||
+++ b/dlls/combase/combase.spec
|
||||
@@ -292,14 +292,14 @@
|
||||
@ stdcall WindowsCreateString(ptr long ptr)
|
||||
@ stdcall WindowsCreateStringReference(wstr long ptr ptr)
|
||||
@ stdcall WindowsDeleteString(ptr)
|
||||
-@ stub WindowsDeleteStringBuffer
|
||||
+@ stdcall WindowsDeleteStringBuffer(ptr)
|
||||
@ stdcall WindowsDuplicateString(ptr ptr)
|
||||
@ stdcall WindowsGetStringLen(ptr)
|
||||
@ stdcall WindowsGetStringRawBuffer(ptr ptr)
|
||||
@ stub WindowsInspectString
|
||||
@ stdcall WindowsIsStringEmpty(ptr)
|
||||
-@ stub WindowsPreallocateStringBuffer
|
||||
-@ stub WindowsPromoteStringBuffer
|
||||
+@ stdcall WindowsPreallocateStringBuffer(long ptr ptr)
|
||||
+@ stdcall WindowsPromoteStringBuffer(ptr ptr)
|
||||
@ stub WindowsReplaceString
|
||||
@ stdcall WindowsStringHasEmbeddedNull(ptr ptr)
|
||||
@ stub WindowsSubstring
|
||||
diff --git a/dlls/combase/string.c b/dlls/combase/string.c
|
||||
index a451ed8..693d40a 100644
|
||||
--- a/dlls/combase/string.c
|
||||
+++ b/dlls/combase/string.c
|
||||
@@ -32,6 +32,8 @@ struct hstring_private
|
||||
LONG refcount;
|
||||
};
|
||||
|
||||
+static const WCHAR empty[] = { 0 };
|
||||
+
|
||||
C_ASSERT(sizeof(struct hstring_private) <= sizeof(HSTRING_HEADER));
|
||||
|
||||
static inline struct hstring_private *impl_from_HSTRING(HSTRING string)
|
||||
@@ -44,6 +46,11 @@ static inline struct hstring_private *impl_from_HSTRING_HEADER(HSTRING_HEADER *h
|
||||
return (struct hstring_private *)header;
|
||||
}
|
||||
|
||||
+static inline struct hstring_private *impl_from_HSTRING_BUFFER(HSTRING_BUFFER buffer)
|
||||
+{
|
||||
+ return (struct hstring_private *)buffer;
|
||||
+}
|
||||
+
|
||||
static BOOL alloc_string(UINT32 len, HSTRING *out)
|
||||
{
|
||||
struct hstring_private *priv;
|
||||
@@ -143,6 +150,58 @@ HRESULT WINAPI WindowsDuplicateString(HSTRING str, HSTRING *out)
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
+ * WindowsPreallocateStringBuffer (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsPreallocateStringBuffer(UINT32 len, WCHAR **outptr,
|
||||
+ HSTRING_BUFFER *out)
|
||||
+{
|
||||
+ struct hstring_private *priv;
|
||||
+ HSTRING str;
|
||||
+ if (outptr == NULL || out == NULL)
|
||||
+ return E_POINTER;
|
||||
+ if (len == 0)
|
||||
+ {
|
||||
+ *outptr = (LPWSTR)empty;
|
||||
+ *out = NULL;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+
|
||||
+ if (!alloc_string(len, &str))
|
||||
+ return E_OUTOFMEMORY;
|
||||
+ priv = impl_from_HSTRING(str);
|
||||
+ *outptr = priv->buffer;
|
||||
+ *out = (HSTRING_BUFFER)str;
|
||||
+ return S_OK;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsDeleteStringBuffer (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsDeleteStringBuffer(HSTRING_BUFFER buf)
|
||||
+{
|
||||
+ return WindowsDeleteString((HSTRING)buf);
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * WindowsPromoteStringBuffer (combase.@)
|
||||
+ */
|
||||
+HRESULT WINAPI WindowsPromoteStringBuffer(HSTRING_BUFFER buf, HSTRING *out)
|
||||
+{
|
||||
+ struct hstring_private *priv = impl_from_HSTRING_BUFFER(buf);
|
||||
+ if (out == NULL)
|
||||
+ return E_POINTER;
|
||||
+ if (buf == NULL)
|
||||
+ {
|
||||
+ *out = NULL;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+ if (priv->buffer[priv->length] != 0 || priv->reference || priv->refcount != 1)
|
||||
+ return E_INVALIDARG;
|
||||
+ *out = (HSTRING)buf;
|
||||
+ return S_OK;
|
||||
+}
|
||||
+
|
||||
+/***********************************************************************
|
||||
* WindowsGetStringLen (combase.@)
|
||||
*/
|
||||
UINT32 WINAPI WindowsGetStringLen(HSTRING str)
|
||||
@@ -158,7 +217,6 @@ UINT32 WINAPI WindowsGetStringLen(HSTRING str)
|
||||
*/
|
||||
LPCWSTR WINAPI WindowsGetStringRawBuffer(HSTRING str, UINT32 *len)
|
||||
{
|
||||
- static const WCHAR empty[] = { 0 };
|
||||
struct hstring_private *priv = impl_from_HSTRING(str);
|
||||
if (str == NULL)
|
||||
{
|
||||
diff --git a/dlls/combase/tests/string.c b/dlls/combase/tests/string.c
|
||||
index ec5e517..72eaa84 100644
|
||||
--- a/dlls/combase/tests/string.c
|
||||
+++ b/dlls/combase/tests/string.c
|
||||
@@ -30,10 +30,13 @@
|
||||
static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
|
||||
static HRESULT (WINAPI *pWindowsCreateStringReference)(LPCWSTR, UINT32, HSTRING_HEADER *, HSTRING *);
|
||||
static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
|
||||
+static HRESULT (WINAPI *pWindowsDeleteStringBuffer)(HSTRING_BUFFER);
|
||||
static HRESULT (WINAPI *pWindowsDuplicateString)(HSTRING, HSTRING *);
|
||||
static UINT32 (WINAPI *pWindowsGetStringLen)(HSTRING);
|
||||
static LPCWSTR (WINAPI *pWindowsGetStringRawBuffer)(HSTRING, UINT32 *);
|
||||
static BOOL (WINAPI *pWindowsIsStringEmpty)(HSTRING);
|
||||
+static HRESULT (WINAPI *pWindowsPreallocateStringBuffer)(UINT32, WCHAR **, HSTRING_BUFFER *);
|
||||
+static HRESULT (WINAPI *pWindowsPromoteStringBuffer)(HSTRING_BUFFER, HSTRING *);
|
||||
static HRESULT (WINAPI *pWindowsStringHasEmbeddedNull)(HSTRING, BOOL *);
|
||||
|
||||
#define SET(x) p##x = (void*)GetProcAddress(hmod, #x)
|
||||
@@ -49,10 +52,13 @@ static BOOL init_functions(void)
|
||||
SET(WindowsCreateString);
|
||||
SET(WindowsCreateStringReference);
|
||||
SET(WindowsDeleteString);
|
||||
+ SET(WindowsDeleteStringBuffer);
|
||||
SET(WindowsDuplicateString);
|
||||
SET(WindowsGetStringLen);
|
||||
SET(WindowsGetStringRawBuffer);
|
||||
SET(WindowsIsStringEmpty);
|
||||
+ SET(WindowsPreallocateStringBuffer);
|
||||
+ SET(WindowsPromoteStringBuffer);
|
||||
SET(WindowsStringHasEmbeddedNull);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -181,6 +187,55 @@ static void test_access(void)
|
||||
ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
|
||||
}
|
||||
|
||||
+static void test_string_buffer(void)
|
||||
+{
|
||||
+ /* Initialize ptr to NULL to make sure it actually is set in the first
|
||||
+ * test below. */
|
||||
+ HSTRING_BUFFER buf = NULL;
|
||||
+ WCHAR *ptr = NULL;
|
||||
+ HSTRING str;
|
||||
+
|
||||
+ /* Test creation of an empty buffer */
|
||||
+ ok(pWindowsPreallocateStringBuffer(0, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
|
||||
+ ok(buf == NULL, "Empty string buffer isn't a null string\n");
|
||||
+ ok(ptr != NULL, "Empty string didn't return a buffer pointer\n");
|
||||
+ ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
|
||||
+ ok(str == NULL, "Empty string isn't a null string\n");
|
||||
+ check_string(str, input_empty_string, 0, FALSE);
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+
|
||||
+ ok(pWindowsDeleteStringBuffer(NULL) == S_OK, "Failed to delete null string buffer\n");
|
||||
+
|
||||
+ /* Test creation and deletion of string buffers */
|
||||
+ ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
|
||||
+ ok(pWindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n");
|
||||
+
|
||||
+ /* Test creation and promotion of string buffers */
|
||||
+ ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
|
||||
+ ok(ptr[6] == '\0', "Preallocated string buffer didn't have null termination\n");
|
||||
+ memcpy(ptr, input_string, 6 * sizeof(*input_string));
|
||||
+ ok(pWindowsPromoteStringBuffer(buf, NULL) == E_POINTER, "Incorrect error handling\n");
|
||||
+ ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
|
||||
+ check_string(str, input_string, 6, FALSE);
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+
|
||||
+ /* Test error handling in preallocation */
|
||||
+ ok(pWindowsPreallocateStringBuffer(6, NULL, &buf) == E_POINTER, "Incorrect error handling\n");
|
||||
+ ok(pWindowsPreallocateStringBuffer(6, &ptr, NULL) == E_POINTER, "Incorrect error handling\n");
|
||||
+
|
||||
+ ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
|
||||
+ ptr[6] = 'a'; /* Overwrite the buffer's null termination, promotion should fail */
|
||||
+ ok(pWindowsPromoteStringBuffer(buf, &str) == E_INVALIDARG, "Incorrect error handling\n");
|
||||
+ ok(pWindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n");
|
||||
+
|
||||
+ /* Test strings with trailing null chars */
|
||||
+ ok(pWindowsPreallocateStringBuffer(7, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
|
||||
+ memcpy(ptr, input_string, 7 * sizeof(*input_string));
|
||||
+ ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
|
||||
+ check_string(str, input_string, 7, TRUE);
|
||||
+ ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
|
||||
+}
|
||||
+
|
||||
START_TEST(string)
|
||||
{
|
||||
if (!init_functions())
|
||||
@@ -188,4 +243,5 @@ START_TEST(string)
|
||||
test_create_delete();
|
||||
test_duplicate();
|
||||
test_access();
|
||||
+ test_string_buffer();
|
||||
}
|
||||
--
|
||||
2.1.3
|
||||
|
1
patches/combase-HSTRING/definition
Normal file
1
patches/combase-HSTRING/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: Support for combase HSTRING objects
|
Loading…
x
Reference in New Issue
Block a user