Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

368 lines
9.5 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. StdAfx.h
  5. Abstract:
  6. Top level header file so we can take advantage of precompiled
  7. headers..
  8. Author:
  9. Rohde Wakefield [rohde] 12-Aug-1997
  10. Revision History:
  11. --*/
  12. #ifndef _STDAFX_H
  13. #define _STDAFX_H
  14. //
  15. // These NT header files must be included before any Win32 stuff or you
  16. // get lots of compiler errors
  17. //
  18. extern "C" {
  19. #include <nt.h>
  20. #include <ntrtl.h>
  21. #include <nturtl.h>
  22. // Undefine ASSSERT because the MFC also defines it and we don't
  23. // want the warning.
  24. #undef ASSERT
  25. }
  26. #include <afxwin.h> // MFC core and standard components
  27. #include <afxext.h> // MFC extensions
  28. #include <afxdisp.h> // MFC OLE automation classes
  29. #include <afxcmn.h> // MFC support for Windows Common Controls
  30. #include <afxtempl.h>
  31. #include <mmc.h>
  32. #define WSB_TRACE_IS WSB_TRACE_BIT_UI
  33. #define CComPtr CComPtrAtl21
  34. #include "wsb.h"
  35. #include "rslimits.h"
  36. #undef CComPtr
  37. //
  38. // Temp Hack until using newer ATL
  39. //
  40. #undef ATLASSERT
  41. #define ATLASSERT _ASSERTE
  42. template <class T>
  43. class _NoAddRefReleaseOnCComPtr : public T
  44. {
  45. private:
  46. virtual ULONG STDMETHODCALLTYPE AddRef()=0;
  47. virtual ULONG STDMETHODCALLTYPE Release()=0;
  48. };
  49. template <class T>
  50. class CComPtr
  51. {
  52. public:
  53. typedef T _PtrClass;
  54. CComPtr()
  55. {
  56. p=NULL;
  57. }
  58. CComPtr(T* lp)
  59. {
  60. if ((p = lp) != NULL)
  61. p->AddRef();
  62. }
  63. CComPtr(const CComPtr<T>& lp)
  64. {
  65. if ((p = lp.p) != NULL)
  66. p->AddRef();
  67. }
  68. ~CComPtr()
  69. {
  70. if (p)
  71. p->Release();
  72. }
  73. void Release()
  74. {
  75. IUnknown* pTemp = p;
  76. if (pTemp)
  77. {
  78. p = NULL;
  79. pTemp->Release();
  80. }
  81. }
  82. operator T*() const
  83. {
  84. return (T*)p;
  85. }
  86. T& operator*() const
  87. {
  88. ATLASSERT(p!=NULL);
  89. return *p;
  90. }
  91. //The assert on operator& usually indicates a bug. If this is really
  92. //what is needed, however, take the address of the p member explicitly.
  93. T** operator&()
  94. {
  95. ATLASSERT(p==NULL);
  96. return &p;
  97. }
  98. _NoAddRefReleaseOnCComPtr<T>* operator->() const
  99. {
  100. ATLASSERT(p!=NULL);
  101. return (_NoAddRefReleaseOnCComPtr<T>*)p;
  102. }
  103. T* operator=(T* lp)
  104. {
  105. return (T*)AtlComPtrAssign((IUnknown**)&p, lp);
  106. }
  107. T* operator=(const CComPtr<T>& lp)
  108. {
  109. return (T*)AtlComPtrAssign((IUnknown**)&p, lp.p);
  110. }
  111. bool operator!() const
  112. {
  113. return (p == NULL);
  114. }
  115. bool operator<(T* pT) const
  116. {
  117. return p < pT;
  118. }
  119. bool operator==(T* pT) const
  120. {
  121. return p == pT;
  122. }
  123. // Compare two objects for equivalence
  124. bool IsEqualObject(IUnknown* pOther)
  125. {
  126. if (p == NULL && pOther == NULL)
  127. return true; // They are both NULL objects
  128. if (p == NULL || pOther == NULL)
  129. return false; // One is NULL the other is not
  130. CComPtr<IUnknown> punk1;
  131. CComPtr<IUnknown> punk2;
  132. p->QueryInterface(IID_IUnknown, (void**)&punk1);
  133. pOther->QueryInterface(IID_IUnknown, (void**)&punk2);
  134. return punk1 == punk2;
  135. }
  136. void Attach(T* p2)
  137. {
  138. if (p)
  139. p->Release();
  140. p = p2;
  141. }
  142. T* Detach()
  143. {
  144. T* pt = p;
  145. p = NULL;
  146. return pt;
  147. }
  148. HRESULT CopyTo(T** ppT)
  149. {
  150. ATLASSERT(ppT != NULL);
  151. if (ppT == NULL)
  152. return E_POINTER;
  153. *ppT = p;
  154. if (p)
  155. p->AddRef();
  156. return S_OK;
  157. }
  158. HRESULT SetSite(IUnknown* punkParent)
  159. {
  160. return AtlSetChildSite(p, punkParent);
  161. }
  162. HRESULT Advise(IUnknown* pUnk, const IID& iid, LPDWORD pdw)
  163. {
  164. return AtlAdvise(p, pUnk, iid, pdw);
  165. }
  166. HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  167. {
  168. ATLASSERT(p == NULL);
  169. return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  170. }
  171. HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
  172. {
  173. CLSID clsid;
  174. HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
  175. ATLASSERT(p == NULL);
  176. if (SUCCEEDED(hr))
  177. hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
  178. return hr;
  179. }
  180. template <class Q>
  181. HRESULT QueryInterface(Q** pp) const
  182. {
  183. ATLASSERT(pp != NULL && *pp == NULL);
  184. return p->QueryInterface(__uuidof(Q), (void**)pp);
  185. }
  186. T* p;
  187. };
  188. //
  189. // End Temp Hack
  190. //
  191. #include "Engine.h"
  192. #include "Fsa.h"
  193. #include "Rms.h"
  194. #include "Job.h"
  195. #define RsQueryInterface( pUnk, interf, pNew ) (pUnk)->QueryInterface( IID_##interf, (void**) static_cast<interf **>( &pNew ) )
  196. #define RsQueryInterface2( pUnk, interf, pNew ) (pUnk)->QueryInterface( IID_##interf, (void**) static_cast<interf **>( pNew ) )
  197. #include "hsmadmin.h"
  198. #include "resource.h"
  199. #include "BaseHsm.h"
  200. #include "RsUtil.h"
  201. #include "RsAdUtil.h"
  202. #include "PropPage.h"
  203. #include "CPropSht.h"
  204. #include "rshelpid.h"
  205. class CHsmAdminApp : public CWinApp
  206. {
  207. public:
  208. virtual BOOL InitInstance();
  209. virtual int ExitInstance();
  210. void CHsmAdminApp::ParseCommandLine(CCommandLineInfo& rCmdInfo);
  211. };
  212. extern CHsmAdminApp g_App;
  213. #if 1
  214. // Turn on In-Your-Trace error messages for debugging.
  215. class CWsbThrowContext {
  216. public:
  217. CWsbThrowContext( char * File, long Line, HRESULT Hr ) :
  218. m_File(File), m_Line(Line), m_Hr(Hr) { }
  219. char * m_File;
  220. long m_Line;
  221. HRESULT m_Hr;
  222. };
  223. #undef WsbThrow
  224. #define WsbThrow(hr) throw( CWsbThrowContext( __FILE__, __LINE__, hr ) );
  225. #undef WsbCatchAndDo
  226. #define WsbCatchAndDo(hr, code) \
  227. catch(CWsbThrowContext context) { \
  228. hr = context.m_Hr; \
  229. CString msg; \
  230. msg.Format( L"Throw '%ls' on line [%ld] of %hs\n", WsbHrAsString( hr ), (long)context.m_Line, context.m_File ); \
  231. WsbTrace( (LPWSTR)(LPCWSTR)msg ); \
  232. { code } \
  233. }
  234. #undef WsbCatch
  235. #define WsbCatch(hr) \
  236. catch(CWsbThrowContext context) { \
  237. hr = context.m_Hr; \
  238. CString msg; \
  239. msg.Format( L"Throw '%ls' on line [%ld] of %hs\n", WsbHrAsString( hr ), (long)context.m_Line, context.m_File ); \
  240. WsbTrace( (LPWSTR)(LPCWSTR)msg ); \
  241. }
  242. #endif
  243. // constant values used throughout
  244. #define UNINITIALIZED (-1)
  245. #define HSM_MAX_NAME MAX_COMPUTERNAME_LENGTH
  246. #define ONE_MEG (1048576)
  247. // Clipboard formats
  248. extern const wchar_t* SAKSNAP_INTERNAL;
  249. extern const wchar_t* MMC_SNAPIN_MACHINE_NAME;
  250. extern const wchar_t* CF_EV_VIEWS;
  251. #define ELT_SYSTEM (101)
  252. #define ELT_APPLICATION (103)
  253. #define VIEWINFO_FILTERED (0x0002)
  254. #define VIEWINFO_USER_CREATED (0x0008)
  255. #define LOGINFO_DONT_PERSIST (0x0800)
  256. #define EVENTLOG_ALL_EVENTS (EVENTLOG_ERROR_TYPE|EVENTLOG_WARNING_TYPE|EVENTLOG_INFORMATION_TYPE|EVENTLOG_AUDIT_SUCCESS|EVENTLOG_AUDIT_FAILURE)
  257. #define HSMADMIN_CURRENT_VERSION 1 // Current version for use in IPersist
  258. ///////////////////////////////////////////////////////////////////////////
  259. //
  260. // Menu constants
  261. //
  262. //
  263. // Menubar's submenu order for adding into MMC context menu:
  264. //
  265. #define MENU_INDEX_ROOT 0
  266. #define MENU_INDEX_NEW 1
  267. #define MENU_INDEX_TASK 2
  268. #define MENU_HSMCOM_ROOT_PAUSE 0
  269. #define MENU_HSMCOM_ROOT_CONTINUE 1
  270. #define MENU_HSMCOM_TASK_PAUSE 0
  271. #define MENU_HSMCOM_TASK_CONTINUE 1
  272. #define EXTENSION_RS_FOLDER_PARAM -1
  273. #define HSMADMIN_NO_HSM_NAME L"No Hsm Name"
  274. #ifndef IDC_HAND
  275. #define IDC_HAND MAKEINTRESOURCE(32649)
  276. #endif
  277. #define RS_STR_KICKOFF_PARAMS _T("run manage")
  278. #define RS_STR_RESULT_PROPS_MANRESLST_IDS _T("DisplayName:Capacity:FreeSpace:DesiredFreeSpaceP")
  279. #define RS_STR_RESULT_PROPS_DEFAULT_IDS _T("DisplayName:Type:Description")
  280. #define RS_STR_RESULT_PROPS_COM_IDS _T("DisplayName:Description")
  281. #define RS_STR_RESULT_PROPS_MEDSET_IDS _T("DisplayName:Description:CapacityP:FreeSpaceP:StatusP:CopySet1P:CopySet2P:CopySet3P")
  282. ///////////////////////////////////////////////////////////////////////////
  283. //
  284. // Common Flags
  285. //
  286. #define RS_MB_ERROR (MB_OK|MB_ICONSTOP)
  287. #define RS_WINDIR_SIZE (2*MAX_PATH)
  288. ///////////////////////////////////////////////////////////////////////////
  289. //
  290. // Common internal errors
  291. //
  292. #define RS_E_NOT_CONFIGURED HRESULT_FROM_WIN32( ERROR_BAD_CONFIGURATION )
  293. #define RS_E_NOT_INSTALLED HRESULT_FROM_WIN32( ERROR_PRODUCT_UNINSTALLED )
  294. #define RS_E_DISABLED HRESULT_FROM_WIN32( ERROR_RESOURCE_DISABLED )
  295. #define RS_E_CANCELLED HRESULT_FROM_WIN32( ERROR_CANCELLED )
  296. /////////////////////////////////////////////////////////////////////////////
  297. //
  298. // GUIDs for all UI nodes in the system (used as type identifiers)
  299. //
  300. /////////////////////////////////////////////////////////////////////////////
  301. // HsmCom UI node -
  302. // This is the static node known by the snapin manager. This is the only one that is
  303. // actually registered (see hsmadmin.rgs).
  304. extern const GUID cGuidHsmCom;
  305. // The rest of the UI nodes -
  306. extern const GUID cGuidManVol;
  307. extern const GUID cGuidCar;
  308. extern const GUID cGuidMedSet;
  309. extern const GUID cGuidManVolLst;
  310. #endif // _STDAFX_H