Fixes #4296 by merging in David Maloney's registry patch. The ruby side will be merged once the new binaries are in SVN

git-svn-id: file:///home/svn/framework3/trunk@12920 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2011-06-11 23:04:25 +00:00
parent c3307c80be
commit 662840404f
1 changed files with 31 additions and 2 deletions

View File

@ -15,7 +15,36 @@ DWORD request_registry_create_key(Remote *remote, Packet *packet);
*/
DWORD request_registry_open_key(Remote *remote, Packet *packet)
{
return request_registry_create_key(remote, packet);
Packet *response = packet_create_response(packet);
LPCTSTR baseKey = NULL;
HKEY rootKey = NULL, resKey;
DWORD permission;
DWORD result;
rootKey = (HKEY)packet_get_tlv_value_uint(packet, TLV_TYPE_ROOT_KEY);
baseKey = packet_get_tlv_value_string(packet, TLV_TYPE_BASE_KEY);
permission = packet_get_tlv_value_uint(packet, TLV_TYPE_PERMISSION);
// Validate the parameters and then attempt to create the key
if ((!rootKey) || (!baseKey))
result = ERROR_INVALID_PARAMETER;
else
{
if (!permission)
permission = KEY_ALL_ACCESS;
result = RegOpenKeyEx(rootKey, baseKey, 0, permission, &resKey);
}
// Add the HKEY if we succeeded, but always return a result
if (result == ERROR_SUCCESS)
packet_add_tlv_uint(response, TLV_TYPE_HKEY, (DWORD)resKey);
packet_add_tlv_uint(response, TLV_TYPE_RESULT, result);
packet_transmit(remote, response, NULL);
return ERROR_SUCCESS;
}
/*