[PATCH v6 1/4] wdscore: Implement CurrentIP.

Mohamad Al-Jaf mohamadaljaf at gmail.com
Mon Jan 31 03:16:16 CST 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51850
Signed-off-by: Mohamad Al-Jaf <mohamadaljaf at gmail.com>
---
v6: - Use __ASM_GLOBAL_FUNC instead of __ASM_STDCALL_FUNC.
    - Use cdecl instead of stdcall in wdscore.spec.
---
 configure.ac                    |  1 +
 dlls/wdscore/Makefile.in        |  3 ++
 dlls/wdscore/main.c             | 56 ++++++++++++++++++++++++++++
 dlls/wdscore/tests/Makefile.in  |  4 ++
 dlls/wdscore/tests/main.c       | 65 +++++++++++++++++++++++++++++++++
 dlls/wdscore/wdscore.spec       |  2 +-
 dlls/wdscore/wdscore_internal.h | 24 ++++++++++++
 7 files changed, 154 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
 create mode 100644 dlls/wdscore/wdscore_internal.h

diff --git a/configure.ac b/configure.ac
index 0b1a53f3ff9..1923c95f4b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3345,6 +3345,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..1ed00206adf
--- /dev/null
+++ b/dlls/wdscore/main.c
@@ -0,0 +1,56 @@
+/*
+ * 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"
+
+#include "wdscore_internal.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
+void *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..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..f17abbbdb3f
--- /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 void* (*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
diff --git a/dlls/wdscore/wdscore_internal.h b/dlls/wdscore/wdscore_internal.h
new file mode 100644
index 00000000000..595ce93a3e7
--- /dev/null
+++ b/dlls/wdscore/wdscore_internal.h
@@ -0,0 +1,24 @@
+/*
+ * 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_INTERNAL_H
+#define __WDSCORE_INTERNAL_H
+
+void *CurrentIP(void);
+
+#endif /* __WDSCORE_INTERNAL_H */
-- 
2.35.0




More information about the wine-devel mailing list