@@ -3137,3 +3137,35 @@ int uname(struct utsname *buf)
3137
3137
"%u" , (v >> 16 ) & 0x7fff );
3138
3138
return 0 ;
3139
3139
}
3140
+
3141
+ /*
3142
+ * Based on https://stackoverflow.com/questions/43002803
3143
+ *
3144
+ * [HKLM\SYSTEM\CurrentControlSet\Services\cexecsvc]
3145
+ * "DisplayName"="@%systemroot%\\system32\\cexecsvc.exe,-100"
3146
+ * "ErrorControl"=dword:00000001
3147
+ * "ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,
3148
+ * 6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,
3149
+ * 5c,00,63,00,65,00,78,00,65,00,63,00,73,00,76,00,63,00,2e,00,65,00,78,00,
3150
+ * 65,00,00,00
3151
+ * "Start"=dword:00000002
3152
+ * "Type"=dword:00000010
3153
+ * "Description"="@%systemroot%\\system32\\cexecsvc.exe,-101"
3154
+ * "ObjectName"="LocalSystem"
3155
+ * "ServiceSidType"=dword:00000001
3156
+ */
3157
+ int is_inside_windows_container (void )
3158
+ {
3159
+ static int inside_container = -1 ; /* -1 uninitialized */
3160
+ const char * key = "SYSTEM\\CurrentControlSet\\Services\\cexecsvc" ;
3161
+ HKEY handle = NULL ;
3162
+
3163
+ if (inside_container != -1 )
3164
+ return inside_container ;
3165
+
3166
+ inside_container = ERROR_SUCCESS ==
3167
+ RegOpenKeyExA (HKEY_LOCAL_MACHINE , key , 0 , KEY_READ , & handle );
3168
+ RegCloseKey (handle );
3169
+
3170
+ return inside_container ;
3171
+ }
0 commit comments