ReactOS 0.4.15-dev-7681-g776c3a3
init.c File Reference
#include "winsrv.h"
#include <debug.h>
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define DEFAULT_AUTO_END_TASKS   FALSE
 
#define DEFAULT_HUNG_APP_TIMEOUT   5000
 
#define DEFAULT_WAIT_TO_KILL_APP_TIMEOUT   20000
 
#define DEFAULT_PROCESS_TERMINATE_TIMEOUT   90000
 

Functions

static ULONG GetRegIntFromID (IN HANDLE KeyHandle, IN PWCHAR ValueName, IN ULONG DefaultValue)
 
VOID FASTCALL GetTimeouts (IN PSHUTDOWN_SETTINGS ShutdownSettings)
 
BOOL WINAPI DllMain (IN HINSTANCE hInstanceDll, IN DWORD dwReason, IN LPVOID lpReserved)
 

Variables

SHUTDOWN_SETTINGS ShutdownSettings
 

Macro Definition Documentation

◆ DEFAULT_AUTO_END_TASKS

#define DEFAULT_AUTO_END_TASKS   FALSE

Definition at line 19 of file init.c.

◆ DEFAULT_HUNG_APP_TIMEOUT

#define DEFAULT_HUNG_APP_TIMEOUT   5000

Definition at line 20 of file init.c.

◆ DEFAULT_PROCESS_TERMINATE_TIMEOUT

#define DEFAULT_PROCESS_TERMINATE_TIMEOUT   90000

Definition at line 22 of file init.c.

◆ DEFAULT_WAIT_TO_KILL_APP_TIMEOUT

#define DEFAULT_WAIT_TO_KILL_APP_TIMEOUT   20000

Definition at line 21 of file init.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file init.c.

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( IN HINSTANCE  hInstanceDll,
IN DWORD  dwReason,
IN LPVOID  lpReserved 
)

@DllMain

Core routine of the Utility Manager's library.

Parameters
[in]hDllInstanceThe entry point instance of the library.
[in]fdwReasonThe reason argument to indicate the motive DllMain is being called.
[in]lpvReservedReserved.
Returns
Returns TRUE when main call initialization has succeeded, FALSE otherwise.

Definition at line 172 of file init.c.

175{
176 UNREFERENCED_PARAMETER(hInstanceDll);
178 UNREFERENCED_PARAMETER(lpReserved);
179
180 return TRUE;
181}
DWORD dwReason
Definition: misc.cpp:154
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ GetRegIntFromID()

static ULONG GetRegIntFromID ( IN HANDLE  KeyHandle,
IN PWCHAR  ValueName,
IN ULONG  DefaultValue 
)
static

Definition at line 36 of file init.c.

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}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define REG_SZ
Definition: layer.c:22
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define REG_DWORD
Definition: sdbapi.c:596
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
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
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetTimeouts().

◆ GetTimeouts()

VOID FASTCALL GetTimeouts ( IN PSHUTDOWN_SETTINGS  ShutdownSettings)

Definition at line 87 of file init.c.

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}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
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
#define KEY_READ
Definition: nt_native.h:1023
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define L(x)
Definition: ntvdm.h:50
ULONG WaitToKillServiceTimeout
Definition: winsrv.h:53
ULONG HungAppTimeout
Definition: winsrv.h:51
ULONG WaitToKillAppTimeout
Definition: winsrv.h:52
ULONG ProcessTerminateTimeout
Definition: winsrv.h:54
#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
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

Referenced by CSR_API().

Variable Documentation

◆ ShutdownSettings