CVS: seamlessrdp/ServerExe Makefile,1.1,1.2 clipper.vcproj,1.7,1.8 main.cpp,1.12,1.13
Pierre Ossman <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20533
Modified Files:
Makefile clipper.vcproj main.cpp
Log Message:
Refactor the hook dll loading so that we can remove hook.* and all C++ code.
Index: Makefile
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Makefile 8 Mar 2006 09:53:32 -0000 1.1
--- Makefile 9 Mar 2006 09:17:55 -0000 1.2
***************
*** 10,18 ****
default: seamlessrdpshell.exe HookDll/hookdll.dll
! HookDll/hook.o: HookDll/hook.cpp HookDll/hook.h
! $(CXX) -c -o $@ $<
!
! seamlessrdpshell.exe: main.cpp HookDll/hook.o
! $(CXX) -o $@ $^ -lgdi32
HookDll/hookdll.dll: HookDll/hookdll.cpp
--- 10,15 ----
default: seamlessrdpshell.exe HookDll/hookdll.dll
! seamlessrdpshell.exe: main.cpp
! $(CXX) -o $@ $^
HookDll/hookdll.dll: HookDll/hookdll.cpp
Index: clipper.vcproj
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/clipper.vcproj,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** clipper.vcproj 30 Jun 2005 15:07:49 -0000 1.7
--- clipper.vcproj 9 Mar 2006 09:17:55 -0000 1.8
***************
*** 145,154 ****
</File>
<File
- RelativePath=".\hookdll\hook.cpp">
- </File>
- <File
- RelativePath=".\hookdll\hook.h">
- </File>
- <File
RelativePath=".\icon.ico">
</File>
--- 145,148 ----
Index: main.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/main.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** main.cpp 8 Mar 2006 16:12:48 -0000 1.12
--- main.cpp 9 Mar 2006 09:17:55 -0000 1.13
***************
*** 7,11 ****
#include "resource.h"
- #include "HookDll/hook.h"
#define snprintf _snprintf
--- 7,10 ----
***************
*** 21,24 ****
--- 20,27 ----
static const char szAppName[] = "SeamlessRDP Shell";
+ typedef void ( *SetHooksProc ) ();
+ typedef void ( *RemoveHooksProc ) ();
+ typedef int ( *GetInstanceCountProc ) ();
+
//
// spawn a message box
***************
*** 109,113 ****
TPM_RETURNCMD | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
pt.x, pt.y, 0, ghWnd, NULL );
! DeleteObject( hMenu );
switch ( cmd ) {
--- 112,116 ----
TPM_RETURNCMD | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
pt.x, pt.y, 0, ghWnd, NULL );
! DestroyMenu( hMenu );
switch ( cmd ) {
***************
*** 182,208 ****
//
- // init
- //
- bool Init( LPSTR lpCmdLine )
- {
- // try to load WTSWinClipper.dll
- if ( !WTSWinClipper::Init() ) {
- Message
- ( "Application not installed correctly: Unable to init hookdll.dll." );
- return false;
- }
-
- // check number of instances
- if ( WTSWinClipper::GetInstanceCount() == 1 ) {
- // hook in
- WTSWinClipper::SetHooks();
- return true;
- } else {
- // already hooked
- return false;
- }
- }
-
- //
// our main loop
//
--- 185,188 ----
***************
*** 210,218 ****
LPSTR lpCmdLine, int nCmdShow )
{
hAppInstance = hInstance;
! if ( !Init( lpCmdLine ) ) {
! return 0;
}
// if we have been specified an app to launch, we will wait until the app has closed and use that for
// our cue to exit
--- 190,225 ----
LPSTR lpCmdLine, int nCmdShow )
{
+ HMODULE hHookDLL;
+ GetInstanceCountProc pfnInstanceCount;
+ SetHooksProc pfnSetHooks;
+ RemoveHooksProc pfnRemoveHooks;
+
hAppInstance = hInstance;
!
! hHookDLL = LoadLibrary( "hookdll.dll" );
! if ( !hHookDLL ) {
! Message( "Could not load hook DLL. Unable to continue." );
! return -1;
! }
!
! pfnInstanceCount = (GetInstanceCountProc) GetProcAddress( hHookDLL, "GetInstanceCount" );
! pfnSetHooks = (SetHooksProc) GetProcAddress( hHookDLL, "SetHooks" );
! pfnRemoveHooks = (RemoveHooksProc) GetProcAddress( hHookDLL, "RemoveHooks" );
!
! if ( !pfnInstanceCount || !pfnSetHooks || !pfnRemoveHooks ) {
! FreeLibrary( hHookDLL );
! Message( "Hook DLL doesn't contain the correct functions. Unable to continue." );
! return -1;
! }
!
! /* Check if the DLL is already loaded */
! if ( pfnInstanceCount() != 1 ) {
! FreeLibrary( hHookDLL );
! Message( "Another running instance of Seamless RDP detected." );
! return -1;
}
+ pfnSetHooks();
+
// if we have been specified an app to launch, we will wait until the app has closed and use that for
// our cue to exit
***************
*** 292,298 ****
// remove hook before saying goodbye
! WTSWinClipper::RemoveHooks();
! WTSWinClipper::Done();
return 1;
--- 299,305 ----
// remove hook before saying goodbye
! pfnRemoveHooks();
! FreeLibrary( hHookDLL );
return 1;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642