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.

199 lines
8.8 KiB

  1. #ifndef _HELPER_H_
  2. #define _HELPER_H_
  3. #include "wmrgexp.h"
  4. #include "ocmanage.h"
  5. #include "setupapi.h"
  6. #if DBG == 1
  7. #include <stdio.h>
  8. #include <stdarg.h>
  9. #define DECLARE_INFOLEVEL(comp) extern unsigned long comp##InfoLevel = DEF_INFOLEVEL;
  10. #define DECLARE_DEBUG(comp) \
  11. extern unsigned long comp##InfoLevel; \
  12. _inline void \
  13. comp##InlineDebugOut(unsigned long fDebugMask, TCHAR *pszfmt, ...) \
  14. { \
  15. if (comp##InfoLevel & fDebugMask) \
  16. { \
  17. TCHAR acsString[1000];\
  18. va_list va; \
  19. va_start(va, pszfmt);\
  20. _vstprintf(acsString, pszfmt, va); \
  21. va_end(va);\
  22. OutputDebugString(acsString);\
  23. } \
  24. }\
  25. _inline void \
  26. comp##InlineDebugOut( TCHAR *pszfmt, ...) \
  27. { \
  28. if ( TRUE ) \
  29. { \
  30. TCHAR acsString[1000];\
  31. va_list va; \
  32. va_start(va, pszfmt);\
  33. _vstprintf(acsString, pszfmt, va); \
  34. va_end(va);\
  35. OutputDebugString(acsString);\
  36. } \
  37. }
  38. #else // DBG == 0
  39. #define DECLARE_DEBUG(comp)
  40. #define DECLARE_INFOLEVEL(comp)
  41. #endif // DBG == 0
  42. DECLARE_DEBUG(iis);
  43. #define iisDebugOut(x) iisDebugOut2 x
  44. #define iisDebugOutSafeParams(x) iisDebugOutSafeParams2 x
  45. #define iisDebugOutSafe(x) iisDebugOutSafe2 x
  46. #define DO_IT_FOR_W3SVC_ANONYMOUSUSER 1
  47. #define DO_IT_FOR_MSFTPSVC_ANONYMOUSUSER 2
  48. #define DO_IT_FOR_W3SVC_WAMUSER 4
  49. // External globals from other .cpp files
  50. class MyLogFile;
  51. extern MyLogFile g_MyLogFile;
  52. class CInitApp;
  53. extern CInitApp* g_pTheApp;
  54. extern HANDLE g_MyModuleHandle;
  55. // structs
  56. typedef struct _CLUSTER_SVC_INFO_FILL_STRUCT
  57. {
  58. LPTSTR szTheClusterName;
  59. LPWSTR pszTheServiceType;
  60. CString * csTheReturnServiceResName;
  61. DWORD dwReturnStatus;
  62. } CLUSTER_SVC_INFO_FILL_STRUCT;
  63. typedef struct _ScriptMapNode {
  64. TCHAR szExt[32];
  65. TCHAR szProcessor[_MAX_PATH];
  66. DWORD dwFlags;
  67. TCHAR szMethods[_MAX_PATH];
  68. struct _ScriptMapNode *prev, *next;
  69. } ScriptMapNode;
  70. //
  71. // Functions
  72. //
  73. void iisDebugOut2(int iLogType, TCHAR *pszfmt, ...);
  74. void iisDebugOutSafeParams2(int iLogType, TCHAR *pszfmt, ...);
  75. void iisDebugOutSafe2(int iLogType, TCHAR *pszfmt);
  76. void iisDebugOut_Start(TCHAR *pszString, int iLogType = LOG_TYPE_TRACE_WIN32_API);
  77. void iisDebugOut_Start1(TCHAR *pszString1, TCHAR *pszString2, int iLogType = LOG_TYPE_TRACE_WIN32_API);
  78. void iisDebugOut_Start1(TCHAR *pszString1, CString pszString2, int iLogType = LOG_TYPE_TRACE_WIN32_API);
  79. void iisDebugOut_End(TCHAR *pszString, int iLogType = LOG_TYPE_TRACE_WIN32_API);
  80. void iisDebugOut_End1(TCHAR *pszString1, TCHAR *pszString2, int iLogType = LOG_TYPE_TRACE_WIN32_API);
  81. void iisDebugOut_End1(TCHAR *pszString1, CString pszString2, int iLogType = LOG_TYPE_TRACE_WIN32_API);
  82. void ProgressBarTextStack_Push(CString csText);
  83. void ProgressBarTextStack_Push(LPTSTR szText);
  84. void ProgressBarTextStack_Pop(void);
  85. void ProgressBarTextStack_Set(int iStringID);
  86. void ProgressBarTextStack_Set(int iStringID, const CString& csFileName);
  87. void ProgressBarTextStack_Set(int iStringID, const CString& csString1, const CString& csString2);
  88. void ProgressBarTextStack_Set(LPCTSTR szProgressTextString);
  89. void ProgressBarTextStack_Inst_Set( int ServiceNameID, int iInstanceNum);
  90. void ProgressBarTextStack_InstVRoot_Set( int ServiceNameID, int iInstanceNum, CString csVRName);
  91. void ProgressBarTextStack_InstInProc_Set( int ServiceNameID, int iInstanceNum, CString csVRName);
  92. void ListOfWarnings_Add(TCHAR * szEntry);
  93. void ListOfWarnings_Display(void);
  94. HRESULT GetLastSectionToBeCalled(void);
  95. INT Register_iis_common();
  96. INT Unregister_iis_common();
  97. INT Unregister_old_asp();
  98. INT Register_iis_core();
  99. INT Unregister_iis_core();
  100. INT Register_iis_inetmgr();
  101. INT Unregister_iis_inetmgr();
  102. INT Register_iis_pwmgr();
  103. INT Unregister_iis_pwmgr();
  104. INT Register_iis_www();
  105. INT Unregister_iis_www();
  106. INT Register_iis_doc();
  107. INT Register_iis_ftp();
  108. INT Unregister_iis_ftp();
  109. LPWSTR MakeWideStrFromAnsi(LPSTR psz);
  110. int GetMultiStrSize(LPTSTR p);
  111. BOOL IsValidNumber(LPCTSTR szValue);
  112. int GetRandomNum(void);
  113. void SetRebootFlag(void);
  114. BOOL RunProgram( LPCTSTR pszProgram, LPTSTR CmdLine, BOOL fMinimized , DWORD dwWaitTimeInSeconds, BOOL fCreateNewConsole);
  115. void HandleSpecificErrors(DWORD iTheErrorCode, DWORD dwFormatReturn, CString csMsg, TCHAR pMsg[], CString *);
  116. BOOL GetDataFromMetabase(LPCTSTR szPath, int nID, LPBYTE Buffer, int BufSize);
  117. void AddOLEAUTRegKey();
  118. DWORD RegisterOLEControl(LPCTSTR lpszOcxFile, BOOL fAction);
  119. void lodctr(LPCTSTR lpszIniFile);
  120. void unlodctr(LPCTSTR lpszDriver);
  121. INT InstallPerformance(CString nlsRegPerf,CString nlsDll,CString nlsOpen,CString nlsClose,CString nlsCollect );
  122. INT AddEventLog(BOOL fSystem, CString nlsService, CString nlsMsgFile, DWORD dwType);
  123. INT RemoveEventLog(BOOL fSystem, CString nlsService );
  124. INT InstallAgent( CString nlsName, CString nlsPath );
  125. INT RemoveAgent( CString nlsServiceName );
  126. void InstallMimeMap();
  127. int CreateInProc(LPCTSTR lpszPath, int iUseOOPPool);
  128. void CreateInProc_Wrap(LPCTSTR lpszPath, int iUseOOPPool);
  129. void DeleteInProc(LPCTSTR lpszKeyPath);
  130. void SetAppFriendlyName(LPCTSTR szKeyPath);
  131. void SetInProc(LPCTSTR szKeyPath);
  132. void AddCustomError(IN DWORD dwCustErr, IN INT intSubCode, IN LPCTSTR szErrorString, IN LPCTSTR szKeyPath, IN BOOL fOverwriteExisting );
  133. ScriptMapNode *AllocNewScriptMapNode(LPTSTR szExt, LPTSTR szProcessor, DWORD dwFlags, LPTSTR szMethods);
  134. void InsertScriptMapList(ScriptMapNode *pList, ScriptMapNode *p, BOOL fReplace);
  135. void FreeScriptMapList(ScriptMapNode *pList);
  136. void GetScriptMapListFromRegistry(ScriptMapNode *pList);
  137. void GetScriptMapListFromMetabase(ScriptMapNode *pList, int iUpgradeType);
  138. void WriteScriptMapListToMetabase(ScriptMapNode *pList, LPTSTR szKeyPath, DWORD dwFlags);
  139. DWORD CallProcedureInDll_wrap(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedureToCall, BOOL bDisplayMsgOnErrFlag, BOOL bInitOleFlag, BOOL iFunctionPrototypeFlag);
  140. DWORD CallProcedureInDll(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedureToCall, BOOL bDisplayMsgOnErrFlag, BOOL bInitOleFlag, BOOL iFunctionPrototypeFlag);
  141. void GetDebugLevelFromInf(IN HINF hInfFileHandle);
  142. int IsThisStringInThisCStringList(CStringList &strList, LPCTSTR szStringToLookFor);
  143. int KillProcess_Wrap(LPCTSTR lpFullPathOrJustFileName);
  144. int ProcessSection(IN HINF hFile, IN LPCTSTR szTheSection);
  145. void uiCenterDialog( HWND hwndDlg );
  146. int AfterRemoveAll_SaveMetabase(void);
  147. int iOleInitialize(void);
  148. void iOleUnInitialize(int iBalanceOLE);
  149. BOOL SetupSetDirectoryId_Wrapper(HINF InfHandle,DWORD Id,LPCTSTR Directory);
  150. BOOL SetupSetStringId_Wrapper(HINF InfHandle,DWORD Id,LPCTSTR TheString);
  151. void LogImportantFiles(void);
  152. HRESULT FTestForOutstandingCoInits(void);
  153. void DisplayStringForMetabaseID(DWORD dwMetabaseID);
  154. void ReturnStringForMetabaseID(DWORD dwMetabaseID, LPTSTR lpReturnString);
  155. void SetErrorFlag(char *szFileName, int iLineNumber);
  156. DWORD FillStrListWithListOfSections(IN HINF hFile, CStringList &strList, IN LPCTSTR szSection);
  157. void MesssageBoxErrors_IIS(void);
  158. void MesssageBoxErrors_MTS(int iMtsThingWeWereDoing, DWORD dwErrorCode);
  159. void ShowIfModuleUsedForGroupOfSections(IN HINF hFile, int iUnlockThem);
  160. int ReadGlobalsFromInf(HINF InfHandle);
  161. int CheckIfPlatformMatchesInf(HINF InfHandle);
  162. int CheckSpecificBuildinInf(HINF InfHandle);
  163. int CheckForOldGopher(HINF InfHandle);
  164. void SetOCGlobalPrivateData(void);
  165. BOOL GetJavaTLD(LPTSTR lpszDir);
  166. void SetDIRIDforThisInf(HINF InfHandle,BOOL bOCInit);
  167. void ShowStateOfTheseServices(IN HINF hFile);
  168. int GetScriptMapAllInclusionVerbs(CString &csTheVerbList);
  169. void DumpScriptMapList();
  170. int GetSectionNameToDo(IN HINF hFile, TSTR *pstrSectionName);
  171. void CustomWWWRoot(LPCTSTR szWWWRoot);
  172. void CustomFTPRoot(LPCTSTR szFTPRoot);
  173. void AdvanceProgressBarTickGauge(int iTicks = 1);
  174. int IsMetabaseCorrupt(void);
  175. int ReadUserConfigurable(HINF InfHandle);
  176. int ReverseExpandEnvironmentStrings(LPTSTR szOriginalDir,LPTSTR szNewlyMungedDir);
  177. BOOL SetupFindFirstLine_Wrapped(IN HINF InfHandle,IN LPCTSTR Section,IN LPCTSTR Key,OPTIONAL INFCONTEXT *Context);
  178. INT IsThisOnNotStopList(IN HINF hFile, CString csInputName, BOOL bServiceFlag);
  179. HRESULT MofCompile(TCHAR * szPathMofFile);
  180. DWORD DoesEntryPointExist(LPCTSTR lpszDLLFile, LPCTSTR lpszProcedure);
  181. void CreateDummyMetabaseBin(void);
  182. BOOL RunningAsAdministrator();
  183. LPTSTR CreatePassword(int iSize);
  184. void CreatePasswordOld(TCHAR *pszPassword,int iSize);
  185. void StopAllServicesRegardless(int iShowErrorsFlag);
  186. LPTSTR SafeCopy( LPTSTR szDestination, LPTSTR szSource, DWORD dwSize);
  187. LPTSTR SafeCat( LPTSTR szDestination, LPTSTR szSource, DWORD dwSize);
  188. BOOL DoesTheInstallDrivePreserveAcls( LPBOOL pbPreservesAcls );
  189. BOOL UpdateAnonymousUsers( HINF InfHandle );
  190. #endif // _HELPER_H_