[SETUPAPI] CM_Open_DevNode_Key_Ex: Add support for remote registry access and the Disposition parameter.

This commit is contained in:
Eric Kohl 2017-11-04 20:00:54 +01:00
parent 95447d2fd1
commit 06f9e1220f

View file

@ -5002,9 +5002,10 @@ CM_Open_Class_Key_ExW(
} }
else else
{ {
if (RegConnectRegistryW(((PMACHINE_INFO)hMachine)->szMachineName, if (RegConnectRegistryW(((PMACHINE_INFO)hMachine)->szMachineName,
HKEY_LOCAL_MACHINE, &hKey)) HKEY_LOCAL_MACHINE,
return CR_REGISTRY_ERROR; &hKey))
return CR_REGISTRY_ERROR;
} }
if (ulFlags & CM_OPEN_CLASS_KEY_INTERFACE) if (ulFlags & CM_OPEN_CLASS_KEY_INTERFACE)
@ -5097,6 +5098,8 @@ CM_Open_DevNode_Key_Ex(
HSTRING_TABLE StringTable = NULL; HSTRING_TABLE StringTable = NULL;
LPWSTR pszDevInst, pszKeyPath = NULL, pszInstancePath = NULL; LPWSTR pszDevInst, pszKeyPath = NULL, pszInstancePath = NULL;
LONG lError; LONG lError;
DWORD dwDisposition;
HKEY hRootKey = NULL;
CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED; CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED;
FIXME("CM_Open_DevNode_Key_Ex(%lx %lx %lu %lx %p %lx %lx)\n", FIXME("CM_Open_DevNode_Key_Ex(%lx %lx %lu %lx %p %lx %lx)\n",
@ -5138,14 +5141,14 @@ CM_Open_DevNode_Key_Ex(
TRACE("pszDevInst: %S\n", pszDevInst); TRACE("pszDevInst: %S\n", pszDevInst);
pszKeyPath = MyMalloc(1024); pszKeyPath = MyMalloc(512 * sizeof(WCHAR));
if (pszKeyPath == NULL) if (pszKeyPath == NULL)
{ {
ret = CR_OUT_OF_MEMORY; ret = CR_OUT_OF_MEMORY;
goto done; goto done;
} }
pszInstancePath = MyMalloc(1024); pszInstancePath = MyMalloc(512 * sizeof(WCHAR));
if (pszInstancePath == NULL) if (pszInstancePath == NULL)
{ {
ret = CR_OUT_OF_MEMORY; ret = CR_OUT_OF_MEMORY;
@ -5169,14 +5172,42 @@ CM_Open_DevNode_Key_Ex(
TRACE("pszKeyPath: %S\n", pszKeyPath); TRACE("pszKeyPath: %S\n", pszKeyPath);
// FIXME: Disposition if (hMachine == NULL)
// FIXME: hMachine {
hRootKey = HKEY_LOCAL_MACHINE;
}
else
{
if (RegConnectRegistryW(((PMACHINE_INFO)hMachine)->szMachineName,
HKEY_LOCAL_MACHINE,
&hRootKey))
{
ret = CR_REGISTRY_ERROR;
goto done;
}
}
if (Disposition == RegDisposition_OpenAlways)
{
lError = RegCreateKeyExW(hRootKey,
pszKeyPath,
0,
NULL,
0,
samDesired,
NULL,
phkDevice,
&dwDisposition);
}
else
{
lError = RegOpenKeyExW(hRootKey,
pszKeyPath,
0,
samDesired,
phkDevice);
}
lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
pszKeyPath,
0,
samDesired,
phkDevice);
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
{ {
*phkDevice = NULL; *phkDevice = NULL;
@ -5184,6 +5215,9 @@ CM_Open_DevNode_Key_Ex(
} }
done: done:
if ((hRootKey != NULL) && (hRootKey != HKEY_LOCAL_MACHINE))
RegCloseKey(hRootKey);
if (pszInstancePath != NULL) if (pszInstancePath != NULL)
MyFree(pszInstancePath); MyFree(pszInstancePath);