Implement CMP_Init_Detection, CMP_Report_LogOn, CM_Setup_DevNode[_Ex] and CM_Uninstall_DevNode[_Ex].

svn path=/trunk/; revision=20228
This commit is contained in:
Eric Kohl 2005-12-17 19:58:23 +00:00
parent 8e8d537688
commit 5d810533b0
4 changed files with 396 additions and 11 deletions

View file

@ -5,6 +5,7 @@
#define WORD unsigned short
#define DWORD unsigned long
#define CONFIGRET unsigned long
#define BOOL unsigned long
#define PBOOL unsigned long *
[
@ -33,6 +34,11 @@ interface pnp
/* Function 4 */
CONFIGRET PNP_InitDetection(handle_t BindingHandle);
/* Function 5 */
CONFIGRET PNP_ReportLogOn(handle_t BindingHandle,
[in] BOOL Admin,
[in] DWORD ProcessId);
/* Function 6 */
CONFIGRET PNP_ValidateDeviceInstance(handle_t BindingHandle,
[in, string] wchar_t *DeviceInstance,
@ -103,6 +109,12 @@ interface pnp
[in] unsigned long Length,
[in] unsigned long Flags);
/* Function 15 */
CONFIGRET PNP_GetClassInstance(handle_t BindingHandle,
[in, string] wchar_t *DeviceId,
[out, string, size_is(Length)] wchar_t *Buffer,
[in] unsigned long Length);
/* Function 16 */
CONFIGRET PNP_CreateKey(handle_t BindingHandle,
[in, string] wchar_t *SubKey,
@ -148,6 +160,11 @@ interface pnp
[in] unsigned long Problem,
[in] DWORD Flags);
/* Function 33 */
CONFIGRET PNP_UninstallDevInst(handle_t BindingHandle,
[in, string] wchar_t *DeviceInstance,
[in] DWORD Flags);
/* Function 38 */
CONFIGRET PNP_IsDockStationPresent(handle_t BindingHandle,
[out]PBOOL Present);

View file

@ -153,6 +153,21 @@ DECL_WINELIB_CFGMGR32_TYPE_AW(DEVINSTID)
#define CM_DETECT_RUN 0x80000000
#define CM_DETECT_BITS 0x80000007
/* ulFlags for CM_Setup_DevInst[_Ex] */
#define CM_SETUP_DEVNODE_READY 0x00000000
#define CM_SETUP_DEVINST_READY CM_SETUP_DEVNODE_READY
#define CM_SETUP_DOWNLOAD 0x00000001
#define CM_SETUP_WRITE_LOG_CONFS 0x00000002
#define CM_SETUP_PROP_CHANGE 0x00000003
#define CM_SETUP_DEVNODE_RESET 0x00000004
#define CM_SETUP_DEVINST_RESET CM_SETUP_DEVNODE_RESET
#define CM_SETUP_BITS 0x00000007
#define CMP_MAGIC 0x01234567
CONFIGRET WINAPI CMP_Init_Detection( DWORD );
CONFIGRET WINAPI CMP_Report_LogOn( DWORD, DWORD );
CONFIGRET WINAPI CM_Connect_MachineA( PCSTR, PHMACHINE );
CONFIGRET WINAPI CM_Connect_MachineW( PCWSTR, PHMACHINE );
@ -227,18 +242,21 @@ WORD WINAPI CM_Get_Version_Ex( HMACHINE );
CONFIGRET WINAPI CM_Is_Dock_Station_Present( PBOOL );
CONFIGRET WINAPI CM_Is_Dock_Station_Present_Ex( PBOOL, HMACHINE );
CONFIGRET WINAPI CM_Locate_DevNodeA(PDEVINST, DEVINSTID_A, ULONG);
CONFIGRET WINAPI CM_Locate_DevNodeW(PDEVINST, DEVINSTID_W, ULONG);
CONFIGRET WINAPI CM_Locate_DevNodeA( PDEVINST, DEVINSTID_A, ULONG );
CONFIGRET WINAPI CM_Locate_DevNodeW( PDEVINST, DEVINSTID_W, ULONG );
#define CM_Locate_DevNode WINELIB_NAME_AW(CM_Locate_DevNode)
CONFIGRET WINAPI CM_Locate_DevNode_ExA(PDEVINST, DEVINSTID_A, ULONG, HMACHINE);
CONFIGRET WINAPI CM_Locate_DevNode_ExW(PDEVINST, DEVINSTID_W, ULONG, HMACHINE);
CONFIGRET WINAPI CM_Locate_DevNode_ExA( PDEVINST, DEVINSTID_A, ULONG, HMACHINE );
CONFIGRET WINAPI CM_Locate_DevNode_ExW( PDEVINST, DEVINSTID_W, ULONG, HMACHINE );
#define CM_Locate_DevNode_Ex WINELIB_NAME_AW(CM_Locate_DevNode_Ex)
CONFIGRET WINAPI CM_Open_Class_KeyA(LPGUID, LPCSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG);
CONFIGRET WINAPI CM_Open_Class_KeyW(LPGUID, LPCWSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG);
CONFIGRET WINAPI CM_Move_DevNode( DEVINST, DEVINST, ULONG );
CONFIGRET WINAPI CM_Move_DevNode_Ex( DEVINST, DEVINST, ULONG, HMACHINE );
CONFIGRET WINAPI CM_Open_Class_KeyA( LPGUID, LPCSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG );
CONFIGRET WINAPI CM_Open_Class_KeyW( LPGUID, LPCWSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG );
#define CM_Open_Class_Key WINELIB_NAME_AW(CM_Open_Class_Key)
CONFIGRET WINAPI CM_Open_Class_Key_ExA(LPGUID, LPCSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG, HMACHINE);
CONFIGRET WINAPI CM_Open_Class_Key_ExW(LPGUID, LPCWSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG, HMACHINE);
CONFIGRET WINAPI CM_Open_Class_Key_ExA( LPGUID, LPCSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG, HMACHINE );
CONFIGRET WINAPI CM_Open_Class_Key_ExW( LPGUID, LPCWSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG, HMACHINE );
#define CM_Open_Class_Key_Ex WINELIB_NAME_AW(CM_Open_Class_Key_Ex)
CONFIGRET WINAPI CM_Reenumerate_DevNode( DEVINST, ULONG );
@ -258,4 +276,10 @@ CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExA( DEVINST, ULONG, PCVOID, U
CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExW( DEVINST, ULONG, PCVOID, ULONG, ULONG, HMACHINE );
#define CM_Set_DevNode_Registry_Property_Ex WINELIB_NAME_AW(CM_Set_DevNode_Registry_Property_Ex)
CONFIGRET WINAPI CM_Setup_DevNode( DEVINST, ULONG );
CONFIGRET WINAPI CM_Setup_DevNode_Ex( DEVINST, ULONG, HMACHINE );
CONFIGRET WINAPI CM_Uninstall_DevNode( DEVINST, ULONG );
CONFIGRET WINAPI CM_Uninstall_DevNode_Ex( DEVINST, ULONG, HMACHINE );
#endif /* _CFGMGR32_H_ */

View file

@ -64,10 +64,68 @@ static BOOL GuidToString(LPGUID Guid, LPWSTR String)
}
/***********************************************************************
* CMP_Init_Detection [SETUPAPI.@]
*/
CONFIGRET WINAPI CMP_Init_Detection(
DWORD dwMagic)
{
RPC_BINDING_HANDLE BindingHandle = NULL;
TRACE("%lu\n", dwMagic);
if (dwMagic != CMP_MAGIC)
return CR_INVALID_DATA;
if (!PnpGetLocalHandles(&BindingHandle, NULL))
return CR_FAILURE;
return PNP_InitDetection(BindingHandle);
}
/***********************************************************************
* CMP_Report_LogOn [SETUPAPI.@]
*/
CONFIGRET WINAPI CMP_Report_LogOn(
DWORD dwMagic,
DWORD dwProcessId)
{
RPC_BINDING_HANDLE BindingHandle = NULL;
CONFIGRET ret = CR_SUCCESS;
BOOL bAdmin;
DWORD i;
TRACE("%lu\n", dwMagic);
if (dwMagic != CMP_MAGIC)
return CR_INVALID_DATA;
if (!PnpGetLocalHandles(&BindingHandle, NULL))
return CR_FAILURE;
bAdmin = TRUE; //IsUserAdmin();
for (i = 0; i < 30; i++)
{
ret = PNP_ReportLogOn(BindingHandle,
bAdmin,
dwProcessId);
if (ret == CR_SUCCESS)
break;
Sleep(5000);
}
return ret;
}
/***********************************************************************
* CM_Connect_MachineA [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Connect_MachineA(PCSTR UNCServerName, PHMACHINE phMachine)
CONFIGRET WINAPI CM_Connect_MachineA(
PCSTR UNCServerName, PHMACHINE phMachine)
{
PWSTR pServerNameW;
CONFIGRET ret;
@ -91,7 +149,8 @@ CONFIGRET WINAPI CM_Connect_MachineA(PCSTR UNCServerName, PHMACHINE phMachine)
/***********************************************************************
* CM_Connect_MachineW [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Connect_MachineW(PCWSTR UNCServerName, PHMACHINE phMachine)
CONFIGRET WINAPI CM_Connect_MachineW(
PCWSTR UNCServerName, PHMACHINE phMachine)
{
PMACHINE_INFO pMachine;
@ -128,7 +187,8 @@ CONFIGRET WINAPI CM_Connect_MachineW(PCWSTR UNCServerName, PHMACHINE phMachine)
/***********************************************************************
* CM_Delete_Class_Key [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Delete_Class_Key(LPGUID ClassGuid, ULONG ulFlags)
CONFIGRET WINAPI CM_Delete_Class_Key(
LPGUID ClassGuid, ULONG ulFlags)
{
TRACE("%p %lx\n", ClassGuid, ulFlags);
return CM_Delete_Class_Key_Ex(ClassGuid, ulFlags, NULL);
@ -1835,6 +1895,73 @@ CONFIGRET WINAPI CM_Locate_DevNode_ExW(
}
/***********************************************************************
* CM_Move_DevNode [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Move_DevNode(
DEVINST dnFromDevInst, DEVINST dnToDevInst, ULONG ulFlags)
{
TRACE("%lx %lx %lx\n", dnFromDevInst, dnToDevInst, ulFlags);
return CM_Move_DevNode_Ex(dnFromDevInst, dnToDevInst, ulFlags, NULL);
}
/***********************************************************************
* CM_Move_DevNode_Ex [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Move_DevNode_Ex(
DEVINST dnFromDevInst, DEVINST dnToDevInst, ULONG ulFlags,
HMACHINE hMachine)
{
RPC_BINDING_HANDLE BindingHandle = NULL;
HSTRING_TABLE StringTable = NULL;
LPWSTR lpFromDevInst;
LPWSTR lpToDevInst;
FIXME("%lx %lx %lx %lx\n",
dnFromDevInst, dnToDevInst, ulFlags, hMachine);
// if (!IsUserAdmin())
// return CR_ACCESS_DENIED;
if (dnFromDevInst == 0 || dnToDevInst == 0)
return CR_INVALID_DEVNODE;
if (ulFlags != 0)
return CR_INVALID_FLAG;
if (hMachine != NULL)
{
BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
if (BindingHandle == NULL)
return CR_FAILURE;
StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
if (StringTable == 0)
return CR_FAILURE;
}
else
{
if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
return CR_FAILURE;
}
lpFromDevInst = StringTableStringFromId(StringTable, dnFromDevInst);
if (lpFromDevInst == NULL)
return CR_INVALID_DEVNODE;
lpToDevInst = StringTableStringFromId(StringTable, dnToDevInst);
if (lpToDevInst == NULL)
return CR_INVALID_DEVNODE;
return PNP_DeviceInstanceAction(BindingHandle,
2,
ulFlags,
lpFromDevInst,
lpToDevInst);
}
/***********************************************************************
* CM_Open_Class_KeyA [SETUPAPI.@]
*/
@ -2464,3 +2591,118 @@ CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExW(
ulLength,
ulFlags);
}
/***********************************************************************
* CM_Setup_DevNode [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Setup_DevNode(
DEVINST dnDevInst, ULONG ulFlags)
{
TRACE("%lx %lx\n", dnDevInst, ulFlags);
return CM_Setup_DevNode_Ex(dnDevInst, ulFlags, NULL);
}
/***********************************************************************
* CM_Setup_DevNode_Ex [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Setup_DevNode_Ex(
DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
{
RPC_BINDING_HANDLE BindingHandle = NULL;
HSTRING_TABLE StringTable = NULL;
LPWSTR lpDevInst;
FIXME("%lx %lx %lx\n", dnDevInst, ulFlags, hMachine);
// if (!IsUserAdmin())
// return CR_ACCESS_DENIED;
if (dnDevInst == 0)
return CR_INVALID_DEVNODE;
if (ulFlags & ~CM_SETUP_BITS)
return CR_INVALID_FLAG;
if (hMachine != NULL)
{
BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
if (BindingHandle == NULL)
return CR_FAILURE;
StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
if (StringTable == 0)
return CR_FAILURE;
}
else
{
if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
return CR_FAILURE;
}
lpDevInst = StringTableStringFromId(StringTable, dnDevInst);
if (lpDevInst == NULL)
return CR_INVALID_DEVNODE;
return PNP_DeviceInstanceAction(BindingHandle,
3,
ulFlags,
lpDevInst,
NULL);
}
/***********************************************************************
* CM_Uninstall_DevNode [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Uninstall_DevNode(
DEVINST dnPhantom, ULONG ulFlags)
{
TRACE("%lx %lx\n", dnPhantom, ulFlags);
return CM_Uninstall_DevNode_Ex(dnPhantom, ulFlags, NULL);
}
/***********************************************************************
* CM_Uninstall_DevNode_Ex [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Uninstall_DevNode_Ex(
DEVINST dnPhantom, ULONG ulFlags, HMACHINE hMachine)
{
RPC_BINDING_HANDLE BindingHandle = NULL;
HSTRING_TABLE StringTable = NULL;
LPWSTR lpDevInst;
TRACE("%lx %lx %lx\n", dnPhantom, ulFlags, hMachine);
if (dnPhantom == 0)
return CR_INVALID_DEVNODE;
if (ulFlags != 0)
return CR_INVALID_FLAG;
if (hMachine != NULL)
{
BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
if (BindingHandle == NULL)
return CR_FAILURE;
StringTable = ((PMACHINE_INFO)hMachine)->StringTable;
if (StringTable == 0)
return CR_FAILURE;
}
else
{
if (!PnpGetLocalHandles(&BindingHandle, &StringTable))
return CR_FAILURE;
}
lpDevInst = StringTableStringFromId(StringTable, dnPhantom);
if (lpDevInst == NULL)
return CR_INVALID_DEVNODE;
return PNP_UninstallDevInst(BindingHandle,
lpDevInst,
ulFlags);
}

View file

@ -58,6 +58,10 @@ static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0";
static HKEY hEnumKey = NULL;
static HKEY hClassKey = NULL;
static HANDLE hUserToken = NULL;
static HANDLE hInstallEvent = NULL;
/* FUNCTIONS *****************************************************************/
static DWORD WINAPI
@ -159,6 +163,42 @@ PNP_InitDetection(handle_t BindingHandle)
}
/* Function 5 */
CONFIGRET
PNP_ReportLogOn(handle_t BindingHandle,
unsigned long Admin,
unsigned long ProcessId)
{
HANDLE hProcess;
DPRINT1("PNP_ReportLogOn(%lu, %lu) called\n", Admin, ProcessId);
/* Get the users token */
hProcess = OpenProcess(PROCESS_ALL_ACCESS,
TRUE,
ProcessId);
if (hProcess != NULL)
{
if (hUserToken != NULL)
{
CloseHandle(hUserToken);
hUserToken = NULL;
}
OpenProcessToken(hProcess,
TOKEN_ALL_ACCESS,
&hUserToken);
CloseHandle(hProcess);
}
/* Trigger the installer thread */
if (hInstallEvent != NULL)
SetEvent(hInstallEvent);
return CR_SUCCESS;
}
/* Function 6 */
CONFIGRET
PNP_ValidateDeviceInstance(handle_t BindingHandle,
@ -684,6 +724,23 @@ PNP_SetDeviceRegProp(handle_t BindingHandle,
}
/* Function 15 */
CONFIGRET
PNP_GetClassInstance(handle_t BindingHandle,
wchar_t *DeviceId, /* in */
wchar_t *Buffer, /* out */
unsigned long Length)
{
CONFIGRET ret = CR_SUCCESS;
DPRINT("PNP_Get_Class_Instance() called\n");
DPRINT("PNP_Get_Class_Instance() done (returns %lx)\n", ret);
return ret;
}
/* Function 16 */
CONFIGRET
PNP_CreateKey(handle_t BindingHandle,
@ -849,16 +906,34 @@ PNP_DeviceInstanceAction(handle_t BindingHandle,
switch (MajorAction)
{
case 2:
DPRINT("Move device instance\n");
/* FIXME */
ret = CR_CALL_NOT_IMPLEMENTED;
break;
case 3:
DPRINT("Setup device instance\n");
/* FIXME */
ret = CR_CALL_NOT_IMPLEMENTED;
break;
case 4:
DPRINT("Enable device instance\n");
/* FIXME */
ret = CR_CALL_NOT_IMPLEMENTED;
break;
case 5:
DPRINT("Disable device instance\n");
/* FIXME */
ret = CR_CALL_NOT_IMPLEMENTED;
break;
case 7:
DPRINT("Reenumerate device instance\n");
/* FIXME */
ret = CR_CALL_NOT_IMPLEMENTED;
break;
default:
@ -909,6 +984,7 @@ PNP_GetDeviceStatus(handle_t BindingHandle,
}
/* Function 31 */
CONFIGRET
PNP_SetDeviceProblem(handle_t BindingHandle,
wchar_t *DeviceInstance,
@ -927,6 +1003,24 @@ PNP_SetDeviceProblem(handle_t BindingHandle,
}
/* Function 33 */
CONFIGRET
PNP_UninstallDevInst(handle_t BindingHandle,
wchar_t *DeviceInstance,
DWORD Flags)
{
CONFIGRET ret = CR_SUCCESS;
DPRINT1("PNP_UninstallDevInst() called\n");
/* FIXME */
DPRINT1("PNP_UninstallDevInst() done (returns %lx)\n", ret);
return ret;
}
/* Function 38 */
CONFIGRET
PNP_IsDockStationPresent(handle_t BindingHandle,
@ -1184,6 +1278,14 @@ main(int argc, char *argv[])
DPRINT("Umpnpmgr: main() started\n");
hInstallEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hInstallEvent == NULL)
{
dwError = GetLastError();
DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError);
return dwError;
}
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"System\\CurrentControlSet\\Enum",
0,