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.

331 lines
7.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998-2000.
  5. //
  6. // File: SetupQry.hxx
  7. //
  8. // Contents: Indexing Service ocmgr installation routine definitions.
  9. //
  10. // History: 20 Oct 1998 AlanW Added file header and copyright.
  11. //
  12. //--------------------------------------------------------------------------
  13. #pragma once
  14. DECLARE_DEBUG(is);
  15. #if DBG == 1
  16. #define isDebugOut( x ) isInlineDebugOut x
  17. #else // DBG == 0
  18. #define isDebugOut( x )
  19. #endif // DBG
  20. #ifndef NUMELEM
  21. # define NUMELEM(x) (sizeof(x)/sizeof(*x))
  22. #endif
  23. #define TRY try
  24. #define THROW(e) throw e;
  25. #define CATCH(class,e) catch( class & e )
  26. #define END_CATCH
  27. class CCiNullClass {};
  28. #define INHERIT_UNWIND public CCiNullClass
  29. #define INHERIT_VIRTUAL_UNWIND public CCiNullClass
  30. #define DECLARE_UNWIND
  31. #define IMPLEMENT_UNWIND(class)
  32. #define END_CONSTRUCTION(class)
  33. #define INLINE_UNWIND(class)
  34. #define INLINE_TEMPL_UNWIND(class1, class2)
  35. class CException
  36. {
  37. public:
  38. CException(long lError) : _lError(lError) {}
  39. CException() : _lError(HRESULT_FROM_WIN32(GetLastError())) {}
  40. long GetErrorCode() { return _lError;}
  41. protected:
  42. long _lError;
  43. };
  44. inline void * __cdecl operator new( size_t st )
  45. {
  46. void *p = (void *) LocalAlloc( LMEM_FIXED, st );
  47. if ( 0 == p )
  48. THROW( CException() );
  49. return p;
  50. } //new
  51. inline void __cdecl operator delete( void *pv )
  52. {
  53. if ( 0 != pv )
  54. LocalFree( (HLOCAL) pv );
  55. } //delete
  56. //
  57. // Exceptions are always translated up front in the ocm entrypoint
  58. //
  59. #define TRANSLATE_EXCEPTIONS
  60. #define UNTRANSLATE_EXCEPTIONS
  61. #define ciDebugOut isDebugOut
  62. #define Win4Assert ISAssert
  63. //+---------------------------------------------------------------------------
  64. //
  65. // Class: XPtrST<class CItem>
  66. //
  67. // Purpose: Smart Pointer template for Simple Types
  68. //
  69. // History: 12-Mar-96 dlee Created
  70. //
  71. //----------------------------------------------------------------------------
  72. template<class CItem> class XPtrST
  73. {
  74. public:
  75. XPtrST(CItem* p = 0) : _p( p )
  76. {
  77. }
  78. ~XPtrST() { delete _p; }
  79. BOOL IsNull() const { return ( 0 == _p ); }
  80. void Set ( CItem* p )
  81. {
  82. Win4Assert( 0 == _p );
  83. _p = p;
  84. }
  85. CItem * Acquire()
  86. {
  87. CItem * pTemp = _p;
  88. _p = 0;
  89. return pTemp;
  90. }
  91. CItem & GetReference() const
  92. {
  93. Win4Assert( 0 != _p );
  94. return *_p;
  95. }
  96. CItem * GetPointer() const { return _p ; }
  97. void Free() { delete Acquire(); }
  98. private:
  99. XPtrST (const XPtrST<CItem> & x);
  100. XPtrST<CItem> & operator=( const XPtrST<CItem> & x);
  101. CItem * _p;
  102. };
  103. template<class CItem> class XInterface
  104. {
  105. public:
  106. XInterface(CItem* p = 0) : _p( p )
  107. {
  108. }
  109. XInterface (XInterface<CItem> & x) : _p( x.Acquire() )
  110. {
  111. }
  112. ~XInterface() { if (0 != _p) _p->Release(); }
  113. CItem* operator->() { return _p; }
  114. CItem const * operator->() const { return _p; }
  115. BOOL IsNull() const { return (0 == _p); }
  116. void Set ( CItem* p )
  117. {
  118. Win4Assert (0 == _p);
  119. _p = p;
  120. }
  121. CItem * Acquire()
  122. {
  123. CItem * pTemp = _p;
  124. _p = 0;
  125. return( pTemp );
  126. }
  127. CItem & GetReference() const
  128. {
  129. Win4Assert( 0 != _p );
  130. return( *_p );
  131. }
  132. CItem * GetPointer() const { return( _p ); }
  133. CItem ** GetPPointer() { return &_p; }
  134. void ** GetQIPointer() { return (void **)&_p; }
  135. void Free()
  136. {
  137. CItem *p = Acquire();
  138. if ( 0 != p )
  139. p->Release();
  140. }
  141. private:
  142. CItem * _p;
  143. };
  144. //
  145. // smart pointer class for SC_HANDLEs
  146. //
  147. class CServiceHandle
  148. {
  149. public :
  150. CServiceHandle() { _h = 0; }
  151. CServiceHandle( SC_HANDLE hSC ) : _h( hSC ) {}
  152. ~CServiceHandle() { Free(); }
  153. void Set( SC_HANDLE h ) { _h = h; }
  154. SC_HANDLE Get() { return _h; }
  155. void Free() { if ( 0 != _h ) CloseServiceHandle( _h ); _h = 0; }
  156. private:
  157. SC_HANDLE _h;
  158. };
  159. //+-------------------------------------------------------------------------
  160. //
  161. // Class: CSmartException
  162. //
  163. // Synopsis: wrapper for TRANSLATE/UNTRANSLATE exceptions.
  164. //
  165. // History: 2-9-98 mohamedn
  166. //
  167. //--------------------------------------------------------------------------
  168. #pragma warning(4:4535) // set_se_translator used w/o /EHa
  169. void _cdecl SystemExceptionTranslator( unsigned int uiWhat,
  170. struct _EXCEPTION_POINTERS * pexcept );
  171. class CSmartException
  172. {
  173. public:
  174. CSmartException()
  175. {
  176. _tf = _set_se_translator( SystemExceptionTranslator );
  177. }
  178. ~CSmartException()
  179. {
  180. _set_se_translator( _tf );
  181. }
  182. private:
  183. _se_translator_function _tf;
  184. };
  185. //+-------------------------------------------------------------------------
  186. //
  187. // Class: CError
  188. //
  189. // Synopsis: munges & reports a message to various destinations
  190. //
  191. // History: 2-9-98 mohamedn
  192. //
  193. //--------------------------------------------------------------------------
  194. class CError
  195. {
  196. public:
  197. CError();
  198. ~CError();
  199. void Report( LogSeverity Severity, DWORD dwErr, WCHAR const * MessageString, ...);
  200. private:
  201. WCHAR _awcMsg[MAX_PATH*2];
  202. };
  203. void ISError( UINT id, CError &Err, LogSeverity Severity, DWORD code = 0 );
  204. //
  205. // DLL module handle
  206. //
  207. extern HINSTANCE MyModuleHandle;
  208. extern WCHAR g_awcCatalogDir[MAX_PATH]; // prompt (default from def cat in reg)
  209. extern WCHAR g_awcSystemDir[MAX_PATH]; // system32 directory
  210. extern WCHAR g_awcHomeDir[MAX_PATH]; // prompt (default from reg vroot)
  211. extern WCHAR g_awcScriptDir[MAX_PATH]; // prompt (default from reg vroot)
  212. extern INT g_MajorVersion;
  213. extern INT g_MinorVersion;
  214. const UINT cwcResBuf = 2048;
  215. class CResString
  216. {
  217. public:
  218. CResString() { _awc[ 0 ] = 0; }
  219. CResString( UINT strIDS )
  220. {
  221. _awc[ 0 ] = 0;
  222. LoadString( MyModuleHandle,
  223. strIDS,
  224. _awc,
  225. sizeof _awc / sizeof WCHAR );
  226. }
  227. BOOL Load( UINT strIDS )
  228. {
  229. _awc[ 0 ] = 0;
  230. LoadString( MyModuleHandle,
  231. strIDS,
  232. _awc,
  233. sizeof _awc / sizeof WCHAR );
  234. return ( 0 != _awc[ 0 ] );
  235. }
  236. WCHAR const * Get() { return _awc; }
  237. private:
  238. WCHAR _awc[ cwcResBuf ];
  239. };
  240. // SETUPMODE_UPGRADE
  241. // SETUPMODE_UPGRADEONLY
  242. // SETUPMODE_ADDEXTRACOMPS
  243. //
  244. // SETUPMODE_MAINTANENCE
  245. // SETUPMODE_ADDREMOVE
  246. // SETUPMODE_REINSTALL
  247. // SETUPMODE_REMOVEALL
  248. // SETUPMODE_FRESH
  249. // SETUPMODE_MINIMAL
  250. // SETUPMODE_TYPICAL
  251. // SETUPMODE_CUSTOM
  252. //
  253. #ifndef SETUPMODE_UPGRADEONLY
  254. #define SETUPMODE_UPGRADEONLY 0x20000100
  255. #define SETUPMODE_ADDEXTRACOMPS 0x20000200
  256. #define SETUPMODE_ADDREMOVE 0x10000100
  257. #define SETUPMODE_REINSTALL 0x10000200
  258. #define SETUPMODE_REMOVEALL 0x10000400
  259. #define SETUPMODE_FRESH 0x00000000
  260. #define SETUPMODE_MAINTANENCE 0x10000000
  261. #define SETUPMODE_UPGRADE 0x20000000
  262. #endif // ndef SETUPMODE_UPGRADEONLY