Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


CWin32Thread Class Reference

#include <Win32Thread.h>

Inheritance diagram for CWin32Thread:
Collaboration diagram for CWin32Thread:

List of all members.


Public Types

enum  _ThreadStatus { tsSuspended, tsRunning, tsStopped, tsError }
enum  _ThreadPriority {
  tpIdle = 0, tpLowest, tpBelowNormal, tpNormal,
  tpAboveNormal, tpHighest, tpTimeCritical
}
typedef GenericThreadProc LPGenericThreadProc
typedef enum
CGenericThread::_ThreadStatus 
ThreadStatus
typedef enum
CGenericThread::_ThreadPriority 
ThreadPriority
typedef DWORD(* GenericThreadProc )(LPVOID pParam)

Public Member Functions

virtual BOOL IsInThread () const
virtual BOOL SetPriority (CGenericThread::ThreadPriority aPriority)
virtual
CGenericThread::ThreadPriority 
GetPriority () const
virtual BOOL Start (LPVOID pData)
virtual BOOL Stop ()
 CWin32Thread (LPGenericThreadProc pThreadProc)
virtual ~CWin32Thread ()
void SetBruteTermination (BOOL bBrute)
void SetAutoDelete (BOOL bAuto)
virtual DWORD GetThreadID () const
ThreadStatus GetThreadStatus () const
void SetLocalLog (CErrorLog *pLog, bool bWriteToMain=false)
void WriteError (const std::string &rClass, const std::string &rMethod, const std::string &rError) const
void WriteMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage) const

Static Public Member Functions

static CErrorHandlerGetSecondaryLog ()
static CErrorHandlerGetThirdLog ()
static void ClearStaticLogs ()
static std::string GetCurrentDateTime ()
static std::string ErrorCodeToString (DWORD dwErrorCode)
static void RegisterError (DWORD dwErrorCode, const std::string &rDescription)
static void SetLog (CErrorLog *pLog)
static void WriteStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rError)
static void WriteStaticMessage (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)
static std::string FormatData (const std::string &rClass, const std::string &rMethod, const std::string &rMsgOrError, bool bError=true)

Protected Member Functions

BOOL GetBruteTermination () const
BOOL GetAutoDelete () const
LPGenericThreadProc GetThreadProc () const
void SetThreadStatus (ThreadStatus aStatus)
virtual LPVOID GetData () const
void SetThreadID (DWORD dwThreadID)
void WriteMessage (const std::string &rMethod, const std::string &rMessage) const
const std::string & GetClassName () const
virtual void ReportError (const std::string &rMethod) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, const std::string &rAdditionalData) const
virtual void ReportError (const std::string &rMethod, int iErrorCode) const
virtual void ReportError (const std::string &rMethod, const std::string &rMessage, int iErrorCode) const
virtual void ReportErrorOS (const std::string &rMethod, const std::string &rMessage) const
void SetName (const std::string &rName) const

Static Protected Member Functions

static void ReportStaticError (const std::string &rClass, const std::string &rMethod)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)
static void ReportStaticError (const std::string &rClass, const std::string &rMethod, const std::string &rMessage, DWORD dwAdditionalData)
static void ReportStaticErrorOS (const std::string &rClass, const std::string &rMethod, const std::string &rMessage)

Detailed Description

Definition at line 49 of file Win32Thread.h.


Member Typedef Documentation

typedef DWORD(* CGenericThread::GenericThreadProc)(LPVOID pParam) [inherited]

Definition at line 56 of file GenericThread.h.


Member Enumeration Documentation

Enumerator:
tpIdle 
tpLowest 
tpBelowNormal 
tpNormal 
tpAboveNormal 
tpHighest 
tpTimeCritical 

Definition at line 68 of file GenericThread.h.

00069     {
00070         tpIdle=0,
00071         tpLowest,
00072         tpBelowNormal,
00073         tpNormal,
00074         tpAboveNormal,
00075         tpHighest,
00076         tpTimeCritical
00077     } ThreadPriority;

Enumerator:
tsSuspended 
tsRunning 
tsStopped 
tsError 

Definition at line 59 of file GenericThread.h.

00060     {
00061         tsSuspended,
00062         tsRunning,
00063         tsStopped,
00064         tsError
00065     } ThreadStatus;


Constructor & Destructor Documentation

CWin32Thread::CWin32Thread ( LPGenericThreadProc  pThreadProc  ) 

Definition at line 51 of file Win32Thread.cpp.

00051                                                           : CGenericThread(pThreadProc),
00052                                                               m_hThread(0)
00053 {
00054     try
00055     {
00056         //Set our name
00057         SetName(CWin32Thread_Class);
00058 
00059         //Create the thread
00060         if (GetThreadProc())
00061         {
00062             //Our thread ID
00063             DWORD dwThreadID;
00064 
00065             //Create the thread in suspend mode
00066             m_hThread=CreateThread(NULL,
00067                                    0,
00068                                    Win32Thread,
00069                                    this,
00070                                    CREATE_SUSPENDED,
00071                                    &dwThreadID);
00072 
00073             //Check if created
00074             if (m_hThread)
00075             {
00076                 //Set the thread ID
00077                 SetThreadID(dwThreadID);
00078 
00079                 //Set the status
00080                 SetThreadStatus(tsSuspended);
00081             }
00082             else
00083                 //An error
00084                 throw std::string("Failed to create thread!");
00085         }
00086         else
00087             //Throw the error
00088             throw std::string("No thread proc!");
00089     }
00090     ERROR_HANDLER_RETHROW("CWin32Thread")
00091 }

CWin32Thread::~CWin32Thread (  )  [virtual]

Definition at line 93 of file Win32Thread.cpp.

00094 {
00095     try
00096     {
00097         //Stop the thread
00098         Stop();
00099     }
00100     ERROR_HANDLER("~CWin32Thread")
00101 }


Member Function Documentation

void CErrorHandler::ClearStaticLogs (  )  [static, inherited]

Definition at line 680 of file ErrorHandler.cpp.

00681 {
00682     //Delete the logs
00683     delete m_pSecondLevelLog;
00684     m_pSecondLevelLog=NULL;
00685 
00686     delete m_pThirdLevelLog;
00687     m_pThirdLevelLog=NULL;
00688 }

std::string CErrorHandler::ErrorCodeToString ( DWORD  dwErrorCode  )  [static, inherited]

Definition at line 251 of file ErrorHandler.cpp.

00252 {
00253     try
00254     {
00255         //Try to look it in the errors
00256         if (!CErrorsRepository::GetInstance().GetErrorsMap().empty())
00257         {
00258             //Search
00259             CErrorsRepository::ErrorMap::const_iterator aIterator;
00260             aIterator=CErrorsRepository::GetInstance().GetErrorsMap().find(dwErrorCode);
00261 
00262             //Do we have it
00263             if (aIterator!=CErrorsRepository::GetInstance().GetErrorsMap().end())
00264                 return aIterator->second;
00265         }
00266 
00267         //Get the error string
00268         LPVOID lpMsgBuf;
00269         FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
00270                       FORMAT_MESSAGE_FROM_SYSTEM | 
00271                       FORMAT_MESSAGE_IGNORE_INSERTS,
00272                       NULL,
00273                       dwErrorCode,
00274                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00275                       (LPTSTR) &lpMsgBuf,
00276                       0,
00277                       NULL);
00278 
00279         //Save it
00280         std::string sMessage;
00281 
00282         //Do we have the message?
00283         if (lpMsgBuf)
00284         {
00285             //Save it
00286             sMessage=(char*)lpMsgBuf;
00287             
00288             //Release the buffer
00289             LocalFree(lpMsgBuf);
00290         }
00291         else
00292             //Failed to find
00293             sMessage="No error description found!";
00294 
00295         //Done
00296         return sMessage;
00297     }
00298     catch (...)
00299     {
00300         return "Unknown";
00301     }
00302 }

std::string CErrorHandler::FormatData ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMsgOrError,
bool  bError = true 
) [static, inherited]

Definition at line 145 of file ErrorHandler.cpp.

00149 {
00150     //Our message
00151     std::string sMsg;
00152 
00153     //Is it an error?
00154     if (bError)
00155         sMsg="*** Error *** ";
00156     else
00157         sMsg="###  Msg  ### ";
00158 
00159     //Add the data now
00160     sMsg+="in "+rClass;
00161     sMsg+="::"+rMethod;
00162     sMsg+=" - " + rMsgOrError;
00163 
00164     //Done
00165     return sMsg;
00166 }

BOOL CGenericThread::GetAutoDelete (  )  const [protected, inherited]

Definition at line 129 of file GenericThread.cpp.

00130 {
00131     return m_bAutoDelete;
00132 }

BOOL CGenericThread::GetBruteTermination (  )  const [protected, inherited]

Definition at line 139 of file GenericThread.cpp.

00140 {
00141     return m_bBruteTermination;
00142 }

const std::string & CErrorHandler::GetClassName (  )  const [protected, inherited]

Reimplemented in CSocketThreadManager.

Definition at line 617 of file ErrorHandler.cpp.

00618 {
00619     return m_sClassName;
00620 }

std::string CErrorHandler::GetCurrentDateTime (  )  [static, inherited]

Definition at line 622 of file ErrorHandler.cpp.

00623 {
00624     try
00625     {
00626         //Our string
00627         std::string sDate;
00628 
00629         //Our tmp buf
00630         char cTmp[128];
00631 
00632         //Get date
00633         _strdate(cTmp);
00634         sDate=cTmp;
00635         sDate+=' ';
00636 
00637         //Get time
00638         _strtime(cTmp);
00639         sDate+=cTmp;
00640 
00641         //Done
00642         return sDate;
00643     }
00644     ERROR_HANDLER_STATIC_RETURN(CErrorHandler_Class,"GetCurrentDateTime","")
00645 }

LPVOID CGenericThread::GetData (  )  const [protected, virtual, inherited]

Definition at line 87 of file GenericThread.cpp.

00088 {
00089     return m_pData;
00090 }

CGenericThread::ThreadPriority CWin32Thread::GetPriority (  )  const [virtual]

Implements CGenericThread.

Definition at line 310 of file Win32Thread.cpp.

00311 {
00312     try
00313     {
00314         //Check if we have the thread
00315         if (!m_hThread)
00316             return CGenericThread::tpNormal;
00317 
00318         int iPriority;
00319 
00320         //Get the priority
00321         iPriority=GetThreadPriority(m_hThread);
00322 
00323         //And return the value
00324         switch (iPriority)
00325         {
00326         case THREAD_PRIORITY_ABOVE_NORMAL:
00327             return CGenericThread::tpAboveNormal;
00328         case THREAD_PRIORITY_BELOW_NORMAL:
00329             return CGenericThread::tpBelowNormal;
00330         case THREAD_PRIORITY_HIGHEST:
00331             return CGenericThread::tpHighest;
00332         case THREAD_PRIORITY_IDLE:
00333             return CGenericThread::tpIdle;
00334         case THREAD_PRIORITY_LOWEST:
00335             return CGenericThread::tpLowest;
00336         case THREAD_PRIORITY_NORMAL:
00337             return CGenericThread::tpNormal;
00338         case THREAD_PRIORITY_TIME_CRITICAL:
00339             return CGenericThread::tpTimeCritical;
00340         default:
00341             return CGenericThread::tpNormal;
00342         }
00343     }
00344     ERROR_HANDLER_RETURN("GetPriority",CGenericThread::tpNormal)
00345 }

CErrorHandler * CErrorHandler::GetSecondaryLog (  )  [static, inherited]

Definition at line 658 of file ErrorHandler.cpp.

00659 {
00660     //Do we have log
00661     if (!m_pSecondLevelLog)
00662         //Create it
00663         m_pSecondLevelLog=new CErrorHandler;
00664 
00665     //Return it
00666     return m_pSecondLevelLog;
00667 }

CErrorHandler * CErrorHandler::GetThirdLog (  )  [static, inherited]

Definition at line 669 of file ErrorHandler.cpp.

00670 {
00671     //Do we have log
00672     if (!m_pThirdLevelLog)
00673         //Create it
00674         m_pThirdLevelLog=new CErrorHandler;
00675 
00676     //Return it
00677     return m_pThirdLevelLog;
00678 }

DWORD CGenericThread::GetThreadID (  )  const [virtual, inherited]

Definition at line 77 of file GenericThread.cpp.

00078 {
00079     return m_dwThreadID;
00080 }

CGenericThread::LPGenericThreadProc CGenericThread::GetThreadProc (  )  const [protected, inherited]

Definition at line 119 of file GenericThread.cpp.

00120 {
00121     return m_pThreadProc;
00122 }

CGenericThread::ThreadStatus CGenericThread::GetThreadStatus (  )  const [inherited]

Definition at line 114 of file GenericThread.cpp.

00115 {
00116     return m_aThreadStatus;
00117 }

BOOL CWin32Thread::IsInThread (  )  const [virtual]

Implements CGenericThread.

Definition at line 347 of file Win32Thread.cpp.

00348 {
00349     return GetCurrentThreadId()==GetThreadID();
00350 }

void CErrorHandler::RegisterError ( DWORD  dwErrorCode,
const std::string &  rDescription 
) [static, inherited]

Definition at line 647 of file ErrorHandler.cpp.

00649 {
00650     try
00651     {
00652         //Add the error
00653         CErrorsRepository::GetInstance().GetErrorsMap().insert(CErrorsRepository::ErrorMap::value_type(dwErrorCode,rDescription));
00654     }
00655     ERROR_HANDLER_STATIC(CErrorHandler_Class,"RegisterError")
00656 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
int  iErrorCode 
) const [protected, virtual, inherited]

Definition at line 304 of file ErrorHandler.cpp.

00307 {
00308     if (!GetLog())
00309         return;
00310 
00311     try
00312     {
00313         //Convert the error code
00314         char aTmp[11];
00315         sprintf(aTmp,"%d",iErrorCode);
00316 
00317         //Get the string for it
00318         std::string sError;
00319         sError=rMessage;
00320         sError+=", and Socket error: ";
00321         sError+=aTmp;
00322         sError+=", ";
00323         sError+=ErrorCodeToString(iErrorCode);
00324 
00325         //Report to the log
00326         WriteError(m_sClassName,
00327                    rMethod,
00328                    sError);
00329     }
00330     ERROR_UNKNOWN("ReportError")
00331 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
int  iErrorCode 
) const [protected, virtual, inherited]

Definition at line 333 of file ErrorHandler.cpp.

00335 {
00336     if (!GetLog())
00337         return;
00338 
00339     try
00340     {
00341         //Convert the error code
00342         char aTmp[11];
00343         sprintf(aTmp,"%d",iErrorCode);
00344 
00345         //Get the string for it
00346         std::string sError;
00347         sError="Socket error: ";
00348         sError+=aTmp;
00349         sError+=", ";
00350         sError+=ErrorCodeToString(iErrorCode);
00351 
00352         //Report to the log
00353         WriteError(m_sClassName,
00354                    rMethod,
00355                    sError);
00356     }
00357     ERROR_UNKNOWN("ReportError")
00358 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
const std::string &  rAdditionalData 
) const [protected, virtual, inherited]

Definition at line 461 of file ErrorHandler.cpp.

00464 {
00465     if (!GetLog())
00466         return;
00467 
00468     try
00469     {
00470         //Create the new message
00471         std::string sNewMessage(rMessage);
00472         sNewMessage+=", Additional data: ";
00473         sNewMessage+=rAdditionalData;
00474 
00475         //Report to the log
00476         WriteError(m_sClassName,
00477                    rMethod,
00478                    sNewMessage);
00479     }
00480     ERROR_UNKNOWN("ReportError")
00481 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData 
) const [protected, virtual, inherited]

Definition at line 483 of file ErrorHandler.cpp.

00486 {
00487     if (!GetLog())
00488         return;
00489 
00490     try
00491     {
00492         //Convert the number
00493         char aTmp[11];
00494         ltoa(dwAdditionalData,aTmp,10);
00495 
00496         //Create the new message
00497         std::string sNewMessage(rMessage);
00498         sNewMessage+=", Additional data: ";
00499         sNewMessage+=aTmp;
00500 
00501         //Report to the log
00502         WriteError(m_sClassName,
00503                    rMethod,
00504                    sNewMessage);
00505     }
00506     ERROR_UNKNOWN("ReportError")
00507 }

void CErrorHandler::ReportError ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, virtual, inherited]

Definition at line 376 of file ErrorHandler.cpp.

00378 {
00379     if (!GetLog())
00380         return;
00381 
00382     try
00383     {
00384         //Report to the log
00385         WriteError(m_sClassName,
00386                    rMethod,
00387                    rMessage);
00388     }
00389     ERROR_UNKNOWN("ReportError")
00390 }

void CErrorHandler::ReportError ( const std::string &  rMethod  )  const [protected, virtual, inherited]

Definition at line 515 of file ErrorHandler.cpp.

00516 {
00517     if (!GetLog())
00518         return;
00519 
00520     try
00521     {
00522         //Get the last error
00523         DWORD dwLastError;
00524         dwLastError=GetLastError();
00525 
00526         //Report the error
00527         WriteError(m_sClassName,
00528                    rMethod,
00529                    ErrorCodeToString(dwLastError));
00530     }
00531     ERROR_UNKNOWN("ReportError")
00532 }

void CErrorHandler::ReportErrorOS ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, virtual, inherited]

Definition at line 427 of file ErrorHandler.cpp.

00429 {
00430     if (!GetLog())
00431         return;
00432 
00433     try
00434     {
00435         //Get the last error
00436         DWORD dwLastError;
00437         dwLastError=GetLastError();
00438 
00439         //Format the message
00440         std::string sMessage;
00441         sMessage=rMessage;
00442         sMessage+=", with error code: ";
00443 
00444         //Convert the error code
00445         char aTmp[11];
00446         itoa(dwLastError,aTmp,10);
00447 
00448         //Add it again
00449         sMessage+=aTmp;
00450         sMessage+=" ";
00451         sMessage+=ErrorCodeToString(dwLastError);
00452 
00453         //Report to the log
00454         WriteError(m_sClassName,
00455                    rMethod,
00456                    sMessage);
00457     }
00458     ERROR_UNKNOWN("ReportErrorOS")
00459 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage,
DWORD  dwAdditionalData 
) [static, protected, inherited]

Definition at line 590 of file ErrorHandler.cpp.

00594 {
00595     if (!m_pLog)
00596         return;
00597 
00598     try
00599     {
00600         //Convert the number
00601         char aTmp[11];
00602         ltoa(dwAdditionalData,aTmp,10);
00603 
00604         //Create the new message
00605         std::string sNewMessage(rMessage);
00606         sNewMessage+=", Additional data: ";
00607         sNewMessage+=aTmp;
00608 
00609         //Report to the log
00610         WriteStaticError(rClass,
00611                          rMethod,
00612                          sNewMessage);
00613     }
00614     ERROR_UNKNOWN("ReportStaticError")
00615 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) [static, protected, inherited]

Definition at line 573 of file ErrorHandler.cpp.

00576 {
00577     if (!m_pLog)
00578         return;
00579 
00580     try
00581     {
00582         //Report to the log
00583         WriteStaticError(rClass,
00584                          rMethod,
00585                          rMessage);
00586     }
00587     ERROR_UNKNOWN("ReportStaticError")
00588 }

void CErrorHandler::ReportStaticError ( const std::string &  rClass,
const std::string &  rMethod 
) [static, protected, inherited]

Definition at line 553 of file ErrorHandler.cpp.

00555 {
00556     if (!m_pLog)
00557         return;
00558 
00559     try
00560     {
00561         //Get the last error
00562         DWORD dwLastError;
00563         dwLastError=GetLastError();
00564 
00565         //Report the error
00566         WriteStaticError(rClass,
00567                           rMethod,
00568                           ErrorCodeToString(dwLastError));
00569     }
00570     ERROR_UNKNOWN("ReportStaticError")
00571 }

void CErrorHandler::ReportStaticErrorOS ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) [static, protected, inherited]

Definition at line 392 of file ErrorHandler.cpp.

00395 {
00396     if (!m_pLog)
00397         return;
00398 
00399     try
00400     {
00401         //Get the last error
00402         DWORD dwLastError;
00403         dwLastError=GetLastError();
00404 
00405         //Format the message
00406         std::string sMessage;
00407         sMessage=rMessage;
00408         sMessage+=", with error code: ";
00409 
00410         //Convert the error code
00411         char aTmp[11];
00412         itoa(dwLastError,aTmp,10);
00413 
00414         //Add it again
00415         sMessage+=aTmp;
00416         sMessage+=" ";
00417         sMessage+=ErrorCodeToString(dwLastError);
00418         
00419         //Report to the log
00420         WriteStaticError(rClass,
00421                          rMethod,
00422                          sMessage);
00423     }
00424     ERROR_UNKNOWN("ReportStaticError")
00425 }

void CGenericThread::SetAutoDelete ( BOOL  bAuto  )  [inherited]

Definition at line 124 of file GenericThread.cpp.

00125 {
00126     m_bAutoDelete=bAuto;
00127 }

void CGenericThread::SetBruteTermination ( BOOL  bBrute  )  [inherited]

Definition at line 134 of file GenericThread.cpp.

00135 {
00136     m_bBruteTermination=bBrute;
00137 }

void CErrorHandler::SetLocalLog ( CErrorLog pLog,
bool  bWriteToMain = false 
) [inherited]

Definition at line 543 of file ErrorHandler.cpp.

00545 {
00546     //Save the log
00547     m_pLocalLog=pLog;
00548 
00549     //Save the write to main flag
00550     m_bWriteToMain=bWriteToMain;
00551 }

void CErrorHandler::SetLog ( CErrorLog pLog  )  [static, inherited]

Definition at line 509 of file ErrorHandler.cpp.

00510 {
00511     //Save the new log
00512     m_pLog=pLog;
00513 }

void CErrorHandler::SetName ( const std::string &  rName  )  const [protected, inherited]

Definition at line 139 of file ErrorHandler.cpp.

00140 {
00141     //Save the class name
00142     m_sClassName=rName;
00143 }

BOOL CWin32Thread::SetPriority ( CGenericThread::ThreadPriority  aPriority  )  [virtual]

Implements CGenericThread.

Definition at line 262 of file Win32Thread.cpp.

00263 {
00264     try
00265     {
00266         static const int iThreadPriority[]={THREAD_PRIORITY_IDLE,
00267                                             THREAD_PRIORITY_LOWEST,
00268                                             THREAD_PRIORITY_BELOW_NORMAL,
00269                                             THREAD_PRIORITY_NORMAL,
00270                                             THREAD_PRIORITY_ABOVE_NORMAL,
00271                                             THREAD_PRIORITY_HIGHEST,
00272                                             THREAD_PRIORITY_TIME_CRITICAL};
00273 
00274         //Do we have a thread
00275         if (GetThreadStatus()==tsStopped)
00276         {
00277             //Recreate the thread
00278             //Our thread ID
00279             DWORD dwThreadID;
00280 
00281             //Create the thread in suspend mode
00282             m_hThread=CreateThread(NULL,
00283                                    0,
00284                                    Win32Thread,
00285                                    this,
00286                                    CREATE_SUSPENDED,
00287                                    &dwThreadID);
00288 
00289             //Check if created
00290             if (m_hThread)
00291             {
00292                 //Set the thread ID
00293                 SetThreadID(dwThreadID);
00294 
00295                 //Set the status
00296                 SetThreadStatus(tsSuspended);
00297             }
00298             else
00299                 //Can't run
00300                 return FALSE;
00301         }
00302 
00303         //Now we can set the priority
00304         return SetThreadPriority(m_hThread,
00305                                  iThreadPriority[aPriority]);
00306     }
00307     ERROR_HANDLER_RETURN("SetPriority",FALSE)
00308 }

void CGenericThread::SetThreadID ( DWORD  dwThreadID  )  [protected, inherited]

Definition at line 82 of file GenericThread.cpp.

00083 {
00084     m_dwThreadID=dwThreadID;
00085 }

void CGenericThread::SetThreadStatus ( ThreadStatus  aStatus  )  [protected, inherited]

Definition at line 101 of file GenericThread.cpp.

00102 {
00103     try
00104     {
00105         //Enter the CS
00106         CCriticalAutoRelease aRelease(m_pCSection);
00107 
00108         //Set it
00109         m_aThreadStatus=aStatus;
00110     }
00111     ERROR_HANDLER("SetThreadStatus")
00112 }

BOOL CWin32Thread::Start ( LPVOID  pData  )  [virtual]

Reimplemented from CGenericThread.

Definition at line 103 of file Win32Thread.cpp.

00104 {
00105     try
00106     {
00107         if (GetThreadStatus()==tsStopped)
00108         {
00109             //Recreate the thread
00110             //Our thread ID
00111             DWORD dwThreadID;
00112 
00113             //Create the thread in suspend mode
00114             m_hThread=CreateThread(NULL,
00115                                    0,
00116                                    Win32Thread,
00117                                    this,
00118                                    CREATE_SUSPENDED,
00119                                    &dwThreadID);
00120 
00121             //Check if created
00122             if (m_hThread)
00123             {
00124                 //Set the thread ID
00125                 SetThreadID(dwThreadID);
00126 
00127                 //Set the status
00128                 SetThreadStatus(tsSuspended);
00129             }
00130             else
00131                 //Can't run
00132                 return FALSE;
00133         }
00134         else if (GetThreadStatus()!=tsSuspended)
00135             return FALSE;
00136 
00137         //Start the thread
00138         CGenericThread::Start(pData);
00139 
00140         //Resume the thread
00141         if (m_hThread)
00142             if (ResumeThread(m_hThread)!=-1)
00143                 //We are running
00144                 return TRUE;
00145 
00146         return FALSE;
00147     }
00148     ERROR_HANDLER_RETURN("Start",FALSE)
00149 }

BOOL CWin32Thread::Stop (  )  [virtual]

Implements CGenericThread.

Definition at line 151 of file Win32Thread.cpp.

00152 {
00153     try
00154     {
00155         //Only if suspened or running
00156         //Do we have the thread ?
00157         if (m_hThread)
00158         {
00159             //What status are we
00160             if (GetThreadStatus()==tsRunning &&
00161                 GetBruteTermination())
00162                 //First try to close it
00163                 if (!TerminateThread(m_hThread,THREAD_DO_NOTHING_EXIT_VALUE))
00164                 {
00165                     //Close it first
00166                     CloseHandle(m_hThread);
00167 
00168                     //Reset it
00169                     m_hThread=NULL;
00170 
00171                     //Exit
00172                     return FALSE;
00173                 }
00174 
00175             //Are we running, suspended?
00176             if (GetThreadStatus()==tsSuspended ||
00177                 GetThreadStatus()==tsRunning)
00178                 if (CloseHandle(m_hThread))
00179                 {
00180                     //Close the handle
00181                     m_hThread=NULL;
00182 
00183                     //Stopped
00184                     SetThreadStatus(tsStopped);
00185 
00186                     //Exit
00187                     return TRUE;
00188                 }
00189                 else
00190                     return FALSE;
00191             else
00192             {
00193                 //Just close the handle
00194                 if (CloseHandle(m_hThread))
00195                     m_hThread=NULL;
00196 
00197                 //Exit
00198                 return FALSE;
00199             }
00200         }
00201         else
00202             return FALSE;
00203     }
00204     ERROR_HANDLER_RETURN("Stop",FALSE)
00205 }

void CErrorHandler::WriteError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rError 
) const [inherited]

Definition at line 168 of file ErrorHandler.cpp.

00171 {
00172     //Do we have a log?
00173     if (!GetLog())
00174         return;
00175 
00176     //Format the msg
00177     std::string sError;
00178     sError=FormatData(rClass,
00179                       rMethod,
00180                       rError);
00181 
00182     //Write it
00183     GetLog()->WriteError(sError);
00184 
00185     //Write to main
00186     if (m_bWriteToMain &&
00187         m_pLog)
00188         //Write it
00189         m_pLog->WriteError(sError);
00190 }

void CErrorHandler::WriteMessage ( const std::string &  rMethod,
const std::string &  rMessage 
) const [protected, inherited]

Definition at line 360 of file ErrorHandler.cpp.

00362 {
00363     if (!GetLog())
00364         return;
00365 
00366     try
00367     {
00368         //Report to the log
00369         WriteMessage(m_sClassName,
00370                      rMethod,
00371                      rMessage);
00372     }
00373     ERROR_UNKNOWN("WriteMessage")
00374 }

void CErrorHandler::WriteMessage ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) const [inherited]

Definition at line 226 of file ErrorHandler.cpp.

00229 {
00230     //Do we have a log?
00231     if (!GetLog())
00232         return;
00233 
00234     //Format the msg
00235     std::string sMsg;
00236     sMsg=FormatData(rClass,
00237                     rMethod,
00238                     rMessage,
00239                     false);
00240 
00241     //Write it
00242     GetLog()->WriteMessage(sMsg);
00243 
00244     //Write to main
00245     if (m_bWriteToMain &&
00246         m_pLog)
00247         //Write it
00248         m_pLog->WriteMessage(sMsg);
00249 }

void CErrorHandler::WriteStaticError ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rError 
) [static, inherited]

Definition at line 192 of file ErrorHandler.cpp.

00195 {
00196     //Do we have a log?
00197     if (!m_pLog)
00198         return;
00199 
00200     //Format the msg
00201     std::string sError;
00202     sError=FormatData(rClass,
00203                       rMethod,
00204                       rError);
00205 
00206     //Write it
00207     m_pLog->WriteError(sError);
00208 }

void CErrorHandler::WriteStaticMessage ( const std::string &  rClass,
const std::string &  rMethod,
const std::string &  rMessage 
) [static, inherited]

Definition at line 210 of file ErrorHandler.cpp.

00213 {
00214     //Do we have a log?
00215     if (!m_pLog)
00216         return;
00217 
00218     //Format the msg
00219     std::string sMsg;
00220     sMsg=FormatData(rClass,
00221                     rMethod,
00222                     rMessage,
00223                     false);
00224 }


The documentation for this class was generated from the following files: