[SETUPAPI]

Partial implementation of CMP_RegisterNotification and CMP_UnregisterNotification.

[UMPNPMGR]
Partial implementation of PNP_RegisterNotification and PNP_UnregisterNotification.

CORE-12217 #comment This should fix one of the issues.

svn path=/trunk/; revision=73394
This commit is contained in:
Eric Kohl 2016-11-27 11:14:25 +00:00
parent a3dbf1b448
commit a6eabc0043
3 changed files with 147 additions and 17 deletions

View file

@ -2857,10 +2857,28 @@ PNP_RunDetection(
DWORD DWORD
WINAPI WINAPI
PNP_RegisterNotification( PNP_RegisterNotification(
handle_t hBinding) handle_t hBinding,
DWORD ulFlags,
DWORD *pulNotify)
{ {
UNIMPLEMENTED; #if 0
return CR_CALL_NOT_IMPLEMENTED; 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;
} }
@ -2868,10 +2886,18 @@ PNP_RegisterNotification(
DWORD DWORD
WINAPI WINAPI
PNP_UnregisterNotification( PNP_UnregisterNotification(
handle_t hBinding) handle_t hBinding,
DWORD ulNotify)
{ {
DPRINT1("PNP_UnregisterNotification(%p 0x%lx)\n",
hBinding, ulNotify);
#if 0
UNIMPLEMENTED; UNIMPLEMENTED;
return CR_CALL_NOT_IMPLEMENTED; return CR_CALL_NOT_IMPLEMENTED;
#endif
return CR_SUCCESS;
} }

View file

@ -21,6 +21,7 @@
#include "setupapi_private.h" #include "setupapi_private.h"
#include <dbt.h>
#include <pnp_c.h> #include <pnp_c.h>
#include "rpc_private.h" #include "rpc_private.h"
@ -59,6 +60,15 @@ typedef struct _LOG_CONF_INFO
#define LOG_CONF_MAGIC 0x464E434C /* "LCNF" */ #define LOG_CONF_MAGIC 0x464E434C /* "LCNF" */
typedef struct _NOTIFY_DATA
{
ULONG ulMagic;
ULONG ulNotifyData;
} NOTIFY_DATA, *PNOTIFY_DATA;
#define NOTIFY_MAGIC 0x44556677
static BOOL GuidToString(LPGUID Guid, LPWSTR String) static BOOL GuidToString(LPGUID Guid, LPWSTR String)
{ {
LPWSTR lpString; LPWSTR lpString;
@ -121,14 +131,76 @@ CONFIGRET WINAPI CMP_Init_Detection(
*/ */
CONFIGRET CONFIGRET
WINAPI WINAPI
CMP_RegisterNotification(IN HANDLE hRecipient, CMP_RegisterNotification(
IN LPVOID lpvNotificationFilter, IN HANDLE hRecipient,
IN DWORD dwFlags, IN LPVOID lpvNotificationFilter,
OUT PULONG pluhDevNotify) IN DWORD dwFlags,
OUT PHDEVNOTIFY phDevNotify)
{ {
FIXME("Stub %p %p %lu %p\n", hRecipient, lpvNotificationFilter, dwFlags, pluhDevNotify); RPC_BINDING_HANDLE BindingHandle = NULL;
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); PNOTIFY_DATA pNotifyData = NULL;
return CR_FAILURE; CONFIGRET ret = CR_SUCCESS;
TRACE("CMP_RegisterNotification(%p %p %lu %p)\n", hRecipient, lpvNotificationFilter, dwFlags, phDevNotify);
if ((hRecipient == NULL) ||
(lpvNotificationFilter == NULL) ||
(phDevNotify == NULL))
return CR_INVALID_POINTER;
if (dwFlags & ~0x7)
return CR_INVALID_FLAG;
if (((PDEV_BROADCAST_HDR)lpvNotificationFilter)->dbch_size < sizeof(DEV_BROADCAST_HDR))
return CR_INVALID_DATA;
if (!PnpGetLocalHandles(&BindingHandle, NULL))
return CR_FAILURE;
pNotifyData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(NOTIFY_DATA));
if (pNotifyData == NULL)
return CR_OUT_OF_MEMORY;
pNotifyData->ulMagic = NOTIFY_MAGIC;
/*
if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_WINDOW_HANDLE)
{
}
else if (dwFlags & DEVICE_NOTIFY_SERVICE_HANDLE == DEVICE_NOTYFY_SERVICE_HANDLE)
{
}
*/
RpcTryExcept
{
ret = PNP_RegisterNotification(BindingHandle,
dwFlags,
&pNotifyData->ulNotifyData);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
ret = RpcStatusToCmStatus(RpcExceptionCode());
}
RpcEndExcept;
if (ret == CR_SUCCESS)
{
*phDevNotify = (HDEVNOTIFY)pNotifyData;
}
else
{
if (pNotifyData != NULL)
HeapFree(GetProcessHeap(), 0, pNotifyData);
*phDevNotify = (HDEVNOTIFY)NULL;
}
return ret;
} }
@ -144,7 +216,7 @@ CONFIGRET WINAPI CMP_Report_LogOn(
BOOL bAdmin; BOOL bAdmin;
DWORD i; DWORD i;
TRACE("%lu\n", dwMagic); TRACE("CMP_Report_LogOn(%lu %lu)\n", dwMagic, dwProcessId);
if (dwMagic != CMP_MAGIC) if (dwMagic != CMP_MAGIC)
return CR_INVALID_DATA; return CR_INVALID_DATA;
@ -183,10 +255,39 @@ CONFIGRET WINAPI CMP_Report_LogOn(
*/ */
CONFIGRET CONFIGRET
WINAPI WINAPI
CMP_UnregisterNotification(IN HDEVNOTIFY handle) CMP_UnregisterNotification(
IN HDEVNOTIFY hDevNotify)
{ {
FIXME("Stub %p\n", handle); RPC_BINDING_HANDLE BindingHandle = NULL;
return CR_SUCCESS; PNOTIFY_DATA pNotifyData;
CONFIGRET ret = CR_SUCCESS;
TRACE("CMP_UnregisterNotification(%p)\n", hDevNotify);
pNotifyData = (PNOTIFY_DATA)hDevNotify;
if ((pNotifyData == NULL) ||
(pNotifyData->ulMagic != NOTIFY_MAGIC))
return CR_INVALID_POINTER;
if (!PnpGetLocalHandles(&BindingHandle, NULL))
return CR_FAILURE;
RpcTryExcept
{
ret = PNP_UnregisterNotification(BindingHandle,
pNotifyData->ulNotifyData);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
ret = RpcStatusToCmStatus(RpcExceptionCode());
}
RpcEndExcept;
if (ret == CR_SUCCESS)
HeapFree(GetProcessHeap(), 0, pNotifyData);
return ret;
} }

View file

@ -874,13 +874,16 @@ interface pnp
DWORD DWORD
__stdcall __stdcall
PNP_RegisterNotification( PNP_RegisterNotification(
[in] handle_t hBinding); [in] handle_t hBinding,
[in] DWORD ulFlags,
[out] DWORD *pulNotifyData);
/* Function 60 */ /* Function 60 */
DWORD DWORD
__stdcall __stdcall
PNP_UnregisterNotification( PNP_UnregisterNotification(
[in] handle_t hBinding); [in] handle_t hBinding,
[in] DWORD ulNotifyData);
cpp_quote("#if _WIN32_WINNT >= 0x0501") cpp_quote("#if _WIN32_WINNT >= 0x0501")