//========================================================================== // PRODUCT: RusRoute - MaaSoftware routing firewall software driver // (C) Copyright Moiseenko A.A., MaaSoftware, 2003-2008. All Rights Reserved. // http://www.maasoftware.ru http://www.maasoftware.com // http://www.rusroute.ru http://www.rusroute.com // support@maasoftware.ru //========================================================================== // FILE: Service.cpp // // AUTHOR: Andrey A. Moiseenko // // OVERVIEW Common adapter services. // ~~~~~~~~ // DATE: 26.03.2003(VCOMMMAA) - 24.08.2004(MAARF) - 2007(RusRoute) //========================================================================== #include "perm.h" #include "temp.h" //--------------------------------------------------------------------------- static void NDIS_API TimerFunction ( void * p1, void * Context, void * p3, void * p4 ); //--------------------------------------------------------------------------- CDrvTimer::CDrvTimer ( int MilliSeconds ) { m_MilliSeconds = MilliSeconds; #ifdef __unix__ m_pTimer = myget_timer (); #else NdisInitializeTimer ( &m_Timer, TimerFunction, this ); #endif } //--------------------------------------------------------------------------- static void NDIS_API TimerFunction ( void * p1, void * Context, void * p3, void * p4 ) { //INT3; ( ( CDrvTimer * ) Context ) -> Event (); } //---------------------------------------------------------------------------- CDrvTimer::~CDrvTimer () { Stop (); } //---------------------------------------------------------------------------- int CDrvTimer::Start ( int MilliSeconds ) { m_MilliSeconds = MilliSeconds; return Start (); } //---------------------------------------------------------------------------- int CDrvTimer::Start () { // only seconds defined in linux kernel, tick per second may differ // from 1024 (alpha) to 100 (others) // and we use second / 10 // C function with unsigned long parameter = this ==> C++ class member... #ifdef __unix__ myset_timer ( m_pTimer, m_MilliSeconds / 100, this, Event ); myadd_timer ( m_pTimer ); #else NdisSetTimer ( &m_Timer, m_MilliSeconds ); // MillisecondsToDelay #endif return 0; } //---------------------------------------------------------------------------- int CDrvTimer::Stop () { #ifdef __unix__ mydel_timer ( m_pTimer ); #else BOOLEAN TimerCancelled; NdisCancelTimer ( &m_Timer, &TimerCancelled ); #endif return 0; } //---------------------------------------------------------------------------- /* //--------------------------------------------------------------------------- CCliLock::CCliLock () { m_Count = 0; _dword f; __asm { pushfd pop f } m_Flags = f; } CCliLock::~CCliLock () { if ( m_Count ) { INT3; } } void CCliLock::Lock () { __asm cli; ++m_Count; } void CCliLock::UnLock () { if ( m_Count ) { if ( !--m_Count ) { _dword f = m_Flags; __asm { push f popfd } } } } //--------------------------------------------------------------------------- CAutoCliLock::CAutoCliLock () { Lock (); } CAutoCliLock::~CAutoCliLock () { UnLock (); } //--------------------------------------------------------------------------- */