@@ -3689,3 +3689,35 @@ int uname(struct utsname *buf)
3689
3689
"%u" , (v >> 16 ) & 0x7fff );
3690
3690
return 0 ;
3691
3691
}
3692
+
3693
+ /*
3694
+ * Based on https://stackoverflow.com/questions/43002803
3695
+ *
3696
+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
3697
+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
3698
+ * "ErrorControl"=dword:00000001
3699
+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
3700
+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
3701
+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
3702
+ * 65,00,00,00
3703
+ * "Start"=dword:00000002
3704
+ * "Type"=dword:00000010
3705
+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
3706
+ * "ObjectName"="LocalSystem"
3707
+ * "ServiceSidType"=dword:00000001
3708
+ */
3709
+ int is_inside_windows_container (void )
3710
+ {
3711
+ static int inside_container = -1 ; /* -1 uninitialized */
3712
+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
3713
+ HKEY handle = NULL ;
3714
+
3715
+ if (inside_container != -1 )
3716
+ return inside_container ;
3717
+
3718
+ inside_container = ERROR_SUCCESS ==
3719
+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
3720
+ RegCloseKey (handle );
3721
+
3722
+ return inside_container ;
3723
+ }
0 commit comments