diff --git a/checkin_notes b/checkin_notes
index 4a75ee4861..c5e397ee8c 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -6274,3 +6274,12 @@ Rom 15 July 2009
client/
hostinfo_win.cpp
+
+Rom 15 July 2009
+ - clientlib: Remove backwards compatible mouse and keyboard activity
+ detection code since we no longer support Win9x
+
+ clientlib/win/
+ boinc_dll.cpp
+ IdleTracker.cpp
+ stdafx.h
diff --git a/clientlib/win/IdleTracker.cpp b/clientlib/win/IdleTracker.cpp
index 10720aabec..b5fca3fd7c 100644
--- a/clientlib/win/IdleTracker.cpp
+++ b/clientlib/win/IdleTracker.cpp
@@ -1,18 +1,20 @@
-/**
- * IdleTracker - a DLL that tracks the user's idle input time
- * system-wide.
- *
- * Usage
- * =====
- * - call IdleTrackerInit() when you want to start monitoring.
- * - call IdleTrackerTerm() when you want to stop monitoring.
- * - to get the time past since last user input, do the following:
- * GetTickCount() - IdleTrackerGetLastTickCount()
- *
- * Author: Sidney Chong
- * Date: 25/5/2000
- * Version: 1.0
- **/
+// This file is part of BOINC.
+// http://boinc.berkeley.edu
+// Copyright (C) 2008 University of California
+//
+// BOINC is free software; you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation,
+// either version 3 of the License, or (at your option) any later version.
+//
+// BOINC is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with BOINC. If not, see .
+
#include "stdafx.h"
#include "boinc_dll.h"
@@ -22,23 +24,7 @@
/**
* The following global data is only shared in this instance of the DLL
**/
-HMODULE g_hUser32 = NULL;
HANDLE g_hMemoryMappedData = NULL;
-BOOL g_bIsWindows2000Compatible = FALSE;
-BOOL g_bIsTerminalServicesEnabled = FALSE;
-
-/**
- * The following global data is SHARED among all instances of the DLL
- * (processes) within a terminal services session.
- **/
-#pragma data_seg(".IdleTrac") // you must define as SHARED in .def
-HHOOK g_hHkKeyboard = NULL; // handle to the keyboard hook
-HHOOK g_hHkMouse = NULL; // handle to the mouse hook
-LONG g_mouseLocX = -1; // x-location of mouse position
-LONG g_mouseLocY = -1; // y-location of mouse position
-DWORD g_dwLastTick = 0; // tick time of last input event
-#pragma data_seg()
-#pragma comment(linker, "/section:.IdleTrac,rws")
/**
* The following global data is SHARED among all instances of the DLL
@@ -51,49 +37,6 @@ struct SystemWideIdleData
struct SystemWideIdleData* g_pSystemWideIdleData = NULL;
-/**
- * Define stuff that only exists on Windows 2000 compatible machines
- **/
-typedef struct tagLASTINPUTINFO {
- UINT cbSize;
- DWORD dwTime;
-} LASTINPUTINFO, *PLASTINPUTINFO;
-
-typedef BOOL (WINAPI *GETLASTINPUTINFO)(PLASTINPUTINFO);
-
-GETLASTINPUTINFO g_fnGetLastInputInfo = NULL;
-
-/**
- * Keyboard hook: record tick count
- **/
-LRESULT CALLBACK KeyboardTracker(int code, WPARAM wParam, LPARAM lParam)
-{
- if (code==HC_ACTION)
- {
- g_dwLastTick = GetTickCount();
- }
- return ::CallNextHookEx(g_hHkKeyboard, code, wParam, lParam);
-}
-
-/**
- * Mouse hook: record tick count
- **/
-LRESULT CALLBACK MouseTracker(int code, WPARAM wParam, LPARAM lParam)
-{
- if (code==HC_ACTION)
- {
- MOUSEHOOKSTRUCT* pStruct = (MOUSEHOOKSTRUCT*)lParam;
- //we will assume that any mouse msg with the same locations as spurious
- if (pStruct->pt.x != g_mouseLocX || pStruct->pt.y != g_mouseLocY)
- {
- g_mouseLocX = pStruct->pt.x;
- g_mouseLocY = pStruct->pt.y;
- g_dwLastTick = GetTickCount();
- }
- }
- return ::CallNextHookEx(g_hHkMouse, code, wParam, lParam);
-}
-
/**
* Get tick count of last keyboard or mouse event
**/
@@ -102,44 +45,34 @@ EXTERN_C __declspec(dllexport) DWORD BOINCGetIdleTickCount()
DWORD dwCurrentTickCount = GetTickCount();
DWORD dwLastTickCount = 0;
- if ( g_bIsWindows2000Compatible )
+ if ( g_pSystemWideIdleData )
{
- if ( g_pSystemWideIdleData )
+ LASTINPUTINFO lii;
+ ZeroMemory( &lii, sizeof(lii) );
+ lii.cbSize = sizeof(lii);
+ GetLastInputInfo( &lii );
+
+ /**
+ * If both values are greater than the system tick count then
+ * the system must have looped back to the beginning.
+ **/
+ if ( ( dwCurrentTickCount < lii.dwTime ) &&
+ ( dwCurrentTickCount < g_pSystemWideIdleData->dwLastTick ) )
{
- LASTINPUTINFO lii;
- ZeroMemory( &lii, sizeof(lii) );
- lii.cbSize = sizeof(lii);
- g_fnGetLastInputInfo( &lii );
-
- /**
- * If both values are greater than the system tick count then
- * the system must have looped back to the beginning.
- **/
- if ( ( dwCurrentTickCount < lii.dwTime ) &&
- ( dwCurrentTickCount < g_pSystemWideIdleData->dwLastTick ) )
- {
- lii.dwTime = dwCurrentTickCount;
- g_pSystemWideIdleData->dwLastTick = dwCurrentTickCount;
- }
-
- if ( lii.dwTime > g_pSystemWideIdleData->dwLastTick )
- g_pSystemWideIdleData->dwLastTick = lii.dwTime;
-
- dwLastTickCount = g_pSystemWideIdleData->dwLastTick;
+ lii.dwTime = dwCurrentTickCount;
+ g_pSystemWideIdleData->dwLastTick = dwCurrentTickCount;
}
- }
- else
- {
- dwLastTickCount = g_dwLastTick;
+
+ if ( lii.dwTime > g_pSystemWideIdleData->dwLastTick )
+ g_pSystemWideIdleData->dwLastTick = lii.dwTime;
+
+ dwLastTickCount = g_pSystemWideIdleData->dwLastTick;
}
return (dwCurrentTickCount - dwLastTickCount);
}
-/**
- * Initialize DLL: install kbd/mouse hooks.
- **/
EXTERN_C __declspec(dllexport) BOOL IdleTrackerStartup()
{
BOOL bExists = FALSE;
@@ -148,124 +81,76 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerStartup()
SECURITY_DESCRIPTOR sd;
- g_bIsWindows2000Compatible = IsWindows2000Compatible();
- g_bIsTerminalServicesEnabled = IsTerminalServicesEnabled();
+ /*
+ * Create a security descriptor that will allow
+ * everyone full access.
+ */
+ InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION );
+ SetSecurityDescriptorDacl( &sd, TRUE, NULL, FALSE );
-
- if ( !g_bIsWindows2000Compatible )
+ sec_attr.nLength = sizeof(sec_attr);
+ sec_attr.bInheritHandle = TRUE;
+ sec_attr.lpSecurityDescriptor = &sd;
+
+ /*
+ * Create a filemap object that is global for everyone,
+ * including users logged in via terminal services.
+ */
+ g_hMemoryMappedData =
+ CreateFileMapping(
+ INVALID_HANDLE_VALUE,
+ &sec_attr,
+ PAGE_READWRITE,
+ 0,
+ 4096,
+ "Global\\BoincIdleTracker"
+ );
+ if( NULL == g_hMemoryMappedData )
{
- if ( NULL == g_hHkKeyboard )
- {
- g_hHkKeyboard = SetWindowsHookEx(
- WH_KEYBOARD,
- KeyboardTracker,
- g_hModule,
- 0
- );
- }
- if ( NULL == g_hHkMouse )
- {
- g_hHkMouse = SetWindowsHookEx(
- WH_MOUSE,
- MouseTracker,
- g_hModule,
- 0
- );
- }
-
- _ASSERT( g_hHkKeyboard );
- _ASSERT( g_hHkMouse );
- }
- else
- {
- g_hUser32 = LoadLibrary("user32.dll");
- if (g_hUser32)
- g_fnGetLastInputInfo = (GETLASTINPUTINFO)GetProcAddress(g_hUser32, "GetLastInputInfo");
-
-
- /*
- * Create a security descriptor that will allow
- * everyone full access.
- */
- InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION );
- SetSecurityDescriptorDacl( &sd, TRUE, NULL, FALSE );
-
- sec_attr.nLength = sizeof(sec_attr);
- sec_attr.bInheritHandle = TRUE;
- sec_attr.lpSecurityDescriptor = &sd;
-
- /*
- * Create a filemap object that is global for everyone,
- * including users logged in via terminal services.
- */
- g_hMemoryMappedData =
+ g_hMemoryMappedData =
CreateFileMapping(
INVALID_HANDLE_VALUE,
- &sec_attr,
- PAGE_READWRITE,
- 0,
- 4096,
- "Global\\BoincIdleTracker"
+ &sec_attr,
+ PAGE_READWRITE,
+ 0,
+ 4096,
+ "BoincIdleTracker"
);
- if( NULL == g_hMemoryMappedData )
- {
- g_hMemoryMappedData =
- CreateFileMapping(
- INVALID_HANDLE_VALUE,
- &sec_attr,
- PAGE_READWRITE,
- 0,
- 4096,
- "BoincIdleTracker"
- );
- }
-
- if( NULL != g_hMemoryMappedData )
- {
- if( ERROR_ALREADY_EXISTS == GetLastError() )
- bExists = TRUE;
-
- g_pSystemWideIdleData = (struct SystemWideIdleData*)
- MapViewOfFile(
- g_hMemoryMappedData,
- FILE_MAP_ALL_ACCESS,
- 0,
- 0,
- 0
- );
-
- _ASSERT( g_pSystemWideIdleData );
- }
-
- if( !bExists && g_pSystemWideIdleData )
- {
- g_pSystemWideIdleData->dwLastTick = GetTickCount();
- }
}
-
- if ( !g_bIsWindows2000Compatible )
+ if( NULL != g_hMemoryMappedData )
{
- if ( !g_hHkKeyboard || !g_hHkMouse )
- bResult = FALSE;
- else
- bResult = TRUE;
+ if( ERROR_ALREADY_EXISTS == GetLastError() )
+ bExists = TRUE;
+
+ g_pSystemWideIdleData = (struct SystemWideIdleData*)
+ MapViewOfFile(
+ g_hMemoryMappedData,
+ FILE_MAP_ALL_ACCESS,
+ 0,
+ 0,
+ 0
+ );
+
+ _ASSERT( g_pSystemWideIdleData );
}
+
+ if( !bExists && g_pSystemWideIdleData )
+ {
+ g_pSystemWideIdleData->dwLastTick = GetTickCount();
+ }
+
+
+ if (!g_hMemoryMappedData || !g_pSystemWideIdleData )
+ bResult = FALSE;
else
- {
- if ( !g_hUser32 || !g_fnGetLastInputInfo || !g_hMemoryMappedData || !g_pSystemWideIdleData )
- bResult = FALSE;
- else
- bResult = TRUE;
- }
+ bResult = TRUE;
+
return bResult;
}
-/**
- * Initialize DLL: install kbd/mouse hooks.
- **/
EXTERN_C __declspec(dllexport) BOOL IdleTrackerAttach()
{
BOOL bExists = FALSE;
@@ -274,182 +159,82 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerAttach()
SECURITY_DESCRIPTOR sd;
- g_bIsWindows2000Compatible = IsWindows2000Compatible();
- g_bIsTerminalServicesEnabled = IsTerminalServicesEnabled();
+ /*
+ * Create a security descriptor that will allow
+ * everyone full access.
+ */
+ InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION );
+ SetSecurityDescriptorDacl( &sd, TRUE, NULL, FALSE );
-
- if ( !g_bIsWindows2000Compatible )
+ sec_attr.nLength = sizeof(sec_attr);
+ sec_attr.bInheritHandle = TRUE;
+ sec_attr.lpSecurityDescriptor = &sd;
+
+ /*
+ * Create a filemap object that is global for everyone,
+ * including users logged in via terminal services.
+ */
+ g_hMemoryMappedData =
+ OpenFileMapping(
+ FILE_MAP_READ | FILE_MAP_WRITE,
+ FALSE,
+ "Global\\BoincIdleTracker"
+ );
+ if( NULL == g_hMemoryMappedData )
{
- if ( NULL == g_hHkKeyboard )
- {
- g_hHkKeyboard = SetWindowsHookEx(
- WH_KEYBOARD,
- KeyboardTracker,
- g_hModule,
- 0
- );
- }
- if ( NULL == g_hHkMouse )
- {
- g_hHkMouse = SetWindowsHookEx(
- WH_MOUSE,
- MouseTracker,
- g_hModule,
- 0
- );
- }
-
- _ASSERT( g_hHkKeyboard );
- _ASSERT( g_hHkMouse );
- }
- else
- {
- g_hUser32 = LoadLibrary("user32.dll");
- if (g_hUser32)
- g_fnGetLastInputInfo = (GETLASTINPUTINFO)GetProcAddress(g_hUser32, "GetLastInputInfo");
-
-
- /*
- * Create a security descriptor that will allow
- * everyone full access.
- */
- InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION );
- SetSecurityDescriptorDacl( &sd, TRUE, NULL, FALSE );
-
- sec_attr.nLength = sizeof(sec_attr);
- sec_attr.bInheritHandle = TRUE;
- sec_attr.lpSecurityDescriptor = &sd;
-
- /*
- * Create a filemap object that is global for everyone,
- * including users logged in via terminal services.
- */
- g_hMemoryMappedData =
+ g_hMemoryMappedData =
OpenFileMapping(
FILE_MAP_READ | FILE_MAP_WRITE,
- FALSE,
- "Global\\BoincIdleTracker"
+ FALSE,
+ "BoincIdleTracker"
);
- if( NULL == g_hMemoryMappedData )
- {
- g_hMemoryMappedData =
- OpenFileMapping(
- FILE_MAP_READ | FILE_MAP_WRITE,
- FALSE,
- "BoincIdleTracker"
- );
- }
-
- if( NULL != g_hMemoryMappedData )
- {
- if( ERROR_ALREADY_EXISTS == GetLastError() )
- bExists = TRUE;
-
- g_pSystemWideIdleData = (struct SystemWideIdleData*)
- MapViewOfFile(
- g_hMemoryMappedData,
- FILE_MAP_ALL_ACCESS,
- 0,
- 0,
- 0
- );
-
- _ASSERT( g_pSystemWideIdleData );
- }
-
- if( !bExists && g_pSystemWideIdleData )
- {
- g_pSystemWideIdleData->dwLastTick = GetTickCount();
- }
}
-
- if ( !g_bIsWindows2000Compatible )
+ if( NULL != g_hMemoryMappedData )
{
- if ( !g_hHkKeyboard || !g_hHkMouse )
- bResult = FALSE;
- else
- bResult = TRUE;
+ if( ERROR_ALREADY_EXISTS == GetLastError() )
+ bExists = TRUE;
+
+ g_pSystemWideIdleData = (struct SystemWideIdleData*)
+ MapViewOfFile(
+ g_hMemoryMappedData,
+ FILE_MAP_ALL_ACCESS,
+ 0,
+ 0,
+ 0
+ );
+
+ _ASSERT( g_pSystemWideIdleData );
}
+
+ if( !bExists && g_pSystemWideIdleData )
+ {
+ g_pSystemWideIdleData->dwLastTick = GetTickCount();
+ }
+
+
+ if (!g_hMemoryMappedData || !g_pSystemWideIdleData )
+ bResult = FALSE;
else
- {
- if ( !g_hUser32 || !g_fnGetLastInputInfo || !g_hMemoryMappedData || !g_pSystemWideIdleData )
- bResult = FALSE;
- else
- bResult = TRUE;
- }
+ bResult = TRUE;
return bResult;
}
-/**
- * Terminate DLL: remove hooks.
- **/
-EXTERN_C __declspec(dllexport) void IdleTrackerDetach()
+EXTERN_C __declspec(dllexport) void IdleTrackerShutdown()
{
- if ( !g_bIsWindows2000Compatible )
+ if( NULL != g_pSystemWideIdleData )
{
- BOOL bResult;
- if ( g_hHkKeyboard )
- {
- bResult = UnhookWindowsHookEx( g_hHkKeyboard );
- _ASSERT( bResult );
- g_hHkKeyboard = NULL;
- }
- if ( g_hHkMouse )
- {
- bResult = UnhookWindowsHookEx(g_hHkMouse);
- _ASSERT( bResult );
- g_hHkMouse = NULL;
- }
- }
- else
- {
- if( NULL != g_pSystemWideIdleData )
- {
- UnmapViewOfFile(g_pSystemWideIdleData);
- CloseHandle(g_hMemoryMappedData);
- }
-
- if ( NULL != g_hUser32 )
- FreeLibrary(g_hUser32);
+ UnmapViewOfFile(g_pSystemWideIdleData);
+ CloseHandle(g_hMemoryMappedData);
}
}
-/**
- * Terminate DLL: remove hooks.
- **/
-EXTERN_C __declspec(dllexport) void IdleTrackerShutdown()
+EXTERN_C __declspec(dllexport) void IdleTrackerDetach()
{
- if ( !g_bIsWindows2000Compatible )
- {
- BOOL bResult;
- if ( g_hHkKeyboard )
- {
- bResult = UnhookWindowsHookEx( g_hHkKeyboard );
- _ASSERT( bResult );
- g_hHkKeyboard = NULL;
- }
- if ( g_hHkMouse )
- {
- bResult = UnhookWindowsHookEx(g_hHkMouse);
- _ASSERT( bResult );
- g_hHkMouse = NULL;
- }
- }
- else
- {
- if( NULL != g_pSystemWideIdleData )
- {
- UnmapViewOfFile(g_pSystemWideIdleData);
- CloseHandle(g_hMemoryMappedData);
- }
-
- if ( NULL != g_hUser32 )
- FreeLibrary(g_hUser32);
- }
+ IdleTrackerShutdown();
}
diff --git a/clientlib/win/boinc_dll.cpp b/clientlib/win/boinc_dll.cpp
index 89f7f6ab6d..0139573291 100644
--- a/clientlib/win/boinc_dll.cpp
+++ b/clientlib/win/boinc_dll.cpp
@@ -19,7 +19,6 @@
#include "stdafx.h"
#include "resource.h"
#include "win_util.h"
-#include "IdleTracker.h"
// Declare a global hModule variable for this process, which will
// be initialized when the DLL is loaded.
diff --git a/clientlib/win/stdafx.h b/clientlib/win/stdafx.h
index 5586f82a28..71de8b0f97 100644
--- a/clientlib/win/stdafx.h
+++ b/clientlib/win/stdafx.h
@@ -10,20 +10,16 @@
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
-#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#ifndef WINVER // Allow use of features specific to Windows 2000 or later
+#define WINVER 0x0500
#endif
-#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
-#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows 2000 or later.
+#define _WIN32_WINNT 0x0500
#endif
-#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
-#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
-#endif
-
#ifndef _WIN32_IE // Allow use of features specific to IE 5.01 or later.
-#define _WIN32_IE 0x0501 // Change this to the appropriate value to target IE 6.0 or later.
+#define _WIN32_IE 0x0501
#endif
#include