ReactOS 0.4.15-dev-8061-g57b775e
init.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS User API Server DLL
4 * FILE: win32ss/user/winsrv/init.c
5 * PURPOSE: Initialization
6 * PROGRAMMERS: Dmitry Philippov (shedon@mail.ru)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10/* INCLUDES *******************************************************************/
11
12#include "winsrv.h"
13
14#define NDEBUG
15#include <debug.h>
16
17/* GLOBALS ********************************************************************/
18
19#define DEFAULT_AUTO_END_TASKS FALSE
20#define DEFAULT_HUNG_APP_TIMEOUT 5000
21#define DEFAULT_WAIT_TO_KILL_APP_TIMEOUT 20000
22#define DEFAULT_PROCESS_TERMINATE_TIMEOUT 90000
23
25{
31};
32
33/* FUNCTIONS ******************************************************************/
34
35static ULONG
38 IN ULONG DefaultValue)
39{
40 UNICODE_STRING ValueString;
42 UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 32 * sizeof(WCHAR)];
46
47 /* Open the key */
48 RtlInitUnicodeString(&ValueString, ValueName);
50 &ValueString,
52 PartialInfo,
53 sizeof(Buffer),
54 &Length);
55 if (NT_SUCCESS(Status))
56 {
57 if (PartialInfo->Type == REG_SZ)
58 {
59 /* Convert to integer */
60 RtlInitUnicodeString(&ValueString, (PWCHAR)PartialInfo->Data);
61 Status = RtlUnicodeStringToInteger(&ValueString, 10, &Value);
62 }
63 else if (PartialInfo->Type == REG_DWORD)
64 {
65 /* Directly retrieve the data */
66 Value = *(PULONG)PartialInfo->Data;
68 }
69 else
70 {
71 DPRINT1("Unexpected registry type %d for setting %S\n", PartialInfo->Type, ValueName);
73 }
74 }
75
76 if (!NT_SUCCESS(Status))
77 {
78 /* Use default value instead */
79 Value = DefaultValue;
80 }
81
82 /* Return the value */
83 return Value;
84}
85
88{
90 UNICODE_STRING RegistryString;
92 HANDLE CurrentUserKeyHandle;
94
95 /* Initialize with defaults first */
101
102 /* Open the per-user desktop key */
103 Status = RtlOpenCurrentUser(MAXIMUM_ALLOWED, &CurrentUserKeyHandle);
104 if (NT_SUCCESS(Status))
105 {
106 RtlInitUnicodeString(&RegistryString,
107 L"Control Panel\\Desktop");
109 &RegistryString,
111 CurrentUserKeyHandle,
112 NULL);
114 if (NT_SUCCESS(Status))
115 {
116 /* Read timeouts */
118 L"HungAppTimeout",
121 L"WaitToKillAppTimeout",
124 L"AutoEndTasks",
126 /* Done */
128 }
129
130 /* Done */
131 NtClose(CurrentUserKeyHandle);
132 }
133
134 /* Now open the control key */
135 RtlInitUnicodeString(&RegistryString,
136 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
138 &RegistryString,
140 NULL, NULL);
142 if (NT_SUCCESS(Status))
143 {
144 /* Read the services timeout */
146 L"WaitToKillServiceTimeout",
148
149 /*
150 * Retrieve the process terminate timeout.
151 * See ftp://ftp.microsoft.com/MISC1/BUSSYS/WINNT/KB/Q234/6/06.TXT
152 * and https://web.archive.org/web/20050216235758/http://support.microsoft.com/kb/234606/EN-US/
153 * for more details.
154 *
155 * NOTE: Unused at the moment...
156 */
158 L"ProcessTerminateTimeout",
162
163 /* Done */
165 }
166}
167
168/* ENTRY-POINT ****************************************************************/
169
170BOOL
171WINAPI
172DllMain(IN HINSTANCE hInstanceDll,
174 IN LPVOID lpReserved)
175{
176 UNREFERENCED_PARAMETER(hInstanceDll);
178 UNREFERENCED_PARAMETER(lpReserved);
179
180 return TRUE;
181}
182
183/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
DWORD dwReason
Definition: misc.cpp:154
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN WINAPI DllMain(HINSTANCE Instance, DWORD Reason, LPVOID Reserved)
Definition: init.c:14
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define REG_SZ
Definition: layer.c:22
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser(_In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE KeyHandle)
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FASTCALL
Definition: nt_native.h:50
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG WaitToKillServiceTimeout
Definition: winsrv.h:53
ULONG HungAppTimeout
Definition: winsrv.h:51
ULONG WaitToKillAppTimeout
Definition: winsrv.h:52
ULONG ProcessTerminateTimeout
Definition: winsrv.h:54
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define DEFAULT_PROCESS_TERMINATE_TIMEOUT
Definition: init.c:22
static ULONG GetRegIntFromID(IN HANDLE KeyHandle, IN PWCHAR ValueName, IN ULONG DefaultValue)
Definition: init.c:36
#define DEFAULT_WAIT_TO_KILL_APP_TIMEOUT
Definition: init.c:21
VOID FASTCALL GetTimeouts(IN PSHUTDOWN_SETTINGS ShutdownSettings)
Definition: init.c:87
SHUTDOWN_SETTINGS ShutdownSettings
Definition: init.c:24
#define DEFAULT_HUNG_APP_TIMEOUT
Definition: init.c:20
#define DEFAULT_AUTO_END_TASKS
Definition: init.c:19
#define WINAPI
Definition: msvc.h:6
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180