@@ -3573,3 +3573,35 @@ int uname(struct utsname *buf)
3573
3573
"%u" , (v >> 16 ) & 0x7fff );
3574
3574
return 0 ;
3575
3575
}
3576
+
3577
+ /*
3578
+ * Based on https://stackoverflow.com/questions/43002803
3579
+ *
3580
+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
3581
+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
3582
+ * "ErrorControl"=dword:00000001
3583
+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
3584
+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
3585
+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
3586
+ * 65,00,00,00
3587
+ * "Start"=dword:00000002
3588
+ * "Type"=dword:00000010
3589
+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
3590
+ * "ObjectName"="LocalSystem"
3591
+ * "ServiceSidType"=dword:00000001
3592
+ */
3593
+ int is_inside_windows_container (void )
3594
+ {
3595
+ static int inside_container = -1 ; /* -1 uninitialized */
3596
+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
3597
+ HKEY handle = NULL ;
3598
+
3599
+ if (inside_container != -1 )
3600
+ return inside_container ;
3601
+
3602
+ inside_container = ERROR_SUCCESS ==
3603
+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
3604
+ RegCloseKey (handle );
3605
+
3606
+ return inside_container ;
3607
+ }
0 commit comments