Author: ekohl
Date: Mon Oct 3 16:38:46 2011
New Revision: 53965
URL:
http://svn.reactos.org/svn/reactos?rev=53965&view=rev
Log:
[SETUPAPI]
- Implement CM_Get_DevNode_Custom_Property[_Ex]A/W.
- Fix the return value of CM_Open_Class_Key_ExA.
- Handle REG_MULTI_SZ values properly in CM_Get_DevNode_Registry_Property_ExA.
Modified:
trunk/reactos/dll/win32/setupapi/cfgmgr.c
trunk/reactos/dll/win32/setupapi/setupapi.spec
Modified: trunk/reactos/dll/win32/setupapi/cfgmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/cfgmgr.…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/cfgmgr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/cfgmgr.c [iso-8859-1] Mon Oct 3 16:38:46 2011
@@ -1735,6 +1735,194 @@
/***********************************************************************
+ * CM_Get_DevNode_Custom_PropertyA [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Get_DevNode_Custom_PropertyA(
+ DEVINST dnDevInst, PCSTR pszCustomPropertyName, PULONG pulRegDataType,
+ PVOID Buffer, PULONG pulLength, ULONG ulFlags)
+{
+ TRACE("%lx %s %p %p %p %lx\n", dnDevInst, pszCustomPropertyName,
+ pulRegDataType, Buffer, pulLength, ulFlags);
+ return CM_Get_DevNode_Custom_Property_ExA(dnDevInst, pszCustomPropertyName,
+ pulRegDataType, Buffer,
+ pulLength, ulFlags, NULL);
+}
+
+
+/***********************************************************************
+ * CM_Get_DevNode_Custom_PropertyW [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Get_DevNode_Custom_PropertyW(
+ DEVINST dnDevInst, PCWSTR pszCustomPropertyName, PULONG pulRegDataType,
+ PVOID Buffer, PULONG pulLength, ULONG ulFlags)
+{
+ TRACE("%lx %s %p %p %p %lx\n", dnDevInst,
debugstr_w(pszCustomPropertyName),
+ pulRegDataType, Buffer, pulLength, ulFlags);
+ return CM_Get_DevNode_Custom_Property_ExW(dnDevInst, pszCustomPropertyName,
+ pulRegDataType, Buffer,
+ pulLength, ulFlags, NULL);
+}
+
+
+/***********************************************************************
+ * CM_Get_DevNode_Custom_Property_ExA [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Get_DevNode_Custom_Property_ExA(
+ DEVINST dnDevInst, PCSTR pszCustomPropertyName, PULONG pulRegDataType,
+ PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
+{
+ LPWSTR pszPropertyNameW = NULL;
+ PVOID BufferW;
+ ULONG ulLengthW;
+ ULONG ulDataType = REG_NONE;
+ CONFIGRET ret;
+
+ TRACE("%lx %s %p %p %p %lx %p\n", dnDevInst, pszCustomPropertyName,
+ pulRegDataType, Buffer, pulLength, ulFlags, hMachine);
+
+ if (!pulLength)
+ return CR_INVALID_POINTER;
+
+ ulLengthW = *pulLength * sizeof(WCHAR);
+ BufferW = HeapAlloc(GetProcessHeap(), 0, ulLengthW);
+ if (!BufferW)
+ return CR_OUT_OF_MEMORY;
+
+ pszPropertyNameW = pSetupMultiByteToUnicode(pszCustomPropertyName,
+ CP_ACP);
+ if (pszPropertyNameW == NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, BufferW);
+ return CR_OUT_OF_MEMORY;
+ }
+
+ ret = CM_Get_DevNode_Custom_Property_ExW(dnDevInst,
+ pszPropertyNameW,
+ &ulDataType,
+ BufferW,
+ &ulLengthW,
+ ulFlags,
+ hMachine);
+ if (ret == CR_SUCCESS)
+ {
+ if (ulDataType == REG_SZ ||
+ ulDataType == REG_EXPAND_SZ ||
+ ulDataType == REG_MULTI_SZ)
+ {
+ /* Do W->A conversion */
+ *pulLength = WideCharToMultiByte(CP_ACP,
+ 0,
+ BufferW,
+ lstrlenW(BufferW) + 1,
+ Buffer,
+ *pulLength,
+ NULL,
+ NULL);
+ if (*pulLength == 0)
+ ret = CR_FAILURE;
+ }
+ else
+ {
+ /* Directly copy the value */
+ if (ulLengthW <= *pulLength)
+ memcpy(Buffer, BufferW, ulLengthW);
+ else
+ {
+ *pulLength = ulLengthW;
+ ret = CR_BUFFER_SMALL;
+ }
+ }
+ }
+
+ if (pulRegDataType)
+ *pulRegDataType = ulDataType;
+
+ HeapFree(GetProcessHeap(), 0, BufferW);
+ MyFree(pszPropertyNameW);
+
+ return ret;
+}
+
+
+/***********************************************************************
+ * CM_Get_DevNode_Custom_Property_ExW [SETUPAPI.@]
+ */
+CONFIGRET WINAPI CM_Get_DevNode_Custom_Property_ExW(
+ DEVINST dnDevInst, PCWSTR pszCustomPropertyName, PULONG pulRegDataType,
+ PVOID Buffer, PULONG pulLength, ULONG ulFlags, HMACHINE hMachine)
+{
+ RPC_BINDING_HANDLE BindingHandle = NULL;
+ HSTRING_TABLE StringTable = NULL;
+ LPWSTR lpDevInst;
+ ULONG ulDataType = REG_NONE;
+ ULONG ulTransferLength;
+ CONFIGRET ret = CR_SUCCESS;
+
+ TRACE("%lx %s %p %p %p %lx %p\n", dnDevInst,
+ debugstr_w(pszCustomPropertyName), pulRegDataType, Buffer,
+ pulLength, ulFlags, hMachine);
+
+ if (dnDevInst == 0)
+ return CR_INVALID_DEVNODE;
+
+ if (pszCustomPropertyName == NULL ||
+ pulLength == NULL ||
+ *pulLength == 0)
+ return CR_INVALID_POINTER;
+
+ if (ulFlags & ~CM_CUSTOMDEVPROP_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 = pSetupStringTableStringFromId(StringTable, dnDevInst);
+ if (lpDevInst == NULL)
+ return CR_INVALID_DEVNODE;
+
+ ulTransferLength = *pulLength;
+
+ RpcTryExcept
+ {
+ ret = PNP_GetCustomDevProp(BindingHandle,
+ lpDevInst,
+ (LPWSTR)pszCustomPropertyName,
+ &ulDataType,
+ Buffer,
+ &ulTransferLength,
+ pulLength,
+ ulFlags);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ ret = RpcStatusToCmStatus(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ if (ret == CR_SUCCESS)
+ {
+ if (pulRegDataType != NULL)
+ *pulRegDataType = ulDataType;
+ }
+
+ return ret;
+}
+
+
+/***********************************************************************
* CM_Get_DevNode_Registry_PropertyA [SETUPAPI.@]
*/
CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyA(
@@ -1775,7 +1963,7 @@
{
PVOID BufferW;
ULONG LengthW;
- ULONG RegDataType = REG_NONE;
+ ULONG ulDataType = REG_NONE;
CONFIGRET ret;
TRACE("%lx %lu %p %p %p %lx %lx\n",
@@ -1793,7 +1981,7 @@
ret = CM_Get_DevNode_Registry_Property_ExW(dnDevInst,
ulProperty,
- &RegDataType,
+ &ulDataType,
BufferW,
&LengthW,
ulFlags,
@@ -1801,7 +1989,9 @@
if (ret == CR_SUCCESS)
{
- if (RegDataType == REG_SZ || RegDataType == REG_EXPAND_SZ)
+ if (ulDataType == REG_SZ ||
+ ulDataType == REG_EXPAND_SZ ||
+ ulDataType == REG_MULTI_SZ)
{
/* Do W->A conversion */
*pulLength = WideCharToMultiByte(CP_ACP,
@@ -1829,7 +2019,7 @@
}
if (pulRegDataType)
- *pulRegDataType = RegDataType;
+ *pulRegDataType = ulDataType;
HeapFree(GetProcessHeap(), 0, BufferW);
@@ -1848,7 +2038,7 @@
HSTRING_TABLE StringTable = NULL;
CONFIGRET ret = CR_SUCCESS;
LPWSTR lpDevInst;
- ULONG ulDataType = 0;
+ ULONG ulDataType = REG_NONE;
ULONG ulTransferLength = 0;
TRACE("%lx %lu %p %p %p %lx %lx\n",
@@ -3973,6 +4163,7 @@
HMACHINE hMachine)
{
LPWSTR pszClassNameW = NULL;
+ CONFIGRET ret;
TRACE("%p %s %lx %lx %p %lx %lx\n",
debugstr_guid(pClassGuid), pszClassName,
@@ -3984,13 +4175,13 @@
return CR_INVALID_DATA;
}
- CM_Open_Class_Key_ExW(pClassGuid, pszClassNameW, samDesired,
- Disposition, phkClass, ulFlags, hMachine);
+ ret = CM_Open_Class_Key_ExW(pClassGuid, pszClassNameW, samDesired,
+ Disposition, phkClass, ulFlags, hMachine);
if (pszClassNameW != NULL)
MyFree(pszClassNameW);
- return CR_SUCCESS;
+ return ret;
}
Modified: trunk/reactos/dll/win32/setupapi/setupapi.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupap…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] Mon Oct 3 16:38:46 2011
@@ -66,10 +66,10 @@
@ stdcall CM_Get_Class_Registry_PropertyW(ptr long ptr ptr ptr long ptr)
@ stdcall CM_Get_Depth(ptr long long)
@ stdcall CM_Get_Depth_Ex(ptr long long long)
-@ stub CM_Get_DevNode_Custom_PropertyA
-@ stub CM_Get_DevNode_Custom_PropertyW
-@ stub CM_Get_DevNode_Custom_Property_ExA
-@ stub CM_Get_DevNode_Custom_Property_ExW
+@ stdcall CM_Get_DevNode_Custom_PropertyA(long str ptr ptr ptr long)
+@ stdcall CM_Get_DevNode_Custom_PropertyW(long wstr ptr ptr ptr long)
+@ stdcall CM_Get_DevNode_Custom_Property_ExA(long str ptr ptr ptr long ptr)
+@ stdcall CM_Get_DevNode_Custom_Property_ExW(long wstr ptr ptr ptr long ptr)
@ stdcall CM_Get_DevNode_Registry_PropertyA(long long ptr ptr ptr long)
@ stdcall CM_Get_DevNode_Registry_PropertyW(long long ptr ptr ptr long)
@ stdcall CM_Get_DevNode_Registry_Property_ExA(long long ptr ptr ptr long long)