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