/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: services/umpnpmgr/umpnpmgr.c
+ * FILE: base/services/umpnpmgr/umpnpmgr.c
* PURPOSE: User-mode Plug and Play manager
* PROGRAMMER: Eric Kohl
* Hervé Poussineau (hpoussin@reactos.org)
#include <winbase.h>
#include <winreg.h>
#include <winsvc.h>
+#include <winuser.h>
+#include <dbt.h>
#include <stdio.h>
#include <cmfuncs.h>
#include <rtlfuncs.h>
DWORD ulFlags)
{
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
- CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED;
+ CONFIGRET ret = CR_SUCCESS;
NTSTATUS Status;
DPRINT("PNP_GetDeviceList() called\n");
return CR_INVALID_POINTER;
// if (Buffer == NULL)
-// return
-
- *pulLength = 0;
+// return CR_INVALID_POINTER;
if (ulFlags &
(CM_GETIDLIST_FILTER_BUSRELATIONS |
}
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
{
- /* FIXME */
- PlugPlayData.Relations = 0;
+ PlugPlayData.Relations = 2;
}
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
{
PlugPlayData.Relations = 0;
}
- PlugPlayData.BufferSize = *pulLength;
+ PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
PlugPlayData.Buffer = Buffer;
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
if (NT_SUCCESS(Status))
{
- *pulLength = PlugPlayData.BufferSize;
+ *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
}
else
{
}
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
{
-
+ ret = CR_CALL_NOT_IMPLEMENTED;
}
else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
{
-
+ ret = CR_CALL_NOT_IMPLEMENTED;
}
else /* CM_GETIDLIST_FILTER_NONE */
{
-
+ ret = CR_CALL_NOT_IMPLEMENTED;
}
return ret;
DWORD ulFlags)
{
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
- CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED;
+ CONFIGRET ret = CR_SUCCESS;
NTSTATUS Status;
DPRINT("PNP_GetDeviceListSize() called\n");
}
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
{
- /* FIXME */
- PlugPlayData.Relations = 0;
+ PlugPlayData.Relations = 2;
}
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
{
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
if (NT_SUCCESS(Status))
{
- *pulLength = PlugPlayData.BufferSize;
+ *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
}
else
{
}
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
{
-
+ ret = CR_CALL_NOT_IMPLEMENTED;
}
else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
{
-
+ ret = CR_CALL_NOT_IMPLEMENTED;
}
else /* CM_GETIDLIST_FILTER_NONE */
{
-
+ ret = CR_CALL_NOT_IMPLEMENTED;
}
return ret;
#endif
case CM_DRP_REMOVAL_POLICY:
- PlugPlayData.Property = 0x12; // DevicePropertyRemovalPolicy
+ PlugPlayData.Property = 0x13; // DevicePropertyRemovalPolicy
break;
#if 0
}
done:
- *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
+
+ if (pulTransferLen)
+ *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
if (hKey != NULL)
RegCloseKey(hKey);
CONFIGRET ret = CR_SUCCESS;
NTSTATUS Status;
- DPRINT("Enable device instance\n");
+ DPRINT("Enable device instance %S\n", pszDeviceInstance);
RtlInitUnicodeString(&ResetDeviceData.DeviceInstance, pszDeviceInstance);
Status = NtPlugPlayControl(PlugPlayControlResetDevice, &ResetDeviceData, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA));
DWORD
WINAPI
PNP_RegisterNotification(
- handle_t hBinding)
+ handle_t hBinding,
+ DWORD ulFlags,
+ DWORD *pulNotify)
{
- UNIMPLEMENTED;
- return CR_CALL_NOT_IMPLEMENTED;
+#if 0
+ PNOTIFY_DATA pNotifyData;
+#endif
+
+ DPRINT1("PNP_RegisterNotification(%p 0x%lx %p)\n",
+ hBinding, ulFlags, pulNotify);
+
+#if 0
+ pNotifyData = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(NOTIFY_DATA));
+ if (pNotifyData == NULL)
+ return CR_OUT_OF_MEMORY;
+
+ *pulNotify = (DWORD)pNotifyData;
+#endif
+
+ *pulNotify = 1;
+
+ return CR_SUCCESS;
}
DWORD
WINAPI
PNP_UnregisterNotification(
- handle_t hBinding)
+ handle_t hBinding,
+ DWORD ulNotify)
{
+ DPRINT1("PNP_UnregisterNotification(%p 0x%lx)\n",
+ hBinding, ulNotify);
+
+#if 0
UNIMPLEMENTED;
return CR_CALL_NOT_IMPLEMENTED;
+#endif
+
+ return CR_SUCCESS;
}
WCHAR PipeName[74];
WCHAR UuidString[39];
- DPRINT1("InstallDevice(%S, %d)\n", DeviceInstance, ShowWizard);
+ DPRINT("InstallDevice(%S, %d)\n", DeviceInstance, ShowWizard);
ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
}
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus))
{
+ DWORD dwRecipient;
+
DPRINT("Device arrival: %S\n", PnpEvent->TargetDevice.DeviceIds);
- /* FIXME: ? */
+
+ dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
+ BroadcastSystemMessageW(BSF_POSTMESSAGE,
+ &dwRecipient,
+ WM_DEVICECHANGE,
+ DBT_DEVNODES_CHANGED,
+ 0);
}
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_EJECT_VETOED, &RpcStatus))
{
}
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SAFE_REMOVAL, &RpcStatus))
{
+ DWORD dwRecipient;
+
DPRINT1("Safe removal: %S\n", PnpEvent->TargetDevice.DeviceIds);
+
+ dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
+ BroadcastSystemMessageW(BSF_POSTMESSAGE,
+ &dwRecipient,
+ WM_DEVICECHANGE,
+ DBT_DEVNODES_CHANGED,
+ 0);
}
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SURPRISE_REMOVAL, &RpcStatus))
{
+ DWORD dwRecipient;
+
DPRINT1("Surprise removal: %S\n", PnpEvent->TargetDevice.DeviceIds);
+
+ dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
+ BroadcastSystemMessageW(BSF_POSTMESSAGE,
+ &dwRecipient,
+ WM_DEVICECHANGE,
+ DBT_DEVNODES_CHANGED,
+ 0);
}
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_REMOVAL_VETOED, &RpcStatus))
{