+static VOID
+QueryTimeout(
+ IN OUT PLONG TimeOut)
+{
+ RTL_QUERY_REGISTRY_TABLE QueryTable[2];
+
+ RtlZeroMemory(QueryTable, sizeof(QueryTable));
+ QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
+ QueryTable[0].Name = L"AutoChkTimeOut";
+ QueryTable[0].EntryContext = TimeOut;
+
+ RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, L"Session Manager", QueryTable, NULL, NULL);
+ /* See: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/autochk */
+ if (*TimeOut > 259200)
+ {
+ *TimeOut = 259200;
+ }
+ else if (*TimeOut < 0)
+ {
+ *TimeOut = 0;
+ }
+}
+