static ULONG WINAPI CorDebug_Release(ICorDebug *iface) { CorDebug *This = impl_from_ICorDebug( iface ); ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p ref=%u\n", This, ref); if (ref == 0) { if(!list_empty(&This->processes)) ERR("Processes haven't been removed Correctly\n"); if(This->runtimehost) ICLRRuntimeHost_Release(This->runtimehost); if(This->pCallback) ICorDebugManagedCallback2_Release(This->pCallback2); if(This->pCallback) ICorDebugManagedCallback_Release(This->pCallback); HeapFree(GetProcessHeap(), 0, This); } return ref; }
static void CDECL ReallyFixupVTable(struct dll_fixup *fixup) { HRESULT hr=S_OK; WCHAR filename[MAX_PATH]; ICLRRuntimeInfo *info=NULL; RuntimeHost *host; char *filenameA; MonoImage *image=NULL; MonoAssembly *assembly=NULL; MonoImageOpenStatus status=0; MonoDomain *domain; if (fixup->done) return; /* It's possible we'll have two threads doing this at once. This is * considered preferable to the potential deadlock if we use a mutex. */ GetModuleFileNameW(fixup->dll, filename, MAX_PATH); TRACE("%p,%p,%s\n", fixup, fixup->dll, debugstr_w(filename)); filenameA = WtoA(filename); if (!filenameA) hr = E_OUTOFMEMORY; if (SUCCEEDED(hr)) hr = get_runtime_info(filename, NULL, NULL, 0, 0, FALSE, &info); if (SUCCEEDED(hr)) hr = ICLRRuntimeInfo_GetRuntimeHost(info, &host); if (SUCCEEDED(hr)) hr = RuntimeHost_GetDefaultDomain(host, &domain); if (SUCCEEDED(hr)) { host->mono->mono_thread_attach(domain); image = host->mono->mono_image_open_from_module_handle(fixup->dll, filenameA, 1, &status); } if (image) assembly = host->mono->mono_assembly_load_from(image, filenameA, &status); if (assembly) { int i; /* Mono needs an image that belongs to an assembly. */ image = host->mono->mono_assembly_get_image(assembly); if (fixup->fixup->type & COR_VTABLE_32BIT) { DWORD *vtable = fixup->vtable; DWORD *tokens = fixup->tokens; for (i=0; i<fixup->fixup->count; i++) { TRACE("%x\n", tokens[i]); vtable[i] = PtrToUint(host->mono->mono_marshal_get_vtfixup_ftnptr( image, tokens[i], fixup->fixup->type)); } } fixup->done = 1; } if (info != NULL) ICLRRuntimeHost_Release(info); HeapFree(GetProcessHeap(), 0, filenameA); if (!fixup->done) { ERR("unable to fixup vtable, hr=%x, status=%d\n", hr, status); /* If we returned now, we'd get an infinite loop. */ assert(0); } }