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.

210 lines
6.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: misc.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _MISC_H_
  11. #define _MISC_H_
  12. #define _JumpIfOutOfMemory(hr, label, pMem) \
  13. { \
  14. if (NULL == (pMem)) \
  15. { \
  16. (hr) = E_OUTOFMEMORY; \
  17. _JumpError((hr), label, "Out of Memory"); \
  18. } \
  19. }
  20. __inline
  21. void FREE_DATA(void* pData)
  22. {
  23. if (pData)
  24. GlobalFree(pData);
  25. }
  26. // count the number of bytes needed to fully store the WSZ
  27. #define WSZ_BYTECOUNT(__z__) \
  28. ( (__z__ == NULL) ? 0 : (wcslen(__z__)+1)*sizeof(WCHAR) )
  29. // fwds
  30. class CertSvrCA;
  31. class CertSvrMachine;
  32. BOOL FixupFilterString(LPWSTR szFilter);
  33. LPCWSTR GetNullMachineName(CString* pcstr);
  34. BOOL FIsCurrentMachine(LPCWSTR);
  35. STDMETHODIMP CStringLoad(CString& cstr, IStream *pStm);
  36. STDMETHODIMP CStringSave(CString& cstr, IStream *pStm, BOOL fClearDirty);
  37. STDMETHODIMP CStringGetSizeMax(CString& cstr, int* piSize);
  38. STDMETHODIMP VariantLoad(VARIANT& var, IStream *pStm);
  39. STDMETHODIMP VariantSave(VARIANT& var, IStream *pStm, BOOL fClearDirty);
  40. STDMETHODIMP VariantGetSizeMax(VARIANT& var, int* piSize);
  41. DWORD AllocAndReturnConfigValue(HKEY hKey, LPCWSTR szConfigEntry, PBYTE* ppbOut, DWORD* pcbOut, DWORD* pdwType);
  42. void DisplayCertSrvErrorWithContext(HWND hwnd, DWORD dwErr, UINT iRscContext);
  43. void DisplayCertSrvErrorWithContext(HWND hwnd, DWORD dwErr, LPCWSTR szContext);
  44. void DisplayGenericCertSrvError(HWND hwnd, DWORD dwErr);
  45. void DisplayGenericCertSrvError(LPCONSOLE pConsole, DWORD dwErr);
  46. DWORD CryptAlgToStr(CString* pcstrAlgName, LPCWSTR szProv, DWORD dwProvType, DWORD dwAlg);
  47. enum ENUM_PERIOD DurationEnumFromNonLocalizedString(LPCWSTR szPeriod);
  48. BOOL StringFromDurationEnum(int iEnum, CString* pcstr, BOOL fLocalized);
  49. LPCWSTR OperationToStr(int iOperation);
  50. int StrToOperation(LPCWSTR szOperation);
  51. // Column name localization
  52. LPCWSTR FindUnlocalizedColName(LPCWSTR strColumn); // returns ptr to rsc
  53. // returns localized string
  54. BOOL MakeDisplayStrFromDBVariant(VARIANT* pvt, VARIANT* pvOut);
  55. typedef struct _QUERY_RESTRICTION
  56. {
  57. _QUERY_RESTRICTION* pNext;
  58. LPWSTR szField;
  59. UINT iOperation;
  60. VARIANT varValue;
  61. friend bool operator==(
  62. const struct _QUERY_RESTRICTION& lhs,
  63. const struct _QUERY_RESTRICTION& rhs);
  64. } QUERY_RESTRICTION, *PQUERY_RESTRICTION;
  65. PQUERY_RESTRICTION NewQueryRestriction(LPCWSTR szField, UINT iOp, VARIANT* pvarValue);
  66. void FreeQueryRestriction(PQUERY_RESTRICTION pQR);
  67. void FreeQueryRestrictionList(PQUERY_RESTRICTION pQR);
  68. PQUERY_RESTRICTION QueryRestrictionFound(
  69. PQUERY_RESTRICTION pQR,
  70. PQUERY_RESTRICTION pQRListHead);
  71. void ListInsertAtEnd(void** ppList, void* pElt);
  72. LPWSTR RegEnumKeyContaining(
  73. HKEY hBaseKey,
  74. LPCWSTR szContainsString,
  75. DWORD* pdwIndex);
  76. HRESULT
  77. myGetActiveModule(
  78. CertSvrCA *pCA,
  79. IN BOOL fPolicyModule,
  80. IN DWORD Index,
  81. OPTIONAL OUT LPOLESTR *ppwszProgIdModule, // CoTaskMem*
  82. OPTIONAL OUT CLSID *pclsidModule);
  83. /////////////////////////////////////////
  84. // fxns to load resources automatically
  85. class CLocalizedResources
  86. {
  87. public:
  88. CLocalizedResources();
  89. ~CLocalizedResources();
  90. BOOL Load();
  91. public:
  92. BOOL m_fLoaded;
  93. CBitmap m_bmpSvrMgrToolbar1; // Imagelist for the STOP/START toolbar
  94. CString m_ColumnHead_Name;
  95. CString m_ColumnHead_Size;
  96. CString m_ColumnHead_Type;
  97. CString m_ColumnHead_Description;
  98. CString m_DescrStr_CA;
  99. CString m_DescrStr_Unknown;
  100. CString m_szFilterApplied;
  101. CString m_szSortedAscendingTemplate;
  102. CString m_szSortedDescendingTemplate;
  103. CString m_szStoppedServerMsg;
  104. CString m_szStatusBarErrorFormat;
  105. CString m_szRevokeReason_Unspecified;
  106. CString m_szRevokeReason_KeyCompromise;
  107. CString m_szRevokeReason_CaCompromise;
  108. CString m_szRevokeReason_Affiliation;
  109. CString m_szRevokeReason_Superseded;
  110. CString m_szRevokeReason_Cessatation;
  111. CString m_szRevokeReason_CertHold;
  112. CString m_szRevokeReason_RemoveFromCRL;
  113. CString m_szPeriod_Seconds;
  114. CString m_szPeriod_Minutes;
  115. CString m_szPeriod_Hours;
  116. CString m_szPeriod_Days;
  117. CString m_szPeriod_Weeks;
  118. CString m_szPeriod_Months;
  119. CString m_szPeriod_Years;
  120. CString m_szYes;
  121. };
  122. extern CLocalizedResources *g_pResources;
  123. BOOL OnDialogHelp(LPHELPINFO pHelpInfo, LPCTSTR szHelpFile, const DWORD rgzHelpIDs[]);
  124. BOOL OnDialogContextHelp(HWND hWnd, LPCTSTR szHelpFile, const DWORD rgzHelpIDs[]);
  125. HRESULT ReadOfSize(IStream* pStm, void* pbData, ULONG cbData);
  126. HRESULT WriteOfSize(IStream* pStm, void* pbData, ULONG cbData);
  127. HRESULT myOIDToName(
  128. IN WCHAR const *pwszObjId,
  129. OUT LPWSTR* pszName);
  130. HRESULT myDumpFormattedObject(
  131. IN WCHAR const *pszObjId,
  132. IN BYTE const *pbObject,
  133. IN DWORD cbObject,
  134. OUT LPWSTR* pwszFormatted);
  135. void InplaceStripControlChars(WCHAR* szString);
  136. HANDLE EnablePrivileges(LPCWSTR ppcwszPrivileges[], ULONG cPrivileges);
  137. void ReleasePrivileges(HANDLE hToken);
  138. HRESULT IsUserDomainAdministrator(BOOL* pfIsAdministrator);
  139. BOOL RestartService(HWND hWnd, CertSvrMachine* pMachine);
  140. //
  141. // defined in casec.cpp
  142. //
  143. extern "C"
  144. HRESULT
  145. CreateCASecurityInfo( CertSvrCA *pCA,
  146. LPSECURITYINFO *ppObjSI);
  147. _COM_SMARTPTR_TYPEDEF(ICertAdmin2, IID_ICertAdmin2);
  148. HRESULT FindComputerObjectSid(
  149. LPCWSTR pcwszCAComputerDNSName,
  150. PSID &pSid);
  151. VOID LogOpen(IN BOOL fForceOpen);
  152. VOID LogClose();
  153. #endif _MISC_H_