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