- Implement CM_Disable_DevNode[_Ex], CM_Enable_DevNode[_Ex], CM_Reenumerate_DevNode...
authorEric Kohl <eric.kohl@reactos.org>
Sat, 17 Dec 2005 12:23:41 +0000 (12:23 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 17 Dec 2005 12:23:41 +0000 (12:23 +0000)
- Implement StringTableAddStringEx and StringTableLookUpStringEx.

svn path=/trunk/; revision=20223

reactos/include/idl/pnp.idl
reactos/include/wine/cfgmgr32.h
reactos/lib/setupapi/cfgmgr.c
reactos/lib/setupapi/setupapi.spec
reactos/lib/setupapi/stringtable.c
reactos/services/umpnpmgr/umpnpmgr.c
reactos/w32api/include/ddk/cfgmgr32.h

index d9ff1a7..5a6f98f 100644 (file)
@@ -30,6 +30,9 @@ interface pnp
                                [out] unsigned long *State,\r
                                [in] unsigned long Flags);\r
 \r
+  /* Function 4 */\r
+  CONFIGRET PNP_InitDetection(handle_t BindingHandle);\r
+\r
   /* Function 6 */\r
   CONFIGRET PNP_ValidateDeviceInstance(handle_t BindingHandle,\r
                                        [in, string] wchar_t *DeviceInstance,\r
@@ -106,6 +109,13 @@ interface pnp
                           [in] unsigned long DesiredAccess,\r
                           [in] unsigned long Flags);\r
 \r
+  /* Function 17 */\r
+  CONFIGRET PNP_DeleteRegistryKey(handle_t BindingHandle,\r
+                                  [in, string] wchar_t *DeviceId,\r
+                                  [in, string] wchar_t *ParentKey,\r
+                                  [in, string] wchar_t *ChildKey,\r
+                                  [in] unsigned long Flags);\r
+\r
   /* Function 19 */\r
   CONFIGRET PNP_GetClassName(handle_t BindingHandle,\r
                              [in, string] wchar_t *ClassGuid,\r
@@ -118,6 +128,13 @@ interface pnp
                                [in, string] wchar_t *ClassGuid,\r
                                [in] unsigned long Flags);\r
 \r
+  /* Function 29 */\r
+  CONFIGRET PNP_DeviceInstanceAction(handle_t BindingHandle,\r
+                                     [in] unsigned long MajorAction,\r
+                                     [in] unsigned long MinorAction,\r
+                                     [in, unique, string] wchar_t *DeviceInstance1,\r
+                                     [in, unique, string] wchar_t *DeviceInstance2);\r
+\r
   /* Function 30 */\r
   CONFIGRET PNP_GetDeviceStatus(handle_t BindingHandle,\r
                                 [in, string] wchar_t *DeviceInstance,\r
@@ -137,4 +154,8 @@ interface pnp
 \r
   /* Function 39 */\r
   CONFIGRET PNP_RequestEjectPC(handle_t BindingHandle);\r
+\r
+  /* Function 58 */\r
+  CONFIGRET PNP_RunDetection(handle_t BindingHandle,\r
+                             [in] unsigned long Flags);\r
 }\r
index 70853f6..23c29ad 100644 (file)
@@ -139,13 +139,31 @@ DECL_WINELIB_CFGMGR32_TYPE_AW(DEVINSTID)
 #define CM_GETIDLIST_DONOTGENERATE              (0x10000040)
 #define CM_GETIDLIST_FILTER_BITS                (0x1000007F)
 
+/* ulFlags for CM_Reenumerate_DevNode[_Ex] */
+#define CM_REENUMERATE_NORMAL             0x00000000
+#define CM_REENUMERATE_SYNCHRONOUS        0x00000001
+#define CM_REENUMERATE_RETRY_INSTALLATION 0x00000002
+#define CM_REENUMERATE_ASYNCHRONOUS       0x00000004
+#define CM_REENUMERATE_BITS               0x00000007
+
+/* ulFlags for CM_Run_Detection[_Ex] */
+#define CM_DETECT_NEW_PROFILE       0x00000001
+#define CM_DETECT_CRASHED           0x00000002
+#define CM_DETECT_HWPROF_FIRST_BOOT 0x00000004
+#define CM_DETECT_RUN               0x80000000
+#define CM_DETECT_BITS              0x80000007
+
 
 CONFIGRET WINAPI CM_Connect_MachineA( PCSTR, PHMACHINE );
 CONFIGRET WINAPI CM_Connect_MachineW( PCWSTR, PHMACHINE );
 #define     CM_Connect_Machine WINELIB_NAME_AW(CM_Connect_Machine)
 CONFIGRET WINAPI CM_Delete_Class_Key( LPGUID, ULONG );
 CONFIGRET WINAPI CM_Delete_Class_Key_Ex( LPGUID, ULONG, HANDLE );
+CONFIGRET WINAPI CM_Disable_DevNode( DEVINST, ULONG );
+CONFIGRET WINAPI CM_Disable_DevNode_Ex( DEVINST, ULONG, HMACHINE );
 CONFIGRET WINAPI CM_Disconnect_Machine( HMACHINE );
+CONFIGRET WINAPI CM_Enable_DevNode( DEVINST, ULONG );
+CONFIGRET WINAPI CM_Enable_DevNode_Ex( DEVINST, ULONG, HMACHINE );
 CONFIGRET WINAPI CM_Enumerate_Classes( ULONG, LPGUID, ULONG );
 CONFIGRET WINAPI CM_Enumerate_Classes_Ex( ULONG, LPGUID, ULONG, HMACHINE );
 CONFIGRET WINAPI CM_Enumerate_EnumeratorsA( ULONG, PCHAR, PULONG, ULONG );
@@ -223,9 +241,14 @@ 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_Reenumerate_DevNode( DEVINST, ULONG );
+CONFIGRET WINAPI CM_Reenumerate_DevNode_Ex( DEVINST, ULONG, HMACHINE );
+
 CONFIGRET WINAPI CM_Request_Eject_PC( VOID );
 CONFIGRET WINAPI CM_Request_Eject_PC_Ex( HMACHINE );
 
+CONFIGRET WINAPI CM_Run_Detection( ULONG );
+CONFIGRET WINAPI CM_Run_Detection_Ex( ULONG, HMACHINE );
 CONFIGRET WINAPI CM_Set_DevNode_Problem( DEVINST, ULONG, ULONG );
 CONFIGRET WINAPI CM_Set_DevNode_Problem_Ex( DEVINST, ULONG, ULONG, HMACHINE );
 CONFIGRET WINAPI CM_Set_DevNode_Registry_PropertyA( DEVINST, ULONG, PCVOID, ULONG, ULONG );
index 8a7daad..0c8ec89 100644 (file)
@@ -173,6 +173,66 @@ CONFIGRET WINAPI CM_Delete_Class_Key_Ex(
 }
 
 
+/***********************************************************************
+ * CM_Disable_DevNode [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Disable_DevNode(
+    DEVINST dnDevInst, ULONG ulFlags)
+{
+    TRACE("%p %lx\n", dnDevInst, ulFlags);
+    return CM_Disable_DevNode_Ex(dnDevInst, ulFlags, NULL);
+}
+
+
+/***********************************************************************
+ * CM_Disable_DevNode_Ex [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Disable_DevNode_Ex(
+    DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
+{
+    RPC_BINDING_HANDLE BindingHandle = NULL;
+    HSTRING_TABLE StringTable = NULL;
+    LPWSTR lpDevInst;
+
+    FIXME("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
+
+//    if (!IsUserAdmin())
+//        return CR_ACCESS_DENIED;
+
+    if (dnDevInst == 0)
+        return CR_INVALID_DEVINST;
+
+    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, dnDevInst);
+    if (lpDevInst == NULL)
+        return CR_INVALID_DEVNODE;
+
+    return PNP_DeviceInstanceAction(BindingHandle,
+                                    5,
+                                    ulFlags,
+                                    lpDevInst,
+                                    NULL);
+}
+
+
 /***********************************************************************
  * CM_Disconnect_Machine [SETUPAPI.@]
  */
@@ -198,6 +258,66 @@ CONFIGRET WINAPI CM_Disconnect_Machine(HMACHINE hMachine)
 }
 
 
+/***********************************************************************
+ * CM_Enable_DevNode [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Enable_DevNode(
+    DEVINST dnDevInst, ULONG ulFlags)
+{
+    TRACE("%p %lx\n", dnDevInst, ulFlags);
+    return CM_Enable_DevNode_Ex(dnDevInst, ulFlags, NULL);
+}
+
+
+/***********************************************************************
+ * CM_Enable_DevNode_Ex [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Enable_DevNode_Ex(
+    DEVINST dnDevInst, ULONG ulFlags, HMACHINE hMachine)
+{
+    RPC_BINDING_HANDLE BindingHandle = NULL;
+    HSTRING_TABLE StringTable = NULL;
+    LPWSTR lpDevInst;
+
+    FIXME("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
+
+//    if (!IsUserAdmin())
+//        return CR_ACCESS_DENIED;
+
+    if (dnDevInst == 0)
+        return CR_INVALID_DEVINST;
+
+    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, dnDevInst);
+    if (lpDevInst == NULL)
+        return CR_INVALID_DEVNODE;
+
+    return PNP_DeviceInstanceAction(BindingHandle,
+                                    4,
+                                    ulFlags,
+                                    lpDevInst,
+                                    NULL);
+}
+
+
 /***********************************************************************
  * CM_Enumerate_Classes [SETUPAPI.@]
  */
@@ -1874,6 +1994,64 @@ CONFIGRET WINAPI CM_Open_Class_Key_ExW(
 }
 
 
+/***********************************************************************
+ * CM_Reenumerate_DevNode [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Reenumerate_DevNode(
+    DEVINST dnDevInst, ULONG ulFlags)
+{
+    TRACE("%lx %lx\n", dnDevInst, ulFlags);
+    return CM_Reenumerate_DevNode_Ex(dnDevInst, ulFlags, NULL);
+}
+
+
+/***********************************************************************
+ * CM_Reenumerate_DevNode_Ex [SETUPAPI.@]
+ */
+CONFIGRET WINAPI
+CM_Reenumerate_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 (dnDevInst == 0)
+        return CR_INVALID_DEVNODE;
+
+    if (ulFlags & ~CM_REENUMERATE_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,
+                                    7,
+                                    ulFlags,
+                                    lpDevInst,
+                                    NULL);
+}
+
+
 /***********************************************************************
  * CM_Request_Eject_PC [SETUPAPI.@]
  */
@@ -1910,6 +2088,50 @@ CONFIGRET WINAPI CM_Request_Eject_PC_Ex(
 }
 
 
+/***********************************************************************
+ * CM_Run_Detection [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Run_Detection(
+    ULONG ulFlags)
+{
+    TRACE("%lx\n", ulFlags);
+    return CM_Run_Detection_Ex(ulFlags, NULL);
+}
+
+
+/***********************************************************************
+ * CM_Run_Detection_Ex [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Run_Detection_Ex(
+    ULONG ulFlags, HMACHINE hMachine)
+{
+    RPC_BINDING_HANDLE BindingHandle = NULL;
+
+    TRACE("%lx %lx\n", ulFlags, hMachine);
+
+//    if (!IsUserAdmin())
+//        return CR_ACCESS_DENIED;
+
+    if (ulFlags & ~CM_DETECT_BITS)
+        return CR_INVALID_FLAG;
+
+    if (hMachine != NULL)
+    {
+        BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
+        if (BindingHandle == NULL)
+            return CR_FAILURE;
+    }
+    else
+    {
+        if (!PnpGetLocalHandles(&BindingHandle, NULL))
+            return CR_FAILURE;
+    }
+
+    return PNP_RunDetection(BindingHandle,
+                            ulFlags);
+}
+
+
 /***********************************************************************
  * CM_Set_DevNode_Problem [SETUPAPI.@]
  */
index e7b3d58..023646d 100644 (file)
 @ stub CM_Delete_Range
 @ stub CM_Detect_Resource_Conflict
 @ stub CM_Detect_Resource_Conflict_Ex
-@ stub CM_Disable_DevNode
-@ stub CM_Disable_DevNode_Ex
+@ stdcall CM_Disable_DevNode(long long)
+@ stdcall CM_Disable_DevNode_Ex(long long ptr)
 @ stdcall CM_Disconnect_Machine(long)
 @ stub CM_Dup_Range_List
-@ stub CM_Enable_DevNode
-@ stub CM_Enable_DevNode_Ex
+@ stdcall CM_Enable_DevNode(long long)
+@ stdcall CM_Enable_DevNode_Ex(long long ptr)
 @ stdcall CM_Enumerate_Classes(long ptr long)
 @ stdcall CM_Enumerate_Classes_Ex(long ptr long ptr)
 @ stdcall CM_Enumerate_EnumeratorsA(long str ptr long)
 @ stub CM_Query_Arbitrator_Free_Size_Ex
 @ stub CM_Query_Remove_SubTree
 @ stub CM_Query_Remove_SubTree_Ex
-@ stub CM_Reenumerate_DevNode
-@ stub CM_Reenumerate_DevNode_Ex
+@ stdcall CM_Reenumerate_DevNode(long long)
+@ stdcall CM_Reenumerate_DevNode_Ex(long long long)
 @ stub CM_Register_Device_Driver
 @ stub CM_Register_Device_Driver_Ex
 @ stub CM_Register_Device_InterfaceA
 @ stub CM_Remove_Unmarked_Children_Ex
 @ stub CM_Request_Device_EjectA
 @ stub CM_Request_Device_EjectW
-@ stub CM_Request_Eject_PC
-@ stub CM_Request_Eject_PC_Ex
+@ stdcall CM_Request_Eject_PC()
+@ stdcall CM_Request_Eject_PC_Ex(long)
 @ stub CM_Reset_Children_Marks
 @ stub CM_Reset_Children_Marks_Ex
-@ stub CM_Run_Detection
-@ stub CM_Run_Detection_Ex
+@ stdcall CM_Run_Detection(long)
+@ stdcall CM_Run_Detection_Ex(long long)
 @ stdcall CM_Set_DevNode_Problem(long long long)
 @ stdcall CM_Set_DevNode_Problem_Ex(long long long long)
 @ stdcall CM_Set_DevNode_Registry_PropertyA(long long ptr long long)
index c56d5b6..9159760 100644 (file)
@@ -307,7 +307,83 @@ StringTableAddStringEx(HSTRING_TABLE hStringTable,
                        LPVOID lpExtraData,
                        DWORD dwExtraDataSize)
 {
-    FIXME("\n");
+    PSTRING_TABLE pStringTable;
+    DWORD i;
+
+    TRACE("%p %s %lx\n", (PVOID)hStringTable, debugstr_w(lpString), dwFlags);
+
+    pStringTable = (PSTRING_TABLE)hStringTable;
+    if (pStringTable == NULL)
+    {
+        ERR("Invalid hStringTable!\n");
+        return (DWORD)-1;
+    }
+
+    /* Search for existing string in the string table */
+    for (i = 0; i < pStringTable->dwMaxSlots; i++)
+    {
+        if (pStringTable->pSlots[i].pString != NULL)
+        {
+            if (dwFlags & 1)
+            {
+                if (!lstrcmpW(pStringTable->pSlots[i].pString, lpString))
+                {
+                    return i + 1;
+                }
+            }
+            else
+            {
+                if (!lstrcmpiW(pStringTable->pSlots[i].pString, lpString))
+                {
+                    return i + 1;
+                }
+            }
+        }
+    }
+
+    /* Check for filled slot table */
+    if (pStringTable->dwUsedSlots == pStringTable->dwMaxSlots)
+    {
+        FIXME("Resize the string table!\n");
+        return (DWORD)-1;
+    }
+
+    /* Search for an empty slot */
+    for (i = 0; i < pStringTable->dwMaxSlots; i++)
+    {
+        if (pStringTable->pSlots[i].pString == NULL)
+        {
+            pStringTable->pSlots[i].pString = MyMalloc((lstrlenW(lpString) + 1) * sizeof(WCHAR));
+            if (pStringTable->pSlots[i].pString == NULL)
+            {
+                TRACE("Couldn't allocate memory for a new string!\n");
+                return (DWORD)-1;
+            }
+
+            lstrcpyW(pStringTable->pSlots[i].pString, lpString);
+
+            pStringTable->pSlots[i].pData = MyMalloc(dwExtraDataSize);
+            if (pStringTable->pSlots[i].pData == NULL)
+            {
+                TRACE("Couldn't allocate memory for a new extra data!\n");
+                MyFree(pStringTable->pSlots[i].pString);
+                pStringTable->pSlots[i].pString = NULL;
+                return (DWORD)-1;
+            }
+
+            memcpy(pStringTable->pSlots[i].pData,
+                   lpExtraData,
+                   dwExtraDataSize);
+            pStringTable->pSlots[i].dwSize = dwExtraDataSize;
+
+            pStringTable->dwUsedSlots++;
+
+            return i + 1;
+        }
+    }
+
+    TRACE("Couldn't find an empty slot!\n");
+
     return (DWORD)-1;
 }
 
@@ -527,7 +603,48 @@ StringTableLookUpStringEx(HSTRING_TABLE hStringTable,
                           LPVOID lpExtraData,
                           LPDWORD lpReserved)
 {
-    FIXME("\n");
+    PSTRING_TABLE pStringTable;
+    DWORD i;
+
+    TRACE("%p %s %lx\n", (PVOID)hStringTable, debugstr_w(lpString), dwFlags);
+
+    pStringTable = (PSTRING_TABLE)hStringTable;
+    if (pStringTable == NULL)
+    {
+        ERR("Invalid hStringTable!\n");
+        return (DWORD)-1;
+    }
+
+    /* Search for existing string in the string table */
+    for (i = 0; i < pStringTable->dwMaxSlots; i++)
+    {
+        if (pStringTable->pSlots[i].pString != NULL)
+        {
+            if (dwFlags & 1)
+            {
+                if (!lstrcmpW(pStringTable->pSlots[i].pString, lpString))
+                {
+                    memcpy(lpExtraData,
+                           pStringTable->pSlots[i].pData,
+                           pStringTable->pSlots[i].dwSize);
+                    *lpReserved = 0;
+                    return i + 1;
+                }
+            }
+            else
+            {
+                if (!lstrcmpiW(pStringTable->pSlots[i].pString, lpString))
+                {
+                    memcpy(lpExtraData,
+                           pStringTable->pSlots[i].pData,
+                           pStringTable->pSlots[i].dwSize);
+                    *lpReserved = 0;
+                    return i + 1;
+                }
+            }
+        }
+    }
+
     return (DWORD)-1;
 }
 
index d54e987..6c6e1fe 100644 (file)
@@ -118,16 +118,18 @@ NtStatusToCrError(NTSTATUS Status)
 {
     switch (Status)
     {
-       case STATUS_NO_SUCH_DEVICE:
-               return CR_NO_SUCH_DEVINST;
-       default:
-               /* FIXME: add more mappings */
-               DPRINT1("Unable to map status 0x%08lx\n", Status);
-               return CR_FAILURE;
+        case STATUS_NO_SUCH_DEVICE:
+            return CR_NO_SUCH_DEVINST;
+
+        default:
+            /* FIXME: add more mappings */
+            DPRINT1("Unable to map status 0x%08lx\n", Status);
+            return CR_FAILURE;
     }
 }
 
 
+/* Function 2 */
 CONFIGRET
 PNP_GetVersion(handle_t BindingHandle,
                unsigned short *Version)
@@ -137,6 +139,7 @@ PNP_GetVersion(handle_t BindingHandle,
 }
 
 
+/* Function 3 */
 CONFIGRET
 PNP_GetGlobalState(handle_t BindingHandle,
                    unsigned long *State,
@@ -147,6 +150,16 @@ PNP_GetGlobalState(handle_t BindingHandle,
 }
 
 
+/* Function 4 */
+CONFIGRET
+PNP_InitDetection(handle_t BindingHandle)
+{
+    DPRINT("PNP_InitDetection() called\n");
+    return CR_SUCCESS;
+}
+
+
+/* Function 6 */
 CONFIGRET
 PNP_ValidateDeviceInstance(handle_t BindingHandle,
                            wchar_t *DeviceInstance,
@@ -196,6 +209,7 @@ Done:
 }
 
 
+/* Function 7 */
 CONFIGRET
 PNP_GetRootDeviceInstance(handle_t BindingHandle,
                           wchar_t *DeviceInstance,
@@ -221,6 +235,7 @@ Done:
 }
 
 
+/* Function 8 */
 CONFIGRET
 PNP_GetRelatedDeviceInstance(handle_t BindingHandle,
                              unsigned long Relationship,
@@ -264,6 +279,7 @@ PNP_GetRelatedDeviceInstance(handle_t BindingHandle,
 }
 
 
+/* Function 9 */
 CONFIGRET
 PNP_EnumerateSubKeys(handle_t BindingHandle,
                      unsigned long Branch,
@@ -317,6 +333,7 @@ PNP_EnumerateSubKeys(handle_t BindingHandle,
 }
 
 
+/* Function 11 */
 CONFIGRET
 PNP_GetDeviceListSize(handle_t BindingHandle,
                       wchar_t *Filter,
@@ -332,6 +349,7 @@ PNP_GetDeviceListSize(handle_t BindingHandle,
 }
 
 
+/* Function 12 */
 CONFIGRET
 PNP_GetDepth(handle_t BindingHandle,
              wchar_t *DeviceInstance,
@@ -365,118 +383,7 @@ PNP_GetDepth(handle_t BindingHandle,
 }
 
 
-CONFIGRET
-PNP_SetDeviceRegProp(handle_t BindingHandle,
-                     wchar_t *DeviceId,
-                     unsigned long Property,
-                     unsigned long DataType,
-                     char *Buffer,
-                     unsigned long Length,
-                     unsigned long Flags)
-{
-    CONFIGRET ret = CR_SUCCESS;
-    LPWSTR lpValueName = NULL;
-    HKEY hKey = 0;
-
-    DPRINT("PNP_SetDeviceRegProp() called\n");
-
-    DPRINT("DeviceId: %S\n", DeviceId);
-    DPRINT("Property: %lu\n", Property);
-    DPRINT("DataType: %lu\n", DataType);
-    DPRINT("Length: %lu\n", Length);
-
-    switch (Property)
-    {
-        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;
-
-        default:
-            return CR_INVALID_PROPERTY;
-    }
-
-    DPRINT("Value name: %S\n", lpValueName);
-
-    if (RegOpenKeyExW(hEnumKey,
-                      DeviceId,
-                      0,
-                      KEY_ALL_ACCESS,
-                      &hKey))
-        return CR_INVALID_DEVNODE;
-
-    if (Length == 0)
-    {
-        if (RegDeleteValueW(hKey,
-                            lpValueName))
-            ret = CR_REGISTRY_ERROR;
-    }
-    else
-    {
-        if (RegSetValueExW(hKey,
-                           lpValueName,
-                           0,
-                           DataType,
-                           (const BYTE*)Buffer,
-                           Length))
-            ret = CR_REGISTRY_ERROR;
-    }
-
-    RegCloseKey(hKey);
-
-    DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret);
-
-    return ret;
-}
-
-
+/* Function 13 */
 CONFIGRET
 PNP_GetDeviceRegProp(handle_t BindingHandle,
                      wchar_t *DeviceInstance,
@@ -664,6 +571,120 @@ PNP_GetDeviceRegProp(handle_t BindingHandle,
 }
 
 
+/* Function 14 */
+CONFIGRET
+PNP_SetDeviceRegProp(handle_t BindingHandle,
+                     wchar_t *DeviceId,
+                     unsigned long Property,
+                     unsigned long DataType,
+                     char *Buffer,
+                     unsigned long Length,
+                     unsigned long Flags)
+{
+    CONFIGRET ret = CR_SUCCESS;
+    LPWSTR lpValueName = NULL;
+    HKEY hKey = 0;
+
+    DPRINT("PNP_SetDeviceRegProp() called\n");
+
+    DPRINT("DeviceId: %S\n", DeviceId);
+    DPRINT("Property: %lu\n", Property);
+    DPRINT("DataType: %lu\n", DataType);
+    DPRINT("Length: %lu\n", Length);
+
+    switch (Property)
+    {
+        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;
+
+        default:
+            return CR_INVALID_PROPERTY;
+    }
+
+    DPRINT("Value name: %S\n", lpValueName);
+
+    if (RegOpenKeyExW(hEnumKey,
+                      DeviceId,
+                      0,
+                      KEY_ALL_ACCESS,
+                      &hKey))
+        return CR_INVALID_DEVNODE;
+
+    if (Length == 0)
+    {
+        if (RegDeleteValueW(hKey,
+                            lpValueName))
+            ret = CR_REGISTRY_ERROR;
+    }
+    else
+    {
+        if (RegSetValueExW(hKey,
+                           lpValueName,
+                           0,
+                           DataType,
+                           (const BYTE*)Buffer,
+                           Length))
+            ret = CR_REGISTRY_ERROR;
+    }
+
+    RegCloseKey(hKey);
+
+    DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret);
+
+    return ret;
+}
+
+
+/* Function 16 */
 CONFIGRET
 PNP_CreateKey(handle_t BindingHandle,
               wchar_t *SubKey,
@@ -680,6 +701,64 @@ PNP_CreateKey(handle_t BindingHandle,
 }
 
 
+/* Function 17 */
+CONFIGRET
+PNP_DeleteRegistryKey(handle_t BindingHandle,
+                      wchar_t *DeviceId,
+                      wchar_t *ParentKey,
+                      wchar_t *ChildKey,
+                      unsigned long Flags)
+{
+    CONFIGRET ret = CR_SUCCESS;
+
+    DPRINT("PNP_DeleteRegistryKey() called\n");
+
+    DPRINT("PNP_DeleteRegistryKey() done (returns %lx)\n", ret);
+
+    return ret;
+}
+
+
+/* Function 18 */
+#if 0
+CONFIGRET
+PNP_GetClassCount(handle_t BindingHandle,
+                  unsigned long *ClassCount,
+                  unsigned long Flags)
+{
+    HANDLE hKey = NULL;
+    DWORD dwError;
+
+    dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                            pszRegPathClass,
+                            0,
+                            KEY_QUERY_VALUE,
+                            &hKey);
+    if (dwError != ERROR_SUCCESS)
+        return CR_INVALID_DATA;
+
+    dwError = RegQueryInfoKeyW(hKey,
+                               NULL,
+                               NULL,
+                               NULL,
+                               &ClassCount,
+                               NULL,
+                               NULL,
+                               NULL,
+                               NULL,
+                               NULL,
+                               NULL,
+                               NULL);
+    RegCloseKey(hKey);
+    if (dwError != ERROR_SUCCESS)
+        return CR_INVALID_DATA;
+
+    return CR_SUCCESS;
+}
+#endif
+
+
+/* Function 19 */
 CONFIGRET
 PNP_GetClassName(handle_t BindingHandle,
                  wchar_t *ClassGuid,
@@ -729,6 +808,7 @@ PNP_GetClassName(handle_t BindingHandle,
 }
 
 
+/* Function 20 */
 CONFIGRET
 PNP_DeleteClassKey(handle_t BindingHandle,
                    wchar_t *ClassGuid,
@@ -755,6 +835,44 @@ PNP_DeleteClassKey(handle_t BindingHandle,
 }
 
 
+/* Function 29 */
+CONFIGRET
+PNP_DeviceInstanceAction(handle_t BindingHandle,
+                         unsigned long MajorAction,
+                         unsigned long MinorAction,
+                         wchar_t *DeviceInstance1,
+                         wchar_t *DeviceInstance2)
+{
+    CONFIGRET ret = CR_SUCCESS;
+
+    DPRINT("PNP_DeviceInstanceAction() called\n");
+
+    switch (MajorAction)
+    {
+        case 4:
+            DPRINT("Enable device instance\n");
+            break;
+
+        case 5:
+            DPRINT("Disable device instance\n");
+            break;
+
+        case 7:
+            DPRINT("Reenumerate device instance\n");
+            break;
+
+        default:
+            DPRINT1("Unknown function %lu\n", MajorAction);
+            ret = CR_CALL_NOT_IMPLEMENTED;
+    }
+
+    DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret);
+
+    return ret;
+}
+
+
+/* Function 30 */
 CONFIGRET
 PNP_GetDeviceStatus(handle_t BindingHandle,
                     wchar_t *DeviceInstance,
@@ -875,6 +993,17 @@ PNP_RequestEjectPC(handle_t BindingHandle)
     return ret;
 }
 
+
+/* Function 58 */
+CONFIGRET
+PNP_RunDetection(handle_t BindingHandle,
+                 unsigned long Flags)
+{
+    DPRINT("PNP_RunDetection() called\n");
+    return CR_CALL_NOT_IMPLEMENTED;
+}
+
+
 typedef BOOL (WINAPI *PDEV_INSTALL_W)(HWND, HINSTANCE, LPCWSTR, INT);
 
 static BOOL
@@ -903,12 +1032,15 @@ InstallDevice(PCWSTR DeviceInstance, BOOL SetupIsActive)
 
     /* Install device */
     SetEnvironmentVariable(L"USERPROFILE", L"."); /* FIXME: why is it needed? */
+
     hNewDev = LoadLibraryW(L"newdev.dll");
     if (!hNewDev)
         goto cleanup;
+
     DevInstallW = (PDEV_INSTALL_W)GetProcAddress(hNewDev, (LPCSTR)"DevInstallW");
     if (!DevInstallW)
         goto cleanup;
+
     if (!DevInstallW(NULL, NULL, DeviceInstance, SetupIsActive ? SW_HIDE : SW_SHOWNOACTIVATE))
         goto cleanup;
 
@@ -921,6 +1053,7 @@ cleanup:
     return DeviceInstalled;
 }
 
+
 static BOOL
 SetupIsActive(VOID)
 {
@@ -945,10 +1078,13 @@ SetupIsActive(VOID)
 cleanup:
     if (hKey != INVALID_HANDLE_VALUE)
         RegCloseKey(hKey);
+
     DPRINT("System setup in progress? %S\n", ret ? L"YES" : L"NO");
+
     return ret;
 }
 
+
 static DWORD WINAPI
 PnpEventThread(LPVOID lpParameter)
 {
index 8ab07b4..0179323 100644 (file)
@@ -751,8 +751,24 @@ CM_Delete_Class_Key_Ex(
 /* FIXME: Obsolete CM_Delete_Range */
 /* FIXME: Obsolete CM_Detected_Resource_Conflict */
 /* FIXME: Obsolete CM_Detected_Resource_Conflict_Ex */
-/* FIXME: Obsolete CM_Disable_DevNode */
-/* FIXME: Obsolete CM_Disable_DevNodeEx */
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Disable_DevNode(
+  IN DEVINST  dnDevInst,
+  IN ULONG  ulFlags);
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Disable_DevNode_Ex(
+    IN DEVINST  dnDevInst,
+    IN ULONG  ulFlags,
+    IN HMACHINE  hMachine);
+
+#define CM_Disable_DevInst CM_Disable_DevNode
+#define CM_Disable_DevInst_Ex CM_Disable_DevNode_Ex
 
 CMAPI
 CONFIGRET
@@ -760,8 +776,23 @@ WINAPI
 CM_Disconnect_Machine(
   IN HMACHINE  hMachine);
 
-/* FIXME: Obsolete CM_Enable_DevNode */
-/* FIXME: Obsolete CM_Enable_DevNodeEx */
+CMAPI
+CONFIGRET
+WINAPI
+CM_Enable_DevNode(
+    IN DEVINST  dnDevInst,
+    IN ULONG  ulFlags);
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Enable_DevNode_Ex(
+    IN DEVINST  dnDevInst,
+    IN ULONG  ulFlags,
+    IN HMACHINE  hMachine);
+
+#define CM_Enable_DevInst CM_Enable_DevNode
+#define CM_Enable_DevInst_Ex CM_Enable_DevNode_Ex
 
 CMAPI
 CONFIGRET
@@ -1795,11 +1826,47 @@ WINAPI
 CM_Request_Eject_PC_Ex(
   IN HMACHINE  hMachine);
 
-/* FIXME: Obsolete CM_Run_Detection */
-/* FIXME: Obsolete CM_Run_Detection_Ex */
+/* CM_Run_Detection[_Ex].ulFlags constants */
+#define CM_DETECT_NEW_PROFILE       0x00000001
+#define CM_DETECT_CRASHED           0x00000002
+#define CM_DETECT_HWPROF_FIRST_BOOT 0x00000004
+#define CM_DETECT_RUN               0x80000000
+#define CM_DETECT_BITS              0x80000007
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Run_Detection(
+  IN ULONG  ulFlags);
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Run_Detection_Ex(
+  IN ULONG  ulFlags,
+  IN HMACHINE  hMachine);
+
 /* FIXME: Obsolete CM_Set_Class_Registry_Property */
-/* FIXME: Obsolete CM_Set_DevNode_Problem */
-/* FIXME: Obsolete CM_Set_DevNode_Problem_Ex */
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Set_DevNode_Problem(
+  IN DEVINST  dnDevInst,
+  IN ULONG  ulProblem,
+  IN ULONG  ulFlags);
+
+CMAPI
+CONFIGRET
+WINAPI
+CM_Set_DevNode_Problem_Ex(
+  IN DEVINST  dnDevInst,
+  IN ULONG  ulProblem,
+  IN ULONG  ulFlags,
+  IN HMACHINE  hMachine);
+
+#define CM_Set_DevInst_Problem CM_Set_DevNode_Problem
+#define CM_Set_DevInst_Problem_Ex CM_Set_DevNode_Problem_Ex
 
 CMAPI
 CONFIGRET