CVS: seamlessrdp/ServerExe/HookDll hook.cpp,1.5,1.6 hook.h,1.5,1.6 hookdll.cpp,1.5,1.6 hookdll.h,1.4,1.5
Peter Åstrand <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10751/ServerExe/HookDll
Modified Files:
hook.cpp hook.h hookdll.cpp hookdll.h
Log Message:
Indenting with the CVS version of astyle
Index: hook.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hook.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** hook.cpp 1 Jul 2005 07:01:00 -0000 1.5
--- hook.cpp 28 Aug 2005 12:56:38 -0000 1.6
***************
*** 12,53 ****
bool WTSWinClipper::Init()
{
! if (mCbtDllHinst)
return true;
!
! while (true) {
// try to load hookdll.dll
! if (!(mCbtDllHinst = LoadLibrary("hookdll.dll")))
break;
!
// check number of instances
! if (!
! (mGetInstanceCount =
! (GETINSTANCECOUNT) GetProcAddress(mCbtDllHinst,
! "GetInstanceCount")))
break;
!
!
// get our hook function
! if (!
! (mSetCbtHook =
! (SETHOOKS) GetProcAddress(mCbtDllHinst, "SetCbtHook")))
break;
!
// get our unkook function
! if (!
! (mRemoveCbtHook =
! (REMOVEHOOKS) GetProcAddress(mCbtDllHinst, "RemoveCbtHook")))
break;
!
// report success
return true;
}
!
// if we got here something went wrong
! if (mCbtDllHinst) {
! FreeLibrary(mCbtDllHinst);
mCbtDllHinst = 0;
}
!
return false;
}
--- 12,53 ----
bool WTSWinClipper::Init()
{
! if ( mCbtDllHinst )
return true;
!
! while ( true ) {
// try to load hookdll.dll
! if ( !( mCbtDllHinst = LoadLibrary( "hookdll.dll" ) ) )
break;
!
// check number of instances
! if ( !
! ( mGetInstanceCount =
! ( GETINSTANCECOUNT ) GetProcAddress( mCbtDllHinst,
! "GetInstanceCount" ) ) )
break;
!
!
// get our hook function
! if ( !
! ( mSetCbtHook =
! ( SETHOOKS ) GetProcAddress( mCbtDllHinst, "SetCbtHook" ) ) )
break;
!
// get our unkook function
! if ( !
! ( mRemoveCbtHook =
! ( REMOVEHOOKS ) GetProcAddress( mCbtDllHinst, "RemoveCbtHook" ) ) )
break;
!
// report success
return true;
}
!
// if we got here something went wrong
! if ( mCbtDllHinst ) {
! FreeLibrary( mCbtDllHinst );
mCbtDllHinst = 0;
}
!
return false;
}
Index: hook.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hook.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** hook.h 1 Jul 2005 07:01:00 -0000 1.5
--- hook.h 28 Aug 2005 12:56:38 -0000 1.6
***************
*** 19,46 ****
static REMOVEHOOKS mRemoveCbtHook;
static GETINSTANCECOUNT mGetInstanceCount;
!
public:
static bool Init();
static void Done()
{
! if (mCbtDllHinst)
! FreeLibrary(mCbtDllHinst);
}
!
static void SetCbtHook()
{
! if (mCbtDllHinst)
mSetCbtHook();
}
!
static void RemoveCbtHook()
{
! if (mCbtDllHinst)
mRemoveCbtHook();
}
!
static int GetInstanceCount()
{
! if (mCbtDllHinst)
return mGetInstanceCount();
else
--- 19,46 ----
static REMOVEHOOKS mRemoveCbtHook;
static GETINSTANCECOUNT mGetInstanceCount;
!
public:
static bool Init();
static void Done()
{
! if ( mCbtDllHinst )
! FreeLibrary( mCbtDllHinst );
}
!
static void SetCbtHook()
{
! if ( mCbtDllHinst )
mSetCbtHook();
}
!
static void RemoveCbtHook()
{
! if ( mCbtDllHinst )
mRemoveCbtHook();
}
!
static int GetInstanceCount()
{
! if ( mCbtDllHinst )
return mGetInstanceCount();
else
Index: hookdll.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** hookdll.cpp 1 Jul 2005 07:01:00 -0000 1.5
--- hookdll.cpp 28 Aug 2005 12:56:38 -0000 1.6
***************
*** 10,14 ****
#include "Cchannel.h"
! #define DLL_EXPORT extern "C" __declspec(dllexport)
// Shared DATA
--- 10,14 ----
#include "Cchannel.h"
! #define DLL_EXPORT extern "C" __declspec(dllexport)
// Shared DATA
***************
*** 32,40 ****
HANDLE m_vcHandle = 0;
! BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call,
! LPVOID lpReserved)
{
! switch (ul_reason_for_call) {
! case DLL_PROCESS_ATTACH: {
// remember our instance handle
hInst = hinstDLL;
--- 32,40 ----
HANDLE m_vcHandle = 0;
! BOOL APIENTRY DllMain( HINSTANCE hinstDLL, DWORD ul_reason_for_call,
! LPVOID lpReserved )
{
! switch ( ul_reason_for_call ) {
! case DLL_PROCESS_ATTACH: {
// remember our instance handle
hInst = hinstDLL;
***************
*** 43,52 ****
break;
}
!
! case DLL_THREAD_ATTACH:
break;
! case DLL_THREAD_DETACH:
break;
! case DLL_PROCESS_DETACH: {
--iInstanceCount;
CloseVirtualChannel();
--- 43,52 ----
break;
}
!
! case DLL_THREAD_ATTACH:
break;
! case DLL_THREAD_DETACH:
break;
! case DLL_PROCESS_DETACH: {
--iInstanceCount;
CloseVirtualChannel();
***************
*** 54,443 ****
break;
}
!
return TRUE;
}
! LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
! if (nCode < 0) {
! return CallNextHookEx(hhook3, nCode, wParam, lParam);
}
!
PCHAR buffer = NULL;
! char windowTitle[150] = { "" };
HWND windowHandle = NULL;
! char result[255] = { "" };
! char strWindowId[25];
! char type[25];
!
LONG b, t, l, r;
! char strB[5];
! char strT[5];
! char strL[5];
! char strR[5];
RECT rect;
!
! CWPSTRUCT *details = (CWPSTRUCT *) lParam;
!
! switch (details->message) {
! case WM_SIZING:
! case WM_MOVING:
!
windowHandle = details->hwnd;
//get win name
! GetWindowText(windowHandle, windowTitle, 150);
!
//get an id for it
! itoa((int) windowHandle, strWindowId, 10);
!
//get coords
! GetWindowRect(windowHandle, &rect);
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa(b, strB, 10);
! ltoa(t, strT, 10);
! ltoa(r, strR, 10);
! ltoa(l, strL, 10);
!
////setup return string
! strcat(result, "MSG=CALLWNDPROC_WM_MOVING;");
! strcat(result, "ID=");
! strcat(result, strWindowId);
! strcat(result, ";");
! strcat(result, "TITLE=");
! strcat(result, windowTitle);
! strcat(result, ";");
! strcat(result, "POS=");
! strcat(result, strL);
! strcat(result, "~");
! strcat(result, strT);
! strcat(result, "~");
! strcat(result, strR);
! strcat(result, "~");
! strcat(result, strB);
! strcat(result, ";");
!
buffer = result;
!
break;
!
! default:
break;
}
!
! if (ChannelIsOpen()) {
! if (buffer != NULL) {
! WriteToChannel(buffer);
}
}
!
! return CallNextHookEx(hhook3, nCode, wParam, lParam);
}
! LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam)
{
! if (nCode < 0) {
! return CallNextHookEx(hhook, nCode, wParam, lParam);
}
!
!
PCHAR buffer = NULL;
!
!
! char windowTitle[150] = { "" };
HWND windowHandle = NULL;
! char result[255] = { "" };
! char strWindowId[25];
! char type[25];
!
!
LONG b, t, l, r;
! char strB[5];
! char strT[5];
! char strL[5];
! char strR[5];
RECT rect;
!
int i = 0; //tmp
!
! switch (nCode) {
! case HCBT_MINMAX:
!
! windowHandle = (HWND) wParam;
//get win name
! GetWindowText(windowHandle, windowTitle, 150);
!
//get an id for it
! itoa((int) windowHandle, strWindowId, 10);
!
//get operation type(min,max). if max, do not clip at all,if min use window's previous coords
//codes are:
!
// SW_HIDE= 0 SW_SHOWNORMAL=1 SW_NORMAL=1 SW_SHOWMINIMIZED=2 SW_SHOWMAXIMIZED=3 SW_MAXIMIZE=3
// SW_SHOWNOACTIVATE=4 SW_SHOW=5 SW_MINIMIZE=6 SW_SHOWMINNOACTIVE=7 SW_SHOWNA=8 SW_RESTORE=9
// SW_SHOWDEFAULT=10 SW_FORCEMINIMIZE=11 SW_MAX=11
!
! itoa((int) lParam, type, 10);
!
//get coords
! GetWindowRect(windowHandle, &rect);
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa(b, strB, 10);
! ltoa(t, strT, 10);
! ltoa(r, strR, 10);
! ltoa(l, strL, 10);
!
//get name
! GetWindowText(windowHandle, windowTitle, 150);
!
////setup return string
! strcat(result, "MSG=HCBT_MINMAX;");
! strcat(result, "ID=");
! strcat(result, strWindowId);
! strcat(result, ";");
! strcat(result, "TITLE=");
! strcat(result, windowTitle);
! strcat(result, ";");
! strcat(result, "POS=");
! strcat(result, strL);
! strcat(result, "~");
! strcat(result, strT);
! strcat(result, "~");
! strcat(result, strR);
! strcat(result, "~");
! strcat(result, strB);
! strcat(result, ";");
! strcat(result, "TYPE=");
! strcat(result, type);
! strcat(result, ";");
!
//-------------------------------------------------------------------------------------------------
// code to prevent minimising windows (can be removed once minimise has been implemented)
! i = (int) lParam;
//if (i==0 || i==2 || i==6 || i==7 || i==8 || i==11)
! if (i == 2 || i == 6) {
! MessageBox(0,
! "Minimising windows is not allowed in this version. Sorry!",
! "TS Window Clipper", MB_OK);
return 1;
}
//-----------------------------------------------------------------------------------------
!
//-------------------------------------------------------------------------------------------------
// code to prevent maximising windows (can be removed once maximise has been implemented)
! i = (int) lParam;
//if (i==3 || i==9 || i==11)
! if (i == 3 || i == 11) {
! MessageBox(0,
! "Maximising windows is not allowed in this version. Sorry!",
! "TS Window Clipper", MB_OK);
return 1;
}
//-----------------------------------------------------------------------------------------
!
buffer = result;
!
break;
!
! case HCBT_MOVESIZE:
!
! windowHandle = (HWND) wParam;
//get win name
! GetWindowText(windowHandle, windowTitle, 150);
!
//get an id for it
! itoa((int) windowHandle, strWindowId, 10);
!
//get coords
! GetWindowRect(windowHandle, &rect);
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa(b, strB, 10);
! ltoa(t, strT, 10);
! ltoa(r, strR, 10);
! ltoa(l, strL, 10);
!
//get name
! GetWindowText(windowHandle, windowTitle, 150);
!
////setup return string
! strcat(result, "MSG=HCBT_MOVESIZE;");
! strcat(result, "ID=");
! strcat(result, strWindowId);
! strcat(result, ";");
! strcat(result, "TITLE=");
! strcat(result, windowTitle);
! strcat(result, ";");
! strcat(result, "POS=");
! strcat(result, strL);
! strcat(result, "~");
! strcat(result, strT);
! strcat(result, "~");
! strcat(result, strR);
! strcat(result, "~");
! strcat(result, strB);
! strcat(result, ";");
!
buffer = result;
!
break;
! case HCBT_SETFOCUS:
//buffer = "HCBT_SETFOCUS";
//not needed yet
break;
! default:
break;
}
!
! if (ChannelIsOpen()) {
! if (buffer != NULL) {
! WriteToChannel(buffer);
}
}
!
! return CallNextHookEx(hhook, nCode, wParam, lParam);
}
! LRESULT CALLBACK ShellProc(int nCode, WPARAM wParam, LPARAM lParam)
{
! if (nCode < 0) {
! return CallNextHookEx(hhook, nCode, wParam, lParam);
}
!
! if (ChannelIsOpen()) {
PCHAR buffer = NULL;
!
! char windowTitle[150] = { "" };
HWND windowHandle = NULL;
! char result[255] = { "" };
! char strWindowId[25];
LONG b, t, l, r;
! char strB[5];
! char strT[5];
! char strL[5];
! char strR[5];
RECT rect;
!
! switch (nCode) {
! case HSHELL_WINDOWCREATED:
!
//get window id
! windowHandle = (HWND) wParam;
! itoa((int) windowHandle, strWindowId, 10);
!
//get coords
! GetWindowRect(windowHandle, &rect);
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa(b, strB, 10);
! ltoa(t, strT, 10);
! ltoa(r, strR, 10);
! ltoa(l, strL, 10);
!
//get name
! GetWindowText(windowHandle, windowTitle, 150);
!
////setup return string
! strcat(result, "MSG=HSHELL_WINDOWCREATED;");
! strcat(result, "ID=");
! strcat(result, strWindowId);
! strcat(result, ";");
! strcat(result, "TITLE=");
! strcat(result, windowTitle);
! strcat(result, ";");
! strcat(result, "POS=");
! strcat(result, strL);
! strcat(result, "~");
! strcat(result, strT);
! strcat(result, "~");
! strcat(result, strR);
! strcat(result, "~");
! strcat(result, strB);
! strcat(result, ";");
!
buffer = result;
!
break;
!
! case HSHELL_WINDOWDESTROYED:
!
//get window id
! windowHandle = (HWND) wParam;
! itoa((int) windowHandle, strWindowId, 10);
!
//get name
! GetWindowText(windowHandle, windowTitle, 150);
!
////setup return string
! strcat(result, "MSG=HSHELL_WINDOWDESTROYED;");
! strcat(result, "ID=");
! strcat(result, strWindowId);
! strcat(result, ";");
! strcat(result, "TITLE=");
! strcat(result, windowTitle);
! strcat(result, ";");
!
buffer = result;
!
break;
! default:
break;
}
!
! if (buffer != NULL) {
! WriteToChannel(buffer);
}
}
!
! return CallNextHookEx(hhook, nCode, wParam, lParam);
}
! DLL_EXPORT void SetCbtHook(void)
{
! if (!bHooked) {
hhook =
! SetWindowsHookEx(WH_CBT, (HOOKPROC) CbtProc, hInst, (DWORD) NULL);
bHooked = true;
}
!
! if (!bHooked2) {
hhook2 =
! SetWindowsHookEx(WH_SHELL, (HOOKPROC) ShellProc, hInst,
! (DWORD) NULL);
bHooked2 = true;
}
!
! if (!bHooked3) {
hhook3 =
! SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC) CallWndProc, hInst,
! (DWORD) NULL);
bHooked3 = true;
}
}
! DLL_EXPORT void RemoveCbtHook(void)
{
! if (bHooked) {
! UnhookWindowsHookEx(hhook);
bHooked = false;
}
!
! if (bHooked2) {
! UnhookWindowsHookEx(hhook2);
bHooked2 = false;
}
!
! if (bHooked3) {
! UnhookWindowsHookEx(hhook3);
bHooked3 = false;
}
--- 54,449 ----
break;
}
!
return TRUE;
}
! LRESULT CALLBACK CallWndProc( int nCode, WPARAM wParam, LPARAM lParam )
{
! if ( nCode < 0 ) {
! return CallNextHookEx( hhook3, nCode, wParam, lParam );
}
!
PCHAR buffer = NULL;
! char windowTitle[ 150 ] = { ""
! };
HWND windowHandle = NULL;
! char result[ 255 ] = { ""
! };
! char strWindowId[ 25 ];
! char type[ 25 ];
!
LONG b, t, l, r;
! char strB[ 5 ];
! char strT[ 5 ];
! char strL[ 5 ];
! char strR[ 5 ];
RECT rect;
!
! CWPSTRUCT *details = ( CWPSTRUCT * ) lParam;
!
! switch ( details->message ) {
! case WM_SIZING:
! case WM_MOVING:
!
windowHandle = details->hwnd;
//get win name
! GetWindowText( windowHandle, windowTitle, 150 );
!
//get an id for it
! itoa( ( int ) windowHandle, strWindowId, 10 );
!
//get coords
! GetWindowRect( windowHandle, &rect );
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa( b, strB, 10 );
! ltoa( t, strT, 10 );
! ltoa( r, strR, 10 );
! ltoa( l, strL, 10 );
!
////setup return string
! strcat( result, "MSG=CALLWNDPROC_WM_MOVING;" );
! strcat( result, "ID=" );
! strcat( result, strWindowId );
! strcat( result, ";" );
! strcat( result, "TITLE=" );
! strcat( result, windowTitle );
! strcat( result, ";" );
! strcat( result, "POS=" );
! strcat( result, strL );
! strcat( result, "~" );
! strcat( result, strT );
! strcat( result, "~" );
! strcat( result, strR );
! strcat( result, "~" );
! strcat( result, strB );
! strcat( result, ";" );
!
buffer = result;
!
break;
!
! default:
break;
}
!
! if ( ChannelIsOpen() ) {
! if ( buffer != NULL ) {
! WriteToChannel( buffer );
}
}
!
! return CallNextHookEx( hhook3, nCode, wParam, lParam );
}
! LRESULT CALLBACK CbtProc( int nCode, WPARAM wParam, LPARAM lParam )
{
! if ( nCode < 0 ) {
! return CallNextHookEx( hhook, nCode, wParam, lParam );
}
!
!
PCHAR buffer = NULL;
!
!
! char windowTitle[ 150 ] = { ""
! };
HWND windowHandle = NULL;
! char result[ 255 ] = { ""
! };
! char strWindowId[ 25 ];
! char type[ 25 ];
!
!
LONG b, t, l, r;
! char strB[ 5 ];
! char strT[ 5 ];
! char strL[ 5 ];
! char strR[ 5 ];
RECT rect;
!
int i = 0; //tmp
!
! switch ( nCode ) {
! case HCBT_MINMAX:
!
! windowHandle = ( HWND ) wParam;
//get win name
! GetWindowText( windowHandle, windowTitle, 150 );
!
//get an id for it
! itoa( ( int ) windowHandle, strWindowId, 10 );
!
//get operation type(min,max). if max, do not clip at all,if min use window's previous coords
//codes are:
!
// SW_HIDE= 0 SW_SHOWNORMAL=1 SW_NORMAL=1 SW_SHOWMINIMIZED=2 SW_SHOWMAXIMIZED=3 SW_MAXIMIZE=3
// SW_SHOWNOACTIVATE=4 SW_SHOW=5 SW_MINIMIZE=6 SW_SHOWMINNOACTIVE=7 SW_SHOWNA=8 SW_RESTORE=9
// SW_SHOWDEFAULT=10 SW_FORCEMINIMIZE=11 SW_MAX=11
!
! itoa( ( int ) lParam, type, 10 );
!
//get coords
! GetWindowRect( windowHandle, &rect );
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa( b, strB, 10 );
! ltoa( t, strT, 10 );
! ltoa( r, strR, 10 );
! ltoa( l, strL, 10 );
!
//get name
! GetWindowText( windowHandle, windowTitle, 150 );
!
////setup return string
! strcat( result, "MSG=HCBT_MINMAX;" );
! strcat( result, "ID=" );
! strcat( result, strWindowId );
! strcat( result, ";" );
! strcat( result, "TITLE=" );
! strcat( result, windowTitle );
! strcat( result, ";" );
! strcat( result, "POS=" );
! strcat( result, strL );
! strcat( result, "~" );
! strcat( result, strT );
! strcat( result, "~" );
! strcat( result, strR );
! strcat( result, "~" );
! strcat( result, strB );
! strcat( result, ";" );
! strcat( result, "TYPE=" );
! strcat( result, type );
! strcat( result, ";" );
!
//-------------------------------------------------------------------------------------------------
// code to prevent minimising windows (can be removed once minimise has been implemented)
! i = ( int ) lParam;
//if (i==0 || i==2 || i==6 || i==7 || i==8 || i==11)
! if ( i == 2 || i == 6 ) {
! MessageBox( 0,
! "Minimising windows is not allowed in this version. Sorry!",
! "TS Window Clipper", MB_OK );
return 1;
}
//-----------------------------------------------------------------------------------------
!
//-------------------------------------------------------------------------------------------------
// code to prevent maximising windows (can be removed once maximise has been implemented)
! i = ( int ) lParam;
//if (i==3 || i==9 || i==11)
! if ( i == 3 || i == 11 ) {
! MessageBox( 0,
! "Maximising windows is not allowed in this version. Sorry!",
! "TS Window Clipper", MB_OK );
return 1;
}
//-----------------------------------------------------------------------------------------
!
buffer = result;
!
break;
!
! case HCBT_MOVESIZE:
!
! windowHandle = ( HWND ) wParam;
//get win name
! GetWindowText( windowHandle, windowTitle, 150 );
!
//get an id for it
! itoa( ( int ) windowHandle, strWindowId, 10 );
!
//get coords
! GetWindowRect( windowHandle, &rect );
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa( b, strB, 10 );
! ltoa( t, strT, 10 );
! ltoa( r, strR, 10 );
! ltoa( l, strL, 10 );
!
//get name
! GetWindowText( windowHandle, windowTitle, 150 );
!
////setup return string
! strcat( result, "MSG=HCBT_MOVESIZE;" );
! strcat( result, "ID=" );
! strcat( result, strWindowId );
! strcat( result, ";" );
! strcat( result, "TITLE=" );
! strcat( result, windowTitle );
! strcat( result, ";" );
! strcat( result, "POS=" );
! strcat( result, strL );
! strcat( result, "~" );
! strcat( result, strT );
! strcat( result, "~" );
! strcat( result, strR );
! strcat( result, "~" );
! strcat( result, strB );
! strcat( result, ";" );
!
buffer = result;
!
break;
! case HCBT_SETFOCUS:
//buffer = "HCBT_SETFOCUS";
//not needed yet
break;
! default:
break;
}
!
! if ( ChannelIsOpen() ) {
! if ( buffer != NULL ) {
! WriteToChannel( buffer );
}
}
!
! return CallNextHookEx( hhook, nCode, wParam, lParam );
}
! LRESULT CALLBACK ShellProc( int nCode, WPARAM wParam, LPARAM lParam )
{
! if ( nCode < 0 ) {
! return CallNextHookEx( hhook, nCode, wParam, lParam );
}
!
! if ( ChannelIsOpen() ) {
PCHAR buffer = NULL;
!
! char windowTitle[ 150 ] = { ""
! };
HWND windowHandle = NULL;
! char result[ 255 ] = { ""
! };
! char strWindowId[ 25 ];
LONG b, t, l, r;
! char strB[ 5 ];
! char strT[ 5 ];
! char strL[ 5 ];
! char strR[ 5 ];
RECT rect;
!
! switch ( nCode ) {
! case HSHELL_WINDOWCREATED:
!
//get window id
! windowHandle = ( HWND ) wParam;
! itoa( ( int ) windowHandle, strWindowId, 10 );
!
//get coords
! GetWindowRect( windowHandle, &rect );
b = rect.bottom;
t = rect.top;
l = rect.left;
r = rect.right;
! ltoa( b, strB, 10 );
! ltoa( t, strT, 10 );
! ltoa( r, strR, 10 );
! ltoa( l, strL, 10 );
!
//get name
! GetWindowText( windowHandle, windowTitle, 150 );
!
////setup return string
! strcat( result, "MSG=HSHELL_WINDOWCREATED;" );
! strcat( result, "ID=" );
! strcat( result, strWindowId );
! strcat( result, ";" );
! strcat( result, "TITLE=" );
! strcat( result, windowTitle );
! strcat( result, ";" );
! strcat( result, "POS=" );
! strcat( result, strL );
! strcat( result, "~" );
! strcat( result, strT );
! strcat( result, "~" );
! strcat( result, strR );
! strcat( result, "~" );
! strcat( result, strB );
! strcat( result, ";" );
!
buffer = result;
!
break;
!
! case HSHELL_WINDOWDESTROYED:
!
//get window id
! windowHandle = ( HWND ) wParam;
! itoa( ( int ) windowHandle, strWindowId, 10 );
!
//get name
! GetWindowText( windowHandle, windowTitle, 150 );
!
////setup return string
! strcat( result, "MSG=HSHELL_WINDOWDESTROYED;" );
! strcat( result, "ID=" );
! strcat( result, strWindowId );
! strcat( result, ";" );
! strcat( result, "TITLE=" );
! strcat( result, windowTitle );
! strcat( result, ";" );
!
buffer = result;
!
break;
! default:
break;
}
!
! if ( buffer != NULL ) {
! WriteToChannel( buffer );
}
}
!
! return CallNextHookEx( hhook, nCode, wParam, lParam );
}
! DLL_EXPORT void SetCbtHook( void )
{
! if ( !bHooked ) {
hhook =
! SetWindowsHookEx( WH_CBT, ( HOOKPROC ) CbtProc, hInst, ( DWORD ) NULL );
bHooked = true;
}
!
! if ( !bHooked2 ) {
hhook2 =
! SetWindowsHookEx( WH_SHELL, ( HOOKPROC ) ShellProc, hInst,
! ( DWORD ) NULL );
bHooked2 = true;
}
!
! if ( !bHooked3 ) {
hhook3 =
! SetWindowsHookEx( WH_CALLWNDPROC, ( HOOKPROC ) CallWndProc, hInst,
! ( DWORD ) NULL );
bHooked3 = true;
}
}
! DLL_EXPORT void RemoveCbtHook( void )
{
! if ( bHooked ) {
! UnhookWindowsHookEx( hhook );
bHooked = false;
}
!
! if ( bHooked2 ) {
! UnhookWindowsHookEx( hhook2 );
bHooked2 = false;
}
!
! if ( bHooked3 ) {
! UnhookWindowsHookEx( hhook3 );
bHooked3 = false;
}
***************
*** 452,459 ****
{
m_vcHandle =
! WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION,
! CHANNELNAME);
!
! if (m_vcHandle == NULL) {
return 0;
} else {
--- 458,465 ----
{
m_vcHandle =
! WTSVirtualChannelOpen( WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION,
! CHANNELNAME );
!
! if ( m_vcHandle == NULL ) {
return 0;
} else {
***************
*** 464,472 ****
int CloseVirtualChannel()
{
! BOOL result = WTSVirtualChannelClose(m_vcHandle);
!
m_vcHandle = NULL;
!
! if (result) {
return 1;
} else {
--- 470,478 ----
int CloseVirtualChannel()
{
! BOOL result = WTSVirtualChannelClose( m_vcHandle );
!
m_vcHandle = NULL;
!
! if ( result ) {
return 1;
} else {
***************
*** 477,481 ****
int ChannelIsOpen()
{
! if (m_vcHandle == NULL) {
return 0;
} else {
--- 483,487 ----
int ChannelIsOpen()
{
! if ( m_vcHandle == NULL ) {
return 0;
} else {
***************
*** 484,497 ****
}
! int WriteToChannel(PCHAR buffer)
{
PULONG bytesRead = 0;
PULONG pBytesWritten = 0;
!
BOOL result =
! WTSVirtualChannelWrite(m_vcHandle, buffer, (ULONG) strlen(buffer),
! pBytesWritten);
!
! if (result) {
return 1;
} else {
--- 490,503 ----
}
! int WriteToChannel( PCHAR buffer )
{
PULONG bytesRead = 0;
PULONG pBytesWritten = 0;
!
BOOL result =
! WTSVirtualChannelWrite( m_vcHandle, buffer, ( ULONG ) strlen( buffer ),
! pBytesWritten );
!
! if ( result ) {
return 1;
} else {
Index: hookdll.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** hookdll.h 1 Jul 2005 07:01:00 -0000 1.4
--- hookdll.h 28 Aug 2005 12:56:38 -0000 1.5
***************
*** 13,19 ****
//Hooking
! typedef void (*SETHOOKS) ();
! typedef void (*REMOVEHOOKS) ();
! typedef int (*GETINSTANCECOUNT) ();
//Terminal Server
--- 13,19 ----
//Hooking
! typedef void ( *SETHOOKS ) ();
! typedef void ( *REMOVEHOOKS ) ();
! typedef int ( *GETINSTANCECOUNT ) ();
//Terminal Server
***************
*** 21,25 ****
int CloseVirtualChannel();
int ChannelIsOpen();
! int WriteToChannel(PCHAR buffer);
#endif
--- 21,25 ----
int CloseVirtualChannel();
int ChannelIsOpen();
! int WriteToChannel( PCHAR buffer );
#endif
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf