ReactOS  0.4.14-dev-317-g96040ec
devinst.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS WaitNoPendingInstallEvents (IN PLARGE_INTEGER Timeout OPTIONAL)
 
BOOLEAN EnableUserModePnpManager (VOID)
 
BOOLEAN DisableUserModePnpManager (VOID)
 
NTSTATUS InitializeUserModePnpManager (IN HINF *phSetupInf)
 
VOID TerminateUserModePnpManager (VOID)
 

Function Documentation

◆ DisableUserModePnpManager()

BOOLEAN DisableUserModePnpManager ( VOID  )

Definition at line 538 of file devinst.c.

539 {
540  /* Wait until all pending installations are done, then freeze the threads */
542  DPRINT1("WaitNoPendingInstallEvents() failed to wait!\n");
543 
544  // TODO: use signalling events
545 
548 
549  return TRUE;
550 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtSuspendThread(IN HANDLE ThreadHandle, OUT PULONG PreviousSuspendCount OPTIONAL)
Definition: state.c:352
#define STATUS_WAIT_0
Definition: ntstatus.h:223
static HANDLE hPnpThread
Definition: devinst.c:25
static HANDLE hDeviceInstallThread
Definition: devinst.c:26
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS WaitNoPendingInstallEvents(IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: devinst.c:508
#define DPRINT1
Definition: precomp.h:8

Referenced by TerminateUserModePnpManager().

◆ EnableUserModePnpManager()

BOOLEAN EnableUserModePnpManager ( VOID  )

Definition at line 515 of file devinst.c.

516 {
518 
519  /* Start the PnP thread */
520  if (hPnpThread != NULL)
522 
523  /*
524  * Wait a little bit so that we get a chance to have some events being
525  * queued by the time the device-installation thread becomes resumed.
526  */
527  Timeout.QuadPart = -10000000LL; /* Wait for 1 second */
529 
530  /* Start the device installation thread */
531  if (hDeviceInstallThread != NULL)
533 
534  return TRUE;
535 }
#define TRUE
Definition: types.h:120
#define LL
Definition: tui.h:85
static HANDLE hPnpThread
Definition: devinst.c:25
static HANDLE hDeviceInstallThread
Definition: devinst.c:26
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
static HANDLE hDeviceInstallListNotEmpty
Definition: devinst.c:29
static ULONG Timeout
Definition: ping.c:61
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by SetupStartPage().

◆ InitializeUserModePnpManager()

NTSTATUS InitializeUserModePnpManager ( IN HINF phSetupInf)

Definition at line 553 of file devinst.c.

555 {
558 
559  UNICODE_STRING EnumU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum");
560  UNICODE_STRING ServicesU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services");
561 
564  NULL,
566  FALSE);
567  if (!NT_SUCCESS(Status))
568  {
569  DPRINT1("Could not create the event! (Status 0x%08lx)\n", Status);
570  goto Failure;
571  }
572 
575  NULL,
577  FALSE);
578  if (!NT_SUCCESS(Status))
579  {
580  DPRINT1("Could not create the event! (Status 0x%08lx)\n", Status);
581  goto Failure;
582  }
583 
585 
588  if (!NT_SUCCESS(Status))
589  {
590  DPRINT1("NtOpenKey('%wZ') failed (Status 0x%08lx)\n", &EnumU, Status);
591  goto Failure;
592  }
593 
596  if (!NT_SUCCESS(Status))
597  {
598  DPRINT1("NtCreateKey('%wZ') failed (Status 0x%08lx)\n", &ServicesU, Status);
599  goto Failure;
600  }
601 
602  /* Create the PnP event thread in suspended state */
604  NULL,
605  TRUE,
606  0,
607  0,
608  0,
610  NULL,
611  &hPnpThread,
612  NULL);
613  if (!NT_SUCCESS(Status))
614  {
615  DPRINT1("Failed to create the PnP event thread (Status 0x%08lx)\n", Status);
616  hPnpThread = NULL;
617  goto Failure;
618  }
619 
620  /* Create the device installation thread in suspended state */
622  NULL,
623  TRUE,
624  0,
625  0,
626  0,
628  phSetupInf,
630  NULL);
631  if (!NT_SUCCESS(Status))
632  {
633  DPRINT1("Failed to create the device installation thread (Status 0x%08lx)\n", Status);
635  goto Failure;
636  }
637 
638  return STATUS_SUCCESS;
639 
640 Failure:
641  if (hPnpThread)
642  {
645  }
646  hPnpThread = NULL;
647 
648  if (hServicesKey)
650  hServicesKey = NULL;
651 
652  if (hEnumKey)
653  NtClose(hEnumKey);
654  hEnumKey = NULL;
655 
656  if (hNoPendingInstalls)
659 
663 
664  return Status;
665 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:100
static HANDLE hEnumKey
Definition: devinst.c:20
static HANDLE hPnpThread
Definition: devinst.c:25
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
static HANDLE hDeviceInstallThread
Definition: devinst.c:26
static ULONG NTAPI DeviceInstallThread(IN PVOID Parameter)
Definition: devinst.c:363
smooth NULL
Definition: ftsmooth.c:416
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
static HANDLE hServicesKey
Definition: devinst.c:21
NTSTATUS NtTerminateThread(IN HANDLE ThreadHandle OPTIONAL, IN NTSTATUS ExitStatus)
Definition: kill.c:1278
static HANDLE hNoPendingInstalls
Definition: devinst.c:23
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static ULONG NTAPI PnpEventThread(IN PVOID Parameter)
Definition: devinst.c:405
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS NTAPI RtlCreateUserThread(_In_ PVOID ThreadContext, _Out_ HANDLE *OutThreadHandle, _Reserved_ PVOID Reserved1, _Reserved_ PVOID Reserved2, _Reserved_ PVOID Reserved3, _Reserved_ PVOID Reserved4, _Reserved_ PVOID Reserved5, _Reserved_ PVOID Reserved6, _Reserved_ PVOID Reserved7, _Reserved_ PVOID Reserved8)
Status
Definition: gdiplustypes.h:24
static HANDLE hDeviceInstallListNotEmpty
Definition: devinst.c:29
NTSYSAPI VOID NTAPI RtlInitializeSListHead(_Out_ PSLIST_HEADER ListHead)
Definition: slist.c:25
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
static SLIST_HEADER DeviceInstallListHead
Definition: devinst.c:28
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by RunUSetup().

◆ TerminateUserModePnpManager()

VOID TerminateUserModePnpManager ( VOID  )

Definition at line 668 of file devinst.c.

669 {
671 
672  // TODO: use signalling events
673 
674  /* Kill the PnP thread as it blocks inside the NtGetPlugPlayEvent() call */
675  if (hPnpThread)
676  {
679  }
680  hPnpThread = NULL;
681 
682  /* Kill the device installation thread */
684  {
687  }
689 
690  /* Close the opened handles */
691 
692  if (hServicesKey)
694  hServicesKey = NULL;
695 
696  if (hEnumKey)
697  NtClose(hEnumKey);
698  hEnumKey = NULL;
699 
700  if (hNoPendingInstalls)
703 
707 }
static HANDLE hEnumKey
Definition: devinst.c:20
static HANDLE hPnpThread
Definition: devinst.c:25
static HANDLE hDeviceInstallThread
Definition: devinst.c:26
smooth NULL
Definition: ftsmooth.c:416
static HANDLE hServicesKey
Definition: devinst.c:21
NTSTATUS NtTerminateThread(IN HANDLE ThreadHandle OPTIONAL, IN NTSTATUS ExitStatus)
Definition: kill.c:1278
static HANDLE hNoPendingInstalls
Definition: devinst.c:23
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static HANDLE hDeviceInstallListNotEmpty
Definition: devinst.c:29
BOOLEAN DisableUserModePnpManager(VOID)
Definition: devinst.c:538
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by RunUSetup().

◆ WaitNoPendingInstallEvents()

NTSTATUS WaitNoPendingInstallEvents ( IN PLARGE_INTEGER Timeout  OPTIONAL)

Definition at line 508 of file devinst.c.

510 {
512 }
static HANDLE hNoPendingInstalls
Definition: devinst.c:23
static ULONG Timeout
Definition: ping.c:61
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by DisableUserModePnpManager(), and SetupStartPage().