@@ -3641,3 +3641,35 @@ int uname(struct utsname *buf)
3641
3641
"%u" , (v >> 16 ) & 0x7fff );
3642
3642
return 0 ;
3643
3643
}
3644
+
3645
+ /*
3646
+ * Based on https://stackoverflow.com/questions/43002803
3647
+ *
3648
+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
3649
+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
3650
+ * "ErrorControl"=dword:00000001
3651
+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
3652
+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
3653
+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
3654
+ * 65,00,00,00
3655
+ * "Start"=dword:00000002
3656
+ * "Type"=dword:00000010
3657
+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
3658
+ * "ObjectName"="LocalSystem"
3659
+ * "ServiceSidType"=dword:00000001
3660
+ */
3661
+ int is_inside_windows_container (void )
3662
+ {
3663
+ static int inside_container = -1 ; /* -1 uninitialized */
3664
+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
3665
+ HKEY handle = NULL ;
3666
+
3667
+ if (inside_container != -1 )
3668
+ return inside_container ;
3669
+
3670
+ inside_container = ERROR_SUCCESS ==
3671
+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
3672
+ RegCloseKey (handle );
3673
+
3674
+ return inside_container ;
3675
+ }
0 commit comments