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