@@ -3996,3 +3996,35 @@ int mingw_have_unix_sockets(void)
39963996 return ret ;
39973997}
39983998#endif
3999+
4000+ /*
4001+ * Based on https://stackoverflow.com/questions/43002803
4002+ *
4003+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
4004+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
4005+ * "ErrorControl"=dword:00000001
4006+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
4007+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
4008+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
4009+ * 65,00,00,00
4010+ * "Start"=dword:00000002
4011+ * "Type"=dword:00000010
4012+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
4013+ * "ObjectName"="LocalSystem"
4014+ * "ServiceSidType"=dword:00000001
4015+ */
4016+ int is_inside_windows_container (void )
4017+ {
4018+ static int inside_container = -1 ; /* -1 uninitialized */
4019+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
4020+ HKEY handle = NULL ;
4021+
4022+ if (inside_container != -1 )
4023+ return inside_container ;
4024+
4025+ inside_container = ERROR_SUCCESS ==
4026+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
4027+ RegCloseKey (handle );
4028+
4029+ return inside_container ;
4030+ }
0 commit comments