From: Vibhav Pant <vibhavp(a)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(a)Type@Platform@@U$AAAP$AAVString(a)2@XZ"); p_platform_type_get_FullName = (void *)GetProcAddress(hmod, "?get(a)FullName@Type(a)Platform@@Q$AAAP$AAVString(a)3@XZ"); pCreateValue = (void *)GetProcAddress(hmod, "?CreateValue(a)Details@Platform@@YAP$AAVObject(a)2@W4TypeCode(a)2@PBX(a)Z"); + pAllocateException = (void *)GetProcAddress(hmod, "?AllocateException(a)Heap@Details(a)Platform@@SAPAXI(a)Z"); + pFreeException = (void *)GetProcAddress(hmod, "?FreeException(a)Heap@Details(a)Platform@@SAXPAX(a)Z"); p_type_info_name = (void *)GetProcAddress(msvcrt, "?name(a)type_info@@QBAPBDXZ"); p_type_info_raw_name = (void *)GetProcAddress(msvcrt, "?raw_name(a)type_info@@QBAPBDXZ"); p_type_info_opequals_equals = (void *)GetProcAddress(msvcrt, "??8type_info@@QBAHABV0@@Z"); @@ -198,6 +202,8 @@ static BOOL init(void) "?get(a)FullName@Type(a)Platform@@QE$AAAPE$AAVString(a)3@XZ"); pCreateValue = (void *)GetProcAddress(hmod, "?CreateValue(a)Details@Platform@@YAPE$AAVObject(a)2@W4TypeCode(a)2@PEBX(a)Z"); + pAllocateException = (void *)GetProcAddress(hmod, "?AllocateException(a)Heap@Details(a)Platform@@SAPEAX_K(a)Z"); + pFreeException = (void *)GetProcAddress(hmod, "?FreeException(a)Heap@Details(a)Platform@@SAXPEAX(a)Z"); p_type_info_name = (void *)GetProcAddress(msvcrt, "?name(a)type_info@@QEBAPEBDXZ"); p_type_info_raw_name = (void *)GetProcAddress(msvcrt, "?raw_name(a)type_info@@QEBAPEBDXZ"); p_type_info_opequals_equals = (void *)GetProcAddress(msvcrt, "??8type_info@@QEBAHAEBV0@@Z"); @@ -222,6 +228,8 @@ static BOOL init(void) "?get(a)FullName@Type(a)Platform@@Q$AAAP$AAVString(a)3@XZ"); pCreateValue = (void *)GetProcAddress(hmod, "?CreateValue(a)Details@Platform@@YGP$AAVObject(a)2@W4TypeCode(a)2@PBX(a)Z"); + pAllocateException = (void *)GetProcAddress(hmod, "?AllocateException(a)Heap@Details(a)Platform@@SAPAXI(a)Z"); + pFreeException = (void *)GetProcAddress(hmod, "?FreeException(a)Heap@Details(a)Platform@@SAXPAX(a)Z"); p_type_info_name = (void *)GetProcAddress(msvcrt, "?name(a)type_info@@QBEPBDXZ"); p_type_info_raw_name = (void *)GetProcAddress(msvcrt, "?raw_name(a)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(a)Heap@Details(a)Platform@@SAXPAX(a)Z(ptr) Free @ cdecl -arch=win64 ?Free(a)Heap@Details(a)Platform@@SAXPEAX(a)Z(ptr) Free -@ stub -arch=win32 ?FreeException(a)Heap@Details(a)Platform@@SAXPAX(a)Z -@ stub -arch=win64 ?FreeException(a)Heap@Details(a)Platform@@SAXPEAX(a)Z +@ cdecl -arch=win32 ?FreeException(a)Heap@Details(a)Platform@@SAXPAX(a)Z(ptr) FreeException +@ cdecl -arch=win64 ?FreeException(a)Heap@Details(a)Platform@@SAXPEAX(a)Z(ptr) FreeException @ stub -arch=i386 ?GetActivationFactory(a)Details@Platform@@YGJPAVModuleBase(a)1WRL@Microsoft@@PAUHSTRING__@@PAPAUIActivationFactory@@@Z @ stub -arch=arm ?GetActivationFactory(a)Details@Platform@@YAJPAVModuleBase(a)1WRL@Microsoft@@PAUHSTRING__@@PAPAUIActivationFactory@@@Z @ stub -arch=win64 ?GetActivationFactory(a)Details@Platform@@YAJPEAVModuleBase(a)1WRL@Microsoft@@PEAUHSTRING__@@PEAPEAUIActivationFactory@@@Z @@ -507,10 +507,10 @@ @ cdecl -arch=win64 ?Allocate(a)Heap@Details(a)Platform@@SAPEAX_K(a)Z(long) Allocate @ cdecl -arch=win32 ?Allocate(a)Heap@Details(a)Platform@@SAPAXII(a)Z(long long) AllocateWithWeakRef @ cdecl -arch=win64 ?Allocate(a)Heap@Details(a)Platform@@SAPEAX_K0(a)Z(long long) AllocateWithWeakRef -@ stub -arch=win32 ?AllocateException(a)Heap@Details(a)Platform@@SAPAXI(a)Z +@ cdecl -arch=win32 ?AllocateException(a)Heap@Details(a)Platform@@SAPAXI(a)Z(long) AllocateException @ stub -arch=win64 ?AllocateException(a)Heap@Details(a)Platform@@SAPEAX_K0(a)Z @ stub -arch=win32 ?AllocateException(a)Heap@Details(a)Platform@@SAPAXII(a)Z -@ stub -arch=win64 ?AllocateException(a)Heap@Details(a)Platform@@SAPEAX_K(a)Z +@ cdecl -arch=win64 ?AllocateException(a)Heap@Details(a)Platform@@SAPEAX_K(a)Z(long) AllocateException @ stub ?Compare(a)Duration@Xaml(a)UI@Windows@@SAHV1234(a)0@Z @ stub -arch=win32 ??0COMException(a)Platform@@Q$AAA(a)HP$AAVString(a)1@@Z @ stub -arch=win64 ??0COMException(a)Platform@@QE$AAA(a)HPE$AAVString(a)1@@Z -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9300