@@ -4178,3 +4178,35 @@ int mingw_have_unix_sockets(void)
4178
4178
return ret ;
4179
4179
}
4180
4180
#endif
4181
+
4182
+ /*
4183
+ * Based on https://stackoverflow.com/questions/43002803
4184
+ *
4185
+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
4186
+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
4187
+ * "ErrorControl"=dword:00000001
4188
+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
4189
+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
4190
+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
4191
+ * 65,00,00,00
4192
+ * "Start"=dword:00000002
4193
+ * "Type"=dword:00000010
4194
+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
4195
+ * "ObjectName"="LocalSystem"
4196
+ * "ServiceSidType"=dword:00000001
4197
+ */
4198
+ int is_inside_windows_container (void )
4199
+ {
4200
+ static int inside_container = -1 ; /* -1 uninitialized */
4201
+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
4202
+ HKEY handle = NULL ;
4203
+
4204
+ if (inside_container != -1 )
4205
+ return inside_container ;
4206
+
4207
+ inside_container = ERROR_SUCCESS ==
4208
+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
4209
+ RegCloseKey (handle );
4210
+
4211
+ return inside_container ;
4212
+ }
0 commit comments