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