From: Vibhav Pant vibhavp@gmail.com
--- dlls/vccorlib140/tests/vccorlib.c | 41 ++++++++++++++++++++++++++++++- dlls/vccorlib140/vccorlib.c | 11 +++++++++ dlls/vccorlib140/vccorlib140.spec | 8 +++--- 3 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/dlls/vccorlib140/tests/vccorlib.c b/dlls/vccorlib140/tests/vccorlib.c index 1b597a9325a..a88c6c228f0 100644 --- a/dlls/vccorlib140/tests/vccorlib.c +++ b/dlls/vccorlib140/tests/vccorlib.c @@ -130,6 +130,8 @@ static int (__cdecl *p_platform_type_GetTypeCode)(void *); static HSTRING (__cdecl *p_platform_type_ToString)(void *); static HSTRING (__cdecl *p_platform_type_get_FullName)(void *); static void *(WINAPI *pCreateValue)(int type, const void *); +static void *(__cdecl *pAllocateException)(size_t); +static void (__cdecl *pFreeException)(void *);
static void *(__cdecl *p__RTtypeid)(const void *); static const char *(__thiscall *p_type_info_name)(void *); @@ -173,6 +175,8 @@ static BOOL init(void) p_platform_type_ToString = (void *)GetProcAddress(hmod, "?ToString@Type@Platform@@U$AAAP$AAVString@2@XZ"); p_platform_type_get_FullName = (void *)GetProcAddress(hmod, "?get@FullName@Type@Platform@@Q$AAAP$AAVString@3@XZ"); pCreateValue = (void *)GetProcAddress(hmod, "?CreateValue@Details@Platform@@YAP$AAVObject@2@W4TypeCode@2@PBX@Z"); + pAllocateException = (void *)GetProcAddress(hmod, "?AllocateException@Heap@Details@Platform@@SAPAXI@Z"); + pFreeException = (void *)GetProcAddress(hmod, "?FreeException@Heap@Details@Platform@@SAXPAX@Z"); p_type_info_name = (void *)GetProcAddress(msvcrt, "?name@type_info@@QBAPBDXZ"); p_type_info_raw_name = (void *)GetProcAddress(msvcrt, "?raw_name@type_info@@QBAPBDXZ"); p_type_info_opequals_equals = (void *)GetProcAddress(msvcrt, "??8type_info@@QBAHABV0@@Z"); @@ -198,6 +202,8 @@ static BOOL init(void) "?get@FullName@Type@Platform@@QE$AAAPE$AAVString@3@XZ"); pCreateValue = (void *)GetProcAddress(hmod, "?CreateValue@Details@Platform@@YAPE$AAVObject@2@W4TypeCode@2@PEBX@Z"); + pAllocateException = (void *)GetProcAddress(hmod, "?AllocateException@Heap@Details@Platform@@SAPEAX_K@Z"); + pFreeException = (void *)GetProcAddress(hmod, "?FreeException@Heap@Details@Platform@@SAXPEAX@Z"); p_type_info_name = (void *)GetProcAddress(msvcrt, "?name@type_info@@QEBAPEBDXZ"); p_type_info_raw_name = (void *)GetProcAddress(msvcrt, "?raw_name@type_info@@QEBAPEBDXZ"); p_type_info_opequals_equals = (void *)GetProcAddress(msvcrt, "??8type_info@@QEBAHAEBV0@@Z"); @@ -222,6 +228,8 @@ static BOOL init(void) "?get@FullName@Type@Platform@@Q$AAAP$AAVString@3@XZ"); pCreateValue = (void *)GetProcAddress(hmod, "?CreateValue@Details@Platform@@YGP$AAVObject@2@W4TypeCode@2@PBX@Z"); + pAllocateException = (void *)GetProcAddress(hmod, "?AllocateException@Heap@Details@Platform@@SAPAXI@Z"); + pFreeException = (void *)GetProcAddress(hmod, "?FreeException@Heap@Details@Platform@@SAXPAX@Z"); p_type_info_name = (void *)GetProcAddress(msvcrt, "?name@type_info@@QBEPBDXZ"); p_type_info_raw_name = (void *)GetProcAddress(msvcrt, "?raw_name@type_info@@QBEPBDXZ"); p_type_info_opequals_equals = (void *)GetProcAddress(msvcrt, "??8type_info@@QBEHABV0@@Z"); @@ -240,6 +248,8 @@ static BOOL init(void) ok(p_platform_type_ToString != NULL, "Platform::Type::ToString not available\n"); ok(p_platform_type_get_FullName != NULL, "Platform::Type::FullName not available\n"); ok(pCreateValue != NULL, "CreateValue not available\n"); + ok(pAllocateException != NULL, "AllocateException not available\n"); + ok(pFreeException != NULL, "FreeException not available\n");
ok(p_type_info_name != NULL, "type_info::name not available\n"); ok(p_type_info_raw_name != NULL, "type_info::raw_name not available\n"); @@ -444,7 +454,7 @@ static void test_GetIidsFn(void)
static void test_Allocate(void) { - void *addr; + void *addr, **ptr, **base;
addr = pAllocate(0); ok(!!addr, "got addr %p\n", addr); @@ -454,6 +464,35 @@ static void test_Allocate(void) ok(!!addr, "got addr %p\n", addr); pFree(addr); pFree(NULL); + + /* AllocateException allocates additional space for two pointer-width fields, with the second field used as the + * back-pointer to the exception data. */ + addr = pAllocateException(0); + todo_wine ok(!!addr, "got addr %p\n", addr); + if (!addr) return; + ptr = (void **)((ULONG_PTR)addr - sizeof(void *)); + *ptr = NULL; /* The write should succeed. */ + base = (void **)((ULONG_PTR)addr - 2 * sizeof(void *)); + *base = NULL; + /* Since base is the actual allocation base, Free(base) should succeed. */ + pFree(base); + + addr = pAllocateException(sizeof(void *)); + ok(!!addr, "got addr %p\n", addr); + ptr = (void **)((ULONG_PTR)addr - sizeof(void *)); + *ptr = NULL; + base = (void **)((ULONG_PTR)addr - 2 * sizeof(void *)); + *base = NULL; + /* FreeException will derive the allocation base itself. */ + pFreeException(addr); + + /* Do what AllocateException does, manually. */ + base = pAllocate(sizeof(void *) * 2 + sizeof(UINT32)); + ok(!!base, "got base %p\n", base); + /* addr is what AllocateException would return. */ + addr = (void *)((ULONG_PTR)base + sizeof(void *) * 2); + /* FreeException should succeed with addr. */ + pFreeException(addr); }
#define test_refcount(a, b) test_refcount_(__LINE__, (a), (b)) diff --git a/dlls/vccorlib140/vccorlib.c b/dlls/vccorlib140/vccorlib.c index 3294aab6dd0..e642f7b8d27 100644 --- a/dlls/vccorlib140/vccorlib.c +++ b/dlls/vccorlib140/vccorlib.c @@ -101,6 +101,12 @@ void *__cdecl Allocate(size_t size) return addr; }
+void *__cdecl AllocateException(size_t size) +{ + FIXME("(%Iu): stub!\n", size); + return NULL; +} + void __cdecl Free(void *addr) { TRACE("(%p)\n", addr); @@ -108,6 +114,11 @@ void __cdecl Free(void *addr) free(addr); }
+void __cdecl FreeException(void *addr) +{ + FIXME("(%p): stub!\n", addr); +} + struct control_block { IWeakReference IWeakReference_iface; diff --git a/dlls/vccorlib140/vccorlib140.spec b/dlls/vccorlib140/vccorlib140.spec index d146b07d30e..36ed8606ad4 100644 --- a/dlls/vccorlib140/vccorlib140.spec +++ b/dlls/vccorlib140/vccorlib140.spec @@ -68,8 +68,8 @@ @ stub -arch=win64 ?FlushFactoryCache@@YAXXZ @ cdecl -arch=win32 ?Free@Heap@Details@Platform@@SAXPAX@Z(ptr) Free @ cdecl -arch=win64 ?Free@Heap@Details@Platform@@SAXPEAX@Z(ptr) Free -@ stub -arch=win32 ?FreeException@Heap@Details@Platform@@SAXPAX@Z -@ stub -arch=win64 ?FreeException@Heap@Details@Platform@@SAXPEAX@Z +@ cdecl -arch=win32 ?FreeException@Heap@Details@Platform@@SAXPAX@Z(ptr) FreeException +@ cdecl -arch=win64 ?FreeException@Heap@Details@Platform@@SAXPEAX@Z(ptr) FreeException @ stub -arch=i386 ?GetActivationFactory@Details@Platform@@YGJPAVModuleBase@1WRL@Microsoft@@PAUHSTRING__@@PAPAUIActivationFactory@@@Z @ stub -arch=arm ?GetActivationFactory@Details@Platform@@YAJPAVModuleBase@1WRL@Microsoft@@PAUHSTRING__@@PAPAUIActivationFactory@@@Z @ stub -arch=win64 ?GetActivationFactory@Details@Platform@@YAJPEAVModuleBase@1WRL@Microsoft@@PEAUHSTRING__@@PEAPEAUIActivationFactory@@@Z @@ -507,10 +507,10 @@ @ cdecl -arch=win64 ?Allocate@Heap@Details@Platform@@SAPEAX_K@Z(long) Allocate @ cdecl -arch=win32 ?Allocate@Heap@Details@Platform@@SAPAXII@Z(long long) AllocateWithWeakRef @ cdecl -arch=win64 ?Allocate@Heap@Details@Platform@@SAPEAX_K0@Z(long long) AllocateWithWeakRef -@ stub -arch=win32 ?AllocateException@Heap@Details@Platform@@SAPAXI@Z +@ cdecl -arch=win32 ?AllocateException@Heap@Details@Platform@@SAPAXI@Z(long) AllocateException @ stub -arch=win64 ?AllocateException@Heap@Details@Platform@@SAPEAX_K0@Z @ stub -arch=win32 ?AllocateException@Heap@Details@Platform@@SAPAXII@Z -@ stub -arch=win64 ?AllocateException@Heap@Details@Platform@@SAPEAX_K@Z +@ cdecl -arch=win64 ?AllocateException@Heap@Details@Platform@@SAPEAX_K@Z(long) AllocateException @ stub ?Compare@Duration@Xaml@UI@Windows@@SAHV1234@0@Z @ stub -arch=win32 ??0COMException@Platform@@Q$AAA@HP$AAVString@1@@Z @ stub -arch=win64 ??0COMException@Platform@@QE$AAA@HPE$AAVString@1@@Z