/[rdesktop]/sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.cpp
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 938 by astrand, Fri Jul 1 07:01:00 2005 UTC revision 993 by astrand, Sun Aug 28 12:58:39 2005 UTC
# Line 9  Line 9 
9  #include "wtsapi32.h"  #include "wtsapi32.h"
10  #include "Cchannel.h"  #include "Cchannel.h"
11    
12  #define DLL_EXPORT extern "C" __declspec(dllexport)  #define DLL_EXPORT extern "C" __declspec(dllexport)
13    
14  // Shared DATA  // Shared DATA
15  #pragma data_seg ( "SHAREDDATA" )  #pragma data_seg ( "SHAREDDATA" )
# Line 31  HHOOK hhook3 = 0;               //wnd pr Line 31  HHOOK hhook3 = 0;               //wnd pr
31  HINSTANCE hInst = 0;  HINSTANCE hInst = 0;
32  HANDLE m_vcHandle = 0;  HANDLE m_vcHandle = 0;
33    
34  BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call,  BOOL APIENTRY DllMain( HINSTANCE hinstDLL, DWORD ul_reason_for_call,
35                        LPVOID lpReserved)                         LPVOID lpReserved )
36  {  {
37      switch (ul_reason_for_call) {      switch ( ul_reason_for_call ) {
38      case DLL_PROCESS_ATTACH: {          case DLL_PROCESS_ATTACH: {
39              // remember our instance handle              // remember our instance handle
40              hInst = hinstDLL;              hInst = hinstDLL;
41              ++iInstanceCount;              ++iInstanceCount;
42              OpenVirtualChannel();              OpenVirtualChannel();
43              break;              break;
44          }          }
45            
46      case DLL_THREAD_ATTACH:          case DLL_THREAD_ATTACH:
47          break;          break;
48      case DLL_THREAD_DETACH:          case DLL_THREAD_DETACH:
49          break;          break;
50      case DLL_PROCESS_DETACH: {          case DLL_PROCESS_DETACH: {
51              --iInstanceCount;              --iInstanceCount;
52              CloseVirtualChannel();              CloseVirtualChannel();
53          }          }
54          break;          break;
55      }      }
56        
57      return TRUE;      return TRUE;
58  }  }
59    
60  LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)  LRESULT CALLBACK CallWndProc( int nCode, WPARAM wParam, LPARAM lParam )
61  {  {
62      if (nCode < 0) {      if ( nCode < 0 ) {
63          return CallNextHookEx(hhook3, nCode, wParam, lParam);          return CallNextHookEx( hhook3, nCode, wParam, lParam );
64      }      }
65        
66      PCHAR buffer = NULL;      PCHAR buffer = NULL;
67      char windowTitle[150] = { "" };      char windowTitle[ 150 ] = { ""
68                                  };
69      HWND windowHandle = NULL;      HWND windowHandle = NULL;
70      char result[255] = { "" };      char result[ 255 ] = { ""
71      char strWindowId[25];                           };
72      char type[25];      char strWindowId[ 25 ];
73        char type[ 25 ];
74        
75      LONG b, t, l, r;      LONG b, t, l, r;
76      char strB[5];      char strB[ 5 ];
77      char strT[5];      char strT[ 5 ];
78      char strL[5];      char strL[ 5 ];
79      char strR[5];      char strR[ 5 ];
80      RECT rect;      RECT rect;
81        
82      CWPSTRUCT *details = (CWPSTRUCT *) lParam;      CWPSTRUCT *details = ( CWPSTRUCT * ) lParam;
83        
84      switch (details->message) {      switch ( details->message ) {
85      case WM_SIZING:          case WM_SIZING:
86      case WM_MOVING:          case WM_MOVING:
87            
88          windowHandle = details->hwnd;          windowHandle = details->hwnd;
89          //get win name          //get win name
90          GetWindowText(windowHandle, windowTitle, 150);          GetWindowText( windowHandle, windowTitle, 150 );
91            
92          //get an id for it          //get an id for it
93          itoa((int) windowHandle, strWindowId, 10);          itoa( ( int ) windowHandle, strWindowId, 10 );
94            
95          //get coords          //get coords
96          GetWindowRect(windowHandle, &rect);          GetWindowRect( windowHandle, &rect );
97          b = rect.bottom;          b = rect.bottom;
98          t = rect.top;          t = rect.top;
99          l = rect.left;          l = rect.left;
100          r = rect.right;          r = rect.right;
101          ltoa(b, strB, 10);          ltoa( b, strB, 10 );
102          ltoa(t, strT, 10);          ltoa( t, strT, 10 );
103          ltoa(r, strR, 10);          ltoa( r, strR, 10 );
104          ltoa(l, strL, 10);          ltoa( l, strL, 10 );
105            
106          ////setup return string          ////setup return string
107          strcat(result, "MSG=CALLWNDPROC_WM_MOVING;");          strcat( result, "MSG=CALLWNDPROC_WM_MOVING;" );
108          strcat(result, "ID=");          strcat( result, "ID=" );
109          strcat(result, strWindowId);          strcat( result, strWindowId );
110          strcat(result, ";");          strcat( result, ";" );
111          strcat(result, "TITLE=");          strcat( result, "TITLE=" );
112          strcat(result, windowTitle);          strcat( result, windowTitle );
113          strcat(result, ";");          strcat( result, ";" );
114          strcat(result, "POS=");          strcat( result, "POS=" );
115          strcat(result, strL);          strcat( result, strL );
116          strcat(result, "~");          strcat( result, "~" );
117          strcat(result, strT);          strcat( result, strT );
118          strcat(result, "~");          strcat( result, "~" );
119          strcat(result, strR);          strcat( result, strR );
120          strcat(result, "~");          strcat( result, "~" );
121          strcat(result, strB);          strcat( result, strB );
122          strcat(result, ";");          strcat( result, ";" );
123            
124          buffer = result;          buffer = result;
125            
126          break;          break;
127            
128      default:          default:
129          break;          break;
130      }      }
131        
132      if (ChannelIsOpen()) {      if ( ChannelIsOpen() ) {
133          if (buffer != NULL) {          if ( buffer != NULL ) {
134              WriteToChannel(buffer);              WriteToChannel( buffer );
135          }          }
136      }      }
137        
138      return CallNextHookEx(hhook3, nCode, wParam, lParam);      return CallNextHookEx( hhook3, nCode, wParam, lParam );
139  }  }
140    
141  LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam)  LRESULT CALLBACK CbtProc( int nCode, WPARAM wParam, LPARAM lParam )
142  {  {
143      if (nCode < 0) {      if ( nCode < 0 ) {
144          return CallNextHookEx(hhook, nCode, wParam, lParam);          return CallNextHookEx( hhook, nCode, wParam, lParam );
145      }      }
146        
147        
148      PCHAR buffer = NULL;      PCHAR buffer = NULL;
149        
150        
151      char windowTitle[150] = { "" };      char windowTitle[ 150 ] = { ""
152                                  };
153      HWND windowHandle = NULL;      HWND windowHandle = NULL;
154      char result[255] = { "" };      char result[ 255 ] = { ""
155      char strWindowId[25];                           };
156      char type[25];      char strWindowId[ 25 ];
157        char type[ 25 ];
158        
159        
160      LONG b, t, l, r;      LONG b, t, l, r;
161      char strB[5];      char strB[ 5 ];
162      char strT[5];      char strT[ 5 ];
163      char strL[5];      char strL[ 5 ];
164      char strR[5];      char strR[ 5 ];
165      RECT rect;      RECT rect;
166        
167      int i = 0;                  //tmp      int i = 0;                  //tmp
168        
169      switch (nCode) {      switch ( nCode ) {
170      case HCBT_MINMAX:          case HCBT_MINMAX:
171            
172          windowHandle = (HWND) wParam;          windowHandle = ( HWND ) wParam;
173          //get win name          //get win name
174          GetWindowText(windowHandle, windowTitle, 150);          GetWindowText( windowHandle, windowTitle, 150 );
175            
176          //get an id for it          //get an id for it
177          itoa((int) windowHandle, strWindowId, 10);          itoa( ( int ) windowHandle, strWindowId, 10 );
178            
179          //get operation type(min,max). if max, do not clip at all,if min use window's previous coords          //get operation type(min,max). if max, do not clip at all,if min use window's previous coords
180          //codes are:          //codes are:
181            
182          // SW_HIDE= 0  SW_SHOWNORMAL=1  SW_NORMAL=1  SW_SHOWMINIMIZED=2  SW_SHOWMAXIMIZED=3  SW_MAXIMIZE=3          // SW_HIDE= 0  SW_SHOWNORMAL=1  SW_NORMAL=1  SW_SHOWMINIMIZED=2  SW_SHOWMAXIMIZED=3  SW_MAXIMIZE=3
183          // SW_SHOWNOACTIVATE=4  SW_SHOW=5  SW_MINIMIZE=6  SW_SHOWMINNOACTIVE=7  SW_SHOWNA=8  SW_RESTORE=9          // SW_SHOWNOACTIVATE=4  SW_SHOW=5  SW_MINIMIZE=6  SW_SHOWMINNOACTIVE=7  SW_SHOWNA=8  SW_RESTORE=9
184          // SW_SHOWDEFAULT=10  SW_FORCEMINIMIZE=11  SW_MAX=11          // SW_SHOWDEFAULT=10  SW_FORCEMINIMIZE=11  SW_MAX=11
185            
186          itoa((int) lParam, type, 10);          itoa( ( int ) lParam, type, 10 );
187            
188          //get coords          //get coords
189          GetWindowRect(windowHandle, &rect);          GetWindowRect( windowHandle, &rect );
190          b = rect.bottom;          b = rect.bottom;
191          t = rect.top;          t = rect.top;
192          l = rect.left;          l = rect.left;
193          r = rect.right;          r = rect.right;
194          ltoa(b, strB, 10);          ltoa( b, strB, 10 );
195          ltoa(t, strT, 10);          ltoa( t, strT, 10 );
196          ltoa(r, strR, 10);          ltoa( r, strR, 10 );
197          ltoa(l, strL, 10);          ltoa( l, strL, 10 );
198            
199          //get name          //get name
200          GetWindowText(windowHandle, windowTitle, 150);          GetWindowText( windowHandle, windowTitle, 150 );
201            
202          ////setup return string          ////setup return string
203          strcat(result, "MSG=HCBT_MINMAX;");          strcat( result, "MSG=HCBT_MINMAX;" );
204          strcat(result, "ID=");          strcat( result, "ID=" );
205          strcat(result, strWindowId);          strcat( result, strWindowId );
206          strcat(result, ";");          strcat( result, ";" );
207          strcat(result, "TITLE=");          strcat( result, "TITLE=" );
208          strcat(result, windowTitle);          strcat( result, windowTitle );
209          strcat(result, ";");          strcat( result, ";" );
210          strcat(result, "POS=");          strcat( result, "POS=" );
211          strcat(result, strL);          strcat( result, strL );
212          strcat(result, "~");          strcat( result, "~" );
213          strcat(result, strT);          strcat( result, strT );
214          strcat(result, "~");          strcat( result, "~" );
215          strcat(result, strR);          strcat( result, strR );
216          strcat(result, "~");          strcat( result, "~" );
217          strcat(result, strB);          strcat( result, strB );
218          strcat(result, ";");          strcat( result, ";" );
219          strcat(result, "TYPE=");          strcat( result, "TYPE=" );
220          strcat(result, type);          strcat( result, type );
221          strcat(result, ";");          strcat( result, ";" );
222            
223          //-------------------------------------------------------------------------------------------------          //-------------------------------------------------------------------------------------------------
224          // code to prevent minimising windows (can be removed once minimise has been implemented)          // code to prevent minimising windows (can be removed once minimise has been implemented)
225          i = (int) lParam;          i = ( int ) lParam;
226          //if (i==0 || i==2 || i==6 || i==7 || i==8 || i==11)          //if (i==0 || i==2 || i==6 || i==7 || i==8 || i==11)
227          if (i == 2 || i == 6) {          if ( i == 2 || i == 6 ) {
228              MessageBox(0,              MessageBox( 0,
229                         "Minimising windows is not allowed in this version. Sorry!",                          "Minimising windows is not allowed in this version. Sorry!",
230                         "TS Window Clipper", MB_OK);                          "TS Window Clipper", MB_OK );
231              return 1;              return 1;
232          }          }
233          //-----------------------------------------------------------------------------------------          //-----------------------------------------------------------------------------------------
234            
235          //-------------------------------------------------------------------------------------------------          //-------------------------------------------------------------------------------------------------
236          // code to prevent maximising windows (can be removed once maximise has been implemented)          // code to prevent maximising windows (can be removed once maximise has been implemented)
237          i = (int) lParam;          i = ( int ) lParam;
238          //if (i==3 || i==9 || i==11)          //if (i==3 || i==9 || i==11)
239          if (i == 3 || i == 11) {          if ( i == 3 || i == 11 ) {
240              MessageBox(0,              MessageBox( 0,
241                         "Maximising windows is not allowed in this version. Sorry!",                          "Maximising windows is not allowed in this version. Sorry!",
242                         "TS Window Clipper", MB_OK);                          "TS Window Clipper", MB_OK );
243              return 1;              return 1;
244          }          }
245          //-----------------------------------------------------------------------------------------          //-----------------------------------------------------------------------------------------
246            
247          buffer = result;          buffer = result;
248            
249          break;          break;
250            
251      case HCBT_MOVESIZE:          case HCBT_MOVESIZE:
252            
253          windowHandle = (HWND) wParam;          windowHandle = ( HWND ) wParam;
254          //get win name          //get win name
255          GetWindowText(windowHandle, windowTitle, 150);          GetWindowText( windowHandle, windowTitle, 150 );
256            
257          //get an id for it          //get an id for it
258          itoa((int) windowHandle, strWindowId, 10);          itoa( ( int ) windowHandle, strWindowId, 10 );
259            
260          //get coords          //get coords
261          GetWindowRect(windowHandle, &rect);          GetWindowRect( windowHandle, &rect );
262          b = rect.bottom;          b = rect.bottom;
263          t = rect.top;          t = rect.top;
264          l = rect.left;          l = rect.left;
265          r = rect.right;          r = rect.right;
266          ltoa(b, strB, 10);          ltoa( b, strB, 10 );
267          ltoa(t, strT, 10);          ltoa( t, strT, 10 );
268          ltoa(r, strR, 10);          ltoa( r, strR, 10 );
269          ltoa(l, strL, 10);          ltoa( l, strL, 10 );
270            
271          //get name          //get name
272          GetWindowText(windowHandle, windowTitle, 150);          GetWindowText( windowHandle, windowTitle, 150 );
273            
274          ////setup return string          ////setup return string
275          strcat(result, "MSG=HCBT_MOVESIZE;");          strcat( result, "MSG=HCBT_MOVESIZE;" );
276          strcat(result, "ID=");          strcat( result, "ID=" );
277          strcat(result, strWindowId);          strcat( result, strWindowId );
278          strcat(result, ";");          strcat( result, ";" );
279          strcat(result, "TITLE=");          strcat( result, "TITLE=" );
280          strcat(result, windowTitle);          strcat( result, windowTitle );
281          strcat(result, ";");          strcat( result, ";" );
282          strcat(result, "POS=");          strcat( result, "POS=" );
283          strcat(result, strL);          strcat( result, strL );
284          strcat(result, "~");          strcat( result, "~" );
285          strcat(result, strT);          strcat( result, strT );
286          strcat(result, "~");          strcat( result, "~" );
287          strcat(result, strR);          strcat( result, strR );
288          strcat(result, "~");          strcat( result, "~" );
289          strcat(result, strB);          strcat( result, strB );
290          strcat(result, ";");          strcat( result, ";" );
291            
292          buffer = result;          buffer = result;
293            
294          break;          break;
295      case HCBT_SETFOCUS:          case HCBT_SETFOCUS:
296          //buffer = "HCBT_SETFOCUS";          //buffer = "HCBT_SETFOCUS";
297          //not needed yet          //not needed yet
298          break;          break;
299      default:          default:
300          break;          break;
301      }      }
302        
303      if (ChannelIsOpen()) {      if ( ChannelIsOpen() ) {
304          if (buffer != NULL) {          if ( buffer != NULL ) {
305              WriteToChannel(buffer);              WriteToChannel( buffer );
306          }          }
307      }      }
308        
309      return CallNextHookEx(hhook, nCode, wParam, lParam);      return CallNextHookEx( hhook, nCode, wParam, lParam );
310  }  }
311    
312    
313  LRESULT CALLBACK ShellProc(int nCode, WPARAM wParam, LPARAM lParam)  LRESULT CALLBACK ShellProc( int nCode, WPARAM wParam, LPARAM lParam )
314  {  {
315      if (nCode < 0) {      if ( nCode < 0 ) {
316          return CallNextHookEx(hhook, nCode, wParam, lParam);          return CallNextHookEx( hhook, nCode, wParam, lParam );
317      }      }
318        
319      if (ChannelIsOpen()) {      if ( ChannelIsOpen() ) {
320          PCHAR buffer = NULL;          PCHAR buffer = NULL;
321            
322          char windowTitle[150] = { "" };          char windowTitle[ 150 ] = { ""
323                                      };
324          HWND windowHandle = NULL;          HWND windowHandle = NULL;
325          char result[255] = { "" };          char result[ 255 ] = { ""
326          char strWindowId[25];                               };
327            char strWindowId[ 25 ];
328          LONG b, t, l, r;          LONG b, t, l, r;
329          char strB[5];          char strB[ 5 ];
330          char strT[5];          char strT[ 5 ];
331          char strL[5];          char strL[ 5 ];
332          char strR[5];          char strR[ 5 ];
333          RECT rect;          RECT rect;
334            
335          switch (nCode) {          switch ( nCode ) {
336          case HSHELL_WINDOWCREATED:              case HSHELL_WINDOWCREATED:
337                
338              //get window id              //get window id
339              windowHandle = (HWND) wParam;              windowHandle = ( HWND ) wParam;
340              itoa((int) windowHandle, strWindowId, 10);              itoa( ( int ) windowHandle, strWindowId, 10 );
341                
342              //get coords              //get coords
343              GetWindowRect(windowHandle, &rect);              GetWindowRect( windowHandle, &rect );
344              b = rect.bottom;              b = rect.bottom;
345              t = rect.top;              t = rect.top;
346              l = rect.left;              l = rect.left;
347              r = rect.right;              r = rect.right;
348              ltoa(b, strB, 10);              ltoa( b, strB, 10 );
349              ltoa(t, strT, 10);              ltoa( t, strT, 10 );
350              ltoa(r, strR, 10);              ltoa( r, strR, 10 );
351              ltoa(l, strL, 10);              ltoa( l, strL, 10 );
352                
353              //get name              //get name
354              GetWindowText(windowHandle, windowTitle, 150);              GetWindowText( windowHandle, windowTitle, 150 );
355                
356              ////setup return string              ////setup return string
357              strcat(result, "MSG=HSHELL_WINDOWCREATED;");              strcat( result, "MSG=HSHELL_WINDOWCREATED;" );
358              strcat(result, "ID=");              strcat( result, "ID=" );
359              strcat(result, strWindowId);              strcat( result, strWindowId );
360              strcat(result, ";");              strcat( result, ";" );
361              strcat(result, "TITLE=");              strcat( result, "TITLE=" );
362              strcat(result, windowTitle);              strcat( result, windowTitle );
363              strcat(result, ";");              strcat( result, ";" );
364              strcat(result, "POS=");              strcat( result, "POS=" );
365              strcat(result, strL);              strcat( result, strL );
366              strcat(result, "~");              strcat( result, "~" );
367              strcat(result, strT);              strcat( result, strT );
368              strcat(result, "~");              strcat( result, "~" );
369              strcat(result, strR);              strcat( result, strR );
370              strcat(result, "~");              strcat( result, "~" );
371              strcat(result, strB);              strcat( result, strB );
372              strcat(result, ";");              strcat( result, ";" );
373                
374              buffer = result;              buffer = result;
375                
376              break;              break;
377                
378          case HSHELL_WINDOWDESTROYED:              case HSHELL_WINDOWDESTROYED:
379                
380              //get window id              //get window id
381              windowHandle = (HWND) wParam;              windowHandle = ( HWND ) wParam;
382              itoa((int) windowHandle, strWindowId, 10);              itoa( ( int ) windowHandle, strWindowId, 10 );
383                
384              //get name              //get name
385              GetWindowText(windowHandle, windowTitle, 150);              GetWindowText( windowHandle, windowTitle, 150 );
386                
387              ////setup return string              ////setup return string
388              strcat(result, "MSG=HSHELL_WINDOWDESTROYED;");              strcat( result, "MSG=HSHELL_WINDOWDESTROYED;" );
389              strcat(result, "ID=");              strcat( result, "ID=" );
390              strcat(result, strWindowId);              strcat( result, strWindowId );
391              strcat(result, ";");              strcat( result, ";" );
392              strcat(result, "TITLE=");              strcat( result, "TITLE=" );
393              strcat(result, windowTitle);              strcat( result, windowTitle );
394              strcat(result, ";");              strcat( result, ";" );
395                
396              buffer = result;              buffer = result;
397                
398              break;              break;
399          default:              default:
400              break;              break;
401          }          }
402            
403          if (buffer != NULL) {          if ( buffer != NULL ) {
404              WriteToChannel(buffer);              WriteToChannel( buffer );
405          }          }
406      }      }
407        
408      return CallNextHookEx(hhook, nCode, wParam, lParam);      return CallNextHookEx( hhook, nCode, wParam, lParam );
409  }  }
410    
411  DLL_EXPORT void SetCbtHook(void)  DLL_EXPORT void SetCbtHook( void )
412  {  {
413      if (!bHooked) {      if ( !bHooked ) {
414          hhook =          hhook =
415              SetWindowsHookEx(WH_CBT, (HOOKPROC) CbtProc, hInst, (DWORD) NULL);              SetWindowsHookEx( WH_CBT, ( HOOKPROC ) CbtProc, hInst, ( DWORD ) NULL );
416          bHooked = true;          bHooked = true;
417      }      }
418        
419      if (!bHooked2) {      if ( !bHooked2 ) {
420          hhook2 =          hhook2 =
421              SetWindowsHookEx(WH_SHELL, (HOOKPROC) ShellProc, hInst,              SetWindowsHookEx( WH_SHELL, ( HOOKPROC ) ShellProc, hInst,
422                               (DWORD) NULL);                                ( DWORD ) NULL );
423          bHooked2 = true;          bHooked2 = true;
424      }      }
425        
426      if (!bHooked3) {      if ( !bHooked3 ) {
427          hhook3 =          hhook3 =
428              SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC) CallWndProc, hInst,              SetWindowsHookEx( WH_CALLWNDPROC, ( HOOKPROC ) CallWndProc, hInst,
429                               (DWORD) NULL);                                ( DWORD ) NULL );
430          bHooked3 = true;          bHooked3 = true;
431      }      }
432  }  }
433    
434  DLL_EXPORT void RemoveCbtHook(void)  DLL_EXPORT void RemoveCbtHook( void )
435  {  {
436      if (bHooked) {      if ( bHooked ) {
437          UnhookWindowsHookEx(hhook);          UnhookWindowsHookEx( hhook );
438          bHooked = false;          bHooked = false;
439      }      }
440        
441      if (bHooked2) {      if ( bHooked2 ) {
442          UnhookWindowsHookEx(hhook2);          UnhookWindowsHookEx( hhook2 );
443          bHooked2 = false;          bHooked2 = false;
444      }      }
445        
446      if (bHooked3) {      if ( bHooked3 ) {
447          UnhookWindowsHookEx(hhook3);          UnhookWindowsHookEx( hhook3 );
448          bHooked3 = false;          bHooked3 = false;
449      }      }
450  }  }
# Line 451  DLL_EXPORT int GetInstanceCount() Line 457  DLL_EXPORT int GetInstanceCount()
457  int OpenVirtualChannel()  int OpenVirtualChannel()
458  {  {
459      m_vcHandle =      m_vcHandle =
460          WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION,          WTSVirtualChannelOpen( WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION,
461                                CHANNELNAME);                                 CHANNELNAME );
462                                  
463      if (m_vcHandle == NULL) {      if ( m_vcHandle == NULL ) {
464          return 0;          return 0;
465      } else {      } else {
466          return 1;          return 1;
# Line 463  int OpenVirtualChannel() Line 469  int OpenVirtualChannel()
469    
470  int CloseVirtualChannel()  int CloseVirtualChannel()
471  {  {
472      BOOL result = WTSVirtualChannelClose(m_vcHandle);      BOOL result = WTSVirtualChannelClose( m_vcHandle );
473        
474      m_vcHandle = NULL;      m_vcHandle = NULL;
475        
476      if (result) {      if ( result ) {
477          return 1;          return 1;
478      } else {      } else {
479          return 0;          return 0;
# Line 476  int CloseVirtualChannel() Line 482  int CloseVirtualChannel()
482    
483  int ChannelIsOpen()  int ChannelIsOpen()
484  {  {
485      if (m_vcHandle == NULL) {      if ( m_vcHandle == NULL ) {
486          return 0;          return 0;
487      } else {      } else {
488          return 1;          return 1;
489      }      }
490  }  }
491    
492  int WriteToChannel(PCHAR buffer)  int WriteToChannel( PCHAR buffer )
493  {  {
494      PULONG bytesRead = 0;      PULONG bytesRead = 0;
495      PULONG pBytesWritten = 0;      PULONG pBytesWritten = 0;
496        
497      BOOL result =      BOOL result =
498          WTSVirtualChannelWrite(m_vcHandle, buffer, (ULONG) strlen(buffer),          WTSVirtualChannelWrite( m_vcHandle, buffer, ( ULONG ) strlen( buffer ),
499                                 pBytesWritten);                                  pBytesWritten );
500                                    
501      if (result) {      if ( result ) {
502          return 1;          return 1;
503      } else {      } else {
504          return 0;          return 0;

Legend:
Removed from v.938  
changed lines
  Added in v.993

  ViewVC Help
Powered by ViewVC 1.1.26