libfreerdp-core: start using registry settings

This commit is contained in:
Marc-André Moreau 2012-06-15 17:06:26 -04:00
parent 58d6e11b85
commit b55f958e5d
4 changed files with 59 additions and 1 deletions

View File

@ -109,6 +109,7 @@ target_link_libraries(freerdp-core freerdp-locale)
target_link_libraries(freerdp-core winpr-utils)
target_link_libraries(freerdp-core winpr-rpc)
target_link_libraries(freerdp-core winpr-sspi)
target_link_libraries(freerdp-core winpr-registry)
target_link_libraries(freerdp-core freerdp-crypto)
target_link_libraries(freerdp-core ${OPENSSL_LIBRARIES})

View File

@ -29,8 +29,53 @@
#include <freerdp/settings.h>
#include <freerdp/utils/file.h>
#include <winpr/registry.h>
static const char client_dll[] = "C:\\Windows\\System32\\mstscax.dll";
void settings_load_hkey_local_machine(rdpSettings* settings)
{
HKEY hKey;
LONG status;
DWORD dwType;
DWORD dwSize;
DWORD dwValue;
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Client"), 0, KEY_READ, &hKey);
if (status != ERROR_SUCCESS)
return;
if (RegQueryValueEx(hKey, _T("DesktopWidth"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->width = dwValue;
if (RegQueryValueEx(hKey, _T("DesktopHeight"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->height = dwValue;
if (RegQueryValueEx(hKey, _T("KeyboardType"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->kbd_type = dwValue;
if (RegQueryValueEx(hKey, _T("KeyboardSubType"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->kbd_subtype = dwValue;
if (RegQueryValueEx(hKey, _T("KeyboardFunctionKeys"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->kbd_fn_keys = dwValue;
if (RegQueryValueEx(hKey, _T("KeyboardLayout"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->kbd_layout = dwValue;
if (RegQueryValueEx(hKey, _T("NlaSecurity"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->nla_security = dwValue ? 1 : 0;
if (RegQueryValueEx(hKey, _T("TlsSecurity"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->tls_security = dwValue ? 1 : 0;
if (RegQueryValueEx(hKey, _T("RdpSecurity"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS)
settings->rdp_security = dwValue ? 1 : 0;
RegCloseKey(hKey);
}
rdpSettings* settings_new(void* instance)
{
rdpSettings* settings;
@ -188,6 +233,8 @@ rdpSettings* settings_new(void* instance)
settings->server_certificate = xnew(rdpBlob);
freerdp_detect_paths(settings);
settings_load_hkey_local_machine(settings);
}
return settings;

View File

@ -209,6 +209,10 @@ LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesire
RegKey* pKey;
reg = RegGetInstance();
if (!reg)
return -1;
pKey = reg->root_key->subkeys;
while (pKey != NULL)

View File

@ -141,7 +141,7 @@ RegVal* reg_load_value(Reg* reg, RegKey* key)
if (value->type == REG_DWORD)
{
value->data.dword = strtoul(data, NULL, 0);
value->data.dword = strtoul(data, NULL, 16);
}
else if (value->type == REG_SZ)
{
@ -368,6 +368,12 @@ Reg* reg_open(BOOL read_only)
reg->fp = fopen(reg->filename, "w+");
}
if (!reg->fp)
{
free(reg);
return NULL;
}
reg->root_key = (RegKey*) malloc(sizeof(RegKey));
reg->root_key->values = NULL;