--- trunk/reactos/include/idl/pnp.idl 2005-07-23 11:55:33 UTC (rev 16703)
+++ trunk/reactos/include/idl/pnp.idl 2005-07-23 13:43:52 UTC (rev 16704)
@@ -29,15 +29,15 @@
[out, string, size_is(Length)] wchar_t *DeviceInstance,
[in] DWORD Length);
-// cpp_quote("#define PNP_DEVICE_PARENT 1")
-// cpp_quote("#define PNP_DEVICE_CHILD 2")
-// cpp_quote("#define PNP_DEVICE_SIBLING 3")
-// CONFIGRET PNP_GetRelatedDeviceInstance(handle_t BindingHandle,
-// [in] DWORD Relationship,
-// [in, string] wchar_t *DeviceId,
-// [out, string, size_is(Length)] wchar_t *RelatedDeviceId,
-// [in] DWORD Length,
-// [in] DWORD Flags);
+ cpp_quote("#define PNP_DEVICE_PARENT 1")
+ cpp_quote("#define PNP_DEVICE_CHILD 2")
+ cpp_quote("#define PNP_DEVICE_SIBLING 3")
+ CONFIGRET PNP_GetRelatedDeviceInstance(handle_t BindingHandle,
+ [in] DWORD Relationship,
+ [in, string] wchar_t *DeviceId,
+ [out, string, size_is(Length)] wchar_t *RelatedDeviceId,
+ [in] DWORD Length,
+ [in] DWORD Flags);
CONFIGRET PNP_GetDepth(handle_t BindingHandle,
[in, string] wchar_t *DeviceInstance,
@@ -49,4 +49,9 @@
[out] unsigned long *Status,
[out] unsigned long *Problem,
[in] DWORD Flags);
+
+ CONFIGRET PNP_SetDeviceProblem(handle_t BindingHandle,
+ [in, string] wchar_t *DeviceInstance,
+ [in] unsigned long Problem,
+ [in] DWORD Flags);
}
--- trunk/reactos/lib/setupapi/cfgmgr.c 2005-07-23 11:55:33 UTC (rev 16703)
+++ trunk/reactos/lib/setupapi/cfgmgr.c 2005-07-23 13:43:52 UTC (rev 16704)
@@ -251,7 +251,6 @@
CONFIGRET WINAPI CM_Get_Child_Ex(
PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
{
-#if 0
WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN];
RPC_BINDING_HANDLE BindingHandle = NULL;
HSTRING_TABLE StringTable = NULL;
@@ -310,9 +309,6 @@
*pdnDevInst = dwIndex;
return CR_SUCCESS;
-#endif
- FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine);
- return CR_FAILURE;
}
@@ -322,8 +318,7 @@
CONFIGRET WINAPI CM_Get_Depth(
PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags)
{
- TRACE("%p %lx %lx\n",
- pulDepth, dnDevInst, ulFlags);
+ TRACE("%p %lx %lx\n", pulDepth, dnDevInst, ulFlags);
return CM_Get_Depth_Ex(pulDepth, dnDevInst, ulFlags, NULL);
}
@@ -738,7 +733,6 @@
CONFIGRET WINAPI CM_Get_Parent_Ex(
PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
{
-#if 0
WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN];
RPC_BINDING_HANDLE BindingHandle = NULL;
HSTRING_TABLE StringTable = NULL;
@@ -797,9 +791,6 @@
*pdnDevInst = dwIndex;
return CR_SUCCESS;
-#endif
- FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine);
- return CR_FAILURE;
}
@@ -820,7 +811,6 @@
CONFIGRET WINAPI CM_Get_Sibling_Ex(
PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
{
-#if 0
WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN];
RPC_BINDING_HANDLE BindingHandle = NULL;
HSTRING_TABLE StringTable = NULL;
@@ -879,9 +869,6 @@
*pdnDevInst = dwIndex;
return CR_SUCCESS;
-#endif
- FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine);
- return CR_FAILURE;
}
@@ -1035,3 +1022,60 @@
return rc;
}
+
+
+/***********************************************************************
+ * CM_Set_DevNode_Problem [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Set_DevNode_Problem(
+ DEVINST dnDevInst, ULONG ulProblem, ULONG ulFlags)
+{
+ TRACE("%lx %lx %lx\n", dnDevInst, ulProblem, ulFlags);
+ return CM_Set_DevNode_Problem_Ex(dnDevInst, ulProblem, ulFlags, NULL);
+}
+
+
+/***********************************************************************
+ * CM_Set_DevNode_Problem_Ex [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Set_DevNode_Problem_Ex(
+ DEVINST dnDevInst, ULONG ulProblem, ULONG ulFlags, HMACHINE hMachine)
+{
+ RPC_BINDING_HANDLE BindingHandle = NULL;
+ HSTRING_TABLE StringTable = NULL;
+ LPWSTR lpDevInst;
+ CONFIGRET rc = CR_SUCCESS;
+
+ TRACE("%lx %lx %lx %lx\n", dnDevInst, ulProblem, ulFlags, hMachine);
+
+ if (dnDevInst == 0)
+ return CR_INVALID_DEVNODE;
+
+ if (ulFlags & ~CM_SET_DEVNODE_PROBLEM_BITS)
+ return CR_INVALID_FLAG;
+
+ if (hMachine != NULL)
+ {
+ BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
+ if (BindingHandle == NULL)
+ return CR_FAILURE;
+
+ StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
+ if (StringTable == 0)
+ return CR_FAILURE;
+ }
+ else
+ {
+ if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
+ return CR_FAILURE;
+ }
+
+ lpDevInst = StringTableStringFromId(StringTable, dnDevInst);
+ if (lpDevInst == NULL)
+ return CR_INVALID_DEVNODE;
+
+ return PNP_SetDeviceProblem(BindingHandle,
+ lpDevInst,
+ ulProblem,
+ ulFlags);
+}
--- trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-07-23 11:55:33 UTC (rev 16703)
+++ trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-07-23 13:43:52 UTC (rev 16704)
@@ -48,8 +48,8 @@
static SERVICE_TABLE_ENTRY ServiceTable[2] =
{
- {TEXT("PlugPlay"), ServiceMain},
- {NULL, NULL}
+ {TEXT("PlugPlay"), ServiceMain},
+ {NULL, NULL}
};
static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0";
@@ -59,41 +59,41 @@
static DWORD WINAPI
RpcServerThread(LPVOID lpParameter)
{
- RPC_STATUS Status;
+ RPC_STATUS Status;
- DPRINT("RpcServerThread() called\n");
+ DPRINT("RpcServerThread() called\n");
- Status = RpcServerUseProtseqEpW(L"ncacn_np",
- 20,
- L"\\pipe\\umpnpmgr",
- NULL); // Security descriptor
- if (Status != RPC_S_OK)
- {
- DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
- return 0;
- }
+ Status = RpcServerUseProtseqEpW(L"ncacn_np",
+ 20,
+ L"\\pipe\\umpnpmgr",
+ NULL); // Security descriptor
+ if (Status != RPC_S_OK)
+ {
+ DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
+ return 0;
+ }
- Status = RpcServerRegisterIf(pnp_v1_0_s_ifspec,
- NULL,
- NULL);
- if (Status != RPC_S_OK)
- {
- DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
- return 0;
- }
+ Status = RpcServerRegisterIf(pnp_v1_0_s_ifspec,
+ NULL,
+ NULL);
+ if (Status != RPC_S_OK)
+ {
+ DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
+ return 0;
+ }
- Status = RpcServerListen(1,
- 20,
- FALSE);
- if (Status != RPC_S_OK)
- {
- DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
- return 0;
- }
+ Status = RpcServerListen(1,
+ 20,
+ FALSE);
+ if (Status != RPC_S_OK)
+ {
+ DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
+ return 0;
+ }
- DPRINT("RpcServerThread() done\n");
+ DPRINT("RpcServerThread() done\n");
- return 0;
+ return 0;
}
@@ -202,7 +202,6 @@
}
-#if 0
CONFIGRET
PNP_GetRelatedDeviceInstance(handle_t BindingHandle,
unsigned long Relationship,
@@ -211,21 +210,40 @@
unsigned long Length,
unsigned long Flags)
{
+ PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData;
CONFIGRET ret = CR_SUCCESS;
+ NTSTATUS Status;
- DPRINT1("PNP_GetRelatedDeviceInstance() called\n");
- DPRINT1(" Relationship %ld\n", Relationship);
- DPRINT1(" DeviceId %S\n", DeviceId);
+ DPRINT("PNP_GetRelatedDeviceInstance() called\n");
+ DPRINT(" Relationship %ld\n", Relationship);
+ DPRINT(" DeviceId %S\n", DeviceId);
- lstrcpyW(RelatedDeviceId,
- szRootDeviceId);
+ RtlInitUnicodeString(&PlugPlayData.TargetDeviceInstance,
+ DeviceId);
-//Done:
- DPRINT1("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret);
+ PlugPlayData.Relation = Relationship;
+ PlugPlayData.RelatedDeviceInstance.Length = 0;
+ PlugPlayData.RelatedDeviceInstance.MaximumLength = Length;
+ PlugPlayData.RelatedDeviceInstance.Buffer = RelatedDeviceId;
+
+ Status = NtPlugPlayControl(PlugPlayControlGetRelatedDevice,
+ (PVOID)&PlugPlayData,
+ sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA));
+ if (!NT_SUCCESS(Status))
+ {
+ /* FIXME: Map Status to ret */
+ ret = CR_FAILURE;
+ }
+
+ DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret);
+ if (ret == 0)
+ {
+ DPRINT("RelatedDevice: %wZ\n", &PlugPlayData.RelatedDeviceInstance);
+ }
+
return ret;
}
-#endif
CONFIGRET
@@ -297,104 +315,124 @@
}
+CONFIGRET
+PNP_SetDeviceProblem(handle_t BindingHandle,
+ wchar_t *DeviceInstance,
+ unsigned long Problem,
+ DWORD Flags)
+{
+ CONFIGRET ret = CR_SUCCESS;
+
+ DPRINT1("PNP_SetDeviceProblem() called\n");
+
+ /* FIXME */
+
+ DPRINT1("PNP_SetDeviceProblem() done (returns %lx)\n", ret);
+
+ return ret;
+}
+
+
static DWORD WINAPI
PnpEventThread(LPVOID lpParameter)
{
- PPLUGPLAY_EVENT_BLOCK PnpEvent;
- ULONG PnpEventSize;
- NTSTATUS Status;
- RPC_STATUS RpcStatus;
+ PPLUGPLAY_EVENT_BLOCK PnpEvent;
+ ULONG PnpEventSize;
+ NTSTATUS Status;
+ RPC_STATUS RpcStatus;
- PnpEventSize = 0x1000;
- PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize);
- if (PnpEvent == NULL)
- return ERROR_OUTOFMEMORY;
-
- for (;;)
- {
- DPRINT("Calling NtGetPlugPlayEvent()\n");
-
- /* Wait for the next pnp event */
- Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize);
- /* Resize the buffer for the PnP event if it's too small. */
- if (Status == STATUS_BUFFER_TOO_SMALL)
- {
- PnpEventSize += 0x400;
- PnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize);
- if (PnpEvent == NULL)
+ PnpEventSize = 0x1000;
+ PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize);
+ if (PnpEvent == NULL)
return ERROR_OUTOFMEMORY;
- continue;
- }
- if (!NT_SUCCESS(Status))
- {
- DPRINT("NtPlugPlayEvent() failed (Status %lx)\n", Status);
- break;
- }
- DPRINT("Received PnP Event\n");
- if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus))
+ for (;;)
{
- DPRINT1("Device arrival event: %S\n", PnpEvent->TargetDevice.DeviceIds);
- }
- else
- {
- DPRINT1("Unknown event\n");
- }
+ DPRINT("Calling NtGetPlugPlayEvent()\n");
- /* FIXME: Process the pnp event */
+ /* Wait for the next pnp event */
+ Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize);
- /* Dequeue the current pnp event and signal the next one */
- NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0);
- }
+ /* Resize the buffer for the PnP event if it's too small. */
+ if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ PnpEventSize += 0x400;
+ PnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize);
+ if (PnpEvent == NULL)
+ return ERROR_OUTOFMEMORY;
+ continue;
+ }
- HeapFree(GetProcessHeap(), 0, PnpEvent);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("NtPlugPlayEvent() failed (Status %lx)\n", Status);
+ break;
+ }
- return ERROR_SUCCESS;
+ DPRINT("Received PnP Event\n");
+ if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus))
+ {
+ DPRINT1("Device arrival event: %S\n", PnpEvent->TargetDevice.DeviceIds);
+ }
+ else
+ {
+ DPRINT1("Unknown event\n");
+ }
+
+ /* FIXME: Process the pnp event */
+
+ /* Dequeue the current pnp event and signal the next one */
+ NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0);
+ }
+
+ HeapFree(GetProcessHeap(), 0, PnpEvent);
+
+ return ERROR_SUCCESS;
}
static VOID CALLBACK
ServiceMain(DWORD argc, LPTSTR *argv)
{
- HANDLE hThread;
- DWORD dwThreadId;
+ HANDLE hThread;
+ DWORD dwThreadId;
- DPRINT("ServiceMain() called\n");
+ DPRINT("ServiceMain() called\n");
- hThread = CreateThread(NULL,
- 0,
- PnpEventThread,
- NULL,
- 0,
- &dwThreadId);
- if (hThread != NULL)
- CloseHandle(hThread);
+ hThread = CreateThread(NULL,
+ 0,
+ PnpEventThread,
+ NULL,
+ 0,
+ &dwThreadId);
+ if (hThread != NULL)
+ CloseHandle(hThread);
- hThread = CreateThread(NULL,
- 0,
- RpcServerThread,
- NULL,
- 0,
- &dwThreadId);
- if (hThread != NULL)
- CloseHandle(hThread);
+ hThread = CreateThread(NULL,
+ 0,
+ RpcServerThread,
+ NULL,
+ 0,
+ &dwThreadId);
+ if (hThread != NULL)
+ CloseHandle(hThread);
- DPRINT("ServiceMain() done\n");
+ DPRINT("ServiceMain() done\n");
}
int
main(int argc, char *argv[])
{
- DPRINT("Umpnpmgr: main() started\n");
+ DPRINT("Umpnpmgr: main() started\n");
- StartServiceCtrlDispatcher(ServiceTable);
+ StartServiceCtrlDispatcher(ServiceTable);
- DPRINT("Umpnpmgr: main() done\n");
+ DPRINT("Umpnpmgr: main() done\n");
- ExitThread(0);
+ ExitThread(0);
- return 0;
+ return 0;
}
/* EOF */