Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51850 Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v3: - Swap operands for arm and aarch64 (Credit: Jinoh Kang) - Use void * instead of int for CurrentIP - Add useful test (Credit: Giovanni Mascellani) - Remove unnecessary #include <stdint.h>
Note: In the test I had to remove WINAPI from the declaration because it would result in an 'undefined reference' error only in the 32-bit build of Wine. The 64-bit build compiled without any problems.
I don't understand why this happens. --- configure.ac | 1 + dlls/wdscore/Makefile.in | 3 ++ dlls/wdscore/main.c | 54 ++++++++++++++++++++++++++++++++++ dlls/wdscore/tests/Makefile.in | 5 ++++ dlls/wdscore/tests/main.c | 41 ++++++++++++++++++++++++++ dlls/wdscore/wdscore.spec | 2 +- 6 files changed, 105 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 b42cb8a5346..a50881cc2fb 100644 --- a/configure.ac +++ b/configure.ac @@ -3347,6 +3347,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..2020e72c7bb 100644 --- a/dlls/wdscore/Makefile.in +++ b/dlls/wdscore/Makefile.in @@ -1,3 +1,6 @@ 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..24371068980 --- /dev/null +++ b/dlls/wdscore/main.c @@ -0,0 +1,54 @@ +/* + * 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/asm.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wdscore); + +/*********************************************************************** + * CurrentIP (wdscore.@) + */ +#ifdef __i386__ +__ASM_STDCALL_FUNC(CurrentIP, 0, + "movl 0(%esp), %eax\n\t" + "ret" ) +#elif defined(__x86_64__) +__ASM_STDCALL_FUNC(CurrentIP, 0, + "movq 0(%rsp), %rax\n\t" + "ret" ) +#elif defined(__arm__) +__ASM_STDCALL_FUNC(CurrentIP, 0, + "mov r0, lr\n\t" + "bx lr" ) +#elif defined(__aarch64__) +__ASM_STDCALL_FUNC(CurrentIP, 0, + "mov x0, lr\n\t" + "ret" ) +#else +void *WINAPI CurrentIP(void) +{ + FIXME( "not implemented\n" ); + return 0; +} +#endif diff --git a/dlls/wdscore/tests/Makefile.in b/dlls/wdscore/tests/Makefile.in new file mode 100644 index 00000000000..f0606d902d5 --- /dev/null +++ b/dlls/wdscore/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = wdscore.dll +IMPORTS = wdscore + +C_SRCS = \ + main.c diff --git a/dlls/wdscore/tests/main.c b/dlls/wdscore/tests/main.c new file mode 100644 index 00000000000..71de31a1a0a --- /dev/null +++ b/dlls/wdscore/tests/main.c @@ -0,0 +1,41 @@ +/* + * 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 "wine/test.h" +#include "winbase.h" + +extern void *CurrentIP(void); + +static void test_CurrentIP(void) +{ + char *cur; + char *ret; + + cur = (char*)&test_CurrentIP; + ret = (char*)CurrentIP(); + + ok(cur <= ret && ret < (cur + 0x100), "Address %p not in function starting at %p.\n", ret, cur); +} + +START_TEST(main) +{ + test_CurrentIP(); +} diff --git a/dlls/wdscore/wdscore.spec b/dlls/wdscore/wdscore.spec index 15958b86aba..8b6febe6b3b 100644 --- a/dlls/wdscore/wdscore.spec +++ b/dlls/wdscore/wdscore.spec @@ -71,7 +71,7 @@ @ stub ConstructPartialMsgIfW @ stub ConstructPartialMsgVA @ stub ConstructPartialMsgVW -@ stub CurrentIP +@ stdcall CurrentIP() @ stub EndMajorTask @ stub EndMinorTask @ stub GetMajorTask
Mohamad Al-Jaf mohamadaljaf@gmail.com wrote:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51850 Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com
v3: - Swap operands for arm and aarch64 (Credit: Jinoh Kang) - Use void * instead of int for CurrentIP - Add useful test (Credit: Giovanni Mascellani) - Remove unnecessary #include <stdint.h>
Note: In the test I had to remove WINAPI from the declaration because it would result in an 'undefined reference' error only in the 32-bit build of Wine. The 64-bit build compiled without any problems.
I don't understand why this happens.
Taking into account that wdscore is completely undocumented, and even such a trivial API as CurrentIP() took so much effort to implement, and still has no real confirmation what should it do (the test doesn't verify that returned value belongs to the dll address range), it probably means that there is no any point to keep spending more time on this.
* On 2022-01-20 10:14, Dmitry Timoshkov wrote:
Taking into account that wdscore is completely undocumented, and even such a trivial API as CurrentIP() took so much effort to implement, and still has no real confirmation what should it do (the test doesn't verify that returned value belongs to the dll address range), it probably means that there is no any point to keep spending more time on this.
It seems that there is so little left to do to have the minimal test running. And next to be sure about what specific loaded image (if any) does the return value reflect.
This can serve as a good example of going forward for future implementers of undocumented functions.
So, quite the contrary (in my 2 c€).
S.
Saulius Krasuckas saulius2@ar-fi.lt wrote:
- On 2022-01-20 10:14, Dmitry Timoshkov wrote:
Taking into account that wdscore is completely undocumented, and even such a trivial API as CurrentIP() took so much effort to implement, and still has no real confirmation what should it do (the test doesn't verify that returned value belongs to the dll address range), it probably means that there is no any point to keep spending more time on this.
It seems that there is so little left to do to have the minimal test running. And next to be sure about what specific loaded image (if any) does the return value reflect.
This won't help with other APIs in this module.
This can serve as a good example of going forward for future implementers of undocumented functions.
So, quite the contrary (in my 2 c€).
If someone needs an example - creating a wiki page would probably be a better place for such an exercise.
Hi,
the test doesn't verify that returned
value belongs to the dll address range
Could you explain this?
it probably means that there is no
any point to keep spending more time on this
What do you mean by this?
It seems that there is so little left to do to have the minimal test
running.
Agreed, though it seems to be working even without WINAPI in the declaration.