diff --git a/reactos/include/idl/pnp.idl b/reactos/include/idl/pnp.idl index 738afac4300..0f44d89419e 100644 --- a/reactos/include/idl/pnp.idl +++ b/reactos/include/idl/pnp.idl @@ -29,15 +29,15 @@ interface pnp [out, string, size_is(Length)] wchar_t *DeviceInstance, [in] DWORD Length); -// cpp_quote("#define PNP_DEVICE_PARENT 1") -// cpp_quote("#define PNP_DEVICE_CHILD 2") -// cpp_quote("#define PNP_DEVICE_SIBLING 3") -// CONFIGRET PNP_GetRelatedDeviceInstance(handle_t BindingHandle, -// [in] DWORD Relationship, -// [in, string] wchar_t *DeviceId, -// [out, string, size_is(Length)] wchar_t *RelatedDeviceId, -// [in] DWORD Length, -// [in] DWORD Flags); + cpp_quote("#define PNP_DEVICE_PARENT 1") + cpp_quote("#define PNP_DEVICE_CHILD 2") + cpp_quote("#define PNP_DEVICE_SIBLING 3") + CONFIGRET PNP_GetRelatedDeviceInstance(handle_t BindingHandle, + [in] DWORD Relationship, + [in, string] wchar_t *DeviceId, + [out, string, size_is(Length)] wchar_t *RelatedDeviceId, + [in] DWORD Length, + [in] DWORD Flags); CONFIGRET PNP_GetDepth(handle_t BindingHandle, [in, string] wchar_t *DeviceInstance, @@ -49,4 +49,9 @@ interface pnp [out] unsigned long *Status, [out] unsigned long *Problem, [in] DWORD Flags); + + CONFIGRET PNP_SetDeviceProblem(handle_t BindingHandle, + [in, string] wchar_t *DeviceInstance, + [in] unsigned long Problem, + [in] DWORD Flags); } diff --git a/reactos/include/wine/cfgmgr32.h b/reactos/include/wine/cfgmgr32.h index c64c3609640..c4babda438f 100644 --- a/reactos/include/wine/cfgmgr32.h +++ b/reactos/include/wine/cfgmgr32.h @@ -84,6 +84,15 @@ DECL_WINELIB_CFGMGR32_TYPE_AW(DEVINSTID) #define CM_LOCATE_DEVINST_NOVALIDATION CM_LOCATE_DEVNODE_NOVALIDATION #define CM_LOCATE_DEVINST_BITS CM_LOCATE_DEVNODE_BITS +/* ulFlags for CM_Set_DevNode_Problem[_Ex] */ +#define CM_SET_DEVNODE_PROBLEM_NORMAL 0x00000000 +#define CM_SET_DEVNODE_PROBLEM_OVERRIDE 0x00000001 +#define CM_SET_DEVNODE_PROBLEM_BITS 0x00000001 + +#define CM_SET_DEVINST_PROBLEM_NORMAL CM_SET_DEVNODE_PROBLEM_NORMAL +#define CM_SET_DEVINST_PROBLEM_OVERRIDE CM_SET_DEVNODE_PROBLEM_OVERRIDE +#define CM_SET_DEVINST_PROBLEM_BITS CM_SET_DEVNODE_PROBLEM_BITS + CONFIGRET WINAPI CM_Connect_MachineA( PCSTR, PHMACHINE ); CONFIGRET WINAPI CM_Connect_MachineW( PCWSTR, PHMACHINE ); @@ -141,5 +150,7 @@ CONFIGRET WINAPI CM_Open_Class_Key_ExA(LPGUID, LPCSTR, REGSAM, REGDISPOSITION, P 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_Set_DevNode_Problem( DEVINST, ULONG, ULONG ); +CONFIGRET WINAPI CM_Set_DevNode_Problem_Ex( DEVINST, ULONG, ULONG, HMACHINE ); #endif /* _CFGMGR32_H_ */ diff --git a/reactos/lib/setupapi/cfgmgr.c b/reactos/lib/setupapi/cfgmgr.c index fe644d21a9b..bab775a7d51 100644 --- a/reactos/lib/setupapi/cfgmgr.c +++ b/reactos/lib/setupapi/cfgmgr.c @@ -251,7 +251,6 @@ CONFIGRET WINAPI CM_Get_Child( CONFIGRET WINAPI CM_Get_Child_Ex( PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine) { -#if 0 WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; RPC_BINDING_HANDLE BindingHandle = NULL; HSTRING_TABLE StringTable = NULL; @@ -310,9 +309,6 @@ CONFIGRET WINAPI CM_Get_Child_Ex( *pdnDevInst = dwIndex; return CR_SUCCESS; -#endif - FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); - return CR_FAILURE; } @@ -322,8 +318,7 @@ CONFIGRET WINAPI CM_Get_Child_Ex( CONFIGRET WINAPI CM_Get_Depth( PULONG pulDepth, DEVINST dnDevInst, ULONG ulFlags) { - TRACE("%p %lx %lx\n", - pulDepth, dnDevInst, ulFlags); + TRACE("%p %lx %lx\n", pulDepth, dnDevInst, ulFlags); return CM_Get_Depth_Ex(pulDepth, dnDevInst, ulFlags, NULL); } @@ -738,7 +733,6 @@ CONFIGRET WINAPI CM_Get_Parent( CONFIGRET WINAPI CM_Get_Parent_Ex( PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine) { -#if 0 WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; RPC_BINDING_HANDLE BindingHandle = NULL; HSTRING_TABLE StringTable = NULL; @@ -797,9 +791,6 @@ CONFIGRET WINAPI CM_Get_Parent_Ex( *pdnDevInst = dwIndex; return CR_SUCCESS; -#endif - FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); - return CR_FAILURE; } @@ -820,7 +811,6 @@ CONFIGRET WINAPI CM_Get_Sibling( CONFIGRET WINAPI CM_Get_Sibling_Ex( PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine) { -#if 0 WCHAR szRelatedDevInst[MAX_DEVICE_ID_LEN]; RPC_BINDING_HANDLE BindingHandle = NULL; HSTRING_TABLE StringTable = NULL; @@ -879,9 +869,6 @@ CONFIGRET WINAPI CM_Get_Sibling_Ex( *pdnDevInst = dwIndex; return CR_SUCCESS; -#endif - FIXME("%p %lx %lx %lx\n", pdnDevInst, dnDevInst, ulFlags, hMachine); - return CR_FAILURE; } @@ -1035,3 +1022,60 @@ CONFIGRET WINAPI CM_Locate_DevNode_ExW( return rc; } + + +/*********************************************************************** + * CM_Set_DevNode_Problem [SETUPAPI.@] + */ +CONFIGRET WINAPI CM_Set_DevNode_Problem( + DEVINST dnDevInst, ULONG ulProblem, ULONG ulFlags) +{ + TRACE("%lx %lx %lx\n", dnDevInst, ulProblem, ulFlags); + return CM_Set_DevNode_Problem_Ex(dnDevInst, ulProblem, ulFlags, NULL); +} + + +/*********************************************************************** + * CM_Set_DevNode_Problem_Ex [SETUPAPI.@] + */ +CONFIGRET WINAPI CM_Set_DevNode_Problem_Ex( + DEVINST dnDevInst, ULONG ulProblem, ULONG ulFlags, HMACHINE hMachine) +{ + RPC_BINDING_HANDLE BindingHandle = NULL; + HSTRING_TABLE StringTable = NULL; + LPWSTR lpDevInst; + CONFIGRET rc = CR_SUCCESS; + + TRACE("%lx %lx %lx %lx\n", dnDevInst, ulProblem, ulFlags, hMachine); + + if (dnDevInst == 0) + return CR_INVALID_DEVNODE; + + if (ulFlags & ~CM_SET_DEVNODE_PROBLEM_BITS) + return CR_INVALID_FLAG; + + if (hMachine != NULL) + { + BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; + if (BindingHandle == NULL) + return CR_FAILURE; + + StringTable = ((PMACHINE_INFO)hMachine)->StringTable; + if (StringTable == 0) + return CR_FAILURE; + } + else + { + if (!PnpGetLocalHandles(&BindingHandle, &StringTable)) + return CR_FAILURE; + } + + lpDevInst = StringTableStringFromId(StringTable, dnDevInst); + if (lpDevInst == NULL) + return CR_INVALID_DEVNODE; + + return PNP_SetDeviceProblem(BindingHandle, + lpDevInst, + ulProblem, + ulFlags); +} diff --git a/reactos/lib/setupapi/setupapi.spec b/reactos/lib/setupapi/setupapi.spec index de0e4d1767d..53ffbd16e44 100644 --- a/reactos/lib/setupapi/setupapi.spec +++ b/reactos/lib/setupapi/setupapi.spec @@ -170,8 +170,8 @@ @ stub CM_Reset_Children_Marks_Ex @ stub CM_Run_Detection @ stub CM_Run_Detection_Ex -@ stub CM_Set_DevNode_Problem -@ stub CM_Set_DevNode_Problem_Ex +@ stdcall CM_Set_DevNode_Problem(long long long) +@ stdcall CM_Set_DevNode_Problem_Ex(long long long long) @ stub CM_Set_DevNode_Registry_PropertyA @ stub CM_Set_DevNode_Registry_PropertyW @ stub CM_Set_DevNode_Registry_Property_ExA diff --git a/reactos/services/umpnpmgr/umpnpmgr.c b/reactos/services/umpnpmgr/umpnpmgr.c index aa3db115ee2..8c2256889b0 100644 --- a/reactos/services/umpnpmgr/umpnpmgr.c +++ b/reactos/services/umpnpmgr/umpnpmgr.c @@ -48,8 +48,8 @@ ServiceMain(DWORD argc, LPTSTR *argv); static SERVICE_TABLE_ENTRY ServiceTable[2] = { - {TEXT("PlugPlay"), ServiceMain}, - {NULL, NULL} + {TEXT("PlugPlay"), ServiceMain}, + {NULL, NULL} }; static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0"; @@ -59,41 +59,41 @@ static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0"; static DWORD WINAPI RpcServerThread(LPVOID lpParameter) { - RPC_STATUS Status; + RPC_STATUS Status; - DPRINT("RpcServerThread() called\n"); + DPRINT("RpcServerThread() called\n"); + + Status = RpcServerUseProtseqEpW(L"ncacn_np", + 20, + L"\\pipe\\umpnpmgr", + NULL); // Security descriptor + if (Status != RPC_S_OK) + { + DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); + return 0; + } + + Status = 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; + } + + DPRINT("RpcServerThread() done\n"); - Status = RpcServerUseProtseqEpW(L"ncacn_np", - 20, - L"\\pipe\\umpnpmgr", - NULL); // Security descriptor - if (Status != RPC_S_OK) - { - DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); return 0; - } - - Status = 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; - } - - DPRINT("RpcServerThread() done\n"); - - return 0; } @@ -202,7 +202,6 @@ Done: } -#if 0 CONFIGRET PNP_GetRelatedDeviceInstance(handle_t BindingHandle, unsigned long Relationship, @@ -211,21 +210,40 @@ PNP_GetRelatedDeviceInstance(handle_t BindingHandle, unsigned long Length, unsigned long Flags) { + PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData; CONFIGRET ret = CR_SUCCESS; + NTSTATUS Status; - DPRINT1("PNP_GetRelatedDeviceInstance() called\n"); - DPRINT1(" Relationship %ld\n", Relationship); - DPRINT1(" DeviceId %S\n", DeviceId); + DPRINT("PNP_GetRelatedDeviceInstance() called\n"); + DPRINT(" Relationship %ld\n", Relationship); + DPRINT(" DeviceId %S\n", DeviceId); - lstrcpyW(RelatedDeviceId, - szRootDeviceId); + RtlInitUnicodeString(&PlugPlayData.TargetDeviceInstance, + DeviceId); -//Done: - DPRINT1("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret); + PlugPlayData.Relation = Relationship; + + PlugPlayData.RelatedDeviceInstance.Length = 0; + PlugPlayData.RelatedDeviceInstance.MaximumLength = Length; + PlugPlayData.RelatedDeviceInstance.Buffer = RelatedDeviceId; + + Status = NtPlugPlayControl(PlugPlayControlGetRelatedDevice, + (PVOID)&PlugPlayData, + sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA)); + if (!NT_SUCCESS(Status)) + { + /* FIXME: Map Status to ret */ + ret = CR_FAILURE; + } + + DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret); + if (ret == 0) + { + DPRINT("RelatedDevice: %wZ\n", &PlugPlayData.RelatedDeviceInstance); + } return ret; } -#endif CONFIGRET @@ -297,104 +315,124 @@ PNP_GetDeviceStatus(handle_t BindingHandle, } +CONFIGRET +PNP_SetDeviceProblem(handle_t BindingHandle, + wchar_t *DeviceInstance, + unsigned long Problem, + DWORD Flags) +{ + CONFIGRET ret = CR_SUCCESS; + + DPRINT1("PNP_SetDeviceProblem() called\n"); + + /* FIXME */ + + DPRINT1("PNP_SetDeviceProblem() done (returns %lx)\n", ret); + + return ret; +} + + static DWORD WINAPI PnpEventThread(LPVOID lpParameter) { - PPLUGPLAY_EVENT_BLOCK PnpEvent; - ULONG PnpEventSize; - NTSTATUS Status; - RPC_STATUS RpcStatus; + PPLUGPLAY_EVENT_BLOCK PnpEvent; + ULONG PnpEventSize; + NTSTATUS Status; + RPC_STATUS RpcStatus; - PnpEventSize = 0x1000; - PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize); - if (PnpEvent == NULL) - return ERROR_OUTOFMEMORY; - - for (;;) - { - DPRINT("Calling NtGetPlugPlayEvent()\n"); - - /* Wait for the next pnp event */ - Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize); - /* Resize the buffer for the PnP event if it's too small. */ - if (Status == STATUS_BUFFER_TOO_SMALL) - { - PnpEventSize += 0x400; - PnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize); - if (PnpEvent == NULL) + PnpEventSize = 0x1000; + PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize); + if (PnpEvent == NULL) return ERROR_OUTOFMEMORY; - continue; - } - if (!NT_SUCCESS(Status)) + + for (;;) { - DPRINT("NtPlugPlayEvent() failed (Status %lx)\n", Status); - break; + DPRINT("Calling NtGetPlugPlayEvent()\n"); + + /* Wait for the next pnp event */ + Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize); + + /* Resize the buffer for the PnP event if it's too small. */ + if (Status == STATUS_BUFFER_TOO_SMALL) + { + PnpEventSize += 0x400; + PnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize); + if (PnpEvent == NULL) + return ERROR_OUTOFMEMORY; + continue; + } + + if (!NT_SUCCESS(Status)) + { + DPRINT("NtPlugPlayEvent() failed (Status %lx)\n", Status); + break; + } + + DPRINT("Received PnP Event\n"); + if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus)) + { + DPRINT1("Device arrival event: %S\n", PnpEvent->TargetDevice.DeviceIds); + } + else + { + DPRINT1("Unknown event\n"); + } + + /* FIXME: Process the pnp event */ + + /* Dequeue the current pnp event and signal the next one */ + NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0); } - DPRINT("Received PnP Event\n"); - if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus)) - { - DPRINT1("Device arrival event: %S\n", PnpEvent->TargetDevice.DeviceIds); - } - else - { - DPRINT1("Unknown event\n"); - } + HeapFree(GetProcessHeap(), 0, PnpEvent); - /* FIXME: Process the pnp event */ - - /* Dequeue the current pnp event and signal the next one */ - NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0); - } - - HeapFree(GetProcessHeap(), 0, PnpEvent); - - return ERROR_SUCCESS; + return ERROR_SUCCESS; } static VOID CALLBACK ServiceMain(DWORD argc, LPTSTR *argv) { - HANDLE hThread; - DWORD dwThreadId; + HANDLE hThread; + DWORD dwThreadId; - DPRINT("ServiceMain() called\n"); + DPRINT("ServiceMain() called\n"); - hThread = CreateThread(NULL, - 0, - PnpEventThread, - NULL, - 0, - &dwThreadId); - if (hThread != NULL) - CloseHandle(hThread); + hThread = CreateThread(NULL, + 0, + PnpEventThread, + NULL, + 0, + &dwThreadId); + if (hThread != NULL) + CloseHandle(hThread); - hThread = CreateThread(NULL, - 0, - RpcServerThread, - NULL, - 0, - &dwThreadId); - if (hThread != NULL) - CloseHandle(hThread); + hThread = CreateThread(NULL, + 0, + RpcServerThread, + NULL, + 0, + &dwThreadId); + if (hThread != NULL) + CloseHandle(hThread); - DPRINT("ServiceMain() done\n"); + DPRINT("ServiceMain() done\n"); } int main(int argc, char *argv[]) { - DPRINT("Umpnpmgr: main() started\n"); + DPRINT("Umpnpmgr: main() started\n"); - StartServiceCtrlDispatcher(ServiceTable); + StartServiceCtrlDispatcher(ServiceTable); - DPRINT("Umpnpmgr: main() done\n"); + DPRINT("Umpnpmgr: main() done\n"); - ExitThread(0); + ExitThread(0); - return 0; + return 0; } /* EOF */ diff --git a/reactos/w32api/include/ddk/cfgmgr32.h b/reactos/w32api/include/ddk/cfgmgr32.h index 948b5281815..b49e0da7b37 100644 --- a/reactos/w32api/include/ddk/cfgmgr32.h +++ b/reactos/w32api/include/ddk/cfgmgr32.h @@ -108,7 +108,7 @@ extern "C" { typedef DWORD RETURN_TYPE; -typedef RETURN_TYPE CONFIGRET; +typedef RETURN_TYPE CONFIGRET; typedef HANDLE HMACHINE; typedef HMACHINE *PHMACHINE;