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 f629bcfbcb8..dc67deb7867 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 @@ -22,6 +22,6 @@ @ stub WindowsReplaceString @ stdcall WindowsStringHasEmbeddedNull(ptr ptr) combase.WindowsStringHasEmbeddedNull @ stdcall WindowsSubstring(ptr long ptr) combase.WindowsSubstring -@ stub WindowsSubstringWithSpecifiedLength +@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr) combase.WindowsSubstringWithSpecifiedLength @ stub WindowsTrimStringEnd @ stub WindowsTrimStringStart diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index e7c8866523f..fcd59474ee1 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -303,6 +303,6 @@ @ stub WindowsReplaceString @ stdcall WindowsStringHasEmbeddedNull(ptr ptr) @ stdcall WindowsSubstring(ptr long ptr) -@ stub WindowsSubstringWithSpecifiedLength +@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr) @ stub WindowsTrimStringEnd @ stub WindowsTrimStringStart diff --git a/dlls/combase/string.c b/dlls/combase/string.c index 2146d6179bb..49d76958d94 100644 --- a/dlls/combase/string.c +++ b/dlls/combase/string.c @@ -307,6 +307,28 @@ HRESULT WINAPI WindowsSubstring(HSTRING str, UINT32 start, HSTRING *out) return WindowsCreateString(&priv->buffer[start], len - start, out); } +/*********************************************************************** + * WindowsSubstringWithSpecifiedLength (combase.@) + */ +HRESULT WINAPI WindowsSubstringWithSpecifiedLength(HSTRING str, UINT32 start, UINT32 len, HSTRING *out) +{ + struct hstring_private *priv = impl_from_HSTRING(str); + + TRACE("(%p, %u, %u, %p)\n", str, start, len, out); + + if (out == NULL) + return E_INVALIDARG; + if (start + len < start || + start + len > WindowsGetStringLen(str)) + return E_BOUNDS; + if (len == 0) + { + *out = NULL; + return S_OK; + } + return WindowsCreateString(&priv->buffer[start], len, out); +} + /*********************************************************************** * WindowsIsStringEmpty (combase.@) */