@@ -3761,3 +3761,35 @@ int uname(struct utsname *buf)
3761
3761
"%u" , (v >> 16 ) & 0x7fff );
3762
3762
return 0 ;
3763
3763
}
3764
+
3765
+ /*
3766
+ * Based on https://stackoverflow.com/questions/43002803
3767
+ *
3768
+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
3769
+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
3770
+ * "ErrorControl"=dword:00000001
3771
+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
3772
+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
3773
+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
3774
+ * 65,00,00,00
3775
+ * "Start"=dword:00000002
3776
+ * "Type"=dword:00000010
3777
+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
3778
+ * "ObjectName"="LocalSystem"
3779
+ * "ServiceSidType"=dword:00000001
3780
+ */
3781
+ int is_inside_windows_container (void )
3782
+ {
3783
+ static int inside_container = -1 ; /* -1 uninitialized */
3784
+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
3785
+ HKEY handle = NULL ;
3786
+
3787
+ if (inside_container != -1 )
3788
+ return inside_container ;
3789
+
3790
+ inside_container = ERROR_SUCCESS ==
3791
+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
3792
+ RegCloseKey (handle );
3793
+
3794
+ return inside_container ;
3795
+ }
0 commit comments