@@ -3913,3 +3913,35 @@ int uname(struct utsname *buf)
39133913 "%u" , (v >> 16 ) & 0x7fff );
39143914 return 0 ;
39153915}
3916+
3917+ /*
3918+ * Based on https://stackoverflow.com/questions/43002803
3919+ *
3920+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
3921+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
3922+ * "ErrorControl"=dword:00000001
3923+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
3924+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
3925+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
3926+ * 65,00,00,00
3927+ * "Start"=dword:00000002
3928+ * "Type"=dword:00000010
3929+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
3930+ * "ObjectName"="LocalSystem"
3931+ * "ServiceSidType"=dword:00000001
3932+ */
3933+ int is_inside_windows_container (void )
3934+ {
3935+ static int inside_container = -1 ; /* -1 uninitialized */
3936+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
3937+ HKEY handle = NULL ;
3938+
3939+ if (inside_container != -1 )
3940+ return inside_container ;
3941+
3942+ inside_container = ERROR_SUCCESS ==
3943+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
3944+ RegCloseKey (handle );
3945+
3946+ return inside_container ;
3947+ }
0 commit comments