Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- The functions CurrentIP and ConstructPartialMsgV[A/W] are used by other Windows libraries including kernelbase. --- include/Makefile.in | 1 + include/wdscore.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 include/wdscore.h
diff --git a/include/Makefile.in b/include/Makefile.in index 189b4676091..5b77d5b47c5 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -755,6 +755,7 @@ SOURCES = \ wbemdisp.idl \ wbemprov.idl \ wct.h \ + wdscore.h \ weakreference.idl \ webservices.h \ werapi.h \ diff --git a/include/wdscore.h b/include/wdscore.h new file mode 100644 index 00000000000..8888247e347 --- /dev/null +++ b/include/wdscore.h @@ -0,0 +1,32 @@ +/* + * Copyright 2022 Mohamad Al-Jaf + * + * 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 __WDSCORE__ +#define __WDSCORE__ + +#ifdef __cplusplus +extern "C" { +#endif + +LPVOID CurrentIP(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __WDSCORE__ */
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51850 Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v9: - Include wdscore.h instead of wdscore_internal.h. --- configure.ac | 1 + dlls/wdscore/Makefile.in | 4 +++ dlls/wdscore/main.c | 55 ++++++++++++++++++++++++++++ dlls/wdscore/tests/Makefile.in | 4 +++ dlls/wdscore/tests/main.c | 65 ++++++++++++++++++++++++++++++++++ dlls/wdscore/wdscore.spec | 2 +- 6 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 dlls/wdscore/main.c create mode 100644 dlls/wdscore/tests/Makefile.in create mode 100644 dlls/wdscore/tests/main.c
diff --git a/configure.ac b/configure.ac index 5a85fce12a4..fcac57bf7e3 100644 --- a/configure.ac +++ b/configure.ac @@ -3054,6 +3054,7 @@ WINE_CONFIG_MAKEFILE(dlls/wbemdisp/tests) WINE_CONFIG_MAKEFILE(dlls/wbemprox) WINE_CONFIG_MAKEFILE(dlls/wbemprox/tests) WINE_CONFIG_MAKEFILE(dlls/wdscore) +WINE_CONFIG_MAKEFILE(dlls/wdscore/tests) WINE_CONFIG_MAKEFILE(dlls/webservices) WINE_CONFIG_MAKEFILE(dlls/webservices/tests) WINE_CONFIG_MAKEFILE(dlls/websocket) diff --git a/dlls/wdscore/Makefile.in b/dlls/wdscore/Makefile.in index 20ba1d3b1c9..b4f7282748c 100644 --- a/dlls/wdscore/Makefile.in +++ b/dlls/wdscore/Makefile.in @@ -1,3 +1,7 @@ MODULE = wdscore.dll
EXTRADLLFLAGS = -Wb,--prefer-native + + +C_SRCS = \ + main.c diff --git a/dlls/wdscore/main.c b/dlls/wdscore/main.c new file mode 100644 index 00000000000..bf3e11131c7 --- /dev/null +++ b/dlls/wdscore/main.c @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Mohamad Al-Jaf + * + * 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 "wdscore.h" + +#include "wine/asm.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wdscore); + +/*********************************************************************** + * CurrentIP (wdscore.@) + */ +#ifdef __i386__ +__ASM_GLOBAL_FUNC(CurrentIP, + "movl (%esp), %eax\n\t" + "ret" ) +#elif defined(__x86_64__) +__ASM_GLOBAL_FUNC(CurrentIP, + "movq (%rsp), %rax\n\t" + "ret" ) +#elif defined(__arm__) +__ASM_GLOBAL_FUNC(CurrentIP, + "mov r0, lr\n\t" + "bx lr" ) +#elif defined(__aarch64__) +__ASM_GLOBAL_FUNC(CurrentIP, + "mov x0, lr\n\t" + "ret" ) +#else +LPVOID CurrentIP(void) +{ + FIXME( "not implemented\n" ); + return NULL; +} +#endif diff --git a/dlls/wdscore/tests/Makefile.in b/dlls/wdscore/tests/Makefile.in new file mode 100644 index 00000000000..baf4adf23a1 --- /dev/null +++ b/dlls/wdscore/tests/Makefile.in @@ -0,0 +1,4 @@ +TESTDLL = wdscore.dll + +C_SRCS = \ + main.c diff --git a/dlls/wdscore/tests/main.c b/dlls/wdscore/tests/main.c new file mode 100644 index 00000000000..8c0b6c6a5a8 --- /dev/null +++ b/dlls/wdscore/tests/main.c @@ -0,0 +1,65 @@ +/* + * Unit test suite for wdscore + * + * Copyright 2022 Mohamad Al-Jaf + * + * 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 "wine/test.h" + +static HMODULE dll; +static LPVOID (*pCurrentIP)(void); + +static BOOL init_function_pointers(void) +{ + dll = LoadLibraryA("wdscore.dll"); + + if (dll) + { + pCurrentIP = (void*)GetProcAddress(dll, "CurrentIP"); + return TRUE; + } + + return FALSE; +} + +static void test_CurrentIP(void) +{ + char *cur; + char *ret; + + cur = (char*)&test_CurrentIP; + ret = (char*)pCurrentIP(); + + ok(cur <= ret && ret < (cur + 0x100), "Address %p not in function starting at %p.\n", ret, cur); +} + +START_TEST(main) +{ + if (init_function_pointers()) + { + test_CurrentIP(); + FreeLibrary(dll); + } + else + skip("could not load wdscore.dll\n"); +} diff --git a/dlls/wdscore/wdscore.spec b/dlls/wdscore/wdscore.spec index 15958b86aba..c292f65505b 100644 --- a/dlls/wdscore/wdscore.spec +++ b/dlls/wdscore/wdscore.spec @@ -71,7 +71,7 @@ @ stub ConstructPartialMsgIfW @ stub ConstructPartialMsgVA @ stub ConstructPartialMsgVW -@ stub CurrentIP +@ cdecl CurrentIP() @ stub EndMajorTask @ stub EndMinorTask @ stub GetMajorTask
Needed for the Windows MediaCreationTool21H2 to run.
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- dlls/wdscore/main.c | 9 +++++++++ dlls/wdscore/wdscore.spec | 2 +- include/wdscore.h | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/dlls/wdscore/main.c b/dlls/wdscore/main.c index bf3e11131c7..828e8c2451d 100644 --- a/dlls/wdscore/main.c +++ b/dlls/wdscore/main.c @@ -53,3 +53,12 @@ LPVOID CurrentIP(void) return NULL; } #endif + +/*********************************************************************** + * ConstructPartialMsgVW (wdscore.@) + */ +LPVOID WINAPI ConstructPartialMsgVW( WdsLogLevel level, LPCWSTR msg, va_list args ) +{ + FIXME( "%u %s - stub\n", level, debugstr_w(msg) ); + return NULL; +} diff --git a/dlls/wdscore/wdscore.spec b/dlls/wdscore/wdscore.spec index c292f65505b..4690fb3badd 100644 --- a/dlls/wdscore/wdscore.spec +++ b/dlls/wdscore/wdscore.spec @@ -70,7 +70,7 @@ @ stub ConstructPartialMsgIfA @ stub ConstructPartialMsgIfW @ stub ConstructPartialMsgVA -@ stub ConstructPartialMsgVW +@ stdcall ConstructPartialMsgVW(long wstr ptr) @ cdecl CurrentIP() @ stub EndMajorTask @ stub EndMinorTask diff --git a/include/wdscore.h b/include/wdscore.h index 8888247e347..36e3a216649 100644 --- a/include/wdscore.h +++ b/include/wdscore.h @@ -23,7 +23,19 @@ extern "C" { #endif
+typedef enum _WdsLogLevel { + WdsLogLevelAssert = 0x00000000, + WdsLogLevelFatalError = 0x01000000, + WdsLogLevelError = 0x02000000, + WdsLogLevelWarning = 0x03000000, + WdsLogLevelInfo = 0x04000000, + WdsLogLevelStatus = 0x05000000, + WdsLogLevelVerbose = 0x68000000, + WdsLogLevelTrace = 0x70000000 +} WdsLogLevel; + LPVOID CurrentIP(void); +LPVOID WINAPI ConstructPartialMsgVW(WdsLogLevel,LPCWSTR,va_list);
#ifdef __cplusplus }
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- There's no public API for this function so I didn't add WINELIB_NAME_AW. --- dlls/wdscore/main.c | 23 +++++++++++++++++++++++ dlls/wdscore/wdscore.spec | 2 +- include/wdscore.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/dlls/wdscore/main.c b/dlls/wdscore/main.c index 828e8c2451d..3d18ee2d5ab 100644 --- a/dlls/wdscore/main.c +++ b/dlls/wdscore/main.c @@ -20,6 +20,7 @@
#include "windef.h" #include "winbase.h" +#include "winnls.h" #include "wdscore.h"
#include "wine/asm.h" @@ -54,6 +55,28 @@ LPVOID CurrentIP(void) } #endif
+/*********************************************************************** + * ConstructPartialMsgVA (wdscore.@) + */ +LPVOID WINAPI ConstructPartialMsgVA( WdsLogLevel level, LPCSTR msg, va_list args ) +{ + DWORD len; + LPVOID ret; + LPWSTR str = NULL; + + if(msg) + { + len = MultiByteToWideChar( CP_ACP, 0, msg, -1, NULL, 0 ); + str = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, msg, -1, str, len ); + } + + ret = ConstructPartialMsgVW( level, str, args ); + + HeapFree( GetProcessHeap(), 0, str ); + return ret; +} + /*********************************************************************** * ConstructPartialMsgVW (wdscore.@) */ diff --git a/dlls/wdscore/wdscore.spec b/dlls/wdscore/wdscore.spec index 4690fb3badd..86a3bf37797 100644 --- a/dlls/wdscore/wdscore.spec +++ b/dlls/wdscore/wdscore.spec @@ -69,7 +69,7 @@ #@ extern g_bEnableDiagnosticMode @ stub ConstructPartialMsgIfA @ stub ConstructPartialMsgIfW -@ stub ConstructPartialMsgVA +@ stdcall ConstructPartialMsgVA(long str ptr) @ stdcall ConstructPartialMsgVW(long wstr ptr) @ cdecl CurrentIP() @ stub EndMajorTask diff --git a/include/wdscore.h b/include/wdscore.h index 36e3a216649..d7007d13804 100644 --- a/include/wdscore.h +++ b/include/wdscore.h @@ -35,6 +35,7 @@ typedef enum _WdsLogLevel { } WdsLogLevel;
LPVOID CurrentIP(void); +LPVOID WINAPI ConstructPartialMsgVA(WdsLogLevel,LPCSTR,va_list); LPVOID WINAPI ConstructPartialMsgVW(WdsLogLevel,LPCWSTR,va_list);
#ifdef __cplusplus
Needed for the Windows MediaCreationTool21H2 to run.
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v9: - Rename arguments to conform to Wine's naming convention of unknown variables, based on dlls/wow64win. --- dlls/wdscore/main.c | 13 +++++++++++++ dlls/wdscore/wdscore.spec | 2 +- include/wdscore.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/dlls/wdscore/main.c b/dlls/wdscore/main.c index 3d18ee2d5ab..8ebcedfba6b 100644 --- a/dlls/wdscore/main.c +++ b/dlls/wdscore/main.c @@ -85,3 +85,16 @@ LPVOID WINAPI ConstructPartialMsgVW( WdsLogLevel level, LPCWSTR msg, va_list arg FIXME( "%u %s - stub\n", level, debugstr_w(msg) ); return NULL; } + +/*********************************************************************** + * WdsSetupLogMessageW (wdscore.@) + */ +HRESULT WINAPI WdsSetupLogMessageW( LPVOID msg, WdsLogSource src, LPCWSTR str1, LPCWSTR str2, + ULONG unk1, LPCWSTR file, LPCWSTR func, void *ip, + ULONG unk2, void *unk3, UINT unk4 ) +{ + FIXME( "%p, %u, %s, %s, %lu, %s, %s, %p, %lu, %p, %u - stub\n", msg, src, debugstr_w(str1), + debugstr_w(str2), unk1, debugstr_w(file), debugstr_w(func), ip, unk2, + unk3, unk4 ); + return S_OK; +} diff --git a/dlls/wdscore/wdscore.spec b/dlls/wdscore/wdscore.spec index 86a3bf37797..f1a807b86e6 100644 --- a/dlls/wdscore/wdscore.spec +++ b/dlls/wdscore/wdscore.spec @@ -151,7 +151,7 @@ @ stub WdsSetupLogDestroy @ stub WdsSetupLogInit @ stub WdsSetLogMessageA -@ stub WdsSetLogMessageW +@ stdcall WdsSetupLogMessageW(ptr long wstr wstr long wstr wstr ptr long ptr long) @ stub WdsSubscribeEx @ stub WdsTerminate @ stub WdsUnlockExecutionGroup diff --git a/include/wdscore.h b/include/wdscore.h index d7007d13804..0c357f7e3a4 100644 --- a/include/wdscore.h +++ b/include/wdscore.h @@ -34,9 +34,37 @@ typedef enum _WdsLogLevel { WdsLogLevelTrace = 0x70000000 } WdsLogLevel;
+typedef enum _WdsLogSource { + WdsLogSourceDPX = 0x10000, + WdsLogSourceCBS = 0x20000, + WdsLogSourceCSI = 0x18000, + WdsLogSourceSXS = 0x28000, + WdsLogSourceCMI = 0x30000, + WdsLogSourceDEPLOY = 0x40000, + WdsLogSourceDU = 0x50000, + WdsLogSourceIBS = 0x60000, + WdsLogSourceIBSLIB = 0x64000, + WdsLogSourceDIAG = 0x70000, + WdsLogSourceDIAGER = 0x74000, + WdsLogSourceMIG = 0x80000, + WdsLogSourceHWARE = 0x84000, + WdsLogSourceMIGUI = 0x88000, + WdsLogSourceUI = 0xA0000, + WdsLogSourceCONX = 0xA4000, + WdsLogSourceMOUPG = 0xA8000, + WdsLogSourceWDS = 0xB0000, + WdsLogSourceDISM = 0xB8000, + WdsLogSourcePANTHR = 0x90000, + WdsLogSourceWINPE = 0xC0000, + WdsLogSourceSP = 0xC8000, + WdsLogSourceLIB = 0xD0000, + WdsLogSourceTOOL = 0xE0000 +} WdsLogSource; + LPVOID CurrentIP(void); LPVOID WINAPI ConstructPartialMsgVA(WdsLogLevel,LPCSTR,va_list); LPVOID WINAPI ConstructPartialMsgVW(WdsLogLevel,LPCWSTR,va_list); +HRESULT WINAPI WdsSetupLogMessageW(LPVOID,WdsLogSource,LPCWSTR,LPCWSTR,ULONG,LPCWSTR,LPCWSTR,void*,ULONG,void*,UINT);
#ifdef __cplusplus }
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- dlls/wdscore/main.c | 48 +++++++++++++++++++++++++++++++++++++++ dlls/wdscore/wdscore.spec | 2 +- include/wdscore.h | 1 + 3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/dlls/wdscore/main.c b/dlls/wdscore/main.c index 8ebcedfba6b..92d1ffefeb5 100644 --- a/dlls/wdscore/main.c +++ b/dlls/wdscore/main.c @@ -86,6 +86,54 @@ LPVOID WINAPI ConstructPartialMsgVW( WdsLogLevel level, LPCWSTR msg, va_list arg return NULL; }
+/*********************************************************************** + * WdsSetupLogMessageA (wdscore.@) + */ +HRESULT WINAPI WdsSetupLogMessageA( LPVOID msg, WdsLogSource src, LPCSTR str1, LPCSTR str2, + ULONG unk1, LPCSTR file, LPCSTR func, void *ip, + ULONG unk2, void *unk3, UINT unk4 ) +{ + DWORD len; + HRESULT ret; + LPWSTR str1W = NULL; + LPWSTR str2W = NULL; + LPWSTR fileW = NULL; + LPWSTR funcW = NULL; + + if(str1) + { + len = MultiByteToWideChar( CP_ACP, 0, str1, -1, NULL, 0 ); + str1W = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, str1, -1, str1W, len ); + } + if(str2) + { + len = MultiByteToWideChar( CP_ACP, 0, str2, -1, NULL, 0 ); + str2W = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, str2, -1, str2W, len ); + } + if(file) + { + len = MultiByteToWideChar( CP_ACP, 0, file, -1, NULL, 0 ); + fileW = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, file, -1, fileW, len ); + } + if(func) + { + len = MultiByteToWideChar( CP_ACP, 0, func, -1, NULL, 0 ); + funcW = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, func, -1, funcW, len ); + } + + ret = WdsSetupLogMessageW( msg, src, str1W, str2W, unk1, fileW, funcW, ip, unk2, unk3, unk4 ); + + HeapFree( GetProcessHeap(), 0, str1W ); + HeapFree( GetProcessHeap(), 0, str2W ); + HeapFree( GetProcessHeap(), 0, fileW ); + HeapFree( GetProcessHeap(), 0, funcW ); + return ret; +} + /*********************************************************************** * WdsSetupLogMessageW (wdscore.@) */ diff --git a/dlls/wdscore/wdscore.spec b/dlls/wdscore/wdscore.spec index f1a807b86e6..938f27b776c 100644 --- a/dlls/wdscore/wdscore.spec +++ b/dlls/wdscore/wdscore.spec @@ -150,7 +150,7 @@ @ stub WdsSetUILanguage @ stub WdsSetupLogDestroy @ stub WdsSetupLogInit -@ stub WdsSetLogMessageA +@ stdcall WdsSetupLogMessageA(ptr long str str long str str ptr long ptr long) @ stdcall WdsSetupLogMessageW(ptr long wstr wstr long wstr wstr ptr long ptr long) @ stub WdsSubscribeEx @ stub WdsTerminate diff --git a/include/wdscore.h b/include/wdscore.h index 0c357f7e3a4..fe61fda2e26 100644 --- a/include/wdscore.h +++ b/include/wdscore.h @@ -64,6 +64,7 @@ typedef enum _WdsLogSource { LPVOID CurrentIP(void); LPVOID WINAPI ConstructPartialMsgVA(WdsLogLevel,LPCSTR,va_list); LPVOID WINAPI ConstructPartialMsgVW(WdsLogLevel,LPCWSTR,va_list); +HRESULT WINAPI WdsSetupLogMessageA(LPVOID,WdsLogSource,LPCSTR,LPCSTR,ULONG,LPCSTR,LPCSTR,void*,ULONG,void*,UINT); HRESULT WINAPI WdsSetupLogMessageW(LPVOID,WdsLogSource,LPCWSTR,LPCWSTR,ULONG,LPCWSTR,LPCWSTR,void*,ULONG,void*,UINT);
#ifdef __cplusplus
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- dlls/wdscore/wdscore.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wdscore/wdscore.spec b/dlls/wdscore/wdscore.spec index 938f27b776c..c81c55e31d5 100644 --- a/dlls/wdscore/wdscore.spec +++ b/dlls/wdscore/wdscore.spec @@ -116,7 +116,7 @@ @ stub WdsGetBlackboardValue @ stub WdsGetCurrentExecutionGroup @ stub WdsGetSetupLog -@ stub WdsTempDir +@ stub WdsGetTempDir @ stub WdsInitialize @ stub WdsInitializeCallbackArray @ stub WdsInitializeDataBinary @@ -139,7 +139,7 @@ @ stub WdsPackCollection @ stub WdsPublish @ stub WdsPublishEx -@ stub WdsPublishImmediateAsynch +@ stub WdsPublishImmediateAsync @ stub WdsPublishImmediateEx @ stub WdsPublishOffline @ stub WdsSeqAlloc
Hello,
Just wondering if this header file would ever be used in the future other than in wdscore? I know the native dism uses the native wdscore, but the wine implementation will most likely not need it, especially since the functions are undocumented. Should the header be included as internal or private?
Also, I'd really appreciate it if someone would kindly review this patchset. It allows the Media Creation Tool to run without the native wdscore and resolves the wine-bug.
-- Kind regards, Mohamad