ReactOS  0.4.15-dev-341-g17c5fb8
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 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
DWORD dwReason
Definition: misc.cpp:154

◆ 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;
41  ULONG Length;
42  UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 32 * sizeof(WCHAR)];
45  ULONG Value;
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 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:55
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
unsigned int * PULONG
Definition: retypes.h:1
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define REG_DWORD
Definition: sdbapi.c:596
#define REG_SZ
Definition: layer.c:22

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 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define DEFAULT_AUTO_END_TASKS
Definition: init.c:19
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
ULONG HungAppTimeout
Definition: winsrv.h:49
#define KEY_READ
Definition: nt_native.h:1023
LONG NTSTATUS
Definition: precomp.h:26
#define DEFAULT_PROCESS_TERMINATE_TIMEOUT
Definition: init.c:22
ULONG WaitToKillServiceTimeout
Definition: winsrv.h:51
#define DEFAULT_HUNG_APP_TIMEOUT
Definition: init.c:20
ULONG ProcessTerminateTimeout
Definition: winsrv.h:52
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
#define DEFAULT_WAIT_TO_KILL_APP_TIMEOUT
Definition: init.c:21
ULONG WaitToKillAppTimeout
Definition: winsrv.h:50
NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser(_In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE KeyHandle)
Status
Definition: gdiplustypes.h:24
SHUTDOWN_SETTINGS ShutdownSettings
Definition: init.c:24
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
static ULONG GetRegIntFromID(IN HANDLE KeyHandle, IN PWCHAR ValueName, IN ULONG DefaultValue)
Definition: init.c:36
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106

Referenced by CSR_API().

Variable Documentation

◆ ShutdownSettings

SHUTDOWN_SETTINGS ShutdownSettings