From: Paul Gofman pgofman@codeweavers.com
--- configure.ac | 1 + dlls/tdh/tdh.spec | 2 +- dlls/tdh/tdh_main.c | 17 ++++++++++ dlls/tdh/tests/Makefile.in | 5 +++ dlls/tdh/tests/tdh.c | 63 ++++++++++++++++++++++++++++++++++++++ include/Makefile.in | 1 + include/tdh.h | 42 +++++++++++++++++++++++++ 7 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 dlls/tdh/tests/Makefile.in create mode 100644 dlls/tdh/tests/tdh.c create mode 100644 include/tdh.h
diff --git a/configure.ac b/configure.ac index a7f00402498..142a93b570a 100644 --- a/configure.ac +++ b/configure.ac @@ -3201,6 +3201,7 @@ WINE_CONFIG_MAKEFILE(dlls/taskschd) WINE_CONFIG_MAKEFILE(dlls/taskschd/tests) WINE_CONFIG_MAKEFILE(dlls/tbs) WINE_CONFIG_MAKEFILE(dlls/tdh) +WINE_CONFIG_MAKEFILE(dlls/tdh/tests) WINE_CONFIG_MAKEFILE(dlls/tdi.sys) WINE_CONFIG_MAKEFILE(dlls/threadpoolwinrt) WINE_CONFIG_MAKEFILE(dlls/threadpoolwinrt/tests) diff --git a/dlls/tdh/tdh.spec b/dlls/tdh/tdh.spec index cde397c3899..0a2663714fe 100644 --- a/dlls/tdh/tdh.spec +++ b/dlls/tdh/tdh.spec @@ -7,7 +7,7 @@ @ stub TdhEnumerateManifestProviderEvents @ stub TdhEnumerateProviderFieldInformation @ stub TdhEnumerateProviderFilters -@ stub TdhEnumerateProviders +@ stdcall TdhEnumerateProviders(ptr ptr) @ stub TdhEnumerateRemoteWBEMProviderFieldInformation @ stub TdhEnumerateRemoteWBEMProviders @ stub TdhFormatProperty diff --git a/dlls/tdh/tdh_main.c b/dlls/tdh/tdh_main.c index 60f32976b98..1b46ac793f0 100644 --- a/dlls/tdh/tdh_main.c +++ b/dlls/tdh/tdh_main.c @@ -23,6 +23,7 @@ #include "windef.h" #include "winbase.h" #include "winternl.h" +#include "tdh.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(tdh); @@ -38,3 +39,19 @@ ULONG WINAPI TdhLoadManifestFromBinary(LPWSTR binary) FIXME("(%s): stub\n", debugstr_w(binary)); return STATUS_SUCCESS; } + +ULONG WINAPI TdhEnumerateProviders( PROVIDER_ENUMERATION_INFO *buffer, ULONG *buffer_size ) +{ + FIXME( "%p %p semi-stub.\n", buffer, buffer_size ); + + if (!buffer_size) return ERROR_INVALID_PARAMETER; + if (*buffer_size && !buffer) return ERROR_INVALID_PARAMETER; + + if (*buffer_size < offsetof(PROVIDER_ENUMERATION_INFO, TraceProviderInfoArray)) + { + *buffer_size = offsetof(PROVIDER_ENUMERATION_INFO, TraceProviderInfoArray); + return ERROR_INSUFFICIENT_BUFFER; + } + buffer->NumberOfProviders = 0; + return ERROR_SUCCESS; +} diff --git a/dlls/tdh/tests/Makefile.in b/dlls/tdh/tests/Makefile.in new file mode 100644 index 00000000000..4e0c6aeddb1 --- /dev/null +++ b/dlls/tdh/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = tdh.dll +IMPORTS = tdh + +SOURCES = \ + tdh.c diff --git a/dlls/tdh/tests/tdh.c b/dlls/tdh/tests/tdh.c new file mode 100644 index 00000000000..731e78aaa7e --- /dev/null +++ b/dlls/tdh/tests/tdh.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2025 Paul Gofman for CodeWeavers + * + * 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 "tdh.h" + +#include "wine/test.h" + +static void test_providers(void) +{ + PROVIDER_ENUMERATION_INFO *info; + ULONG size, size2; + DWORD err; + + err = TdhEnumerateProviders( NULL, NULL ); + ok( err == ERROR_INVALID_PARAMETER, "got %lu.\n", err ); + + size = 1; + err = TdhEnumerateProviders( NULL, &size ); + ok( err == ERROR_INVALID_PARAMETER, "got %lu.\n", err ); + ok( size == 1, "got %lu.\n", size ); + + size = 0; + err = TdhEnumerateProviders( NULL, &size ); + ok( err == ERROR_INSUFFICIENT_BUFFER, "got %lu.\n", err ); + ok( size >= offsetof( PROVIDER_ENUMERATION_INFO, TraceProviderInfoArray ), "got %lu.\n", size ); + info = malloc( size ); + size2 = 1; + err = TdhEnumerateProviders( info, &size2 ); + ok( err == ERROR_INSUFFICIENT_BUFFER, "got %lu.\n", err ); + ok( size2 == size, "got %lu, %lu.\n", size2, size ); + + size2 = size; + err = TdhEnumerateProviders( info, &size2 ); + ok( !err, "got %lu.\n", err ); + ok( size2 == size, "got %lu, %lu.\n", size2, size ); + size2 = offsetof( PROVIDER_ENUMERATION_INFO, TraceProviderInfoArray[info->NumberOfProviders] ); + ok( size >= size2, "got %lu, expected %lu.\n", size, size2 ); +} + +START_TEST(tdh) +{ + test_providers(); +} diff --git a/include/Makefile.in b/include/Makefile.in index a43168baf1f..6b33733a6f2 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -785,6 +785,7 @@ SOURCES = \ tchar.h \ tcpestats.h \ tcpmib.h \ + tdh.h \ textserv.h \ textstor.idl \ threadpoolapiset.h \ diff --git a/include/tdh.h b/include/tdh.h new file mode 100644 index 00000000000..007ccfc7fb7 --- /dev/null +++ b/include/tdh.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2025 Paul Gofman for CodeWeavers + * + * 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_TDH_H +#define __WINE_TDH_H + +ULONG WINAPI TdhLoadManifest( WCHAR *manifest ); +ULONG WINAPI TdhLoadManifestFromBinary( WCHAR *binary ); + +typedef struct _TRACE_PROVIDER_INFO +{ + GUID ProviderGuid; + ULONG SchemaSource; + ULONG ProviderNameOffset; +} +TRACE_PROVIDER_INFO; + +typedef struct _PROVIDER_ENUMERATION_INFO +{ + ULONG NumberOfProviders; + ULONG Reserved; + TRACE_PROVIDER_INFO TraceProviderInfoArray[ANYSIZE_ARRAY]; +} +PROVIDER_ENUMERATION_INFO; + +ULONG WINAPI TdhEnumerateProviders( PROVIDER_ENUMERATION_INFO *buffer, ULONG *buffer_size ); +#endif