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