This api is used by libxess on intel GPUs.
From: Etaash Mathamsetty 45927311+Etaash-mathamsetty@users.noreply.github.com
--- include/cfgmgr32.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/cfgmgr32.h b/include/cfgmgr32.h index a0bb89a2a67..6e2a1d9f6c4 100644 --- a/include/cfgmgr32.h +++ b/include/cfgmgr32.h @@ -320,6 +320,9 @@ CMAPI WORD WINAPI CM_Get_Version(void); CMAPI CONFIGRET WINAPI CM_Locate_DevNodeA(PDEVINST,DEVINSTID_A,ULONG); CMAPI CONFIGRET WINAPI CM_Locate_DevNodeW(PDEVINST,DEVINSTID_W,ULONG); #define CM_Locate_DevNode WINELIB_NAME_AW(CM_Locate_DevNode) +CMAPI CONFIGRET WINAPI CM_Locate_DevNode_ExA(PDEVINST,DEVINSTID_A,ULONG,HMACHINE); +CMAPI CONFIGRET WINAPI CM_Locate_DevNode_ExW(PDEVINST,DEVINSTID_W,ULONG,HMACHINE); +#define CM_Locate_DevNode_Ex WINELIB_NAME_AW(CM_Locate_DevNode_Ex) CMAPI DWORD WINAPI CM_MapCrToWin32Err(CONFIGRET,DWORD); CMAPI CONFIGRET WINAPI CM_Open_DevNode_Key(DEVINST dnDevInst, REGSAM access, ULONG ulHardwareProfile, REGDISPOSITION disposition, PHKEY phkDevice, ULONG ulFlags);
From: Etaash Mathamsetty 45927311+Etaash-mathamsetty@users.noreply.github.com
--- dlls/setupapi/devinst.c | 8 ++++++++ dlls/setupapi/stubs.c | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 7e2d683daa6..61e5064afbb 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4224,6 +4224,14 @@ CONFIGRET WINAPI CM_Get_Device_ID_Size(ULONG *len, DEVINST devnode, ULONG flags) return CR_SUCCESS; }
+/*********************************************************************** + * CM_Locate_DevNodeA (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags) +{ + return CM_Locate_DevNode_ExA(pdnDevInst, pDeviceID, ulFlags, NULL); +} + /*********************************************************************** * SetupDiGetINFClassA (SETUPAPI.@) */ diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index 75185de047c..cd35ddde9b9 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -311,16 +311,6 @@ BOOL WINAPI SetupDiGetClassImageIndex(PSP_CLASSIMAGELIST_DATA ClassImageListData return FALSE; }
-/*********************************************************************** - * CM_Locate_DevNodeA (SETUPAPI.@) - */ -CONFIGRET WINAPI CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags) -{ - FIXME("%p %s 0x%08lx: stub\n", pdnDevInst, debugstr_a(pDeviceID), ulFlags); - - return CR_FAILURE; -} - /*********************************************************************** * CM_Locate_DevNodeW (SETUPAPI.@) */
From: Etaash Mathamsetty 45927311+Etaash-mathamsetty@users.noreply.github.com
--- dlls/setupapi/devinst.c | 8 ++++++++ dlls/setupapi/stubs.c | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 61e5064afbb..9a418dd2706 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4232,6 +4232,14 @@ CONFIGRET WINAPI CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, return CM_Locate_DevNode_ExA(pdnDevInst, pDeviceID, ulFlags, NULL); }
+/*********************************************************************** + * CM_Locate_DevNodeW (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Locate_DevNodeW(PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, ULONG ulFlags) +{ + return CM_Locate_DevNode_ExW(pdnDevInst, pDeviceID, ulFlags, NULL); +} + /*********************************************************************** * SetupDiGetINFClassA (SETUPAPI.@) */ diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index cd35ddde9b9..28ce3e68fd6 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -311,16 +311,6 @@ BOOL WINAPI SetupDiGetClassImageIndex(PSP_CLASSIMAGELIST_DATA ClassImageListData return FALSE; }
-/*********************************************************************** - * CM_Locate_DevNodeW (SETUPAPI.@) - */ -CONFIGRET WINAPI CM_Locate_DevNodeW(PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, ULONG ulFlags) -{ - FIXME("%p %s 0x%08lx: stub\n", pdnDevInst, debugstr_w(pDeviceID), ulFlags); - - return CR_FAILURE; -} - /*********************************************************************** * CM_Locate_DevNode_ExA (SETUPAPI.@) */
From: Etaash Mathamsetty 45927311+Etaash-mathamsetty@users.noreply.github.com
--- dlls/setupapi/devinst.c | 24 ++++++++++++++++++++++++ dlls/setupapi/stubs.c | 10 ---------- 2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 9a418dd2706..d49a75bad5b 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4240,6 +4240,30 @@ CONFIGRET WINAPI CM_Locate_DevNodeW(PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, return CM_Locate_DevNode_ExW(pdnDevInst, pDeviceID, ulFlags, NULL); }
+/*********************************************************************** + * CM_Locate_DevNode_ExA (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Locate_DevNode_ExA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags, HMACHINE hMachine) +{ + CONFIGRET ret; + int len; + WCHAR *buffer; + + len = MultiByteToWideChar(CP_ACP, 0, pDeviceID, -1, NULL, 0); + + buffer = calloc(len, sizeof(WCHAR)); + + if (!buffer) return CR_OUT_OF_MEMORY; + + MultiByteToWideChar(CP_ACP, 0, pDeviceID, -1, buffer, len); + + ret = CM_Locate_DevNode_ExW(pdnDevInst, buffer, ulFlags, hMachine); + + free(buffer); + + return ret; +} + /*********************************************************************** * SetupDiGetINFClassA (SETUPAPI.@) */ diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index 28ce3e68fd6..c173fdfe52b 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -311,16 +311,6 @@ BOOL WINAPI SetupDiGetClassImageIndex(PSP_CLASSIMAGELIST_DATA ClassImageListData return FALSE; }
-/*********************************************************************** - * CM_Locate_DevNode_ExA (SETUPAPI.@) - */ -CONFIGRET WINAPI CM_Locate_DevNode_ExA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags, HMACHINE hMachine) -{ - FIXME("%p %s 0x%08lx %p: stub\n", pdnDevInst, debugstr_a(pDeviceID), ulFlags, hMachine); - - return CR_FAILURE; -} - /*********************************************************************** * CM_Locate_DevNode_ExW (SETUPAPI.@) */
From: Etaash Mathamsetty 45927311+Etaash-mathamsetty@users.noreply.github.com
--- dlls/setupapi/devinst.c | 22 ++++++++++++++++++++++ dlls/setupapi/stubs.c | 10 ---------- 2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index d49a75bad5b..6a442631860 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -4264,6 +4264,28 @@ CONFIGRET WINAPI CM_Locate_DevNode_ExA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceI return ret; }
+/*********************************************************************** + * CM_Locate_DevNode_ExW (SETUPAPI.@) + */ +CONFIGRET WINAPI CM_Locate_DevNode_ExW(PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, ULONG ulFlags, HMACHINE hMachine) +{ + FIXME("%p %s 0x%08lx %p: semi-stub\n", pdnDevInst, debugstr_w(pDeviceID), ulFlags, hMachine); + + for (DEVINST i = 0; i < devnode_table_size; i++) + { + if (!devnode_table[i]) + break; + + if (!lstrcmpW(pDeviceID, devnode_table[i]->instanceId)) + { + *pdnDevInst = i; + return CR_SUCCESS; + } + } + + return CR_NO_SUCH_DEVNODE; +} + /*********************************************************************** * SetupDiGetINFClassA (SETUPAPI.@) */ diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index c173fdfe52b..97b3eead406 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -311,16 +311,6 @@ BOOL WINAPI SetupDiGetClassImageIndex(PSP_CLASSIMAGELIST_DATA ClassImageListData return FALSE; }
-/*********************************************************************** - * CM_Locate_DevNode_ExW (SETUPAPI.@) - */ -CONFIGRET WINAPI CM_Locate_DevNode_ExW(PDEVINST pdnDevInst, DEVINSTID_W pDeviceID, ULONG ulFlags, HMACHINE hMachine) -{ - FIXME("%p %s 0x%08lx %p: stub\n", pdnDevInst, debugstr_w(pDeviceID), ulFlags, hMachine); - - return CR_FAILURE; -} - /*********************************************************************** * CM_Get_Device_Interface_List_SizeA (SETUPAPI.@) */
This implementation is only going to return devices that happen to have been opened. That doesn't seem like it's going in the right direction even for a semi-stub.
It needs tests anyway.
And if we're going to have a semi-stub that actually implements the basic functionality, it's not really much of a semi-stub anymore. Better to change the message to a TRACE but add a FIXME for nonzero flags.
Also, if we're touching functions, let's please get rid of the unnecessary pointer typedefs and Hungarian and camel-case variable names.
On Sun Jan 21 18:04:40 2024 +0000, Zebediah Figura wrote:
This implementation is only going to return devices that happen to have been opened. That doesn't seem like it's going in the right direction even for a semi-stub. It needs tests anyway. And if we're going to have a semi-stub that actually implements the basic functionality, it's not really much of a semi-stub anymore. Better to change the message to a TRACE but add a FIXME for nonzero flags. Also, if we're touching functions, let's please get rid of the unnecessary pointer typedefs and Hungarian and camel-case variable names.
im not too familiar with setupapi/cfgmgr32, but MSDN says:
The function retrieves the device instance handle for the specified device only if the device is currently configured in the device tree.
Does this mean that the device has to be opened for it to get a device instance handle?
I should probably write tests to check