@@ -4236,3 +4236,35 @@ int mingw_have_unix_sockets(void)
42364236 return ret ;
42374237}
42384238#endif
4239+
4240+ /*
4241+ * Based on https://stackoverflow.com/questions/43002803
4242+ *
4243+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
4244+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
4245+ * "ErrorControl"=dword:00000001
4246+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
4247+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
4248+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
4249+ * 65,00,00,00
4250+ * "Start"=dword:00000002
4251+ * "Type"=dword:00000010
4252+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
4253+ * "ObjectName"="LocalSystem"
4254+ * "ServiceSidType"=dword:00000001
4255+ */
4256+ int is_inside_windows_container (void )
4257+ {
4258+ static int inside_container = -1 ; /* -1 uninitialized */
4259+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
4260+ HKEY handle = NULL ;
4261+
4262+ if (inside_container != -1 )
4263+ return inside_container ;
4264+
4265+ inside_container = ERROR_SUCCESS ==
4266+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
4267+ RegCloseKey (handle );
4268+
4269+ return inside_container ;
4270+ }
0 commit comments