3 * Copyright (C) 2005 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/umpnpmgr/umpnpmgr.c
24 * PURPOSE: User-mode Plug and Play manager
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
33 #define NTOS_MODE_USER
35 #include <ntos/ntpnp.h>
36 #include <ddk/wdmguid.h>
50 /* GLOBALS ******************************************************************/
53 ServiceMain(DWORD argc
, LPTSTR
*argv
);
55 static SERVICE_TABLE_ENTRY ServiceTable
[2] =
57 {_T("PlugPlay"), ServiceMain
},
62 /* FUNCTIONS *****************************************************************/
65 PnpEventThread(LPVOID lpParameter
)
67 PPLUGPLAY_EVENT_BLOCK PnpEvent
;
71 PnpEvent
= HeapAlloc(GetProcessHeap(), 0, 1024);
73 return ERROR_OUTOFMEMORY
;
77 DPRINT("Calling NtGetPlugPlayEvent()\n");
79 ZeroMemory(PnpEvent
, 1024);
81 /* Wait for the next pnp event */
82 Status
= NtGetPlugPlayEvent(0, 0, PnpEvent
, 1024);
83 if (!NT_SUCCESS(Status
))
85 DPRINT("NtPlugPlayEvent() failed (Status %lx)\n", Status
);
89 DPRINT("Received PnP Event\n");
90 if (UuidEqual((UUID
*)&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_ARRIVAL
, &RpcStatus
))
92 DPRINT1("Device arrival event: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
96 DPRINT1("Unknown event\n");
99 /* FIXME: Process the pnp event */
102 /* Dequeue the current pnp event and signal the next one */
103 NtPlugPlayControl(PLUGPLAY_USER_RESPONSE
, NULL
, 0);
106 HeapFree(GetProcessHeap(), 0, PnpEvent
);
108 return ERROR_SUCCESS
;
113 ServiceMain(DWORD argc
, LPTSTR
*argv
)
118 DPRINT("ServiceMain() called\n");
120 hThread
= CreateThread(NULL
,
127 CloseHandle(hThread
);
129 DPRINT("ServiceMain() done\n");
134 main(int argc
, char *argv
[])
136 DPRINT("Umpnpmgr: main() started\n");
138 StartServiceCtrlDispatcher(ServiceTable
);
140 DPRINT("Umpnpmgr: main() done\n");