@@ -4145,3 +4145,35 @@ int mingw_have_unix_sockets(void)
41454145 return ret ;
41464146}
41474147#endif
4148+
4149+ /*
4150+ * Based on https://stackoverflow.com/questions/43002803
4151+ *
4152+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
4153+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
4154+ * "ErrorControl"=dword:00000001
4155+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
4156+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
4157+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
4158+ * 65,00,00,00
4159+ * "Start"=dword:00000002
4160+ * "Type"=dword:00000010
4161+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
4162+ * "ObjectName"="LocalSystem"
4163+ * "ServiceSidType"=dword:00000001
4164+ */
4165+ int is_inside_windows_container (void )
4166+ {
4167+ static int inside_container = -1 ; /* -1 uninitialized */
4168+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
4169+ HKEY handle = NULL ;
4170+
4171+ if (inside_container != -1 )
4172+ return inside_container ;
4173+
4174+ inside_container = ERROR_SUCCESS ==
4175+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
4176+ RegCloseKey (handle );
4177+
4178+ return inside_container ;
4179+ }
0 commit comments