From 329303b3235afba0ea7950540e60973ed9cb1396 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 13 Nov 2009 21:23:15 +0000 Subject: [PATCH] - Remove need for boinc.dll from the client. client/ hostinfo_win.cpp main.cpp clientctrl/ boincsvcctrl.cpp clientgui/ BOINCClientManager.cpp BOINCGUIApp.cpp BOINCGUIApp.h stdwx.h clienttray/ tray_win.cpp tray_win.h lib/ boinc_win.h daemonmgt.cpp (Deleted) daemonmgt.h (Added) daemonmgt_win.cpp (Added) idlemon.h (Added) idlemon_win.cpp (Added) idlemon_win.h (Deleted) win_build/ boinc.sln boinc_dll.vcproj boincmgr.vcproj boincsvcctrl.vcproj boinctray.vcproj libboinc.vcproj svn path=/trunk/boinc/; revision=19576 --- checkin_notes | 32 + client/hostinfo_win.cpp | 18 +- client/main.cpp | 65 +- clientctrl/boincsvcctrl.cpp | 11 +- clientgui/BOINCClientManager.cpp | 23 +- clientgui/BOINCGUIApp.cpp | 34 +- clientgui/BOINCGUIApp.h | 2 - clientgui/stdwx.h | 22 +- clienttray/tray_win.cpp | 38 +- clienttray/tray_win.h | 1 - lib/boinc_win.h | 4 +- lib/daemonmgt.h | 33 + lib/{daemonmgt.cpp => daemonmgt_win.cpp} | 59 +- lib/{idlemon_win.h => idlemon.h} | 13 +- lib/idlemon_win.cpp | 52 +- win_build/boinc.sln | 20 +- win_build/boinc_dll.vcproj | 1115 ---------------------- win_build/boincmgr.vcproj | 32 +- win_build/boincsvcctrl.vcproj | 16 +- win_build/boinctray.vcproj | 16 +- win_build/libboinc.vcproj | 16 + 21 files changed, 240 insertions(+), 1382 deletions(-) create mode 100644 lib/daemonmgt.h rename lib/{daemonmgt.cpp => daemonmgt_win.cpp} (89%) rename lib/{idlemon_win.h => idlemon.h} (75%) delete mode 100644 win_build/boinc_dll.vcproj diff --git a/checkin_notes b/checkin_notes index 051e9124c5..4091d16cf7 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9180,3 +9180,35 @@ David 13 Nov 2009 cs_prefs.cpp cpu_sched.cpp log_flags.cpp,h + +Rom 13 Nov 2009 + - Remove need for boinc.dll from the client. + + client/ + hostinfo_win.cpp + main.cpp + clientctrl/ + boincsvcctrl.cpp + clientgui/ + BOINCClientManager.cpp + BOINCGUIApp.cpp + BOINCGUIApp.h + stdwx.h + clienttray/ + tray_win.cpp + tray_win.h + lib/ + boinc_win.h + daemonmgt.cpp (Deleted) + daemonmgt.h (Added) + daemonmgt_win.cpp (Added) + idlemon.h (Added) + idlemon_win.cpp (Added) + idlemon_win.h (Deleted) + win_build/ + boinc.sln + boinc_dll.vcproj + boincmgr.vcproj + boincsvcctrl.vcproj + boinctray.vcproj + libboinc.vcproj diff --git a/client/hostinfo_win.cpp b/client/hostinfo_win.cpp index 2d7cd8416d..8fad631383 100644 --- a/client/hostinfo_win.cpp +++ b/client/hostinfo_win.cpp @@ -15,7 +15,10 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . +#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) #include "boinc_win.h" +#endif + #ifdef _MSC_VER #define snprintf _snprintf #endif @@ -31,8 +34,7 @@ #include "client_msgs.h" #include "hostinfo_network.h" #include "hostinfo.h" - -HINSTANCE g_hClientLibraryDll; +#include "idlemon.h" // Newer system metrics values @@ -798,15 +800,9 @@ bool HOST_INFO::host_is_running_on_batteries() { } bool HOST_INFO::users_idle(bool /*check_all_logins*/, double idle_time_to_run) { - typedef DWORD (CALLBACK* GetFn)(); - static GetFn fn = (GetFn)GetProcAddress(g_hClientLibraryDll, "BOINCGetIdleTickCount"); - - if (g_hClientLibraryDll && fn) { - double seconds_idle = fn() / 1000; - double seconds_time_to_run = 60 * idle_time_to_run; - return seconds_idle > seconds_time_to_run; - } - + double seconds_idle = get_idle_tick_count() / 1000; + double seconds_time_to_run = 60 * idle_time_to_run; + return seconds_idle > seconds_time_to_run; return false; } diff --git a/client/main.cpp b/client/main.cpp index bbfc44dd57..8e2a1f5de1 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -27,12 +27,6 @@ #define snprintf _snprintf #endif -extern HINSTANCE g_hClientLibraryDll; -typedef BOOL (CALLBACK* ClientLibraryStartup)(); -typedef BOOL (CALLBACK* IdleTrackerStartup)(); -typedef void (CALLBACK* IdleTrackerShutdown)(); -typedef void (CALLBACK* ClientLibraryShutdown)(); - #else #include "config.h" #ifdef HAVE_SYS_SOCKET_H @@ -59,6 +53,7 @@ typedef void (CALLBACK* ClientLibraryShutdown)(); #include "prefs.h" #include "filesys.h" #include "network.h" +#include "idlemon.h" #include "client_state.h" #include "file_names.h" #include "log_flags.h" @@ -275,13 +270,6 @@ static void init_core_client(int argc, char** argv) { int initialize() { int retval; -#ifdef _WIN32 - g_hClientLibraryDll = LoadLibrary("boinc.dll"); - if(!g_hClientLibraryDll) { - log_message_error("Failed to initialize the BOINC Client Library."); - } -#endif - if (!config.allow_multiple_clients) { retval = wait_client_mutex(".", 10); if (retval) { @@ -302,32 +290,14 @@ int initialize() { curl_init(); #ifdef _WIN32 - if(g_hClientLibraryDll) { - ClientLibraryStartup fnClientLibraryStartup; - IdleTrackerStartup fnIdleTrackerStartup; - - fnClientLibraryStartup = (ClientLibraryStartup)GetProcAddress(g_hClientLibraryDll, "ClientLibraryStartup"); - if(fnClientLibraryStartup) { - if(!fnClientLibraryStartup()) { - log_message_error( - "Failed to initialize the BOINC Client Library Interface." - "BOINC will not be able to determine if the user is idle or not...\n" - ); - } - } - - fnIdleTrackerStartup = (IdleTrackerStartup)GetProcAddress(g_hClientLibraryDll, "IdleTrackerStartup"); - if(fnIdleTrackerStartup) { - if(!fnIdleTrackerStartup()) { - log_message_error( - "Failed to initialize the BOINC Client Library Interface." - "BOINC will not be able to determine if the user is idle or not...\n" - ); - } - } + if(!startup_idle_monitor()) { + log_message_error( + "Failed to initialize the BOINC Client Library Interface." + "BOINC will not be able to determine if the user is idle or not...\n" + ); } - #endif + return 0; } @@ -411,26 +381,7 @@ int finalize() { gstate.quit_activities(); #ifdef _WIN32 - if(g_hClientLibraryDll) { - IdleTrackerShutdown fnIdleTrackerShutdown; - ClientLibraryShutdown fnClientLibraryShutdown; - - fnIdleTrackerShutdown = (IdleTrackerShutdown)GetProcAddress(g_hClientLibraryDll, "IdleTrackerShutdown"); - if(fnIdleTrackerShutdown) { - fnIdleTrackerShutdown(); - } - - fnClientLibraryShutdown = (ClientLibraryShutdown)GetProcAddress(g_hClientLibraryDll, "ClientLibraryShutdown"); - if(fnClientLibraryShutdown) { - fnClientLibraryShutdown(); - } - - if(!FreeLibrary(g_hClientLibraryDll)) { - log_message_error("Failed to cleanup the BOINC Idle Detection Interface"); - } - - g_hClientLibraryDll = NULL; - } + shutdown_idle_monitor(); #ifdef USE_WINSOCK if (WinsockCleanup()) { diff --git a/clientctrl/boincsvcctrl.cpp b/clientctrl/boincsvcctrl.cpp index 929a2bd918..8fa9e0e620 100644 --- a/clientctrl/boincsvcctrl.cpp +++ b/clientctrl/boincsvcctrl.cpp @@ -20,13 +20,10 @@ #endif #include "version.h" - -EXTERN_C BOOL StartBOINCServiceEx(); -EXTERN_C BOOL StopBOINCServiceEx(); - +#include "daemonmgt.h" void version(){ - printf("boincsvcctrl, built from %s \n", PACKAGE_STRING ); + printf("boincsvcctrl, built from %s \n", PACKAGE_STRING ); exit(0); } @@ -58,11 +55,11 @@ int main(int argc, char** argv) { } if (!strcmp(argv[i], "--start")) { - retval = !StartBOINCServiceEx(); + retval = !start_daemon(); } if (!strcmp(argv[i], "--stop")) { - retval = !StopBOINCServiceEx(); + retval = !stop_daemon(); } exit(retval); diff --git a/clientgui/BOINCClientManager.cpp b/clientgui/BOINCClientManager.cpp index 26b721e724..c24d5256a5 100644 --- a/clientgui/BOINCClientManager.cpp +++ b/clientgui/BOINCClientManager.cpp @@ -29,8 +29,8 @@ #include "BOINCClientManager.h" #include "error_numbers.h" #include "procinfo.h" - #include "filesys.h" +#include "daemonmgt.h" #include "util.h" #ifdef __WXMAC__ @@ -45,13 +45,6 @@ enum { #include "diagnostics_win.h" extern int diagnostics_get_process_information(PVOID* ppBuffer, PULONG pcbBuffer); -EXTERN_C BOOL IsBOINCServiceInstalled(); -EXTERN_C BOOL IsBOINCServiceStarting(); -EXTERN_C BOOL IsBOINCServiceRunning(); -EXTERN_C BOOL IsBOINCServiceStopping(); -EXTERN_C BOOL IsBOINCServiceStopped(); -EXTERN_C BOOL StartBOINCService(); -EXTERN_C BOOL StopBOINCService(); #else #include @@ -81,7 +74,7 @@ CBOINCClientManager::~CBOINCClientManager() { bool CBOINCClientManager::AutoRestart() { if (IsBOINCCoreRunning()) return true; #ifndef __WXMAC__ // Mac can restart Client as a daemon - if (! m_bBOINCStartedByManager) return false; + if (!m_bBOINCStartedByManager) return false; #endif m_lBOINCCoreProcessId = 0; StartupBOINCCore(); @@ -103,7 +96,7 @@ bool CBOINCClientManager::IsSystemBooting() { int CBOINCClientManager::IsBOINCConfiguredAsDaemon() { bool bReturnValue = false; #if defined(__WXMSW__) - if (IsBOINCServiceInstalled()) bReturnValue = 1; + if (is_daemon_installed()) bReturnValue = 1; #elif defined(__WXMAC__) if ( boinc_file_exists("/Library/LaunchDaemons/edu.berkeley.boinc.plist")) { bReturnValue = NewStyleDaemon; // New-style daemon uses launchd @@ -123,8 +116,8 @@ bool CBOINCClientManager::IsBOINCCoreRunning() { #ifdef __WXMSW__ char buf[MAX_PATH] = ""; - if (IsBOINCServiceInstalled()) { - running = (FALSE != IsBOINCServiceStarting()) || (FALSE != IsBOINCServiceRunning()); + if (is_daemon_installed()) { + running = (FALSE != is_daemon_starting()) || (FALSE != is_daemon_running()); } else { // Global mutex on Win2k and later // @@ -195,12 +188,12 @@ bool CBOINCClientManager::StartupBOINCCore() { if (IsBOINCCoreRunning()) return true; -#if defined(__WXMSW__) +#if defined(__WXMSW__) LPTSTR szExecute = NULL; LPTSTR szDataDirectory = NULL; if (IsBOINCConfiguredAsDaemon()) { - StartBOINCService(); + start_daemon_via_daemonctrl(); m_bBOINCStartedByManager = true; bReturnValue = IsBOINCCoreRunning(); @@ -434,7 +427,7 @@ void CBOINCClientManager::ShutdownBOINCCore() { if (m_bBOINCStartedByManager) { #ifdef __WXMSW__ if (IsBOINCConfiguredAsDaemon()) { - StopBOINCService(); + stop_daemon_via_daemonctrl(); bClientQuit = true; } else #endif diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index ff5d5e7f32..d17ad59a62 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -36,6 +36,7 @@ #include "mfile.h" #include "miofile.h" #include "parse.h" +#include "idlemon.h" #include "Events.h" #include "common/wxFlatNotebook.h" #include "LogBOINC.h" @@ -52,15 +53,6 @@ #include "DlgExitMessage.h" -#ifdef __WXMSW__ -EXTERN_C BOOL ClientLibraryStartup(); -EXTERN_C BOOL IdleTrackerAttach(); -EXTERN_C void IdleTrackerDetach(); -EXTERN_C void ClientLibraryShutdown(); -EXTERN_C DWORD BOINCGetIdleTickCount(); -#endif - - DEFINE_EVENT_TYPE(wxEVT_RPC_FINISHED) IMPLEMENT_APP(CBOINCGUIApp) @@ -456,7 +448,6 @@ bool CBOINCGUIApp::OnInit() { // Startup the System Idle Detection code - ClientLibraryStartup(); IdleTrackerAttach(); #ifdef __WXMAC__ @@ -499,7 +490,6 @@ bool CBOINCGUIApp::OnInit() { int CBOINCGUIApp::OnExit() { // Shutdown the System Idle Detection code IdleTrackerDetach(); - ClientLibraryShutdown(); if (m_pDocument) { m_pDocument->OnExit(); @@ -746,17 +736,9 @@ void CBOINCGUIApp::InitSupportedLanguages() { } -int CBOINCGUIApp::ClientLibraryStartup() { -#ifdef __WXMSW__ - ::ClientLibraryStartup(); -#endif - return 0; -} - - int CBOINCGUIApp::IdleTrackerAttach() { #ifdef __WXMSW__ - ::IdleTrackerAttach(); + ::attach_idle_monitor(); #endif return 0; } @@ -764,15 +746,7 @@ int CBOINCGUIApp::IdleTrackerAttach() { int CBOINCGUIApp::IdleTrackerDetach() { #ifdef __WXMSW__ - ::IdleTrackerDetach(); -#endif - return 0; -} - - -int CBOINCGUIApp::ClientLibraryShutdown() { -#ifdef __WXMSW__ - ::ClientLibraryShutdown(); + ::detach_idle_monitor(); #endif return 0; } @@ -801,7 +775,7 @@ void CBOINCGUIApp::OnSystemShutDown( wxCloseEvent& event ) { int CBOINCGUIApp::UpdateSystemIdleDetection() { #ifdef __WXMSW__ - return BOINCGetIdleTickCount(); + return get_idle_tick_count(); #else return TRUE; #endif diff --git a/clientgui/BOINCGUIApp.h b/clientgui/BOINCGUIApp.h index 4178c80a5b..606b40dae2 100644 --- a/clientgui/BOINCGUIApp.h +++ b/clientgui/BOINCGUIApp.h @@ -64,10 +64,8 @@ protected: void InitSupportedLanguages(); - int ClientLibraryStartup(); int IdleTrackerAttach(); int IdleTrackerDetach(); - int ClientLibraryShutdown(); wxConfig* m_pConfig; wxLocale* m_pLocale; diff --git a/clientgui/stdwx.h b/clientgui/stdwx.h index 2d501fdde6..9d00e09548 100644 --- a/clientgui/stdwx.h +++ b/clientgui/stdwx.h @@ -21,22 +21,18 @@ #ifdef _WIN32 -// 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. +// Target Windows 2000 or better with Internet Explorer 5.01 or better +#ifndef WINVER +#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 98 and Windows 2000 or later. +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 #endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0400 // Change this to the appropriate value to target Windows Me or later. +#ifndef _WIN32_WINDOWS +#define _WIN32_WINDOWS 0x0500 #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. +#ifndef _WIN32_IE +#define _WIN32_IE 0x0501 #endif #endif diff --git a/clienttray/tray_win.cpp b/clienttray/tray_win.cpp index bfaf1defdf..f39a238c4a 100644 --- a/clienttray/tray_win.cpp +++ b/clienttray/tray_win.cpp @@ -20,13 +20,9 @@ #include "boinc_tray.h" #include "tray_win.h" +#include "idlemon.h" -EXTERN_C BOOL ClientLibraryStartup(); -EXTERN_C BOOL IdleTrackerAttach(); -EXTERN_C void IdleTrackerDetach(); -EXTERN_C void ClientLibraryShutdown(); -EXTERN_C DWORD BOINCGetIdleTickCount(); HMODULE g_hModule = NULL; static CBOINCTray* gspBOINCTray = NULL; @@ -42,14 +38,13 @@ INT WINAPI WinMain( CBOINCTray::CBOINCTray() { gspBOINCTray = this; m_hDataManagementThread = NULL; - m_bClientLibraryInitialized = FALSE; m_bIdleTrackerInitialized = FALSE; } // Starts main execution of BOINC Tray. // -INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { +INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR /* lpCmdLine */ , int /* nCmdShow */ ) { if (!hPrevInstance) { // Register an appropriate window class for the primary window @@ -73,7 +68,7 @@ INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi hWnd = CreateWindow( _T("BOINCTrayWndClass"), - _T("BOINC SystemTray Applet"), + _T("BOINC System Tray Applet"), WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); @@ -86,9 +81,8 @@ INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi } - // Cleanup and shutdown the BOINC client library idle tracking system. - IdleTrackerDetach(); - ClientLibraryShutdown(); + // Cleanup and shutdown the BOINC idle tracking system. + detach_idle_monitor(); return msg.wParam; } @@ -133,20 +127,15 @@ BOOL CBOINCTray::DestroyDataManagementThread() { // DWORD WINAPI CBOINCTray::DataManagementProc() { while (true) { - if (!m_bClientLibraryInitialized || !m_bIdleTrackerInitialized) { - // On Vista systems, only elevated processes can create shared memory - // area's across various user sessions. In this case we need to wait - // for BOINC to create the shared memory area and then boinctray can - // successfully attach to it. What a PITA. - if (!m_bClientLibraryInitialized) { - m_bClientLibraryInitialized = ClientLibraryStartup(); - } - if (m_bClientLibraryInitialized && !m_bIdleTrackerInitialized) { - m_bIdleTrackerInitialized = IdleTrackerAttach(); - } + // On Vista systems, only elevated processes can create shared memory + // area's across various user sessions. In this case we need to wait + // for BOINC to create the shared memory area and then boinctray can + // successfully attach to it. What a PITA. + if (!m_bIdleTrackerInitialized) { + m_bIdleTrackerInitialized = attach_idle_monitor(); } - BOINCGetIdleTickCount(); + get_idle_tick_count(); Sleep(5000); } } @@ -194,6 +183,3 @@ LRESULT CALLBACK CBOINCTray::TrayProcStub( ) { return gspBOINCTray->TrayProc(hWnd, uMsg, wParam, lParam); } - - -const char *BOINC_RCSID_116269c72f = "$Id: screensaver_win.cpp 13819 2007-10-10 09:25:40Z fthomas $"; diff --git a/clienttray/tray_win.h b/clienttray/tray_win.h index 6cb07de53c..9dd08e875e 100644 --- a/clienttray/tray_win.h +++ b/clienttray/tray_win.h @@ -41,7 +41,6 @@ protected: static LRESULT CALLBACK TrayProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); HANDLE m_hDataManagementThread; - BOOL m_bClientLibraryInitialized; BOOL m_bIdleTrackerInitialized; }; diff --git a/lib/boinc_win.h b/lib/boinc_win.h index fc5c797bc8..14eccc7f46 100644 --- a/lib/boinc_win.h +++ b/lib/boinc_win.h @@ -41,7 +41,7 @@ #endif #endif -// Target Windows 2000 or better with Internet Explorer 5.0 or better +// Target Windows 2000 or better with Internet Explorer 5.01 or better #ifndef WINVER #define WINVER 0x0500 #endif @@ -52,7 +52,7 @@ #define _WIN32_WINDOWS 0x0500 #endif #ifndef _WIN32_IE -#define _WIN32_IE 0x0500 +#define _WIN32_IE 0x0501 #endif #include diff --git a/lib/daemonmgt.h b/lib/daemonmgt.h new file mode 100644 index 0000000000..30fcb34a04 --- /dev/null +++ b/lib/daemonmgt.h @@ -0,0 +1,33 @@ +// 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 . + +#ifndef _BOINC_DAEMONMANAGEMENT_H_ +#define _BOINC_DAEMONMANAGEMENT_H_ + +extern bool is_daemon_installed(); +extern bool is_daemon_starting(); +extern bool is_daemon_running(); +extern bool is_daemon_stopping(); +extern bool is_daemon_stopped(); + + +extern bool start_daemon_via_daemonctrl(); +extern bool start_daemon(); +extern bool stop_daemon_via_daemonctrl(); +extern bool stop_daemon(); + +#endif \ No newline at end of file diff --git a/lib/daemonmgt.cpp b/lib/daemonmgt_win.cpp similarity index 89% rename from lib/daemonmgt.cpp rename to lib/daemonmgt_win.cpp index 5fa582c8ed..c5fc82e77f 100644 --- a/lib/daemonmgt.cpp +++ b/lib/daemonmgt_win.cpp @@ -15,17 +15,18 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . - -#include "stdafx.h" +#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) +#include "boinc_win.h" +#endif /** * Find out if BOINC has been installed as a service. **/ -EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceInstalled() +bool is_daemon_installed() { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; - BOOL bRetVal = FALSE; + bool bRetVal = false; schSCManager = OpenSCManager( NULL, // local machine @@ -41,7 +42,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceInstalled() if (schService) { - bRetVal = TRUE; + bRetVal = true; } } @@ -58,12 +59,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceInstalled() /** * Find out if BOINC has been told to start. **/ -EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStarting() +bool is_daemon_starting() { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; SERVICE_STATUS ssStatus; - BOOL bRetVal = FALSE; + bool bRetVal = false; schSCManager = OpenSCManager( NULL, // local machine @@ -82,7 +83,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStarting() if (QueryServiceStatus(schService, &ssStatus)) { if (ssStatus.dwCurrentState == SERVICE_START_PENDING) - bRetVal = TRUE; + bRetVal = true; } } } @@ -100,12 +101,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStarting() /** * Find out if BOINC is executing as a service. **/ -EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceRunning() +bool is_daemon_running() { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; SERVICE_STATUS ssStatus; - BOOL bRetVal = FALSE; + bool bRetVal = false; schSCManager = OpenSCManager( NULL, // local machine @@ -124,7 +125,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceRunning() if (QueryServiceStatus(schService, &ssStatus)) { if (ssStatus.dwCurrentState == SERVICE_RUNNING) - bRetVal = TRUE; + bRetVal = true; } } } @@ -142,12 +143,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceRunning() /** * Find out if BOINC has been told to stop. **/ -EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopping() +bool is_daemon_stopping() { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; SERVICE_STATUS ssStatus; - BOOL bRetVal = FALSE; + bool bRetVal = false; schSCManager = OpenSCManager( NULL, // local machine @@ -166,7 +167,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopping() if (QueryServiceStatus(schService, &ssStatus)) { if (ssStatus.dwCurrentState == SERVICE_STOP_PENDING) - bRetVal = TRUE; + bRetVal = true; } } } @@ -184,12 +185,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopping() /** * Find out if BOINC has stopped executing as a service. **/ -EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopped() +bool is_daemon_stopped() { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; SERVICE_STATUS ssStatus; - BOOL bRetVal = FALSE; + bool bRetVal = false; schSCManager = OpenSCManager( NULL, // local machine @@ -208,7 +209,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopped() if (QueryServiceStatus(schService, &ssStatus)) { if (ssStatus.dwCurrentState == SERVICE_STOPPED) - bRetVal = TRUE; + bRetVal = true; } } } @@ -226,9 +227,9 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopped() /** * Start the BOINC Service via the BOINC Service Control utility. **/ -EXTERN_C __declspec(dllexport) BOOL StartBOINCService() +bool start_daemon_via_daemonctrl() { - BOOL bRetVal = FALSE; + bool bRetVal = false; BOOL bProcessStarted; SHELLEXECUTEINFO shex; TCHAR szPath[MAX_PATH+1]; @@ -271,7 +272,7 @@ EXTERN_C __declspec(dllexport) BOOL StartBOINCService() WaitForSingleObject(shex.hProcess, INFINITE); if (GetExitCodeProcess(shex.hProcess, &ulExitCode)) { if (ulExitCode == 0) { - bRetVal = TRUE; + bRetVal = true; } } } @@ -283,11 +284,11 @@ EXTERN_C __declspec(dllexport) BOOL StartBOINCService() /** * Start the BOINC Service. **/ -EXTERN_C __declspec(dllexport) BOOL StartBOINCServiceEx() +bool start_daemon() { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; - BOOL bRetVal = FALSE; + bool bRetVal = false; schSCManager = OpenSCManager( NULL, // local machine @@ -305,7 +306,7 @@ EXTERN_C __declspec(dllexport) BOOL StartBOINCServiceEx() { if (StartService(schService, 0, NULL)) { - bRetVal = TRUE; + bRetVal = true; } } } @@ -323,9 +324,9 @@ EXTERN_C __declspec(dllexport) BOOL StartBOINCServiceEx() /** * Stop the BOINC Service via the BOINC Service Control utility. **/ -EXTERN_C __declspec(dllexport) BOOL StopBOINCService() +bool stop_daemon_via_daemonctrl() { - BOOL bRetVal = FALSE; + bool bRetVal = false; BOOL bProcessStarted; SHELLEXECUTEINFO shex; TCHAR szPath[MAX_PATH+1]; @@ -368,7 +369,7 @@ EXTERN_C __declspec(dllexport) BOOL StopBOINCService() WaitForSingleObject(shex.hProcess, INFINITE); if (GetExitCodeProcess(shex.hProcess, &ulExitCode)) { if (ulExitCode == 0) { - bRetVal = TRUE; + bRetVal = true; } } } @@ -380,12 +381,12 @@ EXTERN_C __declspec(dllexport) BOOL StopBOINCService() /** * Stop the BOINC Service. **/ -EXTERN_C __declspec(dllexport) BOOL StopBOINCServiceEx() +bool stop_daemon() { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; SERVICE_STATUS ssStatus; - BOOL bRetVal = FALSE; + bool bRetVal = false; schSCManager = OpenSCManager( NULL, // local machine @@ -403,7 +404,7 @@ EXTERN_C __declspec(dllexport) BOOL StopBOINCServiceEx() { if (ControlService(schService, SERVICE_CONTROL_STOP, &ssStatus)) { - bRetVal = TRUE; + bRetVal = true; } } } diff --git a/lib/idlemon_win.h b/lib/idlemon.h similarity index 75% rename from lib/idlemon_win.h rename to lib/idlemon.h index 312a3ce25b..7e4eaeb193 100644 --- a/lib/idlemon_win.h +++ b/lib/idlemon.h @@ -15,7 +15,14 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -#pragma once +#ifndef _BOINC_IDLEMONITOR_H_ +#define _BOINC_IDLEMONITOR_H_ -extern BOOL IdleTrackerStartup(); -extern void IdleTrackerShutdown(); +extern bool startup_idle_monitor(); +extern bool attach_idle_monitor(); +extern void shutdown_idle_monitor(); +extern void detach_idle_monitor(); + +extern long get_idle_tick_count(); + +#endif \ No newline at end of file diff --git a/lib/idlemon_win.cpp b/lib/idlemon_win.cpp index b5fca3fd7c..2e3a0da2be 100644 --- a/lib/idlemon_win.cpp +++ b/lib/idlemon_win.cpp @@ -16,22 +16,22 @@ // along with BOINC. If not, see . -#include "stdafx.h" -#include "boinc_dll.h" +#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_) +#include "boinc_win.h" +#endif + #include "win_util.h" /** - * The following global data is only shared in this instance of the DLL + * The following global data is only shared in this process **/ HANDLE g_hMemoryMappedData = NULL; /** - * The following global data is SHARED among all instances of the DLL - * (processes); i.e., these are system-wide globals. + * The following global data is SHARED among all (processes); i.e., these are system-wide globals. **/ -struct SystemWideIdleData -{ +struct SystemWideIdleData { DWORD dwLastTick; // tick time of last input event }; @@ -40,8 +40,7 @@ struct SystemWideIdleData* g_pSystemWideIdleData = NULL; /** * Get tick count of last keyboard or mouse event **/ -EXTERN_C __declspec(dllexport) DWORD BOINCGetIdleTickCount() -{ +long get_idle_tick_count() { DWORD dwCurrentTickCount = GetTickCount(); DWORD dwLastTickCount = 0; @@ -73,10 +72,9 @@ EXTERN_C __declspec(dllexport) DWORD BOINCGetIdleTickCount() } -EXTERN_C __declspec(dllexport) BOOL IdleTrackerStartup() -{ +bool startup_idle_monitor() { BOOL bExists = FALSE; - BOOL bResult = FALSE; + bool bResult = false; SECURITY_ATTRIBUTES sec_attr; SECURITY_DESCRIPTOR sd; @@ -103,7 +101,7 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerStartup() PAGE_READWRITE, 0, 4096, - "Global\\BoincIdleTracker" + _T("Global\\BoincIdleTracker") ); if( NULL == g_hMemoryMappedData ) { @@ -114,7 +112,7 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerStartup() PAGE_READWRITE, 0, 4096, - "BoincIdleTracker" + _T("BoincIdleTracker") ); } @@ -142,19 +140,18 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerStartup() if (!g_hMemoryMappedData || !g_pSystemWideIdleData ) - bResult = FALSE; + bResult = false; else - bResult = TRUE; + bResult = true; return bResult; } -EXTERN_C __declspec(dllexport) BOOL IdleTrackerAttach() -{ +bool attach_idle_monitor() { BOOL bExists = FALSE; - BOOL bResult = FALSE; + bool bResult = false; SECURITY_ATTRIBUTES sec_attr; SECURITY_DESCRIPTOR sd; @@ -178,7 +175,7 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerAttach() OpenFileMapping( FILE_MAP_READ | FILE_MAP_WRITE, FALSE, - "Global\\BoincIdleTracker" + _T("Global\\BoincIdleTracker") ); if( NULL == g_hMemoryMappedData ) { @@ -186,7 +183,7 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerAttach() OpenFileMapping( FILE_MAP_READ | FILE_MAP_WRITE, FALSE, - "BoincIdleTracker" + _T("BoincIdleTracker") ); } @@ -214,15 +211,15 @@ EXTERN_C __declspec(dllexport) BOOL IdleTrackerAttach() if (!g_hMemoryMappedData || !g_pSystemWideIdleData ) - bResult = FALSE; + bResult = false; else - bResult = TRUE; + bResult = true; return bResult; } -EXTERN_C __declspec(dllexport) void IdleTrackerShutdown() +void shutdown_idle_monitor() { if( NULL != g_pSystemWideIdleData ) { @@ -232,10 +229,7 @@ EXTERN_C __declspec(dllexport) void IdleTrackerShutdown() } -EXTERN_C __declspec(dllexport) void IdleTrackerDetach() +void detach_idle_monitor() { - IdleTrackerShutdown(); + shutdown_idle_monitor(); } - - -const char *BOINC_RCSID_14d432d5b3 = "$Id$"; diff --git a/win_build/boinc.sln b/win_build/boinc.sln index f5487b6fa9..9e10455eba 100644 --- a/win_build/boinc.sln +++ b/win_build/boinc.sln @@ -7,13 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boinc", "boinc_cli.vcproj", EndProjectSection ProjectSection(ProjectDependencies) = postProject {E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8} - {B06280CB-82A4-46DE-8956-602643078BDF} = {B06280CB-82A4-46DE-8956-602643078BDF} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boinc_dll", "boinc_dll.vcproj", "{B06280CB-82A4-46DE-8956-602643078BDF}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boinc_ss", "boinc_ss.vcproj", "{4A2C5963-6A8D-4CA1-A312-C3D749B2EA81}" @@ -38,7 +31,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boincmgr", "boincmgr.vcproj Release.AspNetCompiler.Debug = "False" EndProjectSection ProjectSection(ProjectDependencies) = postProject - {B06280CB-82A4-46DE-8956-602643078BDF} = {B06280CB-82A4-46DE-8956-602643078BDF} {C04F0FCC-BB5D-4627-8656-6173B28BD69E} = {C04F0FCC-BB5D-4627-8656-6173B28BD69E} EndProjectSection EndProject @@ -69,7 +61,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boinctray", "boinctray.vcpr Release.AspNetCompiler.Debug = "False" EndProjectSection ProjectSection(ProjectDependencies) = postProject - {B06280CB-82A4-46DE-8956-602643078BDF} = {B06280CB-82A4-46DE-8956-602643078BDF} + {E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "image_libs", "image_libs.vcproj", "{D3D21F11-A7E7-4EA2-8518-E24695133BFF}" @@ -177,7 +169,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boincsvcctrl", "boincsvcctr Release.AspNetCompiler.Debug = "False" EndProjectSection ProjectSection(ProjectDependencies) = postProject - {B06280CB-82A4-46DE-8956-602643078BDF} = {B06280CB-82A4-46DE-8956-602643078BDF} + {E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ss_app", "ss_app.vcproj", "{C3163ACA-C2E6-49D2-AA21-B8B953331EF7}" @@ -209,14 +201,6 @@ Global {C04F0FCC-BB5D-4627-8656-6173B28BD69E}.Release|Win32.Build.0 = Release|Win32 {C04F0FCC-BB5D-4627-8656-6173B28BD69E}.Release|x64.ActiveCfg = Release|x64 {C04F0FCC-BB5D-4627-8656-6173B28BD69E}.Release|x64.Build.0 = Release|x64 - {B06280CB-82A4-46DE-8956-602643078BDF}.Debug|Win32.ActiveCfg = Debug|Win32 - {B06280CB-82A4-46DE-8956-602643078BDF}.Debug|Win32.Build.0 = Debug|Win32 - {B06280CB-82A4-46DE-8956-602643078BDF}.Debug|x64.ActiveCfg = Debug|x64 - {B06280CB-82A4-46DE-8956-602643078BDF}.Debug|x64.Build.0 = Debug|x64 - {B06280CB-82A4-46DE-8956-602643078BDF}.Release|Win32.ActiveCfg = Release|Win32 - {B06280CB-82A4-46DE-8956-602643078BDF}.Release|Win32.Build.0 = Release|Win32 - {B06280CB-82A4-46DE-8956-602643078BDF}.Release|x64.ActiveCfg = Release|x64 - {B06280CB-82A4-46DE-8956-602643078BDF}.Release|x64.Build.0 = Release|x64 {4A2C5963-6A8D-4CA1-A312-C3D749B2EA81}.Debug|Win32.ActiveCfg = Debug|Win32 {4A2C5963-6A8D-4CA1-A312-C3D749B2EA81}.Debug|Win32.Build.0 = Debug|Win32 {4A2C5963-6A8D-4CA1-A312-C3D749B2EA81}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/win_build/boinc_dll.vcproj b/win_build/boinc_dll.vcproj deleted file mode 100644 index 6f8be81485..0000000000 --- a/win_build/boinc_dll.vcproj +++ /dev/null @@ -1,1115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win_build/boincmgr.vcproj b/win_build/boincmgr.vcproj index 6e09bd4f33..bd1c33a518 100644 --- a/win_build/boincmgr.vcproj +++ b/win_build/boincmgr.vcproj @@ -74,7 +74,7 @@ /> + + + + @@ -1264,6 +1272,14 @@ RelativePath="..\lib\hostinfo.h" > + + + + diff --git a/win_build/boincsvcctrl.vcproj b/win_build/boincsvcctrl.vcproj index 393e06cdfe..4a477609ab 100644 --- a/win_build/boincsvcctrl.vcproj +++ b/win_build/boincsvcctrl.vcproj @@ -85,7 +85,7 @@ /> + + @@ -655,6 +659,10 @@ RelativePath="..\lib\hostinfo.h" > + + @@ -911,6 +919,10 @@ RelativePath="..\lib\crypt.cpp" > + + @@ -1023,6 +1035,10 @@ RelativePath="..\lib\hostinfo.cpp" > + +