2005-07-31 12:11:56 +00:00
|
|
|
|
/*
|
|
|
|
|
* ReactOS kernel
|
|
|
|
|
* Copyright (C) 2005 ReactOS Team
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-07-31 12:11:56 +00:00
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
|
* PROJECT: ReactOS kernel
|
2015-09-12 10:58:07 +00:00
|
|
|
|
* FILE: base/services/umpnpmgr/umpnpmgr.c
|
2005-07-31 12:11:56 +00:00
|
|
|
|
* PURPOSE: User-mode Plug and Play manager
|
2017-04-17 11:34:08 +00:00
|
|
|
|
* PROGRAMMER: Eric Kohl (eric.kohl@reactos.org)
|
2005-10-14 18:24:19 +00:00
|
|
|
|
* Herv<EFBFBD> Poussineau (hpoussin@reactos.org)
|
2009-04-14 22:31:36 +00:00
|
|
|
|
* Colin Finck (colin@reactos.org)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
2014-09-25 23:44:28 +00:00
|
|
|
|
|
2005-10-19 17:03:38 +00:00
|
|
|
|
#define WIN32_NO_STATUS
|
2013-01-24 23:00:42 +00:00
|
|
|
|
#define _INC_WINDOWS
|
|
|
|
|
#define COM_NO_WINDOWS_H
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <windef.h>
|
|
|
|
|
#include <winbase.h>
|
|
|
|
|
#include <winreg.h>
|
|
|
|
|
#include <winsvc.h>
|
2017-04-01 08:07:39 +00:00
|
|
|
|
#include <winuser.h>
|
|
|
|
|
#include <dbt.h>
|
2009-04-14 22:31:36 +00:00
|
|
|
|
#include <stdio.h>
|
2006-01-08 18:55:24 +00:00
|
|
|
|
#include <cmfuncs.h>
|
|
|
|
|
#include <rtlfuncs.h>
|
2009-04-14 22:31:36 +00:00
|
|
|
|
#include <setypes.h>
|
2005-11-22 04:57:45 +00:00
|
|
|
|
#include <umpnpmgr/sysguid.h>
|
2005-12-01 21:37:19 +00:00
|
|
|
|
#include <cfgmgr32.h>
|
2008-04-14 10:48:38 +00:00
|
|
|
|
#include <regstr.h>
|
2009-04-14 22:31:36 +00:00
|
|
|
|
#include <userenv.h>
|
2014-06-08 18:10:04 +00:00
|
|
|
|
#include <shlwapi.h>
|
2013-01-24 23:00:42 +00:00
|
|
|
|
#include <pnp_s.h>
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
|
2010-02-27 17:15:49 +00:00
|
|
|
|
static WCHAR ServiceName[] = L"PlugPlay";
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2010-02-27 17:15:49 +00:00
|
|
|
|
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
|
|
|
|
static SERVICE_STATUS ServiceStatus;
|
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0";
|
|
|
|
|
|
2005-08-01 19:42:19 +00:00
|
|
|
|
static HKEY hEnumKey = NULL;
|
|
|
|
|
static HKEY hClassKey = NULL;
|
|
|
|
|
|
2005-12-17 19:58:23 +00:00
|
|
|
|
static HANDLE hUserToken = NULL;
|
|
|
|
|
static HANDLE hInstallEvent = NULL;
|
2006-10-02 18:46:39 +00:00
|
|
|
|
static HANDLE hNoPendingInstalls = NULL;
|
2005-12-17 19:58:23 +00:00
|
|
|
|
|
2006-10-02 18:46:39 +00:00
|
|
|
|
static SLIST_HEADER DeviceInstallListHead;
|
|
|
|
|
static HANDLE hDeviceInstallListNotEmpty;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
SLIST_ENTRY ListEntry;
|
|
|
|
|
WCHAR DeviceIds[1];
|
|
|
|
|
} DeviceInstallParams;
|
2005-12-17 19:58:23 +00:00
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
|
RpcServerThread(LPVOID lpParameter)
|
|
|
|
|
{
|
|
|
|
|
RPC_STATUS Status;
|
2010-12-31 16:27:01 +00:00
|
|
|
|
BOOLEAN RegisteredProtSeq = FALSE;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(lpParameter);
|
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
DPRINT("RpcServerThread() called\n");
|
|
|
|
|
|
2010-12-31 16:27:01 +00:00
|
|
|
|
#if 0
|
2014-09-25 23:44:28 +00:00
|
|
|
|
/* 2k/XP/2k3-compatible protocol sequence/endpoint */
|
2005-07-31 12:11:56 +00:00
|
|
|
|
Status = RpcServerUseProtseqEpW(L"ncacn_np",
|
|
|
|
|
20,
|
2010-12-31 16:27:01 +00:00
|
|
|
|
L"\\pipe\\ntsvcs",
|
2005-07-31 12:11:56 +00:00
|
|
|
|
NULL); // Security descriptor
|
2010-12-31 16:27:01 +00:00
|
|
|
|
if (Status == RPC_S_OK)
|
|
|
|
|
RegisteredProtSeq = TRUE;
|
|
|
|
|
else
|
|
|
|
|
DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
/* Vista/7-compatible protocol sequence/endpoint */
|
2010-12-31 16:27:01 +00:00
|
|
|
|
Status = RpcServerUseProtseqEpW(L"ncacn_np",
|
|
|
|
|
20,
|
|
|
|
|
L"\\pipe\\plugplay",
|
|
|
|
|
NULL); // Security descriptor
|
|
|
|
|
if (Status == RPC_S_OK)
|
|
|
|
|
RegisteredProtSeq = TRUE;
|
|
|
|
|
else
|
2005-07-31 12:11:56 +00:00
|
|
|
|
DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
|
2010-12-31 16:27:01 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure there's a usable endpoint */
|
|
|
|
|
if (RegisteredProtSeq == FALSE)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-03 12:53:17 +00:00
|
|
|
|
/* ROS HACK (this should never happen...) */
|
|
|
|
|
DPRINT1("*** Other devices won't be installed correctly. If something\n");
|
|
|
|
|
DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
|
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
DPRINT("RpcServerThread() done\n");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-08-07 20:15:12 +00:00
|
|
|
|
void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
|
|
|
|
{
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-10-03 07:06:42 +00:00
|
|
|
|
static CONFIGRET WINAPI
|
|
|
|
|
NtStatusToCrError(NTSTATUS Status)
|
|
|
|
|
{
|
|
|
|
|
switch (Status)
|
|
|
|
|
{
|
2014-11-08 13:28:01 +00:00
|
|
|
|
case STATUS_NOT_IMPLEMENTED:
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2017-11-12 11:51:19 +00:00
|
|
|
|
case STATUS_INVALID_PARAMETER:
|
|
|
|
|
return CR_INVALID_DATA;
|
|
|
|
|
|
|
|
|
|
case STATUS_NO_SUCH_DEVICE:
|
|
|
|
|
return CR_NO_SUCH_DEVINST;
|
|
|
|
|
|
|
|
|
|
case STATUS_ACCESS_DENIED:
|
|
|
|
|
return CR_ACCESS_DENIED;
|
|
|
|
|
|
|
|
|
|
case STATUS_BUFFER_TOO_SMALL:
|
|
|
|
|
return CR_BUFFER_SMALL;
|
|
|
|
|
|
|
|
|
|
case STATUS_OBJECT_NAME_NOT_FOUND:
|
|
|
|
|
return CR_NO_SUCH_VALUE;
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
default:
|
|
|
|
|
return CR_FAILURE;
|
2005-10-03 07:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-29 21:08:35 +00:00
|
|
|
|
static VOID
|
|
|
|
|
SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID,
|
|
|
|
|
OUT LPWSTR pszEnumerator,
|
|
|
|
|
OUT LPWSTR pszDevice,
|
|
|
|
|
OUT LPWSTR pszInstance)
|
|
|
|
|
{
|
|
|
|
|
WCHAR szLocalDeviceInstanceID[MAX_DEVICE_ID_LEN];
|
|
|
|
|
LPWSTR lpEnumerator = NULL;
|
|
|
|
|
LPWSTR lpDevice = NULL;
|
|
|
|
|
LPWSTR lpInstance = NULL;
|
|
|
|
|
LPWSTR ptr;
|
|
|
|
|
|
|
|
|
|
wcscpy(szLocalDeviceInstanceID, pszDeviceInstanceID);
|
|
|
|
|
|
|
|
|
|
*pszEnumerator = 0;
|
|
|
|
|
*pszDevice = 0;
|
|
|
|
|
*pszInstance = 0;
|
|
|
|
|
|
|
|
|
|
lpEnumerator = szLocalDeviceInstanceID;
|
|
|
|
|
|
|
|
|
|
ptr = wcschr(lpEnumerator, L'\\');
|
|
|
|
|
if (ptr != NULL)
|
|
|
|
|
{
|
|
|
|
|
*ptr = 0;
|
|
|
|
|
lpDevice = ++ptr;
|
|
|
|
|
|
|
|
|
|
ptr = wcschr(lpDevice, L'\\');
|
|
|
|
|
if (ptr != NULL)
|
|
|
|
|
{
|
|
|
|
|
*ptr = 0;
|
|
|
|
|
lpInstance = ++ptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lpEnumerator != NULL)
|
|
|
|
|
wcscpy(pszEnumerator, lpEnumerator);
|
|
|
|
|
|
|
|
|
|
if (lpDevice != NULL)
|
|
|
|
|
wcscpy(pszDevice, lpDevice);
|
|
|
|
|
|
|
|
|
|
if (lpInstance != NULL)
|
|
|
|
|
wcscpy(pszInstance, lpInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 0 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_Disconnect(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2011-05-13 15:56:50 +00:00
|
|
|
|
return CR_SUCCESS;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 1 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_Connect(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2011-05-13 15:56:50 +00:00
|
|
|
|
return CR_SUCCESS;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 2 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetVersion(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
WORD *pVersion)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pVersion = 0x0400;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
return CR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 3 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetGlobalState(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD *pulState,
|
|
|
|
|
DWORD ulFlags)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pulState = CM_GLOBAL_STATE_CAN_DO_UI | CM_GLOBAL_STATE_SERVICES_AVAILABLE;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
return CR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 4 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_InitDetection(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
DPRINT("PNP_InitDetection() called\n");
|
|
|
|
|
return CR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 19:58:23 +00:00
|
|
|
|
/* Function 5 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_ReportLogOn(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
BOOL Admin,
|
|
|
|
|
DWORD ProcessId)
|
2005-12-17 19:58:23 +00:00
|
|
|
|
{
|
2009-04-14 22:31:36 +00:00
|
|
|
|
DWORD ReturnValue = CR_FAILURE;
|
2005-12-17 19:58:23 +00:00
|
|
|
|
HANDLE hProcess;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(Admin);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2007-12-11 21:25:10 +00:00
|
|
|
|
DPRINT("PNP_ReportLogOn(%u, %u) called\n", Admin, ProcessId);
|
2005-12-17 19:58:23 +00:00
|
|
|
|
|
|
|
|
|
/* Get the users token */
|
2009-04-14 22:31:36 +00:00
|
|
|
|
hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, ProcessId);
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (!hProcess)
|
2005-12-17 19:58:23 +00:00
|
|
|
|
{
|
2009-04-14 22:31:36 +00:00
|
|
|
|
DPRINT1("OpenProcess failed with error %u\n", GetLastError());
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2005-12-17 19:58:23 +00:00
|
|
|
|
|
2009-04-14 22:31:36 +00:00
|
|
|
|
if (hUserToken)
|
|
|
|
|
{
|
|
|
|
|
CloseHandle(hUserToken);
|
|
|
|
|
hUserToken = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (!OpenProcessToken(hProcess, TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_QUERY, &hUserToken))
|
2009-04-14 22:31:36 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT1("OpenProcessToken failed with error %u\n", GetLastError());
|
|
|
|
|
goto cleanup;
|
2005-12-17 19:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Trigger the installer thread */
|
2009-04-18 14:24:02 +00:00
|
|
|
|
if (hInstallEvent)
|
|
|
|
|
SetEvent(hInstallEvent);
|
2005-12-17 19:58:23 +00:00
|
|
|
|
|
2009-04-14 22:31:36 +00:00
|
|
|
|
ReturnValue = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
cleanup:
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (hProcess)
|
2009-04-14 22:31:36 +00:00
|
|
|
|
CloseHandle(hProcess);
|
|
|
|
|
|
|
|
|
|
return ReturnValue;
|
2005-12-17 19:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 6 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_ValidateDeviceInstance(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulFlags)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
HKEY hDeviceKey = NULL;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
DPRINT("PNP_ValidateDeviceInstance(%S %lx) called\n",
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pDeviceID, ulFlags);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(hEnumKey,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pDeviceID,
|
2005-07-31 12:11:56 +00:00
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hDeviceKey))
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Could not open the Device Key!\n");
|
|
|
|
|
ret = CR_NO_SUCH_DEVNODE;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: add more tests */
|
|
|
|
|
|
|
|
|
|
Done:
|
|
|
|
|
if (hDeviceKey != NULL)
|
|
|
|
|
RegCloseKey(hDeviceKey);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 7 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetRootDeviceInstance(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
PNP_RPC_STRING_LEN ulLength)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
DPRINT("PNP_GetRootDeviceInstance() called\n");
|
|
|
|
|
|
2008-04-21 12:08:42 +00:00
|
|
|
|
if (!pDeviceID)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_POINTER;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
2008-04-14 10:48:38 +00:00
|
|
|
|
if (ulLength < lstrlenW(szRootDeviceId) + 1)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
ret = CR_BUFFER_SMALL;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
lstrcpyW(pDeviceID,
|
2005-07-31 12:11:56 +00:00
|
|
|
|
szRootDeviceId);
|
|
|
|
|
|
|
|
|
|
Done:
|
|
|
|
|
DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 8 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetRelatedDeviceInstance(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD ulRelationship,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
LPWSTR pRelatedDeviceId,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
DPRINT("PNP_GetRelatedDeviceInstance() called\n");
|
2008-04-14 10:48:38 +00:00
|
|
|
|
DPRINT(" Relationship %ld\n", ulRelationship);
|
|
|
|
|
DPRINT(" DeviceId %S\n", pDeviceID);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.TargetDeviceInstance,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pDeviceID);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
PlugPlayData.Relation = ulRelationship;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
PlugPlayData.RelatedDeviceInstanceLength = *pulLength;
|
|
|
|
|
PlugPlayData.RelatedDeviceInstance = pRelatedDeviceId;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlGetRelatedDevice,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA));
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
2005-10-03 07:06:42 +00:00
|
|
|
|
ret = NtStatusToCrError(Status);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret);
|
2005-08-01 19:42:19 +00:00
|
|
|
|
if (ret == CR_SUCCESS)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT("RelatedDevice: %wZ\n", &PlugPlayData.RelatedDeviceInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 9 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_EnumerateSubKeys(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD ulBranch,
|
|
|
|
|
DWORD ulIndex,
|
|
|
|
|
LPWSTR Buffer,
|
|
|
|
|
PNP_RPC_STRING_LEN ulLength,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulRequiredLen,
|
|
|
|
|
DWORD ulFlags)
|
2005-08-01 19:42:19 +00:00
|
|
|
|
{
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
DWORD dwError;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-09-10 19:01:44 +00:00
|
|
|
|
DPRINT("PNP_EnumerateSubKeys() called\n");
|
2005-08-01 19:42:19 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
switch (ulBranch)
|
2005-08-01 19:42:19 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
case PNP_ENUMERATOR_SUBKEYS:
|
2005-08-01 19:42:19 +00:00
|
|
|
|
hKey = hEnumKey;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
case PNP_CLASS_SUBKEYS:
|
2005-08-01 19:42:19 +00:00
|
|
|
|
hKey = hClassKey;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pulRequiredLen = ulLength;
|
2005-08-01 19:42:19 +00:00
|
|
|
|
dwError = RegEnumKeyExW(hKey,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
ulIndex,
|
2005-08-01 19:42:19 +00:00
|
|
|
|
Buffer,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pulRequiredLen,
|
2005-08-01 19:42:19 +00:00
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
2005-09-10 19:01:44 +00:00
|
|
|
|
ret = (dwError == ERROR_NO_MORE_ITEMS) ? CR_NO_SUCH_VALUE : CR_FAILURE;
|
2005-08-01 19:42:19 +00:00
|
|
|
|
}
|
2005-09-10 19:01:44 +00:00
|
|
|
|
else
|
2005-08-01 19:42:19 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
(*pulRequiredLen)++;
|
2005-08-01 19:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-10 19:01:44 +00:00
|
|
|
|
DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret);
|
|
|
|
|
|
2005-08-01 19:42:19 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-31 10:20:30 +00:00
|
|
|
|
static
|
|
|
|
|
CONFIGRET
|
|
|
|
|
GetRelationsInstanceList(
|
|
|
|
|
_In_ PWSTR pszDevice,
|
|
|
|
|
_In_ DWORD ulFlags,
|
|
|
|
|
_Inout_ PWSTR pszBuffer,
|
|
|
|
|
_Inout_ PDWORD pulLength)
|
|
|
|
|
{
|
|
|
|
|
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
|
|
|
|
pszDevice);
|
|
|
|
|
|
|
|
|
|
if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
|
|
|
|
|
PlugPlayData.Buffer = pszBuffer;
|
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
*pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret = NtStatusToCrError(Status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-29 21:08:35 +00:00
|
|
|
|
static
|
|
|
|
|
CONFIGRET
|
|
|
|
|
GetDeviceInstanceList(
|
|
|
|
|
_In_ PWSTR pszDevice,
|
|
|
|
|
_Inout_ PWSTR pszBuffer,
|
|
|
|
|
_Inout_ PDWORD pulLength)
|
|
|
|
|
{
|
|
|
|
|
WCHAR szInstanceBuffer[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szPathBuffer[512];
|
|
|
|
|
HKEY hDeviceKey;
|
|
|
|
|
DWORD dwInstanceLength, dwPathLength, dwUsedLength;
|
|
|
|
|
DWORD dwIndex, dwError;
|
|
|
|
|
PWSTR pPtr;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
2018-12-30 11:55:31 +00:00
|
|
|
|
/* Open the device key */
|
2018-12-29 21:08:35 +00:00
|
|
|
|
dwError = RegOpenKeyExW(hEnumKey,
|
|
|
|
|
pszDevice,
|
|
|
|
|
0,
|
|
|
|
|
KEY_ENUMERATE_SUB_KEYS,
|
|
|
|
|
&hDeviceKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to open the device key (Error %lu)\n", dwError);
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dwUsedLength = 0;
|
|
|
|
|
pPtr = pszBuffer;
|
|
|
|
|
|
|
|
|
|
for (dwIndex = 0; ; dwIndex++)
|
|
|
|
|
{
|
|
|
|
|
dwInstanceLength = MAX_DEVICE_ID_LEN;
|
|
|
|
|
dwError = RegEnumKeyExW(hDeviceKey,
|
|
|
|
|
dwIndex,
|
|
|
|
|
szInstanceBuffer,
|
|
|
|
|
&dwInstanceLength,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
wsprintf(szPathBuffer, L"%s\\%s", pszDevice, szInstanceBuffer);
|
|
|
|
|
DPRINT("Path: %S\n", szPathBuffer);
|
|
|
|
|
|
|
|
|
|
dwPathLength = wcslen(szPathBuffer) + 1;
|
|
|
|
|
if (dwUsedLength + dwPathLength + 1 > *pulLength)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_BUFFER_SMALL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wcscpy(pPtr, szPathBuffer);
|
|
|
|
|
dwUsedLength += dwPathLength;
|
|
|
|
|
pPtr += dwPathLength;
|
|
|
|
|
|
|
|
|
|
*pPtr = UNICODE_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hDeviceKey);
|
|
|
|
|
|
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
*pulLength = dwUsedLength + 1;
|
|
|
|
|
else
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-30 11:55:31 +00:00
|
|
|
|
CONFIGRET
|
|
|
|
|
GetEnumeratorInstanceList(
|
|
|
|
|
_In_ PWSTR pszEnumerator,
|
|
|
|
|
_Inout_ PWSTR pszBuffer,
|
|
|
|
|
_Inout_ PDWORD pulLength)
|
|
|
|
|
{
|
|
|
|
|
WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szPathBuffer[512];
|
|
|
|
|
HKEY hEnumeratorKey;
|
|
|
|
|
PWSTR pPtr;
|
|
|
|
|
DWORD dwIndex, dwDeviceLength, dwUsedLength, dwRemainingLength, dwPathLength;
|
|
|
|
|
DWORD dwError;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
/* Open the enumerator key */
|
|
|
|
|
dwError = RegOpenKeyExW(hEnumKey,
|
|
|
|
|
pszEnumerator,
|
|
|
|
|
0,
|
|
|
|
|
KEY_ENUMERATE_SUB_KEYS,
|
|
|
|
|
&hEnumeratorKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dwUsedLength = 0;
|
|
|
|
|
dwRemainingLength = *pulLength;
|
|
|
|
|
pPtr = pszBuffer;
|
|
|
|
|
|
|
|
|
|
for (dwIndex = 0; ; dwIndex++)
|
|
|
|
|
{
|
|
|
|
|
dwDeviceLength = MAX_DEVICE_ID_LEN;
|
|
|
|
|
dwError = RegEnumKeyExW(hEnumeratorKey,
|
|
|
|
|
dwIndex,
|
|
|
|
|
szDeviceBuffer,
|
|
|
|
|
&dwDeviceLength,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
|
|
|
|
|
DPRINT("Path: %S\n", szPathBuffer);
|
|
|
|
|
|
|
|
|
|
dwPathLength = dwRemainingLength;
|
|
|
|
|
ret = GetDeviceInstanceList(szPathBuffer,
|
|
|
|
|
pPtr,
|
|
|
|
|
&dwPathLength);
|
|
|
|
|
if (ret != CR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
dwUsedLength += dwPathLength - 1;
|
|
|
|
|
dwRemainingLength += dwPathLength - 1;
|
|
|
|
|
pPtr += dwPathLength - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hEnumeratorKey);
|
|
|
|
|
|
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
*pulLength = dwUsedLength + 1;
|
|
|
|
|
else
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-30 16:14:43 +00:00
|
|
|
|
static
|
|
|
|
|
CONFIGRET
|
|
|
|
|
GetAllInstanceList(
|
|
|
|
|
_Inout_ PWSTR pszBuffer,
|
|
|
|
|
_Inout_ PDWORD pulLength)
|
|
|
|
|
{
|
|
|
|
|
WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
|
|
|
|
|
PWSTR pPtr;
|
|
|
|
|
DWORD dwIndex, dwEnumeratorLength, dwUsedLength, dwRemainingLength, dwPathLength;
|
|
|
|
|
DWORD dwError;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
dwUsedLength = 0;
|
|
|
|
|
dwRemainingLength = *pulLength;
|
|
|
|
|
pPtr = pszBuffer;
|
|
|
|
|
|
|
|
|
|
for (dwIndex = 0; ; dwIndex++)
|
|
|
|
|
{
|
|
|
|
|
dwEnumeratorLength = MAX_DEVICE_ID_LEN;
|
|
|
|
|
dwError = RegEnumKeyExW(hEnumKey,
|
|
|
|
|
dwIndex,
|
|
|
|
|
szEnumeratorBuffer,
|
|
|
|
|
&dwEnumeratorLength,
|
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
dwPathLength = dwRemainingLength;
|
|
|
|
|
ret = GetEnumeratorInstanceList(szEnumeratorBuffer,
|
|
|
|
|
pPtr,
|
|
|
|
|
&dwPathLength);
|
|
|
|
|
if (ret != CR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
dwUsedLength += dwPathLength - 1;
|
|
|
|
|
dwRemainingLength += dwPathLength - 1;
|
|
|
|
|
pPtr += dwPathLength - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
*pulLength = dwUsedLength + 1;
|
|
|
|
|
else
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 10 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetDeviceList(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszFilter,
|
|
|
|
|
LPWSTR Buffer,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
2005-09-24 09:30:43 +00:00
|
|
|
|
{
|
2018-12-29 21:08:35 +00:00
|
|
|
|
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szDevice[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szInstance[MAX_DEVICE_ID_LEN];
|
2017-02-13 22:59:40 +00:00
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
2015-06-08 23:29:59 +00:00
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetDeviceList() called\n");
|
|
|
|
|
|
|
|
|
|
if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
|
|
|
|
|
return CR_INVALID_FLAG;
|
|
|
|
|
|
2018-12-29 21:08:35 +00:00
|
|
|
|
if (pulLength == NULL)
|
2015-06-08 23:29:59 +00:00
|
|
|
|
return CR_INVALID_POINTER;
|
|
|
|
|
|
2018-12-29 21:08:35 +00:00
|
|
|
|
if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
|
|
|
|
|
(pszFilter == NULL))
|
|
|
|
|
return CR_INVALID_POINTER;
|
2015-06-08 23:29:59 +00:00
|
|
|
|
|
|
|
|
|
if (ulFlags &
|
|
|
|
|
(CM_GETIDLIST_FILTER_BUSRELATIONS |
|
|
|
|
|
CM_GETIDLIST_FILTER_POWERRELATIONS |
|
|
|
|
|
CM_GETIDLIST_FILTER_REMOVALRELATIONS |
|
|
|
|
|
CM_GETIDLIST_FILTER_EJECTRELATIONS))
|
|
|
|
|
{
|
2018-12-31 10:20:30 +00:00
|
|
|
|
ret = GetRelationsInstanceList(pszFilter,
|
|
|
|
|
ulFlags,
|
|
|
|
|
Buffer,
|
|
|
|
|
pulLength);
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
|
|
|
|
|
{
|
2017-02-13 22:59:40 +00:00
|
|
|
|
ret = CR_CALL_NOT_IMPLEMENTED;
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
|
|
|
|
|
{
|
2018-12-29 21:08:35 +00:00
|
|
|
|
SplitDeviceInstanceID(pszFilter,
|
|
|
|
|
szEnumerator,
|
|
|
|
|
szDevice,
|
|
|
|
|
szInstance);
|
|
|
|
|
|
|
|
|
|
if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
|
|
|
|
|
{
|
|
|
|
|
ret = GetDeviceInstanceList(pszFilter,
|
|
|
|
|
Buffer,
|
|
|
|
|
pulLength);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-12-30 11:55:31 +00:00
|
|
|
|
ret = GetEnumeratorInstanceList(pszFilter,
|
|
|
|
|
Buffer,
|
|
|
|
|
pulLength);
|
2018-12-29 21:08:35 +00:00
|
|
|
|
}
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
else /* CM_GETIDLIST_FILTER_NONE */
|
|
|
|
|
{
|
2018-12-30 16:14:43 +00:00
|
|
|
|
ret = GetAllInstanceList(Buffer,
|
|
|
|
|
pulLength);
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
2005-09-24 09:30:43 +00:00
|
|
|
|
|
|
|
|
|
|
2018-12-31 10:20:30 +00:00
|
|
|
|
static
|
|
|
|
|
CONFIGRET
|
|
|
|
|
GetRelationsInstanceListSize(
|
|
|
|
|
_In_ PWSTR pszDevice,
|
|
|
|
|
_In_ DWORD ulFlags,
|
|
|
|
|
_Inout_ PDWORD pulLength)
|
|
|
|
|
{
|
|
|
|
|
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
|
|
|
|
pszDevice);
|
|
|
|
|
|
|
|
|
|
if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
|
|
|
|
|
{
|
|
|
|
|
PlugPlayData.Relations = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlugPlayData.BufferSize = 0;
|
|
|
|
|
PlugPlayData.Buffer = NULL;
|
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
*pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret = NtStatusToCrError(Status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-29 21:08:35 +00:00
|
|
|
|
static
|
|
|
|
|
CONFIGRET
|
|
|
|
|
GetDeviceInstanceListSize(
|
|
|
|
|
_In_ LPCWSTR pszDevice,
|
|
|
|
|
_Out_ PULONG pulLength)
|
|
|
|
|
{
|
|
|
|
|
HKEY hDeviceKey;
|
|
|
|
|
DWORD dwSubKeys, dwMaxSubKeyLength;
|
|
|
|
|
DWORD dwError;
|
|
|
|
|
|
|
|
|
|
/* Open the device key */
|
|
|
|
|
dwError = RegOpenKeyExW(hEnumKey,
|
|
|
|
|
pszDevice,
|
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hDeviceKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to open the device key (Error %lu)\n", dwError);
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Retrieve the number of device instances and the maximum name length */
|
|
|
|
|
dwError = RegQueryInfoKeyW(hDeviceKey,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
&dwSubKeys,
|
|
|
|
|
&dwMaxSubKeyLength,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
|
|
|
|
|
dwSubKeys = 0;
|
|
|
|
|
dwMaxSubKeyLength = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Close the device key */
|
|
|
|
|
RegCloseKey(hDeviceKey);
|
|
|
|
|
|
|
|
|
|
/* Return the largest possible buffer size */
|
2018-12-29 23:39:08 +00:00
|
|
|
|
*pulLength = dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1);
|
2018-12-29 21:08:35 +00:00
|
|
|
|
|
|
|
|
|
return CR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-29 23:39:08 +00:00
|
|
|
|
static
|
|
|
|
|
CONFIGRET
|
|
|
|
|
GetEnumeratorInstanceListSize(
|
|
|
|
|
_In_ LPCWSTR pszEnumerator,
|
|
|
|
|
_Out_ PULONG pulLength)
|
|
|
|
|
{
|
|
|
|
|
WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szPathBuffer[512];
|
|
|
|
|
HKEY hEnumeratorKey;
|
|
|
|
|
DWORD dwIndex, dwDeviceLength, dwBufferLength;
|
|
|
|
|
DWORD dwError;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
|
|
|
|
|
/* Open the enumerator key */
|
|
|
|
|
dwError = RegOpenKeyExW(hEnumKey,
|
|
|
|
|
pszEnumerator,
|
|
|
|
|
0,
|
|
|
|
|
KEY_ENUMERATE_SUB_KEYS,
|
|
|
|
|
&hEnumeratorKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (dwIndex = 0; ; dwIndex++)
|
|
|
|
|
{
|
|
|
|
|
dwDeviceLength = MAX_DEVICE_ID_LEN;
|
|
|
|
|
dwError = RegEnumKeyExW(hEnumeratorKey,
|
|
|
|
|
dwIndex,
|
|
|
|
|
szDeviceBuffer,
|
|
|
|
|
&dwDeviceLength,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
|
|
|
|
|
DPRINT("Path: %S\n", szPathBuffer);
|
|
|
|
|
|
|
|
|
|
ret = GetDeviceInstanceListSize(szPathBuffer, &dwBufferLength);
|
|
|
|
|
if (ret != CR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*pulLength += dwBufferLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Close the enumerator key */
|
|
|
|
|
RegCloseKey(hEnumeratorKey);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-30 13:42:12 +00:00
|
|
|
|
static
|
|
|
|
|
CONFIGRET
|
|
|
|
|
GetAllInstanceListSize(
|
|
|
|
|
_Out_ PULONG pulLength)
|
|
|
|
|
{
|
|
|
|
|
WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
|
|
|
|
|
DWORD dwIndex, dwEnumeratorLength, dwBufferLength;
|
|
|
|
|
DWORD dwError;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
for (dwIndex = 0; ; dwIndex++)
|
|
|
|
|
{
|
|
|
|
|
dwEnumeratorLength = MAX_DEVICE_ID_LEN;
|
|
|
|
|
dwError = RegEnumKeyExW(hEnumKey,
|
|
|
|
|
dwIndex,
|
|
|
|
|
szEnumeratorBuffer,
|
|
|
|
|
&dwEnumeratorLength,
|
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Get the size of all device instances for the enumerator */
|
|
|
|
|
ret = GetEnumeratorInstanceListSize(szEnumeratorBuffer,
|
|
|
|
|
&dwBufferLength);
|
|
|
|
|
if (ret != CR_SUCCESS)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
*pulLength += dwBufferLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 11 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetDeviceListSize(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszFilter,
|
2015-06-08 23:29:59 +00:00
|
|
|
|
PNP_RPC_BUFFER_SIZE *pulLength,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2018-12-29 21:08:35 +00:00
|
|
|
|
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szDevice[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szInstance[MAX_DEVICE_ID_LEN];
|
2017-02-13 22:59:40 +00:00
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
2015-06-08 23:29:59 +00:00
|
|
|
|
|
2018-12-30 13:42:12 +00:00
|
|
|
|
DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%lx)\n",
|
|
|
|
|
hBinding, pszFilter, pulLength, ulFlags);
|
2015-06-08 23:29:59 +00:00
|
|
|
|
|
|
|
|
|
if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
|
|
|
|
|
return CR_INVALID_FLAG;
|
|
|
|
|
|
2018-12-29 21:08:35 +00:00
|
|
|
|
if (pulLength == NULL)
|
|
|
|
|
return CR_INVALID_POINTER;
|
|
|
|
|
|
|
|
|
|
if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
|
|
|
|
|
(pszFilter == NULL))
|
2015-06-08 23:29:59 +00:00
|
|
|
|
return CR_INVALID_POINTER;
|
|
|
|
|
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
|
|
|
|
|
if (ulFlags &
|
|
|
|
|
(CM_GETIDLIST_FILTER_BUSRELATIONS |
|
|
|
|
|
CM_GETIDLIST_FILTER_POWERRELATIONS |
|
|
|
|
|
CM_GETIDLIST_FILTER_REMOVALRELATIONS |
|
|
|
|
|
CM_GETIDLIST_FILTER_EJECTRELATIONS))
|
|
|
|
|
{
|
2018-12-31 10:20:30 +00:00
|
|
|
|
ret = GetRelationsInstanceListSize(pszFilter,
|
|
|
|
|
ulFlags,
|
|
|
|
|
pulLength);
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
|
|
|
|
|
{
|
2017-02-13 22:59:40 +00:00
|
|
|
|
ret = CR_CALL_NOT_IMPLEMENTED;
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
|
|
|
|
|
{
|
2018-12-29 21:08:35 +00:00
|
|
|
|
SplitDeviceInstanceID(pszFilter,
|
|
|
|
|
szEnumerator,
|
|
|
|
|
szDevice,
|
|
|
|
|
szInstance);
|
|
|
|
|
|
|
|
|
|
if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
|
|
|
|
|
{
|
|
|
|
|
ret = GetDeviceInstanceListSize(pszFilter,
|
|
|
|
|
pulLength);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-12-29 23:39:08 +00:00
|
|
|
|
ret = GetEnumeratorInstanceListSize(pszFilter,
|
|
|
|
|
pulLength);
|
2018-12-29 21:08:35 +00:00
|
|
|
|
}
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
else /* CM_GETIDLIST_FILTER_NONE */
|
|
|
|
|
{
|
2018-12-30 16:14:43 +00:00
|
|
|
|
ret = GetAllInstanceListSize(pulLength);
|
2015-06-08 23:29:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-29 23:39:08 +00:00
|
|
|
|
/* Add one character for the terminating double UNICODE_NULL */
|
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
(*pulLength) += 1;
|
|
|
|
|
|
2015-06-08 23:29:59 +00:00
|
|
|
|
return ret;
|
2005-09-24 09:30:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 12 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetDepth(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
DWORD *pulDepth,
|
|
|
|
|
DWORD ulFlags)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-08-01 19:42:19 +00:00
|
|
|
|
DPRINT("PNP_GetDepth() called\n");
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pszDeviceID);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlGetDeviceDepth,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_DEPTH_DATA));
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pulDepth = PlugPlayData.Depth;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-10-03 07:06:42 +00:00
|
|
|
|
ret = NtStatusToCrError(Status);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-01 19:42:19 +00:00
|
|
|
|
DPRINT("PNP_GetDepth() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 13 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetDeviceRegProp(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulProperty,
|
|
|
|
|
DWORD *pulRegDataType,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_PROP_SIZE *pulTransferLen,
|
|
|
|
|
PNP_PROP_SIZE *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
2005-08-01 19:42:19 +00:00
|
|
|
|
{
|
2005-08-07 09:03:35 +00:00
|
|
|
|
PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData;
|
2005-08-01 19:42:19 +00:00
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
LPWSTR lpValueName = NULL;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
|
LONG lError;
|
2005-08-07 09:03:35 +00:00
|
|
|
|
NTSTATUS Status;
|
2005-08-01 19:42:19 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-08-07 09:03:35 +00:00
|
|
|
|
DPRINT("PNP_GetDeviceRegProp() called\n");
|
2005-08-01 19:42:19 +00:00
|
|
|
|
|
2011-05-28 17:35:51 +00:00
|
|
|
|
if (pulTransferLen == NULL || pulLength == NULL)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_POINTER;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ulFlags != 0)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_FLAG;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: Check pDeviceID */
|
|
|
|
|
|
|
|
|
|
if (*pulLength < *pulTransferLen)
|
|
|
|
|
*pulLength = *pulTransferLen;
|
|
|
|
|
|
|
|
|
|
*pulTransferLen = 0;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
switch (ulProperty)
|
2005-08-03 20:10:32 +00:00
|
|
|
|
{
|
|
|
|
|
case CM_DRP_DEVICEDESC:
|
|
|
|
|
lpValueName = L"DeviceDesc";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_HARDWAREID:
|
|
|
|
|
lpValueName = L"HardwareID";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_COMPATIBLEIDS:
|
|
|
|
|
lpValueName = L"CompatibleIDs";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_SERVICE:
|
|
|
|
|
lpValueName = L"Service";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CLASS:
|
|
|
|
|
lpValueName = L"Class";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CLASSGUID:
|
|
|
|
|
lpValueName = L"ClassGUID";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_DRIVER:
|
|
|
|
|
lpValueName = L"Driver";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CONFIGFLAGS:
|
|
|
|
|
lpValueName = L"ConfigFlags";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_MFG:
|
|
|
|
|
lpValueName = L"Mfg";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_FRIENDLYNAME:
|
|
|
|
|
lpValueName = L"FriendlyName";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_LOCATION_INFORMATION:
|
|
|
|
|
lpValueName = L"LocationInformation";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CAPABILITIES:
|
|
|
|
|
lpValueName = L"Capabilities";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_UI_NUMBER:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_UI_NUMBER;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_UPPERFILTERS:
|
|
|
|
|
lpValueName = L"UpperFilters";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_LOWERFILTERS:
|
|
|
|
|
lpValueName = L"LowerFilters";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_BUSTYPEGUID:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_BUSTYPEGUID;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_LEGACYBUSTYPE:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_LEGACYBUSTYPE;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_BUSNUMBER:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_BUSNUMBER;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_ENUMERATOR_NAME:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_ENUMERATOR_NAME;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2011-05-28 17:35:51 +00:00
|
|
|
|
case CM_DRP_SECURITY:
|
|
|
|
|
lpValueName = L"Security";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_DEVTYPE:
|
|
|
|
|
lpValueName = L"DeviceType";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_EXCLUSIVE:
|
|
|
|
|
lpValueName = L"Exclusive";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CHARACTERISTICS:
|
|
|
|
|
lpValueName = L"DeviceCharacteristics";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_ADDRESS:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_ADDRESS;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_UI_NUMBER_DESC_FORMAT:
|
|
|
|
|
lpValueName = L"UINumberDescFormat";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_DEVICE_POWER_DATA:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_POWER_DATA;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_REMOVAL_POLICY:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_REMOVAL_POLICY;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_REMOVAL_POLICY_HW_DEFAULT:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_REMOVAL_POLICY_OVERRIDE:
|
2011-05-28 19:08:20 +00:00
|
|
|
|
lpValueName = L"RemovalPolicy";
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_INSTALL_STATE:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_INSTALL_STATE;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#if (WINVER >= _WIN32_WINNT_WS03)
|
|
|
|
|
case CM_DRP_LOCATION_PATHS:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_LOCATION_PATHS;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if (WINVER >= _WIN32_WINNT_WIN7)
|
|
|
|
|
case CM_DRP_BASE_CONTAINERID:
|
2018-08-19 22:55:03 +00:00
|
|
|
|
PlugPlayData.Property = PNP_PROPERTY_CONTAINERID;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-08-03 20:10:32 +00:00
|
|
|
|
default:
|
2011-05-28 17:35:51 +00:00
|
|
|
|
ret = CR_INVALID_PROPERTY;
|
|
|
|
|
goto done;
|
2005-08-03 20:10:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-07 09:03:35 +00:00
|
|
|
|
DPRINT("Value name: %S\n", lpValueName);
|
2005-08-03 20:10:32 +00:00
|
|
|
|
|
|
|
|
|
if (lpValueName)
|
|
|
|
|
{
|
|
|
|
|
/* Retrieve information from the Registry */
|
2011-05-28 17:35:51 +00:00
|
|
|
|
lError = RegOpenKeyExW(hEnumKey,
|
|
|
|
|
pDeviceID,
|
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&hKey);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
hKey = NULL;
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
ret = CR_INVALID_DEVNODE;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2005-08-03 20:10:32 +00:00
|
|
|
|
|
2011-05-28 17:35:51 +00:00
|
|
|
|
lError = RegQueryValueExW(hKey,
|
|
|
|
|
lpValueName,
|
|
|
|
|
NULL,
|
|
|
|
|
pulRegDataType,
|
|
|
|
|
Buffer,
|
|
|
|
|
pulLength);
|
2011-05-29 15:58:49 +00:00
|
|
|
|
if (lError != ERROR_SUCCESS)
|
2011-05-28 17:35:51 +00:00
|
|
|
|
{
|
2011-05-29 15:58:49 +00:00
|
|
|
|
if (lError == ERROR_MORE_DATA)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_BUFFER_SMALL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
ret = CR_NO_SUCH_VALUE;
|
|
|
|
|
}
|
2011-05-28 17:35:51 +00:00
|
|
|
|
}
|
2005-08-03 20:10:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Retrieve information from the Device Node */
|
2005-08-07 09:03:35 +00:00
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pDeviceID);
|
2005-08-07 09:03:35 +00:00
|
|
|
|
PlugPlayData.Buffer = Buffer;
|
2011-08-13 20:26:44 +00:00
|
|
|
|
PlugPlayData.BufferSize = *pulLength;
|
2005-08-07 09:03:35 +00:00
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlProperty,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA));
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pulLength = PlugPlayData.BufferSize;
|
2005-08-07 09:03:35 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-10-03 07:06:42 +00:00
|
|
|
|
ret = NtStatusToCrError(Status);
|
2005-08-07 09:03:35 +00:00
|
|
|
|
}
|
2005-08-03 20:10:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-13 20:26:44 +00:00
|
|
|
|
done:
|
2017-02-13 22:59:40 +00:00
|
|
|
|
if (pulTransferLen)
|
2017-02-11 10:34:35 +00:00
|
|
|
|
*pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
|
2011-05-28 17:35:51 +00:00
|
|
|
|
|
|
|
|
|
if (hKey != NULL)
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
2005-08-07 09:03:35 +00:00
|
|
|
|
DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 14 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_SetDeviceRegProp(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceId,
|
|
|
|
|
DWORD ulProperty,
|
|
|
|
|
DWORD ulDataType,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_PROP_SIZE ulLength,
|
|
|
|
|
DWORD ulFlags)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
LPWSTR lpValueName = NULL;
|
|
|
|
|
HKEY hKey = 0;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
DPRINT("PNP_SetDeviceRegProp() called\n");
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
DPRINT("DeviceId: %S\n", pDeviceId);
|
|
|
|
|
DPRINT("Property: %lu\n", ulProperty);
|
|
|
|
|
DPRINT("DataType: %lu\n", ulDataType);
|
|
|
|
|
DPRINT("Length: %lu\n", ulLength);
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
switch (ulProperty)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
|
|
|
|
case CM_DRP_DEVICEDESC:
|
|
|
|
|
lpValueName = L"DeviceDesc";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_HARDWAREID:
|
|
|
|
|
lpValueName = L"HardwareID";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_COMPATIBLEIDS:
|
|
|
|
|
lpValueName = L"CompatibleIDs";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_SERVICE:
|
|
|
|
|
lpValueName = L"Service";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CLASS:
|
|
|
|
|
lpValueName = L"Class";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CLASSGUID:
|
|
|
|
|
lpValueName = L"ClassGUID";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_DRIVER:
|
|
|
|
|
lpValueName = L"Driver";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CONFIGFLAGS:
|
|
|
|
|
lpValueName = L"ConfigFlags";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_MFG:
|
|
|
|
|
lpValueName = L"Mfg";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_FRIENDLYNAME:
|
|
|
|
|
lpValueName = L"FriendlyName";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_LOCATION_INFORMATION:
|
|
|
|
|
lpValueName = L"LocationInformation";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_UPPERFILTERS:
|
|
|
|
|
lpValueName = L"UpperFilters";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_LOWERFILTERS:
|
|
|
|
|
lpValueName = L"LowerFilters";
|
|
|
|
|
break;
|
|
|
|
|
|
2011-05-28 19:08:20 +00:00
|
|
|
|
case CM_DRP_SECURITY:
|
|
|
|
|
lpValueName = L"Security";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_DEVTYPE:
|
|
|
|
|
lpValueName = L"DeviceType";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_EXCLUSIVE:
|
|
|
|
|
lpValueName = L"Exclusive";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_CHARACTERISTICS:
|
|
|
|
|
lpValueName = L"DeviceCharacteristics";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_UI_NUMBER_DESC_FORMAT:
|
|
|
|
|
lpValueName = L"UINumberDescFormat";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_DRP_REMOVAL_POLICY_OVERRIDE:
|
|
|
|
|
lpValueName = L"RemovalPolicy";
|
|
|
|
|
break;
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
default:
|
|
|
|
|
return CR_INVALID_PROPERTY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT("Value name: %S\n", lpValueName);
|
|
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(hEnumKey,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pDeviceId,
|
2005-12-17 12:23:41 +00:00
|
|
|
|
0,
|
2011-05-28 19:08:20 +00:00
|
|
|
|
KEY_SET_VALUE,
|
2005-12-17 12:23:41 +00:00
|
|
|
|
&hKey))
|
|
|
|
|
return CR_INVALID_DEVNODE;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
if (ulLength == 0)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
|
|
|
|
if (RegDeleteValueW(hKey,
|
|
|
|
|
lpValueName))
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (RegSetValueExW(hKey,
|
|
|
|
|
lpValueName,
|
|
|
|
|
0,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
ulDataType,
|
|
|
|
|
Buffer,
|
|
|
|
|
ulLength))
|
2005-12-17 12:23:41 +00:00
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 19:58:23 +00:00
|
|
|
|
/* Function 15 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetClassInstance(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceId,
|
|
|
|
|
LPWSTR pszClassInstance,
|
|
|
|
|
PNP_RPC_STRING_LEN ulLength)
|
2005-12-17 19:58:23 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2005-12-17 19:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 16 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_CreateKey(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszSubKey,
|
|
|
|
|
DWORD samDesired,
|
|
|
|
|
DWORD ulFlags)
|
2005-09-24 09:30:43 +00:00
|
|
|
|
{
|
2010-01-31 19:44:02 +00:00
|
|
|
|
HKEY hKey = 0;
|
|
|
|
|
|
|
|
|
|
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
|
pszSubKey,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
0,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKey,
|
|
|
|
|
NULL))
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
|
|
|
|
|
/* FIXME: Set security key */
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
|
|
return CR_SUCCESS;
|
2005-09-24 09:30:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 17 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DeleteRegistryKey(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
LPWSTR pszParentKey,
|
|
|
|
|
LPWSTR pszChildKey,
|
|
|
|
|
DWORD ulFlags)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2005-12-17 12:23:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 18 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetClassCount(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD *pulClassCount,
|
|
|
|
|
DWORD ulFlags)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
HKEY hKey;
|
2005-12-17 12:23:41 +00:00
|
|
|
|
DWORD dwError;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
REGSTR_PATH_CLASS,
|
2005-12-17 12:23:41 +00:00
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&hKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
return CR_INVALID_DATA;
|
|
|
|
|
|
|
|
|
|
dwError = RegQueryInfoKeyW(hKey,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pulClassCount,
|
2005-12-17 12:23:41 +00:00
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
return CR_INVALID_DATA;
|
|
|
|
|
|
|
|
|
|
return CR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 19 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetClassName(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszClassGuid,
|
|
|
|
|
LPWSTR Buffer,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
2005-08-28 15:07:45 +00:00
|
|
|
|
{
|
|
|
|
|
WCHAR szKeyName[MAX_PATH];
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
HKEY hKey;
|
2007-07-28 18:06:51 +00:00
|
|
|
|
DWORD dwSize;
|
2005-08-28 15:07:45 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-09-10 13:02:02 +00:00
|
|
|
|
DPRINT("PNP_GetClassName() called\n");
|
2005-08-28 15:07:45 +00:00
|
|
|
|
|
2008-04-21 12:08:42 +00:00
|
|
|
|
lstrcpyW(szKeyName, L"System\\CurrentControlSet\\Control\\Class\\");
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (lstrlenW(pszClassGuid) + 1 < sizeof(szKeyName)/sizeof(WCHAR)-(lstrlenW(szKeyName) * sizeof(WCHAR)))
|
2008-04-14 10:48:38 +00:00
|
|
|
|
lstrcatW(szKeyName, pszClassGuid);
|
2015-03-04 21:37:35 +00:00
|
|
|
|
else
|
|
|
|
|
return CR_INVALID_DATA;
|
2005-08-28 15:07:45 +00:00
|
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
|
szKeyName,
|
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&hKey))
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
dwSize = *pulLength * sizeof(WCHAR);
|
2005-08-28 15:07:45 +00:00
|
|
|
|
if (RegQueryValueExW(hKey,
|
|
|
|
|
L"Class",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
(LPBYTE)Buffer,
|
2007-07-28 18:06:51 +00:00
|
|
|
|
&dwSize))
|
2005-08-28 15:07:45 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pulLength = 0;
|
2005-08-28 15:07:45 +00:00
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pulLength = dwSize / sizeof(WCHAR);
|
2005-08-28 15:07:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
2005-09-10 13:02:02 +00:00
|
|
|
|
DPRINT("PNP_GetClassName() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 20 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DeleteClassKey(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszClassGuid,
|
|
|
|
|
DWORD ulFlags)
|
2005-09-10 13:02:02 +00:00
|
|
|
|
{
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
DPRINT("PNP_GetClassName(%S, %lx) called\n", pszClassGuid, ulFlags);
|
2005-09-10 13:02:02 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
if (ulFlags & CM_DELETE_CLASS_SUBKEYS)
|
2005-09-10 13:02:02 +00:00
|
|
|
|
{
|
2014-06-08 18:10:04 +00:00
|
|
|
|
if (SHDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
|
2005-09-10 13:02:02 +00:00
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
if (RegDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
|
2005-09-10 13:02:02 +00:00
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret);
|
2005-08-28 15:07:45 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 21 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetInterfaceDeviceAlias(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszInterfaceDevice,
|
|
|
|
|
GUID *AliasInterfaceGuid,
|
|
|
|
|
LPWSTR pszAliasInterfaceDevice,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulLength,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulTransferLen,
|
|
|
|
|
DWORD ulFlags)
|
2006-01-22 14:33:04 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-01-22 14:33:04 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 22 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetInterfaceDeviceList(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
GUID *InterfaceGuid,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2014-11-08 13:28:01 +00:00
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData;
|
|
|
|
|
DWORD ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
|
|
|
|
pszDeviceID);
|
|
|
|
|
|
2014-11-08 20:54:40 +00:00
|
|
|
|
PlugPlayData.Flags = ulFlags;
|
2014-11-08 13:28:01 +00:00
|
|
|
|
PlugPlayData.FilterGuid = InterfaceGuid;
|
|
|
|
|
PlugPlayData.Buffer = Buffer;
|
|
|
|
|
PlugPlayData.BufferSize = *pulLength;
|
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA));
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
*pulLength = PlugPlayData.BufferSize;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret = NtStatusToCrError(Status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret);
|
|
|
|
|
return ret;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
2006-01-22 14:33:04 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 23 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetInterfaceDeviceListSize(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE *pulLen,
|
|
|
|
|
GUID *InterfaceGuid,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2014-11-08 13:28:01 +00:00
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData;
|
|
|
|
|
DWORD ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetInterfaceDeviceListSize() called\n");
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
|
|
|
|
pszDeviceID);
|
|
|
|
|
|
|
|
|
|
PlugPlayData.FilterGuid = InterfaceGuid;
|
|
|
|
|
PlugPlayData.Buffer = NULL;
|
|
|
|
|
PlugPlayData.BufferSize = 0;
|
2014-11-08 20:54:40 +00:00
|
|
|
|
PlugPlayData.Flags = ulFlags;
|
2014-11-08 13:28:01 +00:00
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA));
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
|
|
|
|
*pulLen = PlugPlayData.BufferSize;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret = NtStatusToCrError(Status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret);
|
|
|
|
|
return ret;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 24 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_RegisterDeviceClassAssociation(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
GUID *InterfaceGuid,
|
|
|
|
|
LPWSTR pszReference,
|
|
|
|
|
LPWSTR pszSymLink,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulLength,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulTransferLen,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 25 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_UnregisterDeviceClassAssociation(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszInterfaceDevice,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 26 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetClassRegProp(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszClassGuid,
|
|
|
|
|
DWORD ulProperty,
|
|
|
|
|
DWORD *pulRegDataType,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulTransferLen,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2011-05-29 15:58:49 +00:00
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
LPWSTR lpValueName = NULL;
|
|
|
|
|
HKEY hInstKey = NULL;
|
|
|
|
|
HKEY hPropKey = NULL;
|
|
|
|
|
LONG lError;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetClassRegProp() called\n");
|
|
|
|
|
|
|
|
|
|
if (pulTransferLen == NULL || pulLength == NULL)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_POINTER;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ulFlags != 0)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_FLAG;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*pulLength < *pulTransferLen)
|
|
|
|
|
*pulLength = *pulTransferLen;
|
|
|
|
|
|
|
|
|
|
*pulTransferLen = 0;
|
|
|
|
|
|
|
|
|
|
switch (ulProperty)
|
|
|
|
|
{
|
|
|
|
|
case CM_CRP_SECURITY:
|
|
|
|
|
lpValueName = L"Security";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_CRP_DEVTYPE:
|
|
|
|
|
lpValueName = L"DeviceType";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_CRP_EXCLUSIVE:
|
|
|
|
|
lpValueName = L"Exclusive";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CM_CRP_CHARACTERISTICS:
|
|
|
|
|
lpValueName = L"DeviceCharacteristics";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
ret = CR_INVALID_PROPERTY;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT("Value name: %S\n", lpValueName);
|
|
|
|
|
|
|
|
|
|
lError = RegOpenKeyExW(hClassKey,
|
|
|
|
|
pszClassGuid,
|
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hInstKey);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
ret = CR_NO_SUCH_REGISTRY_KEY;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lError = RegOpenKeyExW(hInstKey,
|
|
|
|
|
L"Properties",
|
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hPropKey);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
ret = CR_NO_SUCH_REGISTRY_KEY;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lError = RegQueryValueExW(hPropKey,
|
|
|
|
|
lpValueName,
|
|
|
|
|
NULL,
|
|
|
|
|
pulRegDataType,
|
|
|
|
|
Buffer,
|
|
|
|
|
pulLength);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
if (lError == ERROR_MORE_DATA)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_BUFFER_SMALL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
ret = CR_NO_SUCH_VALUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
done:
|
2011-10-29 21:54:24 +00:00
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
*pulTransferLen = *pulLength;
|
2011-05-29 15:58:49 +00:00
|
|
|
|
|
|
|
|
|
if (hPropKey != NULL)
|
|
|
|
|
RegCloseKey(hPropKey);
|
|
|
|
|
|
|
|
|
|
if (hInstKey != NULL)
|
|
|
|
|
RegCloseKey(hInstKey);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 27 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_SetClassRegProp(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
2011-05-28 22:15:38 +00:00
|
|
|
|
LPWSTR pszClassGuid,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
DWORD ulProperty,
|
|
|
|
|
DWORD ulDataType,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_PROP_SIZE ulLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2011-05-28 22:15:38 +00:00
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
LPWSTR lpValueName = NULL;
|
|
|
|
|
HKEY hInstKey = 0;
|
|
|
|
|
HKEY hPropKey = 0;
|
|
|
|
|
LONG lError;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_SetClassRegProp() called\n");
|
|
|
|
|
|
|
|
|
|
if (ulFlags != 0)
|
|
|
|
|
return CR_INVALID_FLAG;
|
|
|
|
|
|
|
|
|
|
switch (ulProperty)
|
|
|
|
|
{
|
2011-05-29 15:58:49 +00:00
|
|
|
|
case CM_CRP_SECURITY:
|
2011-05-28 22:15:38 +00:00
|
|
|
|
lpValueName = L"Security";
|
|
|
|
|
break;
|
|
|
|
|
|
2011-05-29 15:58:49 +00:00
|
|
|
|
case CM_CRP_DEVTYPE:
|
2011-05-28 22:15:38 +00:00
|
|
|
|
lpValueName = L"DeviceType";
|
|
|
|
|
break;
|
|
|
|
|
|
2011-05-29 15:58:49 +00:00
|
|
|
|
case CM_CRP_EXCLUSIVE:
|
2011-05-28 22:15:38 +00:00
|
|
|
|
lpValueName = L"Exclusive";
|
|
|
|
|
break;
|
|
|
|
|
|
2011-05-29 15:58:49 +00:00
|
|
|
|
case CM_CRP_CHARACTERISTICS:
|
2011-05-28 22:15:38 +00:00
|
|
|
|
lpValueName = L"DeviceCharacteristics";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return CR_INVALID_PROPERTY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lError = RegOpenKeyExW(hClassKey,
|
|
|
|
|
pszClassGuid,
|
|
|
|
|
0,
|
|
|
|
|
KEY_WRITE,
|
|
|
|
|
&hInstKey);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_NO_SUCH_REGISTRY_KEY;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: Set security descriptor */
|
|
|
|
|
lError = RegCreateKeyExW(hInstKey,
|
|
|
|
|
L"Properties",
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
&hPropKey,
|
|
|
|
|
NULL);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ulLength == 0)
|
|
|
|
|
{
|
|
|
|
|
if (RegDeleteValueW(hPropKey,
|
|
|
|
|
lpValueName))
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (RegSetValueExW(hPropKey,
|
|
|
|
|
lpValueName,
|
|
|
|
|
0,
|
|
|
|
|
ulDataType,
|
|
|
|
|
Buffer,
|
|
|
|
|
ulLength))
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
done:
|
2011-05-28 22:15:38 +00:00
|
|
|
|
if (hPropKey != NULL)
|
|
|
|
|
RegCloseKey(hPropKey);
|
|
|
|
|
|
|
|
|
|
if (hInstKey != NULL)
|
|
|
|
|
RegCloseKey(hInstKey);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-05-13 15:56:50 +00:00
|
|
|
|
static CONFIGRET
|
|
|
|
|
CreateDeviceInstance(LPWSTR pszDeviceID)
|
|
|
|
|
{
|
|
|
|
|
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szDevice[MAX_DEVICE_ID_LEN];
|
|
|
|
|
WCHAR szInstance[MAX_DEVICE_ID_LEN];
|
|
|
|
|
HKEY hKeyEnumerator;
|
|
|
|
|
HKEY hKeyDevice;
|
|
|
|
|
HKEY hKeyInstance;
|
|
|
|
|
HKEY hKeyControl;
|
|
|
|
|
LONG lError;
|
|
|
|
|
|
|
|
|
|
/* Split the instance ID */
|
|
|
|
|
SplitDeviceInstanceID(pszDeviceID,
|
|
|
|
|
szEnumerator,
|
|
|
|
|
szDevice,
|
|
|
|
|
szInstance);
|
|
|
|
|
|
|
|
|
|
/* Open or create the enumerator key */
|
|
|
|
|
lError = RegCreateKeyExW(hEnumKey,
|
|
|
|
|
szEnumerator,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKeyEnumerator,
|
|
|
|
|
NULL);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Open or create the device key */
|
|
|
|
|
lError = RegCreateKeyExW(hKeyEnumerator,
|
|
|
|
|
szDevice,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKeyDevice,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
/* Close the enumerator key */
|
|
|
|
|
RegCloseKey(hKeyEnumerator);
|
|
|
|
|
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Try to open the instance key and fail if it exists */
|
|
|
|
|
lError = RegOpenKeyExW(hKeyDevice,
|
|
|
|
|
szInstance,
|
|
|
|
|
0,
|
|
|
|
|
KEY_SET_VALUE,
|
|
|
|
|
&hKeyInstance);
|
|
|
|
|
if (lError == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("Instance %S already exists!\n", szInstance);
|
|
|
|
|
RegCloseKey(hKeyInstance);
|
|
|
|
|
RegCloseKey(hKeyDevice);
|
|
|
|
|
return CR_ALREADY_SUCH_DEVINST;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a new instance key */
|
|
|
|
|
lError = RegCreateKeyExW(hKeyDevice,
|
|
|
|
|
szInstance,
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKeyInstance,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
/* Close the device key */
|
|
|
|
|
RegCloseKey(hKeyDevice);
|
|
|
|
|
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create the 'Control' sub key */
|
|
|
|
|
lError = RegCreateKeyExW(hKeyInstance,
|
|
|
|
|
L"Control",
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKeyControl,
|
|
|
|
|
NULL);
|
|
|
|
|
if (lError == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
RegCloseKey(hKeyControl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKeyInstance);
|
|
|
|
|
|
|
|
|
|
return (lError == ERROR_SUCCESS) ? CR_SUCCESS : CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 28 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_CreateDevInst(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
LPWSTR pszParentDeviceID,
|
|
|
|
|
PNP_RPC_STRING_LEN ulLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2011-05-13 15:56:50 +00:00
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_CreateDevInst: %S\n", pszDeviceID);
|
|
|
|
|
|
|
|
|
|
if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
|
|
|
|
|
{
|
2013-08-11 19:57:47 +00:00
|
|
|
|
WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
|
|
|
|
|
DWORD dwInstanceNumber;
|
2011-05-13 15:56:50 +00:00
|
|
|
|
|
2013-08-11 19:57:47 +00:00
|
|
|
|
/* Generated ID is: Root\<Device ID>\<Instance number> */
|
|
|
|
|
dwInstanceNumber = 0;
|
|
|
|
|
do
|
|
|
|
|
{
|
2014-04-30 19:05:42 +00:00
|
|
|
|
swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
|
2013-08-11 19:57:47 +00:00
|
|
|
|
pszDeviceID, dwInstanceNumber);
|
|
|
|
|
|
|
|
|
|
/* Try to create a device instance with this ID */
|
|
|
|
|
ret = CreateDeviceInstance(szGeneratedInstance);
|
|
|
|
|
|
|
|
|
|
dwInstanceNumber++;
|
|
|
|
|
}
|
|
|
|
|
while (ret == CR_ALREADY_SUCH_DEVINST);
|
2014-11-02 11:30:14 +00:00
|
|
|
|
|
2013-08-11 19:57:47 +00:00
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
/* pszDeviceID is an out parameter too for generated IDs */
|
|
|
|
|
if (wcslen(szGeneratedInstance) > ulLength)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_BUFFER_SMALL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wcscpy(pszDeviceID, szGeneratedInstance);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Create the device instance */
|
|
|
|
|
ret = CreateDeviceInstance(pszDeviceID);
|
|
|
|
|
}
|
2011-05-13 15:56:50 +00:00
|
|
|
|
|
|
|
|
|
DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2006-01-22 14:33:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-01-05 20:26:31 +00:00
|
|
|
|
static CONFIGRET
|
|
|
|
|
MoveDeviceInstance(LPWSTR pszDeviceInstanceDestination,
|
|
|
|
|
LPWSTR pszDeviceInstanceSource)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("MoveDeviceInstance: not implemented\n");
|
|
|
|
|
/* FIXME */
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static CONFIGRET
|
|
|
|
|
SetupDeviceInstance(LPWSTR pszDeviceInstance,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("SetupDeviceInstance: not implemented\n");
|
|
|
|
|
/* FIXME */
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static CONFIGRET
|
|
|
|
|
EnableDeviceInstance(LPWSTR pszDeviceInstance)
|
|
|
|
|
{
|
|
|
|
|
PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
2015-11-14 13:28:03 +00:00
|
|
|
|
DPRINT("Enable device instance %S\n", pszDeviceInstance);
|
2010-01-05 20:26:31 +00:00
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&ResetDeviceData.DeviceInstance, pszDeviceInstance);
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlResetDevice, &ResetDeviceData, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA));
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
ret = NtStatusToCrError(Status);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static CONFIGRET
|
|
|
|
|
DisableDeviceInstance(LPWSTR pszDeviceInstance)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("DisableDeviceInstance: not implemented\n");
|
|
|
|
|
/* FIXME */
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static CONFIGRET
|
2018-08-12 20:19:05 +00:00
|
|
|
|
ReenumerateDeviceInstance(
|
|
|
|
|
_In_ LPWSTR pszDeviceInstance,
|
|
|
|
|
_In_ ULONG ulFlags)
|
2010-01-05 20:26:31 +00:00
|
|
|
|
{
|
2018-08-12 20:19:05 +00:00
|
|
|
|
PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA EnumerateDeviceData;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
|
|
DPRINT1("ReenumerateDeviceInstance(%S 0x%08lx)\n",
|
|
|
|
|
pszDeviceInstance, ulFlags);
|
|
|
|
|
|
|
|
|
|
if (ulFlags & ~CM_REENUMERATE_BITS)
|
|
|
|
|
return CR_INVALID_FLAG;
|
|
|
|
|
|
|
|
|
|
if (ulFlags & CM_REENUMERATE_RETRY_INSTALLATION)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("CM_REENUMERATE_RETRY_INSTALLATION not implemented!\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&EnumerateDeviceData.DeviceInstance,
|
|
|
|
|
pszDeviceInstance);
|
|
|
|
|
EnumerateDeviceData.Flags = 0;
|
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlEnumerateDevice,
|
|
|
|
|
&EnumerateDeviceData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA));
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
ret = NtStatusToCrError(Status);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2010-01-05 20:26:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
/* Function 29 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DeviceInstanceAction(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
2010-01-05 20:26:31 +00:00
|
|
|
|
DWORD ulAction,
|
|
|
|
|
DWORD ulFlags,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
LPWSTR pszDeviceInstance1,
|
|
|
|
|
LPWSTR pszDeviceInstance2)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
DPRINT("PNP_DeviceInstanceAction() called\n");
|
|
|
|
|
|
2010-01-05 20:26:31 +00:00
|
|
|
|
switch (ulAction)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
2010-01-05 20:26:31 +00:00
|
|
|
|
case PNP_DEVINST_MOVE:
|
|
|
|
|
ret = MoveDeviceInstance(pszDeviceInstance1,
|
|
|
|
|
pszDeviceInstance2);
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
case PNP_DEVINST_SETUP:
|
2010-01-05 20:26:31 +00:00
|
|
|
|
ret = SetupDeviceInstance(pszDeviceInstance1,
|
|
|
|
|
ulFlags);
|
2005-12-17 19:58:23 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
case PNP_DEVINST_ENABLE:
|
2010-01-05 20:26:31 +00:00
|
|
|
|
ret = EnableDeviceInstance(pszDeviceInstance1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PNP_DEVINST_DISABLE:
|
|
|
|
|
ret = DisableDeviceInstance(pszDeviceInstance1);
|
2005-12-17 12:23:41 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
case PNP_DEVINST_REENUMERATE:
|
2018-08-12 20:19:05 +00:00
|
|
|
|
ret = ReenumerateDeviceInstance(pszDeviceInstance1,
|
|
|
|
|
ulFlags);
|
2005-12-17 12:23:41 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2010-01-05 20:26:31 +00:00
|
|
|
|
DPRINT1("Unknown device action %lu: not implemented\n", ulAction);
|
2005-12-17 12:23:41 +00:00
|
|
|
|
ret = CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 30 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetDeviceStatus(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD *pulStatus,
|
|
|
|
|
DWORD *pulProblem,
|
|
|
|
|
DWORD ulFlags)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
UNREFERENCED_PARAMETER(ulFlags);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-08-01 19:42:19 +00:00
|
|
|
|
DPRINT("PNP_GetDeviceStatus() called\n");
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pDeviceID);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
PlugPlayData.Operation = 0; /* Get status */
|
|
|
|
|
|
|
|
|
|
Status = NtPlugPlayControl(PlugPlayControlDeviceStatus,
|
|
|
|
|
(PVOID)&PlugPlayData,
|
|
|
|
|
sizeof(PLUGPLAY_CONTROL_STATUS_DATA));
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
*pulStatus = PlugPlayData.DeviceStatus;
|
|
|
|
|
*pulProblem = PlugPlayData.DeviceProblem;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-10-03 07:06:42 +00:00
|
|
|
|
ret = NtStatusToCrError(Status);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-01 19:42:19 +00:00
|
|
|
|
DPRINT("PNP_GetDeviceStatus() done (returns %lx)\n", ret);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-17 19:58:23 +00:00
|
|
|
|
/* Function 31 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_SetDeviceProblem(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulProblem,
|
|
|
|
|
DWORD ulFlags)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 32 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DisableDevInst(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
PPNP_VETO_TYPE pVetoType,
|
|
|
|
|
LPWSTR pszVetoName,
|
|
|
|
|
DWORD ulNameLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-17 19:58:23 +00:00
|
|
|
|
/* Function 33 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_UninstallDevInst(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulFlags)
|
2005-12-17 19:58:23 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2005-12-17 19:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-11 13:20:46 +00:00
|
|
|
|
static BOOL
|
|
|
|
|
CheckForDeviceId(LPWSTR lpDeviceIdList,
|
|
|
|
|
LPWSTR lpDeviceId)
|
|
|
|
|
{
|
|
|
|
|
LPWSTR lpPtr;
|
|
|
|
|
DWORD dwLength;
|
|
|
|
|
|
|
|
|
|
lpPtr = lpDeviceIdList;
|
|
|
|
|
while (*lpPtr != 0)
|
|
|
|
|
{
|
|
|
|
|
dwLength = wcslen(lpPtr);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
if (0 == _wcsicmp(lpPtr, lpDeviceId))
|
2006-06-11 13:20:46 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
lpPtr += (dwLength + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
|
AppendDeviceId(LPWSTR lpDeviceIdList,
|
|
|
|
|
LPDWORD lpDeviceIdListSize,
|
|
|
|
|
LPWSTR lpDeviceId)
|
|
|
|
|
{
|
|
|
|
|
DWORD dwLen;
|
|
|
|
|
DWORD dwPos;
|
|
|
|
|
|
|
|
|
|
dwLen = wcslen(lpDeviceId);
|
|
|
|
|
dwPos = (*lpDeviceIdListSize / sizeof(WCHAR)) - 1;
|
|
|
|
|
|
|
|
|
|
wcscpy(&lpDeviceIdList[dwPos], lpDeviceId);
|
|
|
|
|
|
|
|
|
|
dwPos += (dwLen + 1);
|
|
|
|
|
|
|
|
|
|
lpDeviceIdList[dwPos] = 0;
|
|
|
|
|
|
|
|
|
|
*lpDeviceIdListSize = dwPos * sizeof(WCHAR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-04 19:12:58 +00:00
|
|
|
|
/* Function 34 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_AddID(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
LPWSTR pszID,
|
|
|
|
|
DWORD ulFlags)
|
2006-06-04 19:12:58 +00:00
|
|
|
|
{
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
2006-06-11 13:20:46 +00:00
|
|
|
|
HKEY hDeviceKey;
|
|
|
|
|
LPWSTR pszSubKey;
|
|
|
|
|
DWORD dwDeviceIdListSize;
|
2008-04-21 12:08:42 +00:00
|
|
|
|
DWORD dwNewDeviceIdSize;
|
|
|
|
|
WCHAR * pszDeviceIdList = NULL;
|
2006-06-04 19:12:58 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2006-06-11 13:20:46 +00:00
|
|
|
|
DPRINT("PNP_AddID() called\n");
|
2008-04-14 10:48:38 +00:00
|
|
|
|
DPRINT(" DeviceInstance: %S\n", pszDeviceID);
|
|
|
|
|
DPRINT(" DeviceId: %S\n", pszID);
|
|
|
|
|
DPRINT(" Flags: %lx\n", ulFlags);
|
2006-06-04 19:12:58 +00:00
|
|
|
|
|
2006-06-11 13:20:46 +00:00
|
|
|
|
if (RegOpenKeyExW(hEnumKey,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pszDeviceID,
|
2006-06-11 13:20:46 +00:00
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE | KEY_SET_VALUE,
|
|
|
|
|
&hDeviceKey) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to open the device key!\n");
|
|
|
|
|
return CR_INVALID_DEVNODE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
pszSubKey = (ulFlags & CM_ADD_ID_COMPATIBLE) ? L"CompatibleIDs" : L"HardwareID";
|
2006-06-11 13:20:46 +00:00
|
|
|
|
|
|
|
|
|
if (RegQueryValueExW(hDeviceKey,
|
|
|
|
|
pszSubKey,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
2008-04-21 12:08:42 +00:00
|
|
|
|
NULL,
|
|
|
|
|
&dwDeviceIdListSize) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to query the desired ID string!\n");
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dwNewDeviceIdSize = lstrlenW(pszDeviceID);
|
|
|
|
|
if (!dwNewDeviceIdSize)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_POINTER;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dwDeviceIdListSize += (dwNewDeviceIdSize + 2) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
|
|
pszDeviceIdList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwDeviceIdListSize);
|
|
|
|
|
if (!pszDeviceIdList)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to allocate memory for the desired ID string!\n");
|
|
|
|
|
ret = CR_OUT_OF_MEMORY;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RegQueryValueExW(hDeviceKey,
|
|
|
|
|
pszSubKey,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
(LPBYTE)pszDeviceIdList,
|
2006-06-11 13:20:46 +00:00
|
|
|
|
&dwDeviceIdListSize) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to query the desired ID string!\n");
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check whether the device ID is already in use */
|
2008-04-21 12:08:42 +00:00
|
|
|
|
if (CheckForDeviceId(pszDeviceIdList, pszDeviceID))
|
2006-06-11 13:20:46 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT("Device ID was found in the ID string!\n");
|
|
|
|
|
ret = CR_SUCCESS;
|
|
|
|
|
goto Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Append the Device ID */
|
2008-04-21 12:08:42 +00:00
|
|
|
|
AppendDeviceId(pszDeviceIdList, &dwDeviceIdListSize, pszID);
|
2006-06-11 13:20:46 +00:00
|
|
|
|
|
|
|
|
|
if (RegSetValueExW(hDeviceKey,
|
|
|
|
|
pszSubKey,
|
|
|
|
|
0,
|
|
|
|
|
REG_MULTI_SZ,
|
2008-04-21 12:08:42 +00:00
|
|
|
|
(LPBYTE)pszDeviceIdList,
|
2006-06-11 13:20:46 +00:00
|
|
|
|
dwDeviceIdListSize) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Failed to set the desired ID string!\n");
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Done:
|
|
|
|
|
RegCloseKey(hDeviceKey);
|
2008-04-21 12:08:42 +00:00
|
|
|
|
if (pszDeviceIdList)
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszDeviceIdList);
|
2006-06-04 19:12:58 +00:00
|
|
|
|
|
2006-06-11 13:20:46 +00:00
|
|
|
|
DPRINT("PNP_AddID() done (returns %lx)\n", ret);
|
2006-06-04 19:12:58 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 35 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_RegisterDriver(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 36 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_QueryRemove(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
PPNP_VETO_TYPE pVetoType,
|
|
|
|
|
LPWSTR pszVetoName,
|
|
|
|
|
DWORD ulNameLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 37 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_RequestDeviceEject(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszDeviceID,
|
|
|
|
|
PPNP_VETO_TYPE pVetoType,
|
|
|
|
|
LPWSTR pszVetoName,
|
|
|
|
|
DWORD ulNameLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-26 09:47:02 +00:00
|
|
|
|
|
2005-10-02 10:07:25 +00:00
|
|
|
|
/* Function 38 */
|
2005-09-25 21:02:43 +00:00
|
|
|
|
CONFIGRET
|
2014-09-26 09:47:02 +00:00
|
|
|
|
WINAPI
|
|
|
|
|
PNP_IsDockStationPresent(
|
|
|
|
|
handle_t hBinding,
|
|
|
|
|
BOOL *Present)
|
2005-09-25 21:02:43 +00:00
|
|
|
|
{
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
DWORD dwType;
|
|
|
|
|
DWORD dwValue;
|
|
|
|
|
DWORD dwSize;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-09-25 21:02:43 +00:00
|
|
|
|
DPRINT1("PNP_IsDockStationPresent() called\n");
|
|
|
|
|
|
|
|
|
|
*Present = FALSE;
|
|
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_CURRENT_CONFIG,
|
|
|
|
|
L"CurrentDockInfo",
|
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hKey) != ERROR_SUCCESS)
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
|
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
|
if (RegQueryValueExW(hKey,
|
|
|
|
|
L"DockingState",
|
|
|
|
|
NULL,
|
|
|
|
|
&dwType,
|
|
|
|
|
(LPBYTE)&dwValue,
|
|
|
|
|
&dwSize) != ERROR_SUCCESS)
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
if (dwType != REG_DWORD || dwSize != sizeof(DWORD))
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
}
|
|
|
|
|
else if (dwValue != 0)
|
|
|
|
|
{
|
|
|
|
|
*Present = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-10-02 10:07:25 +00:00
|
|
|
|
/* Function 39 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_RequestEjectPC(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding)
|
2005-10-02 10:07:25 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2005-10-02 10:07:25 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 40 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_HwProfFlags(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD ulAction,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulConfig,
|
|
|
|
|
DWORD *pulValue,
|
|
|
|
|
PPNP_VETO_TYPE pVetoType,
|
|
|
|
|
LPWSTR pszVetoName,
|
|
|
|
|
DWORD ulNameLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2010-01-16 16:18:00 +00:00
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
WCHAR szKeyName[MAX_PATH];
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
HKEY hDeviceKey;
|
|
|
|
|
DWORD dwSize;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_HwProfFlags() called\n");
|
|
|
|
|
|
|
|
|
|
if (ulConfig == 0)
|
|
|
|
|
{
|
|
|
|
|
wcscpy(szKeyName,
|
|
|
|
|
L"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
swprintf(szKeyName,
|
2014-04-30 19:05:42 +00:00
|
|
|
|
L"System\\CurrentControlSet\\HardwareProfiles\\%04lu\\System\\CurrentControlSet\\Enum",
|
2010-01-16 16:18:00 +00:00
|
|
|
|
ulConfig);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
|
szKeyName,
|
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&hKey) != ERROR_SUCCESS)
|
|
|
|
|
return CR_REGISTRY_ERROR;
|
|
|
|
|
|
|
|
|
|
if (ulAction == PNP_GET_HWPROFFLAGS)
|
|
|
|
|
{
|
|
|
|
|
if (RegOpenKeyExW(hKey,
|
|
|
|
|
pDeviceID,
|
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&hDeviceKey) != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
*pulValue = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dwSize = sizeof(DWORD);
|
2018-05-04 04:15:37 +00:00
|
|
|
|
if (RegQueryValueExW(hDeviceKey,
|
|
|
|
|
L"CSConfigFlags",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
(LPBYTE)pulValue,
|
|
|
|
|
&dwSize) != ERROR_SUCCESS)
|
2010-01-16 16:18:00 +00:00
|
|
|
|
{
|
|
|
|
|
*pulValue = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hDeviceKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (ulAction == PNP_SET_HWPROFFLAGS)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: not implemented yet */
|
|
|
|
|
ret = CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
2005-10-02 10:07:25 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 41 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetHwProfInfo(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD ulIndex,
|
|
|
|
|
HWPROFILEINFO *pHWProfileInfo,
|
|
|
|
|
DWORD ulProfileInfoSize,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2011-10-29 21:54:24 +00:00
|
|
|
|
WCHAR szProfileName[5];
|
|
|
|
|
HKEY hKeyConfig = NULL;
|
|
|
|
|
HKEY hKeyProfiles = NULL;
|
|
|
|
|
HKEY hKeyProfile = NULL;
|
|
|
|
|
DWORD dwDisposition;
|
|
|
|
|
DWORD dwSize;
|
|
|
|
|
LONG lError;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetHwProfInfo() called\n");
|
|
|
|
|
|
|
|
|
|
if (ulProfileInfoSize == 0)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_DATA;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ulFlags != 0)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_FLAG;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Initialize the profile information */
|
|
|
|
|
pHWProfileInfo->HWPI_ulHWProfile = 0;
|
|
|
|
|
pHWProfileInfo->HWPI_szFriendlyName[0] = 0;
|
|
|
|
|
pHWProfileInfo->HWPI_dwFlags = 0;
|
|
|
|
|
|
|
|
|
|
/* Open the 'IDConfigDB' key */
|
|
|
|
|
lError = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
|
L"System\\CurrentControlSet\\Control\\IDConfigDB",
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKeyConfig,
|
|
|
|
|
&dwDisposition);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Open the 'Hardware Profiles' subkey */
|
|
|
|
|
lError = RegCreateKeyExW(hKeyConfig,
|
|
|
|
|
L"Hardware Profiles",
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
|
KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE,
|
|
|
|
|
NULL,
|
|
|
|
|
&hKeyProfiles,
|
|
|
|
|
&dwDisposition);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ulIndex == (ULONG)-1)
|
|
|
|
|
{
|
|
|
|
|
dwSize = sizeof(ULONG);
|
|
|
|
|
lError = RegQueryValueExW(hKeyConfig,
|
|
|
|
|
L"CurrentConfig",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
(LPBYTE)&pHWProfileInfo->HWPI_ulHWProfile,
|
|
|
|
|
&dwSize);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
pHWProfileInfo->HWPI_ulHWProfile = 0;
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: not implemented yet */
|
|
|
|
|
ret = CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swprintf(szProfileName, L"%04lu", pHWProfileInfo->HWPI_ulHWProfile);
|
|
|
|
|
|
|
|
|
|
lError = RegOpenKeyExW(hKeyProfiles,
|
|
|
|
|
szProfileName,
|
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&hKeyProfile);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dwSize = sizeof(pHWProfileInfo->HWPI_szFriendlyName);
|
|
|
|
|
lError = RegQueryValueExW(hKeyProfile,
|
|
|
|
|
L"FriendlyName",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
(LPBYTE)&pHWProfileInfo->HWPI_szFriendlyName,
|
|
|
|
|
&dwSize);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
if (hKeyProfile != NULL)
|
|
|
|
|
RegCloseKey(hKeyProfile);
|
|
|
|
|
|
|
|
|
|
if (hKeyProfiles != NULL)
|
|
|
|
|
RegCloseKey(hKeyProfiles);
|
|
|
|
|
|
|
|
|
|
if (hKeyConfig != NULL)
|
|
|
|
|
RegCloseKey(hKeyConfig);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2005-10-02 10:07:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 42 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_AddEmptyLogConf(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulPriority,
|
|
|
|
|
DWORD *pulLogConfTag,
|
|
|
|
|
DWORD ulFlags)
|
2006-06-18 14:36:42 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-06-18 14:36:42 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 43 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_FreeLogConf(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
DWORD ulLogConfTag,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-06-18 14:36:42 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 44 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetFirstLogConf(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
DWORD *pulLogConfTag,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-06-18 14:36:42 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
|
|
|
|
|
/* Function 45 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetNextLogConf(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
DWORD ulCurrentTag,
|
|
|
|
|
DWORD *pulNextTag,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2006-06-18 14:36:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 46 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetLogConfPriority(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulType,
|
|
|
|
|
DWORD ulTag,
|
|
|
|
|
DWORD *pPriority,
|
|
|
|
|
DWORD ulFlags)
|
2006-07-08 21:37:32 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-08 21:37:32 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 47 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_AddResDes(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfTag,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
DWORD *pulResourceTag,
|
|
|
|
|
BYTE *ResourceData,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE ResourceLen,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-08 21:37:32 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 48 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_FreeResDes(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfTag,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
DWORD ulResourceTag,
|
|
|
|
|
DWORD *pulPreviousResType,
|
|
|
|
|
DWORD *pulPreviousResTag,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-08 21:37:32 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
|
|
|
|
|
/* Function 49 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetNextResDes(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfTag,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
DWORD ulResourceTag,
|
|
|
|
|
DWORD *pulNextResType,
|
|
|
|
|
DWORD *pulNextResTag,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2006-07-08 21:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 50 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetResDesData(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfTag,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
DWORD ulResourceTag,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE BufferLen,
|
|
|
|
|
DWORD ulFlags)
|
2006-07-13 21:28:01 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-13 21:28:01 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 51 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetResDesDataSize(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfTag,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
DWORD ulResourceTag,
|
|
|
|
|
DWORD *pulSize,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-13 21:28:01 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 52 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_ModifyResDes(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
DWORD ulLogConfTag,
|
|
|
|
|
DWORD ulLogConfType,
|
|
|
|
|
RESOURCEID CurrentResourceID,
|
|
|
|
|
RESOURCEID NewResourceID,
|
|
|
|
|
DWORD ulResourceTag,
|
|
|
|
|
BYTE *ResourceData,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE ResourceLen,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-13 21:28:01 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
|
|
|
|
|
/* Function 53 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DetectResourceConflict(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
BYTE *ResourceData,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE ResourceLen,
|
|
|
|
|
BOOL *pbConflictDetected,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2018-11-01 13:50:08 +00:00
|
|
|
|
DPRINT("PNP_DetectResourceConflict()\n");
|
|
|
|
|
|
|
|
|
|
if (pbConflictDetected != NULL)
|
|
|
|
|
*pbConflictDetected = FALSE;
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2006-07-13 21:28:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 54 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_QueryResConfList(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
BYTE *ResourceData,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE ResourceLen,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE BufferLen,
|
|
|
|
|
DWORD ulFlags)
|
2006-07-16 12:11:26 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-16 12:11:26 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 55 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_SetHwProf(
|
2010-01-16 16:31:58 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD ulHardwareProfile,
|
|
|
|
|
DWORD ulFlags)
|
2008-04-14 10:48:38 +00:00
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-16 12:11:26 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 56 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_QueryArbitratorFreeData(
|
2011-03-06 14:15:41 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
BYTE *pData,
|
|
|
|
|
DWORD DataLen,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
DWORD ulFlags)
|
2008-04-14 10:48:38 +00:00
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-16 12:11:26 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
|
|
|
|
|
/* Function 57 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_QueryArbitratorFreeSize(
|
2011-03-06 14:15:41 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD *pulSize,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
RESOURCEID ResourceID,
|
|
|
|
|
DWORD ulFlags)
|
2008-04-14 10:48:38 +00:00
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2006-07-16 12:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 58 */
|
2006-07-22 14:45:14 +00:00
|
|
|
|
CONFIGRET
|
2014-09-26 09:47:02 +00:00
|
|
|
|
WINAPI
|
2008-04-14 10:48:38 +00:00
|
|
|
|
PNP_RunDetection(
|
2008-07-24 19:50:09 +00:00
|
|
|
|
handle_t hBinding,
|
2008-04-14 10:48:38 +00:00
|
|
|
|
DWORD ulFlags)
|
2006-07-22 14:45:14 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-22 14:45:14 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 59 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_RegisterNotification(
|
2016-11-27 11:14:25 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD ulFlags,
|
|
|
|
|
DWORD *pulNotify)
|
2008-04-14 10:48:38 +00:00
|
|
|
|
{
|
2016-11-27 11:14:25 +00:00
|
|
|
|
#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;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
2006-07-22 14:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 60 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_UnregisterNotification(
|
2016-11-27 11:14:25 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD ulNotify)
|
2008-04-14 10:48:38 +00:00
|
|
|
|
{
|
2016-11-27 11:14:25 +00:00
|
|
|
|
DPRINT1("PNP_UnregisterNotification(%p 0x%lx)\n",
|
|
|
|
|
hBinding, ulNotify);
|
|
|
|
|
|
|
|
|
|
#if 0
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2016-11-27 11:14:25 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return CR_SUCCESS;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
2006-07-22 14:45:14 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
|
|
|
|
|
/* Function 61 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetCustomDevProp(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pDeviceID,
|
|
|
|
|
LPWSTR CustomPropName,
|
|
|
|
|
DWORD *pulRegDataType,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulTransferLen,
|
|
|
|
|
PNP_RPC_STRING_LEN *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2011-10-03 13:51:00 +00:00
|
|
|
|
HKEY hDeviceKey = NULL;
|
|
|
|
|
HKEY hParamKey = NULL;
|
|
|
|
|
LONG lError;
|
|
|
|
|
CONFIGRET ret = CR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetCustomDevProp() called\n");
|
|
|
|
|
|
|
|
|
|
if (pulTransferLen == NULL || pulLength == NULL)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_POINTER;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ulFlags & ~CM_CUSTOMDEVPROP_BITS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_INVALID_FLAG;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*pulLength < *pulTransferLen)
|
|
|
|
|
*pulLength = *pulTransferLen;
|
|
|
|
|
|
|
|
|
|
*pulTransferLen = 0;
|
|
|
|
|
|
|
|
|
|
lError = RegOpenKeyExW(hEnumKey,
|
|
|
|
|
pDeviceID,
|
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hDeviceKey);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lError = RegOpenKeyExW(hDeviceKey,
|
|
|
|
|
L"Device Parameters",
|
|
|
|
|
0,
|
|
|
|
|
KEY_READ,
|
|
|
|
|
&hParamKey);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_REGISTRY_ERROR;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lError = RegQueryValueExW(hParamKey,
|
|
|
|
|
CustomPropName,
|
|
|
|
|
NULL,
|
|
|
|
|
pulRegDataType,
|
|
|
|
|
Buffer,
|
|
|
|
|
pulLength);
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
if (lError == ERROR_MORE_DATA)
|
|
|
|
|
{
|
|
|
|
|
ret = CR_BUFFER_SMALL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*pulLength = 0;
|
|
|
|
|
ret = CR_NO_SUCH_VALUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
done:
|
2011-10-03 13:51:00 +00:00
|
|
|
|
if (ret == CR_SUCCESS)
|
|
|
|
|
*pulTransferLen = *pulLength;
|
|
|
|
|
|
|
|
|
|
if (hParamKey != NULL)
|
|
|
|
|
RegCloseKey(hParamKey);
|
|
|
|
|
|
|
|
|
|
if (hDeviceKey != NULL)
|
|
|
|
|
RegCloseKey(hDeviceKey);
|
|
|
|
|
|
|
|
|
|
DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2006-07-22 14:45:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 62 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetVersionInternal(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
WORD *pwVersion)
|
2006-07-23 10:35:27 +00:00
|
|
|
|
{
|
2017-04-10 19:12:17 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
2011-10-29 21:54:24 +00:00
|
|
|
|
*pwVersion = 0x501;
|
|
|
|
|
return CR_SUCCESS;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
2006-07-23 10:35:27 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 63 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetBlockedDriverInfo(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
BYTE *Buffer,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE *pulTransferLen,
|
|
|
|
|
PNP_RPC_BUFFER_SIZE *pulLength,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-07-23 10:35:27 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 64 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetServerSideDeviceInstallFlags(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
DWORD *pulSSDIFlags,
|
|
|
|
|
DWORD ulFlags)
|
|
|
|
|
{
|
2017-04-10 19:12:17 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(hBinding);
|
|
|
|
|
|
|
|
|
|
DPRINT1("PNP_GetServerSideDeviceInstallFlags(%p %p %lu)\n",
|
|
|
|
|
hBinding, pulSSDIFlags, ulFlags);
|
|
|
|
|
|
|
|
|
|
if (pulSSDIFlags == NULL)
|
|
|
|
|
return CR_INVALID_POINTER;
|
|
|
|
|
|
|
|
|
|
if (ulFlags != 0)
|
|
|
|
|
return CR_INVALID_FLAG;
|
|
|
|
|
|
|
|
|
|
/* FIXME */
|
|
|
|
|
*pulSSDIFlags = 0;
|
|
|
|
|
|
|
|
|
|
return CR_SUCCESS;
|
2008-04-14 10:48:38 +00:00
|
|
|
|
}
|
2006-07-23 10:35:27 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
|
|
|
|
|
/* Function 65 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetObjectPropKeys(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR ObjectName,
|
|
|
|
|
DWORD ObjectType,
|
|
|
|
|
LPWSTR PropertyCultureName,
|
|
|
|
|
PNP_PROP_COUNT *PropertyCount,
|
|
|
|
|
PNP_PROP_COUNT *TransferLen,
|
|
|
|
|
DEVPROPKEY *PropertyKeys,
|
|
|
|
|
DWORD Flags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
2006-07-23 10:35:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
/* Function 66 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_GetObjectProp(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR ObjectName,
|
|
|
|
|
DWORD ObjectType,
|
|
|
|
|
LPWSTR PropertyCultureName,
|
|
|
|
|
const DEVPROPKEY *PropertyKey,
|
|
|
|
|
DEVPROPTYPE *PropertyType,
|
|
|
|
|
PNP_PROP_SIZE *PropertySize,
|
|
|
|
|
PNP_PROP_SIZE *TransferLen,
|
|
|
|
|
BYTE *PropertyBuffer,
|
|
|
|
|
DWORD Flags)
|
2005-12-17 12:23:41 +00:00
|
|
|
|
{
|
2008-04-14 10:48:38 +00:00
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
2006-10-03 14:28:21 +00:00
|
|
|
|
|
2008-04-14 10:48:38 +00:00
|
|
|
|
|
|
|
|
|
/* Function 67 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_SetObjectProp(
|
2008-04-14 10:48:38 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR ObjectName,
|
|
|
|
|
DWORD ObjectType,
|
|
|
|
|
LPWSTR PropertyCultureName,
|
|
|
|
|
const DEVPROPKEY *PropertyKey,
|
|
|
|
|
DEVPROPTYPE PropertyType,
|
|
|
|
|
PNP_PROP_SIZE PropertySize,
|
|
|
|
|
BYTE *PropertyBuffer,
|
|
|
|
|
DWORD Flags)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
2005-12-17 12:23:41 +00:00
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-07-24 19:50:09 +00:00
|
|
|
|
/* Function 68 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_InstallDevInst(
|
2008-07-24 19:50:09 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 69 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_ApplyPowerSettings(
|
2008-07-24 19:50:09 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 70 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DriverStoreAddDriverPackage(
|
2008-07-24 19:50:09 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 71 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DriverStoreDeleteDriverPackage(
|
2008-07-24 19:50:09 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 72 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_RegisterServiceNotification(
|
2008-07-24 19:50:09 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 73 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_SetActiveService(
|
2014-09-25 23:44:28 +00:00
|
|
|
|
handle_t hBinding,
|
|
|
|
|
LPWSTR pszFilter,
|
|
|
|
|
DWORD ulFlags)
|
2008-07-24 19:50:09 +00:00
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Function 74 */
|
2014-09-26 09:47:02 +00:00
|
|
|
|
DWORD
|
|
|
|
|
WINAPI
|
|
|
|
|
PNP_DeleteServiceDevices(
|
2008-07-24 19:50:09 +00:00
|
|
|
|
handle_t hBinding)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
return CR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-10-14 18:24:19 +00:00
|
|
|
|
static BOOL
|
2007-10-29 11:55:06 +00:00
|
|
|
|
InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
|
2005-10-14 18:24:19 +00:00
|
|
|
|
{
|
|
|
|
|
BOOL DeviceInstalled = FALSE;
|
2009-04-14 22:31:36 +00:00
|
|
|
|
DWORD BytesWritten;
|
|
|
|
|
DWORD Value;
|
2015-04-03 18:30:37 +00:00
|
|
|
|
HANDLE hInstallEvent;
|
2009-04-14 22:31:36 +00:00
|
|
|
|
HANDLE hPipe = INVALID_HANDLE_VALUE;
|
|
|
|
|
LPVOID Environment = NULL;
|
|
|
|
|
PROCESS_INFORMATION ProcessInfo;
|
|
|
|
|
STARTUPINFOW StartupInfo;
|
|
|
|
|
UUID RandomUuid;
|
2011-05-27 20:50:17 +00:00
|
|
|
|
HKEY DeviceKey;
|
2009-04-14 22:31:36 +00:00
|
|
|
|
|
|
|
|
|
/* The following lengths are constant (see below), they cannot overflow */
|
|
|
|
|
WCHAR CommandLine[116];
|
|
|
|
|
WCHAR InstallEventName[73];
|
|
|
|
|
WCHAR PipeName[74];
|
|
|
|
|
WCHAR UuidString[39];
|
2005-10-14 18:24:19 +00:00
|
|
|
|
|
2015-11-14 13:28:03 +00:00
|
|
|
|
DPRINT("InstallDevice(%S, %d)\n", DeviceInstance, ShowWizard);
|
2007-12-27 20:51:53 +00:00
|
|
|
|
|
2009-04-14 22:31:36 +00:00
|
|
|
|
ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
|
|
|
|
|
|
2011-05-28 13:42:06 +00:00
|
|
|
|
if (RegOpenKeyExW(hEnumKey,
|
|
|
|
|
DeviceInstance,
|
2011-05-27 20:50:17 +00:00
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&DeviceKey) == ERROR_SUCCESS)
|
2007-12-27 20:51:53 +00:00
|
|
|
|
{
|
2011-05-27 20:50:17 +00:00
|
|
|
|
if (RegQueryValueExW(DeviceKey,
|
2012-02-03 23:34:21 +00:00
|
|
|
|
L"Class",
|
2011-05-27 20:50:17 +00:00
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL) == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("No need to install: %S\n", DeviceInstance);
|
2011-05-28 13:42:06 +00:00
|
|
|
|
RegCloseKey(DeviceKey);
|
2011-05-27 20:50:17 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2005-10-14 18:24:19 +00:00
|
|
|
|
|
2017-04-17 11:34:08 +00:00
|
|
|
|
BytesWritten = sizeof(DWORD);
|
|
|
|
|
if (RegQueryValueExW(DeviceKey,
|
|
|
|
|
L"ConfigFlags",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
(PBYTE)&Value,
|
|
|
|
|
&BytesWritten) == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
if (Value & CONFIGFLAG_FAILEDINSTALL)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("No need to install: %S\n", DeviceInstance);
|
|
|
|
|
RegCloseKey(DeviceKey);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-28 13:42:06 +00:00
|
|
|
|
RegCloseKey(DeviceKey);
|
2007-12-27 20:51:53 +00:00
|
|
|
|
}
|
2005-10-14 18:24:19 +00:00
|
|
|
|
|
2011-05-27 20:50:17 +00:00
|
|
|
|
DPRINT1("Installing: %S\n", DeviceInstance);
|
|
|
|
|
|
2015-04-03 18:30:37 +00:00
|
|
|
|
/* Create a random UUID for the named pipe & event*/
|
2009-04-14 22:31:36 +00:00
|
|
|
|
UuidCreate(&RandomUuid);
|
|
|
|
|
swprintf(UuidString, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
|
|
|
|
RandomUuid.Data1, RandomUuid.Data2, RandomUuid.Data3,
|
|
|
|
|
RandomUuid.Data4[0], RandomUuid.Data4[1], RandomUuid.Data4[2],
|
|
|
|
|
RandomUuid.Data4[3], RandomUuid.Data4[4], RandomUuid.Data4[5],
|
|
|
|
|
RandomUuid.Data4[6], RandomUuid.Data4[7]);
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2015-04-03 18:30:37 +00:00
|
|
|
|
/* Create the event */
|
|
|
|
|
wcscpy(InstallEventName, L"Global\\PNP_Device_Install_Event_0.");
|
|
|
|
|
wcscat(InstallEventName, UuidString);
|
|
|
|
|
hInstallEvent = CreateEventW(NULL, TRUE, FALSE, InstallEventName);
|
|
|
|
|
if (!hInstallEvent)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("CreateEventW('%ls') failed with error %lu\n", InstallEventName, GetLastError());
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-14 22:31:36 +00:00
|
|
|
|
/* Create the named pipe */
|
|
|
|
|
wcscpy(PipeName, L"\\\\.\\pipe\\PNP_Device_Install_Pipe_0.");
|
|
|
|
|
wcscat(PipeName, UuidString);
|
|
|
|
|
hPipe = CreateNamedPipeW(PipeName, PIPE_ACCESS_OUTBOUND, PIPE_TYPE_BYTE, 1, 512, 512, 0, NULL);
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (hPipe == INVALID_HANDLE_VALUE)
|
2007-12-27 20:51:53 +00:00
|
|
|
|
{
|
2009-04-14 22:31:36 +00:00
|
|
|
|
DPRINT1("CreateNamedPipeW failed with error %u\n", GetLastError());
|
2005-10-14 18:24:19 +00:00
|
|
|
|
goto cleanup;
|
2007-12-27 20:51:53 +00:00
|
|
|
|
}
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2009-04-14 22:31:36 +00:00
|
|
|
|
/* Launch rundll32 to call ClientSideInstallW */
|
|
|
|
|
wcscpy(CommandLine, L"rundll32.exe newdev.dll,ClientSideInstall ");
|
|
|
|
|
wcscat(CommandLine, PipeName);
|
|
|
|
|
|
|
|
|
|
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
|
|
|
|
StartupInfo.cb = sizeof(StartupInfo);
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (hUserToken)
|
2009-04-14 22:31:36 +00:00
|
|
|
|
{
|
|
|
|
|
/* newdev has to run under the environment of the current user */
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (!CreateEnvironmentBlock(&Environment, hUserToken, FALSE))
|
2009-04-14 22:31:36 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT1("CreateEnvironmentBlock failed with error %d\n", GetLastError());
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (!CreateProcessAsUserW(hUserToken, NULL, CommandLine, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, Environment, NULL, &StartupInfo, &ProcessInfo))
|
2009-04-14 22:31:36 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT1("CreateProcessAsUserW failed with error %u\n", GetLastError());
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: This is probably not correct, I guess newdev should never be run with SYSTEM privileges.
|
|
|
|
|
|
|
|
|
|
Still, we currently do that in 2nd stage setup and probably Console mode as well, so allow it here.
|
|
|
|
|
(ShowWizard is only set to FALSE for these two modes) */
|
|
|
|
|
ASSERT(!ShowWizard);
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (!CreateProcessW(NULL, CommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo))
|
2009-04-14 22:31:36 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT1("CreateProcessW failed with error %u\n", GetLastError());
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Wait for the function to connect to our pipe */
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (!ConnectNamedPipe(hPipe, NULL))
|
2007-12-27 20:51:53 +00:00
|
|
|
|
{
|
2013-06-02 12:59:06 +00:00
|
|
|
|
if (GetLastError() != ERROR_PIPE_CONNECTED)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("ConnectNamedPipe failed with error %u\n", GetLastError());
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2007-12-27 20:51:53 +00:00
|
|
|
|
}
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2009-04-14 22:31:36 +00:00
|
|
|
|
/* Pass the data. The following output is partly compatible to Windows XP SP2 (researched using a modified newdev.dll to log this stuff) */
|
|
|
|
|
Value = sizeof(InstallEventName);
|
|
|
|
|
WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
|
|
|
|
|
WriteFile(hPipe, InstallEventName, Value, &BytesWritten, NULL);
|
|
|
|
|
|
|
|
|
|
/* I couldn't figure out what the following value means under WinXP. It's usually 0 in my tests, but was also 5 once.
|
|
|
|
|
Therefore the following line is entirely ReactOS-specific. We use the value here to pass the ShowWizard variable. */
|
|
|
|
|
WriteFile(hPipe, &ShowWizard, sizeof(ShowWizard), &BytesWritten, NULL);
|
|
|
|
|
|
|
|
|
|
Value = (wcslen(DeviceInstance) + 1) * sizeof(WCHAR);
|
|
|
|
|
WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
|
|
|
|
|
WriteFile(hPipe, DeviceInstance, Value, &BytesWritten, NULL);
|
|
|
|
|
|
|
|
|
|
/* Wait for newdev.dll to finish processing */
|
|
|
|
|
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
|
|
|
|
|
|
2015-04-03 18:30:37 +00:00
|
|
|
|
/* If the event got signalled, this is success */
|
|
|
|
|
DeviceInstalled = WaitForSingleObject(hInstallEvent, 0) == WAIT_OBJECT_0;
|
2005-10-14 18:24:19 +00:00
|
|
|
|
|
|
|
|
|
cleanup:
|
2015-04-03 18:30:37 +00:00
|
|
|
|
if (hInstallEvent)
|
|
|
|
|
CloseHandle(hInstallEvent);
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (hPipe != INVALID_HANDLE_VALUE)
|
2009-04-14 22:31:36 +00:00
|
|
|
|
CloseHandle(hPipe);
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (Environment)
|
2009-04-14 22:31:36 +00:00
|
|
|
|
DestroyEnvironmentBlock(Environment);
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (ProcessInfo.hProcess)
|
2009-04-14 22:31:36 +00:00
|
|
|
|
CloseHandle(ProcessInfo.hProcess);
|
|
|
|
|
|
2015-03-04 21:37:35 +00:00
|
|
|
|
if (ProcessInfo.hThread)
|
2009-04-14 22:31:36 +00:00
|
|
|
|
CloseHandle(ProcessInfo.hThread);
|
2005-10-14 18:24:19 +00:00
|
|
|
|
|
2014-11-02 11:30:14 +00:00
|
|
|
|
if (!DeviceInstalled)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("InstallDevice failed for DeviceInstance '%ws'\n", DeviceInstance);
|
|
|
|
|
}
|
2011-05-27 20:50:17 +00:00
|
|
|
|
|
2005-10-14 18:24:19 +00:00
|
|
|
|
return DeviceInstalled;
|
|
|
|
|
}
|
2005-10-02 10:07:25 +00:00
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2007-10-29 11:55:06 +00:00
|
|
|
|
static LONG
|
|
|
|
|
ReadRegSzKey(
|
|
|
|
|
IN HKEY hKey,
|
|
|
|
|
IN LPCWSTR pszKey,
|
|
|
|
|
OUT LPWSTR* pValue)
|
|
|
|
|
{
|
|
|
|
|
LONG rc;
|
|
|
|
|
DWORD dwType;
|
|
|
|
|
DWORD cbData = 0;
|
|
|
|
|
LPWSTR Value;
|
|
|
|
|
|
|
|
|
|
if (!pValue)
|
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
|
|
*pValue = NULL;
|
|
|
|
|
rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
return rc;
|
|
|
|
|
if (dwType != REG_SZ)
|
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
|
|
|
|
Value = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
|
|
|
|
|
if (!Value)
|
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, Value);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
/* NULL-terminate the string */
|
|
|
|
|
Value[cbData / sizeof(WCHAR)] = '\0';
|
|
|
|
|
|
|
|
|
|
*pValue = Value;
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-11-10 08:37:40 +00:00
|
|
|
|
static BOOL
|
|
|
|
|
SetupIsActive(VOID)
|
|
|
|
|
{
|
2006-06-02 14:37:25 +00:00
|
|
|
|
HKEY hKey = NULL;
|
2005-11-10 08:37:40 +00:00
|
|
|
|
DWORD regType, active, size;
|
|
|
|
|
LONG rc;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\Setup", 0, KEY_QUERY_VALUE, &hKey);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2005-11-10 08:47:43 +00:00
|
|
|
|
size = sizeof(DWORD);
|
2005-11-10 08:37:40 +00:00
|
|
|
|
rc = RegQueryValueExW(hKey, L"SystemSetupInProgress", NULL, ®Type, (LPBYTE)&active, &size);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
2005-11-10 08:47:43 +00:00
|
|
|
|
if (regType != REG_DWORD || size != sizeof(DWORD))
|
2005-11-10 08:37:40 +00:00
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
ret = (active != 0);
|
|
|
|
|
|
|
|
|
|
cleanup:
|
2006-06-02 14:37:25 +00:00
|
|
|
|
if (hKey != NULL)
|
2005-11-10 08:37:40 +00:00
|
|
|
|
RegCloseKey(hKey);
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2005-11-10 08:37:40 +00:00
|
|
|
|
DPRINT("System setup in progress? %S\n", ret ? L"YES" : L"NO");
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2005-11-10 08:37:40 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-17 12:23:41 +00:00
|
|
|
|
|
2007-10-29 11:55:06 +00:00
|
|
|
|
static BOOL
|
|
|
|
|
IsConsoleBoot(VOID)
|
|
|
|
|
{
|
|
|
|
|
HKEY ControlKey = NULL;
|
|
|
|
|
LPWSTR SystemStartOptions = NULL;
|
|
|
|
|
LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
|
|
|
|
|
BOOL ConsoleBoot = FALSE;
|
|
|
|
|
LONG rc;
|
|
|
|
|
|
|
|
|
|
rc = RegOpenKeyExW(
|
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
|
L"SYSTEM\\CurrentControlSet\\Control",
|
|
|
|
|
0,
|
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
|
&ControlKey);
|
|
|
|
|
|
|
|
|
|
rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2012-11-23 20:05:35 +00:00
|
|
|
|
/* Check for CONSOLE switch in SystemStartOptions */
|
2007-10-29 11:55:06 +00:00
|
|
|
|
CurrentOption = SystemStartOptions;
|
|
|
|
|
while (CurrentOption)
|
|
|
|
|
{
|
|
|
|
|
NextOption = wcschr(CurrentOption, L' ');
|
|
|
|
|
if (NextOption)
|
|
|
|
|
*NextOption = L'\0';
|
2008-12-23 01:23:25 +00:00
|
|
|
|
if (_wcsicmp(CurrentOption, L"CONSOLE") == 0)
|
2007-10-29 11:55:06 +00:00
|
|
|
|
{
|
|
|
|
|
DPRINT("Found %S. Switching to console boot\n", CurrentOption);
|
|
|
|
|
ConsoleBoot = TRUE;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
CurrentOption = NextOption ? NextOption + 1 : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
if (ControlKey != NULL)
|
|
|
|
|
RegCloseKey(ControlKey);
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, SystemStartOptions);
|
|
|
|
|
return ConsoleBoot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-02 18:46:39 +00:00
|
|
|
|
/* Loop to install all queued devices installations */
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
|
DeviceInstallThread(LPVOID lpParameter)
|
|
|
|
|
{
|
|
|
|
|
PSLIST_ENTRY ListEntry;
|
|
|
|
|
DeviceInstallParams* Params;
|
2007-10-29 11:55:06 +00:00
|
|
|
|
BOOL showWizard;
|
2006-10-02 18:46:39 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(lpParameter);
|
|
|
|
|
|
2008-01-11 13:00:44 +00:00
|
|
|
|
WaitForSingleObject(hInstallEvent, INFINITE);
|
|
|
|
|
|
2007-10-29 11:55:06 +00:00
|
|
|
|
showWizard = !SetupIsActive() && !IsConsoleBoot();
|
2006-10-02 18:46:39 +00:00
|
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
|
{
|
|
|
|
|
ListEntry = InterlockedPopEntrySList(&DeviceInstallListHead);
|
2018-12-15 14:26:01 +00:00
|
|
|
|
|
2006-10-02 18:46:39 +00:00
|
|
|
|
if (ListEntry == NULL)
|
|
|
|
|
{
|
|
|
|
|
SetEvent(hNoPendingInstalls);
|
|
|
|
|
WaitForSingleObject(hDeviceInstallListNotEmpty, INFINITE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ResetEvent(hNoPendingInstalls);
|
|
|
|
|
Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry);
|
2007-10-29 11:55:06 +00:00
|
|
|
|
InstallDevice(Params->DeviceIds, showWizard);
|
2018-12-23 13:06:03 +00:00
|
|
|
|
HeapFree(GetProcessHeap(), 0, Params);
|
2006-10-02 18:46:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
static DWORD WINAPI
|
|
|
|
|
PnpEventThread(LPVOID lpParameter)
|
|
|
|
|
{
|
2018-12-23 13:06:03 +00:00
|
|
|
|
DWORD dwRet = ERROR_SUCCESS;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
RPC_STATUS RpcStatus;
|
2018-12-23 13:06:03 +00:00
|
|
|
|
PPLUGPLAY_EVENT_BLOCK PnpEvent, NewPnpEvent;
|
|
|
|
|
ULONG PnpEventSize;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2006-10-03 14:28:21 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(lpParameter);
|
|
|
|
|
|
2005-07-31 12:11:56 +00:00
|
|
|
|
PnpEventSize = 0x1000;
|
|
|
|
|
PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize);
|
|
|
|
|
if (PnpEvent == NULL)
|
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
DPRINT("Calling NtGetPlugPlayEvent()\n");
|
|
|
|
|
|
2018-12-23 13:02:16 +00:00
|
|
|
|
/* Wait for the next PnP event */
|
2005-07-31 12:11:56 +00:00
|
|
|
|
Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize);
|
|
|
|
|
|
2018-12-23 13:02:16 +00:00
|
|
|
|
/* Resize the buffer for the PnP event if it's too small */
|
2005-07-31 12:11:56 +00:00
|
|
|
|
if (Status == STATUS_BUFFER_TOO_SMALL)
|
|
|
|
|
{
|
|
|
|
|
PnpEventSize += 0x400;
|
2018-12-23 13:06:03 +00:00
|
|
|
|
NewPnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize);
|
|
|
|
|
if (NewPnpEvent == NULL)
|
|
|
|
|
{
|
|
|
|
|
dwRet = ERROR_OUTOFMEMORY;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
PnpEvent = NewPnpEvent;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
|
{
|
2018-12-23 13:02:16 +00:00
|
|
|
|
DPRINT1("NtGetPlugPlayEvent() failed (Status 0x%08lx)\n", Status);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-23 13:02:16 +00:00
|
|
|
|
/* Process the PnP event */
|
2005-07-31 12:11:56 +00:00
|
|
|
|
DPRINT("Received PnP Event\n");
|
2008-08-22 21:43:42 +00:00
|
|
|
|
if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ENUMERATED, &RpcStatus))
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
2006-10-02 18:46:39 +00:00
|
|
|
|
DeviceInstallParams* Params;
|
|
|
|
|
DWORD len;
|
2008-04-21 12:08:42 +00:00
|
|
|
|
DWORD DeviceIdLength;
|
2006-10-02 18:46:39 +00:00
|
|
|
|
|
2011-11-11 20:41:10 +00:00
|
|
|
|
DPRINT("Device enumerated: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
2006-10-02 18:46:39 +00:00
|
|
|
|
|
2008-04-21 12:08:42 +00:00
|
|
|
|
DeviceIdLength = lstrlenW(PnpEvent->TargetDevice.DeviceIds);
|
|
|
|
|
if (DeviceIdLength)
|
2006-10-02 18:46:39 +00:00
|
|
|
|
{
|
2018-12-14 23:41:40 +00:00
|
|
|
|
/* Queue device install (will be dequeued by DeviceInstallThread) */
|
2008-04-21 12:08:42 +00:00
|
|
|
|
len = FIELD_OFFSET(DeviceInstallParams, DeviceIds) + (DeviceIdLength + 1) * sizeof(WCHAR);
|
|
|
|
|
Params = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
|
if (Params)
|
|
|
|
|
{
|
|
|
|
|
wcscpy(Params->DeviceIds, PnpEvent->TargetDevice.DeviceIds);
|
|
|
|
|
InterlockedPushEntrySList(&DeviceInstallListHead, &Params->ListEntry);
|
|
|
|
|
SetEvent(hDeviceInstallListNotEmpty);
|
|
|
|
|
}
|
2006-10-02 18:46:39 +00:00
|
|
|
|
}
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
2010-01-06 21:14:13 +00:00
|
|
|
|
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus))
|
|
|
|
|
{
|
2017-04-09 08:51:03 +00:00
|
|
|
|
// DWORD dwRecipient;
|
2017-04-01 08:07:39 +00:00
|
|
|
|
|
2011-11-11 20:41:10 +00:00
|
|
|
|
DPRINT("Device arrival: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
2017-04-01 08:07:39 +00:00
|
|
|
|
|
2017-04-09 08:51:03 +00:00
|
|
|
|
// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
|
|
|
|
|
// BroadcastSystemMessageW(BSF_POSTMESSAGE,
|
|
|
|
|
// &dwRecipient,
|
|
|
|
|
// WM_DEVICECHANGE,
|
|
|
|
|
// DBT_DEVNODES_CHANGED,
|
|
|
|
|
// 0);
|
|
|
|
|
SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0);
|
2010-01-06 21:14:13 +00:00
|
|
|
|
}
|
2011-06-01 19:44:03 +00:00
|
|
|
|
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_EJECT_VETOED, &RpcStatus))
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("Eject vetoed: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
|
|
|
|
}
|
|
|
|
|
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_KERNEL_INITIATED_EJECT, &RpcStatus))
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("Kernel initiated eject: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
|
|
|
|
}
|
|
|
|
|
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SAFE_REMOVAL, &RpcStatus))
|
|
|
|
|
{
|
2017-04-09 08:51:03 +00:00
|
|
|
|
// DWORD dwRecipient;
|
2017-04-01 08:07:39 +00:00
|
|
|
|
|
2011-06-01 19:44:03 +00:00
|
|
|
|
DPRINT1("Safe removal: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
2017-04-01 08:07:39 +00:00
|
|
|
|
|
2017-04-09 08:51:03 +00:00
|
|
|
|
// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
|
|
|
|
|
// BroadcastSystemMessageW(BSF_POSTMESSAGE,
|
|
|
|
|
// &dwRecipient,
|
|
|
|
|
// WM_DEVICECHANGE,
|
|
|
|
|
// DBT_DEVNODES_CHANGED,
|
|
|
|
|
// 0);
|
|
|
|
|
SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0);
|
2011-06-01 19:44:03 +00:00
|
|
|
|
}
|
|
|
|
|
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SURPRISE_REMOVAL, &RpcStatus))
|
|
|
|
|
{
|
2017-04-09 08:51:03 +00:00
|
|
|
|
// DWORD dwRecipient;
|
2017-04-01 08:07:39 +00:00
|
|
|
|
|
2011-06-01 19:44:03 +00:00
|
|
|
|
DPRINT1("Surprise removal: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
2017-04-01 08:07:39 +00:00
|
|
|
|
|
2017-04-09 08:51:03 +00:00
|
|
|
|
// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
|
|
|
|
|
// BroadcastSystemMessageW(BSF_POSTMESSAGE,
|
|
|
|
|
// &dwRecipient,
|
|
|
|
|
// WM_DEVICECHANGE,
|
|
|
|
|
// DBT_DEVNODES_CHANGED,
|
|
|
|
|
// 0);
|
|
|
|
|
SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0);
|
2011-06-01 19:44:03 +00:00
|
|
|
|
}
|
|
|
|
|
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_REMOVAL_VETOED, &RpcStatus))
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("Removal vetoed: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
|
|
|
|
}
|
|
|
|
|
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_REMOVE_PENDING, &RpcStatus))
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("Removal pending: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
|
|
|
|
}
|
2005-07-31 12:11:56 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2008-10-26 14:38:50 +00:00
|
|
|
|
DPRINT1("Unknown event, GUID {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n",
|
|
|
|
|
PnpEvent->EventGuid.Data1, PnpEvent->EventGuid.Data2, PnpEvent->EventGuid.Data3,
|
|
|
|
|
PnpEvent->EventGuid.Data4[0], PnpEvent->EventGuid.Data4[1], PnpEvent->EventGuid.Data4[2],
|
|
|
|
|
PnpEvent->EventGuid.Data4[3], PnpEvent->EventGuid.Data4[4], PnpEvent->EventGuid.Data4[5],
|
|
|
|
|
PnpEvent->EventGuid.Data4[6], PnpEvent->EventGuid.Data4[7]);
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-23 13:02:16 +00:00
|
|
|
|
/* Dequeue the current PnP event and signal the next one */
|
2005-07-31 12:11:56 +00:00
|
|
|
|
NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, PnpEvent);
|
|
|
|
|
|
2018-12-23 13:06:03 +00:00
|
|
|
|
return dwRet;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-02-27 17:15:49 +00:00
|
|
|
|
static VOID
|
|
|
|
|
UpdateServiceStatus(DWORD dwState)
|
|
|
|
|
{
|
|
|
|
|
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
|
|
|
|
ServiceStatus.dwCurrentState = dwState;
|
|
|
|
|
ServiceStatus.dwControlsAccepted = 0;
|
|
|
|
|
ServiceStatus.dwWin32ExitCode = 0;
|
|
|
|
|
ServiceStatus.dwServiceSpecificExitCode = 0;
|
|
|
|
|
ServiceStatus.dwCheckPoint = 0;
|
|
|
|
|
|
|
|
|
|
if (dwState == SERVICE_START_PENDING ||
|
|
|
|
|
dwState == SERVICE_STOP_PENDING ||
|
|
|
|
|
dwState == SERVICE_PAUSE_PENDING ||
|
|
|
|
|
dwState == SERVICE_CONTINUE_PENDING)
|
|
|
|
|
ServiceStatus.dwWaitHint = 10000;
|
|
|
|
|
else
|
|
|
|
|
ServiceStatus.dwWaitHint = 0;
|
|
|
|
|
|
|
|
|
|
SetServiceStatus(ServiceStatusHandle,
|
|
|
|
|
&ServiceStatus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
|
ServiceControlHandler(DWORD dwControl,
|
|
|
|
|
DWORD dwEventType,
|
|
|
|
|
LPVOID lpEventData,
|
|
|
|
|
LPVOID lpContext)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("ServiceControlHandler() called\n");
|
|
|
|
|
|
|
|
|
|
switch (dwControl)
|
|
|
|
|
{
|
|
|
|
|
case SERVICE_CONTROL_STOP:
|
|
|
|
|
DPRINT1(" SERVICE_CONTROL_STOP received\n");
|
2011-08-15 20:55:07 +00:00
|
|
|
|
/* Stop listening to RPC Messages */
|
|
|
|
|
RpcMgmtStopServerListening(NULL);
|
2010-02-27 17:15:49 +00:00
|
|
|
|
UpdateServiceStatus(SERVICE_STOPPED);
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
case SERVICE_CONTROL_PAUSE:
|
|
|
|
|
DPRINT1(" SERVICE_CONTROL_PAUSE received\n");
|
|
|
|
|
UpdateServiceStatus(SERVICE_PAUSED);
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
case SERVICE_CONTROL_CONTINUE:
|
|
|
|
|
DPRINT1(" SERVICE_CONTROL_CONTINUE received\n");
|
|
|
|
|
UpdateServiceStatus(SERVICE_RUNNING);
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
case SERVICE_CONTROL_INTERROGATE:
|
|
|
|
|
DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n");
|
|
|
|
|
SetServiceStatus(ServiceStatusHandle,
|
|
|
|
|
&ServiceStatus);
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
case SERVICE_CONTROL_SHUTDOWN:
|
|
|
|
|
DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
|
2011-10-29 21:54:24 +00:00
|
|
|
|
/* Stop listening to RPC Messages */
|
|
|
|
|
RpcMgmtStopServerListening(NULL);
|
2010-02-27 17:15:49 +00:00
|
|
|
|
UpdateServiceStatus(SERVICE_STOPPED);
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
default :
|
2015-06-08 23:29:59 +00:00
|
|
|
|
DPRINT1(" Control %lu received\n", dwControl);
|
2010-02-27 17:15:49 +00:00
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
VOID WINAPI
|
2010-02-22 19:26:54 +00:00
|
|
|
|
ServiceMain(DWORD argc, LPTSTR *argv)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
2010-02-22 19:26:54 +00:00
|
|
|
|
HANDLE hThread;
|
|
|
|
|
DWORD dwThreadId;
|
|
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(argc);
|
|
|
|
|
UNREFERENCED_PARAMETER(argv);
|
|
|
|
|
|
|
|
|
|
DPRINT("ServiceMain() called\n");
|
|
|
|
|
|
2010-02-27 17:15:49 +00:00
|
|
|
|
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
|
|
|
|
|
ServiceControlHandler,
|
|
|
|
|
NULL);
|
|
|
|
|
if (!ServiceStatusHandle)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateServiceStatus(SERVICE_START_PENDING);
|
|
|
|
|
|
2010-02-22 19:26:54 +00:00
|
|
|
|
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,
|
|
|
|
|
DeviceInstallThread,
|
|
|
|
|
NULL,
|
|
|
|
|
0,
|
|
|
|
|
&dwThreadId);
|
|
|
|
|
if (hThread != NULL)
|
|
|
|
|
CloseHandle(hThread);
|
|
|
|
|
|
2010-02-27 17:15:49 +00:00
|
|
|
|
UpdateServiceStatus(SERVICE_RUNNING);
|
|
|
|
|
|
2010-02-22 19:26:54 +00:00
|
|
|
|
DPRINT("ServiceMain() done\n");
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
static DWORD
|
|
|
|
|
InitializePnPManager(VOID)
|
2005-07-31 12:11:56 +00:00
|
|
|
|
{
|
2010-02-19 20:03:11 +00:00
|
|
|
|
BOOLEAN OldValue;
|
2010-02-22 19:26:54 +00:00
|
|
|
|
DWORD dwError;
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
DPRINT("UMPNPMGR: InitializePnPManager() started\n");
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2009-04-14 22:31:36 +00:00
|
|
|
|
/* We need this privilege for using CreateProcessAsUserW */
|
2010-02-22 19:26:54 +00:00
|
|
|
|
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &OldValue);
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
hInstallEvent = CreateEventW(NULL, TRUE, SetupIsActive()/*FALSE*/, NULL);
|
2005-12-17 19:58:23 +00:00
|
|
|
|
if (hInstallEvent == NULL)
|
|
|
|
|
{
|
|
|
|
|
dwError = GetLastError();
|
|
|
|
|
DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError);
|
|
|
|
|
return dwError;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
hDeviceInstallListNotEmpty = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2006-10-02 18:46:39 +00:00
|
|
|
|
if (hDeviceInstallListNotEmpty == NULL)
|
|
|
|
|
{
|
|
|
|
|
dwError = GetLastError();
|
|
|
|
|
DPRINT1("Could not create the Event! (Error %lu)\n", dwError);
|
|
|
|
|
return dwError;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-06 12:54:24 +00:00
|
|
|
|
hNoPendingInstalls = CreateEventW(NULL,
|
|
|
|
|
TRUE,
|
|
|
|
|
FALSE,
|
|
|
|
|
L"Global\\PnP_No_Pending_Install_Events");
|
|
|
|
|
if (hNoPendingInstalls == NULL)
|
|
|
|
|
{
|
|
|
|
|
dwError = GetLastError();
|
|
|
|
|
DPRINT1("Could not create the Event! (Error %lu)\n", dwError);
|
|
|
|
|
return dwError;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-02 18:46:39 +00:00
|
|
|
|
InitializeSListHead(&DeviceInstallListHead);
|
|
|
|
|
|
2005-08-01 19:42:19 +00:00
|
|
|
|
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
|
L"System\\CurrentControlSet\\Enum",
|
|
|
|
|
0,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
&hEnumKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("Could not open the Enum Key! (Error %lu)\n", dwError);
|
|
|
|
|
return dwError;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
|
L"System\\CurrentControlSet\\Control\\Class",
|
|
|
|
|
0,
|
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
|
&hClassKey);
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
DPRINT1("Could not open the Class Key! (Error %lu)\n", dwError);
|
|
|
|
|
return dwError;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
DPRINT("UMPNPMGR: InitializePnPManager() done\n");
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
BOOL WINAPI
|
|
|
|
|
DllMain(HINSTANCE hinstDLL,
|
|
|
|
|
DWORD fdwReason,
|
|
|
|
|
LPVOID lpvReserved)
|
|
|
|
|
{
|
|
|
|
|
switch (fdwReason)
|
|
|
|
|
{
|
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
|
InitializePnPManager();
|
|
|
|
|
break;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
|
2014-09-25 23:44:28 +00:00
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2005-07-31 12:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* EOF */
|