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