wfreerdp-server: modified and documented the attatchtodesktop function
authorC-o-r-E <can.of.tuna@gmail.com>
Tue, 14 Aug 2012 16:31:52 +0000 (12:31 -0400)
committerC-o-r-E <can.of.tuna@gmail.com>
Tue, 14 Aug 2012 16:31:52 +0000 (12:31 -0400)
server/Windows/wf_mirage.c
server/Windows/wf_mirage.h

index 0555084..fd04cf3 100644 (file)
@@ -75,7 +75,16 @@ BOOL wf_check_disp_devices(wfPeerContext* context)
        return false;\r
 }\r
 \r
-int wf_mirage_step2(wfPeerContext* context)\r
+/*\r
+This function will attempt to access the the windows registry using the device\r
+ key stored in the current context. It will attempt to read the value of the\r
+ "Attach.ToDesktop" subkey and will return true if the value is already set to\r
+ val. If unable to read the subkey, this function will return false. If the \r
+ subkey is not set to val it will then attempt to set it to val and return true. If \r
+ unsuccessful or an unexpected value is encountered, the function returns \r
+ false.\r
+ */\r
+BOOL wf_disp_device_set_attatch(wfPeerContext* context, DWORD val)\r
 {\r
        LONG status;\r
        DWORD rtype, rdata, rdata_size;\r
@@ -93,38 +102,38 @@ int wf_mirage_step2(wfPeerContext* context)
        {\r
                printf("Failed to read registry value.\n");\r
                printf("operation returned %d\n", status);\r
-               return -1;\r
+               return false;\r
        }\r
 \r
        _tprintf(_T("type = %04X, data = %04X\n\nNow let's try attaching it...\n"), rtype, rdata);\r
 \r
-       if (rdata == 0)\r
+       if (rdata == val ^ 1)\r
        {\r
-               rdata = 1;\r
+               rdata = val;\r
 \r
                status = RegSetKeyValue(HKEY_LOCAL_MACHINE, context->deviceKey,\r
                        _T("Attach.ToDesktop"), REG_DWORD, &rdata, rdata_size);\r
 \r
                if (status != ERROR_SUCCESS)\r
                {\r
-                       _tprintf(_T("Failed to read registry value.\n"));\r
+                       _tprintf(_T("Failed to write registry value.\n"));\r
                        _tprintf(_T("operation returned %d\n"), status);\r
-                       return -1;\r
+                       return false;\r
                }\r
 \r
-               _tprintf(_T("Attached to Desktop\n\n"));\r
+               _tprintf(_T("Wrote subkey \"Attach.ToDesktop\" -> %04X\n\n", rdata));\r
        }\r
-       else if (rdata == 1)\r
+       else if (rdata == val)\r
        {\r
-               _tprintf(_T("Already attached to desktop!\n"));\r
+               _tprintf(_T("\"Attach.ToDesktop\" is already set to %04X!\n", rdata));\r
        }\r
        else\r
        {\r
-               _tprintf(_T("Something went wrong with attaching to desktop...\nrdata=%d\n"), rdata);\r
-               return -1;\r
+               _tprintf(_T("An wild value appeared!...\nrdata=%d\n"), rdata);\r
+               return false;\r
        }\r
 \r
-       return 0;\r
+       return true;\r
 }\r
 \r
 int wf_mirage_step3(wfPeerContext* context)\r
index 8f2f07c..5774f92 100644 (file)
@@ -200,8 +200,8 @@ typedef struct
        ULONG nColorBmPalEntries;\r
 } Esc_dmf_pointer_shape_get_OUT;\r
 \r
-int wf_check_disp_devices(wfPeerContext* context);\r
-int wf_mirage_step2(wfPeerContext* context);\r
+BOOL wf_check_disp_devices(wfPeerContext* context);\r
+BOOL wf_disp_device_set_attatch(wfPeerContext* context, DWORD val);\r
 int wf_mirage_step3(wfPeerContext* context);\r
 int wf_mirage_step4(wfPeerContext* context);\r
 \r