Piotr Caban : msvcp140: Add task_continuation_context constructor implementation.

Alexandre Julliard julliard at winehq.org
Wed Mar 1 16:45:11 CST 2017


Module: wine
Branch: master
Commit: 10b36e3977edb214f5451fcaf6f9c316465c01e7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=10b36e3977edb214f5451fcaf6f9c316465c01e7

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed Mar  1 13:18:01 2017 +0100

msvcp140: Add task_continuation_context constructor implementation.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcp140/msvcp140.spec    |  6 ++--
 dlls/msvcp140/tests/msvcp140.c | 72 ++++++++++++++++++++++++++++++++++++++++++
 dlls/msvcp90/misc.c            | 17 ++++++++++
 3 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec
index ee31c77..9da2675 100644
--- a/dlls/msvcp140/msvcp140.spec
+++ b/dlls/msvcp140/msvcp140.spec
@@ -358,9 +358,9 @@
 @ cdecl -arch=arm ??0ios_base at std@@IAA at XZ(ptr) ios_base_ctor
 @ thiscall -arch=i386 ??0ios_base at std@@IAE at XZ(ptr) ios_base_ctor
 @ cdecl -arch=win64 ??0ios_base at std@@IEAA at XZ(ptr) ios_base_ctor
-@ stub -arch=arm ??0task_continuation_context at Concurrency@@AAA at XZ
-@ stub -arch=i386 ??0task_continuation_context at Concurrency@@AAE at XZ
-@ stub -arch=win64 ??0task_continuation_context at Concurrency@@AEAA at XZ
+@ cdecl -arch=arm ??0task_continuation_context at Concurrency@@AAA at XZ(ptr) task_continuation_context_ctor
+@ thiscall -arch=i386 ??0task_continuation_context at Concurrency@@AAE at XZ(ptr) task_continuation_context_ctor
+@ cdecl -arch=win64 ??0task_continuation_context at Concurrency@@AEAA at XZ(ptr) task_continuation_context_ctor
 @ stub -arch=arm ??0time_base at std@@QAA at I@Z
 @ stub -arch=i386 ??0time_base at std@@QAE at I@Z
 @ stub -arch=win64 ??0time_base at std@@QEAA at _K@Z
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c
index 82e2b34..db241ca 100644
--- a/dlls/msvcp140/tests/msvcp140.c
+++ b/dlls/msvcp140/tests/msvcp140.c
@@ -21,7 +21,57 @@
 #include "wine/test.h"
 #include "winbase.h"
 
+#undef __thiscall
+#ifdef __i386__
+#define __thiscall __stdcall
+#else
+#define __thiscall __cdecl
+#endif
+
+/* Emulate a __thiscall */
+#ifdef __i386__
+
+#include "pshpack1.h"
+struct thiscall_thunk
+{
+    BYTE pop_eax;    /* popl  %eax (ret addr) */
+    BYTE pop_edx;    /* popl  %edx (func) */
+    BYTE pop_ecx;    /* popl  %ecx (this) */
+    BYTE push_eax;   /* pushl %eax */
+    WORD jmp_edx;    /* jmp  *%edx */
+};
+#include "poppack.h"
+
+static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
+
+static void init_thiscall_thunk(void)
+{
+    struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
+            MEM_COMMIT, PAGE_EXECUTE_READWRITE );
+    thunk->pop_eax  = 0x58;   /* popl  %eax */
+    thunk->pop_edx  = 0x5a;   /* popl  %edx */
+    thunk->pop_ecx  = 0x59;   /* popl  %ecx */
+    thunk->push_eax = 0x50;   /* pushl %eax */
+    thunk->jmp_edx  = 0xe2ff; /* jmp  *%edx */
+    call_thiscall_func1 = (void *)thunk;
+}
+
+#define call_func1(func,_this) call_thiscall_func1(func,_this)
+
+#else
+
+#define init_thiscall_thunk()
+#define call_func1(func,_this) func(_this)
+
+#endif /* __i386__ */
+
+typedef struct {
+    void *unk0;
+    BYTE unk1;
+} task_continuation_context;
+
 static unsigned int (__cdecl *p__Thrd_id)(void);
+static task_continuation_context* (__thiscall *p_task_continuation_context_ctor)(task_continuation_context*);
 
 static HMODULE msvcp;
 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
@@ -37,6 +87,17 @@ static BOOL init(void)
 
     SET(p__Thrd_id, "_Thrd_id");
 
+    if(sizeof(void*) == 8) { /* 64-bit initialization */
+        SET(p_task_continuation_context_ctor, "??0task_continuation_context at Concurrency@@AEAA at XZ");
+    } else {
+#ifdef __arm__
+        SET(p_task_continuation_context_ctor, "??0task_continuation_context at Concurrency@@AAA at XZ");
+#else
+        SET(p_task_continuation_context_ctor, "??0task_continuation_context at Concurrency@@AAE at XZ");
+#endif
+    }
+
+    init_thiscall_thunk();
     return TRUE;
 }
 
@@ -82,10 +143,21 @@ static void test_vbtable_size_exports(void)
     }
 }
 
+static void test_task_continuation_context(void)
+{
+    task_continuation_context tcc;
+
+    memset(&tcc, 0xdead, sizeof(tcc));
+    call_func1(p_task_continuation_context_ctor, &tcc);
+    ok(!tcc.unk0, "tcc.unk0 != NULL (%p)\n", tcc.unk0);
+    ok(!tcc.unk1, "tcc.unk1 != 0 (%x)\n", tcc.unk1);
+}
+
 START_TEST(msvcp140)
 {
     if(!init()) return;
     test_thrd();
     test_vbtable_size_exports();
+    test_task_continuation_context();
     FreeLibrary(msvcp);
 }
diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c
index 703ed9f..e819699 100644
--- a/dlls/msvcp90/misc.c
+++ b/dlls/msvcp90/misc.c
@@ -1360,3 +1360,20 @@ void __cdecl _Unlock_shared_ptr_spin_lock(void)
     shared_ptr_lock = 0;
 }
 #endif
+
+#if _MSVCP_VER >= 140
+typedef struct {
+    void *unk0;
+    BYTE unk1;
+} task_continuation_context;
+
+/* ??0task_continuation_context at Concurrency@@AAE at XZ */
+/* ??0task_continuation_context at Concurrency@@AEAA at XZ */
+DEFINE_THISCALL_WRAPPER(task_continuation_context_ctor, 4)
+task_continuation_context* __thiscall task_continuation_context_ctor(task_continuation_context *this)
+{
+    TRACE("(%p)\n", this);
+    memset(this, 0, sizeof(*this));
+    return this;
+}
+#endif




More information about the wine-cvs mailing list