Merged SSH1 robustness changes from 0.55 release branch on to trunk.
[u/mdw/putty] / winstore.c
index 90d262f..3ce84e0 100644 (file)
@@ -3,7 +3,6 @@
  * defined in storage.h.
  */
 
-#include <windows.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
@@ -61,12 +60,14 @@ static void unmungestr(const char *in, char *out, int outlen)
     return;
 }
 
-void *open_settings_w(const char *sessionname)
+void *open_settings_w(const char *sessionname, char **errmsg)
 {
     HKEY subkey1, sesskey;
     int ret;
     char *p;
 
+    *errmsg = NULL;
+
     if (!sessionname || !*sessionname)
        sessionname = "Default Settings";
 
@@ -76,13 +77,18 @@ void *open_settings_w(const char *sessionname)
     ret = RegCreateKey(HKEY_CURRENT_USER, puttystr, &subkey1);
     if (ret != ERROR_SUCCESS) {
        sfree(p);
+        *errmsg = dupprintf("Unable to create registry key\n"
+                            "HKEY_CURRENT_USER%s", puttystr);
        return NULL;
     }
     ret = RegCreateKey(subkey1, p, &sesskey);
     sfree(p);
     RegCloseKey(subkey1);
-    if (ret != ERROR_SUCCESS)
+    if (ret != ERROR_SUCCESS) {
+        *errmsg = dupprintf("Unable to create registry key\n"
+                            "HKEY_CURRENT_USER%s\\%s", puttystr, p);
        return NULL;
+    }
     return (void *) sesskey;
 }
 
@@ -176,18 +182,6 @@ int read_setting_fontspec(void *handle, const char *name, FontSpec *result)
     ret.height = read_setting_i(handle, settingname, INT_MIN);
     sfree(settingname);
     if (ret.height == INT_MIN) return 0;
-    if (ret.height < 0) {
-       int oldh, newh;
-       HDC hdc = GetDC(NULL);
-       int logpix = GetDeviceCaps(hdc, LOGPIXELSY);
-       ReleaseDC(NULL, hdc);
-
-       oldh = -ret.height;
-       newh = MulDiv(oldh, 72, logpix) + 1;
-       if (MulDiv(newh, logpix, 72) > oldh)
-           newh--;
-       ret.height = newh;
-    }
     *result = ret;
     return 1;
 }