@@ -4222,3 +4222,35 @@ int mingw_have_unix_sockets(void)
42224222 return ret ;
42234223}
42244224#endif
4225+
4226+ /*
4227+ * Based on https://stackoverflow.com/questions/43002803
4228+ *
4229+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
4230+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
4231+ * "ErrorControl"=dword:00000001
4232+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
4233+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
4234+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
4235+ * 65,00,00,00
4236+ * "Start"=dword:00000002
4237+ * "Type"=dword:00000010
4238+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
4239+ * "ObjectName"="LocalSystem"
4240+ * "ServiceSidType"=dword:00000001
4241+ */
4242+ int is_inside_windows_container (void )
4243+ {
4244+ static int inside_container = -1 ; /* -1 uninitialized */
4245+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
4246+ HKEY handle = NULL ;
4247+
4248+ if (inside_container != -1 )
4249+ return inside_container ;
4250+
4251+ inside_container = ERROR_SUCCESS ==
4252+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
4253+ RegCloseKey (handle );
4254+
4255+ return inside_container ;
4256+ }
0 commit comments