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