00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #if !defined(AFX_SPOOFBASE_H__3760FA30_2B52_4F62_9EB6_46640C36E4F1__INCLUDED_)
00037 #define AFX_SPOOFBASE_H__3760FA30_2B52_4F62_9EB6_46640C36E4F1__INCLUDED_
00038
00039 #if _MSC_VER > 1000
00040 #pragma once
00041 #endif // _MSC_VER > 1000
00042
00043
00044 #include <winsock2.h>
00045 #include <ws2tcpip.h>
00046
00047 #include "ErrorHandler.h"
00048
00049 KOMODIA_NAMESPACE_START
00050
00051 class CGenericCriticalSection;
00052 class CGenericEvent;
00053 class CManagedThread;
00054
00055
00056 class CSpoofBase : public CErrorHandler
00057 {
00058 public:
00059
00060
00061 static int GetErrorCode();
00062
00063
00064 int GetSystemLastError()const;
00065
00066
00067 static BOOL IsInitialized();
00068
00069
00070 static unsigned long StringToLong(const std::string& rAddress);
00071
00072
00073 static char FAR * LongToString(unsigned long ulAddr);
00074
00075
00076 static std::string LongToStdString(unsigned long ulAddr);
00077
00078
00079
00080
00081
00082
00083 static BOOL InitializeSockets(BOOL bMultiThreaded=TRUE,
00084 unsigned long ulNumberOfThreads=10);
00085
00086
00087
00088
00089 static BOOL InitializeSocketsNoMap(BOOL bMultiThreaded=TRUE,
00090 unsigned long ulNumberOfThreads=10);
00091
00092
00093 static BOOL ShutdownSockets();
00094
00095
00096 int GetLastError()const;
00097
00098
00099 static unsigned long GetNumberOfThreads();
00100
00101
00102 static BOOL IsMultiThreaded();
00103
00104
00105 static CGenericCriticalSection* GetGlobalCriticalSection();
00106
00107
00108 CSpoofBase();
00109 CSpoofBase(const CSpoofBase& rBase);
00110 virtual ~CSpoofBase();
00111 protected:
00112
00113 virtual void NotifyShutdown();
00114
00115
00116 void RegisterShutdown(CSpoofBase* pBase);
00117
00118
00119 void SetLastError(const std::string& rMethod)const;
00120 void SetLastError(const std::string&,
00121 int iErrorCode)const;
00122
00123
00124 static CGenericCriticalSection* m_pCSection;
00125 private:
00126
00127 typedef struct _ThreadData
00128 {
00129 BOOL bMultiThreaded;
00130 unsigned long ulNumberOfThreads;
00131 CGenericEvent* pEvent;
00132 } ThreadData;
00133 private:
00134
00135 static DWORD InitProc(CGenericEvent* pExitEvent,
00136 LPVOID lpData);
00137
00138
00139 mutable int m_iLastError;
00140
00141
00142 static BOOL m_bInitialized;
00143
00144
00145 static CSpoofBase* m_pShutdownClass;
00146
00147
00148 static BOOL m_bMultiThreaded;
00149
00150
00151 static int m_ulNumberOfThreads;
00152
00153
00154 static CManagedThread* m_pThread;
00155 };
00156
00157 KOMODIA_NAMESPACE_END
00158
00159 #endif // !defined(AFX_SPOOFBASE_H__3760FA30_2B52_4F62_9EB6_46640C36E4F1__INCLUDED_)