php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #41577
Patch reinitialize-dotnet_domain-struct-member revision 2014-03-13 15:12 UTC by a dot kasparas at gmc dot lt
Patch stop_rshutdown_release revision 2013-02-19 05:02 UTC by ku at digitaldolphins dot jp

Patch reinitialize-dotnet_domain-struct-member for COM related Bug #41577

Patch version 2014-03-13 15:12 UTC

Return to Bug #41577 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions:

Developer: a.kasparas@gmc.lt

--- com_dotnet.c.R	2014-03-13 17:05:46.371570882 +0200
+++ com_dotnet.c.new	2014-03-13 17:08:20.867564421 +0200
@@ -198,7 +198,8 @@
 	IUnknown *unk = NULL;
 
 	php_com_initialize(TSRMLS_C);
-	if (COMG(dotnet_runtime_stuff) == NULL) {
+	stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+	if (stuff == NULL) {
 		hr = dotnet_init(&where TSRMLS_CC);
 		if (FAILED(hr)) {
 			char buf[1024];
@@ -210,9 +211,37 @@
 			ZVAL_NULL(object);
 			return;
 		}
+		stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+
+	} else if (stuff->dotnet_domain == NULL) {
+		where = "ICorRuntimeHost_GetDefaultDomain";
+		hr = ICorRuntimeHost_GetDefaultDomain(stuff->dotnet_host, &unk);
+		if (FAILED(hr)) {
+			char buf[1024];
+			char *err = php_win32_error_to_msg(hr);
+			snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
+			if (err)
+				LocalFree(err);
+			php_com_throw_exception(hr, buf TSRMLS_CC);
+			ZVAL_NULL(object);
+			return;
+		}
+
+		where = "QI: System._AppDomain";
+		hr = IUnknown_QueryInterface(unk, &IID_mscorlib_System_AppDomain, (LPVOID*)&stuff->dotnet_domain);
+		if (FAILED(hr)) {
+			char buf[1024];
+			char *err = php_win32_error_to_msg(hr);
+			snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
+			if (err)
+				LocalFree(err);
+			php_com_throw_exception(hr, buf TSRMLS_CC);
+			ZVAL_NULL(object);
+			return;
+		}
 	}
 
-	stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+
 
 	obj = CDNO_FETCH(object);
 
 
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Fri Mar 27 19:02:53 2015 UTC