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.

170 lines
3.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C B A S E . H
  7. //
  8. // Contents: Basic common code.
  9. //
  10. // Notes: Pollute this under penalty of death.
  11. //
  12. // Author: shaunco 20 Sep 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _NCBASE_H_
  17. #define _NCBASE_H_
  18. #include "ncdefine.h" // for NOTHROW
  19. #define STACK_SIZE_DEFAULT 0
  20. #ifdef DBG // Debug builds require larger stack commit sizes due to tracing
  21. #define STACK_SIZE_TINY 65536
  22. #define STACK_SIZE_SMALL 98304
  23. #else
  24. #define STACK_SIZE_TINY 32768
  25. #define STACK_SIZE_SMALL 65536
  26. #endif
  27. #define STACK_SIZE_COMPACT 262144
  28. #define STACK_SIZE_LARGE 1048576
  29. #define STACK_SIZE_HUGE 5242880
  30. NOTHROW
  31. ULONG
  32. AddRefObj (
  33. IUnknown* punk);
  34. NOTHROW
  35. ULONG
  36. ReleaseObj (
  37. IUnknown* punk);
  38. NOTHROW
  39. DWORD
  40. DwWin32ErrorFromHr (
  41. HRESULT hr);
  42. inline
  43. BOOL
  44. FDwordWithinRange (
  45. DWORD dwLower,
  46. DWORD dw,
  47. DWORD dwUpper)
  48. {
  49. return ((dw >= dwLower) && (dw <= dwUpper));
  50. }
  51. NOTHROW
  52. HRESULT
  53. HrFromLastWin32Error ();
  54. HRESULT
  55. HrGetProcAddress (
  56. HMODULE hModule,
  57. PCSTR pszaFunction,
  58. FARPROC* ppfn);
  59. HRESULT
  60. HrLoadLibAndGetProcs (
  61. PCWSTR pszLibPath,
  62. UINT cFunctions,
  63. const PCSTR* apszaFunctionNames,
  64. HMODULE* phmod,
  65. FARPROC* apfn);
  66. inline
  67. HRESULT
  68. HrLoadLibAndGetProc (
  69. PCWSTR pszLibPath,
  70. PCSTR pszaFunctionName,
  71. HMODULE* phmod,
  72. FARPROC* ppfn)
  73. {
  74. return HrLoadLibAndGetProcs (pszLibPath, 1, &pszaFunctionName, phmod, ppfn);
  75. }
  76. HRESULT
  77. __cdecl
  78. HrGetProcAddressesV(
  79. HMODULE hModule, ...);
  80. HRESULT
  81. __cdecl
  82. HrLoadLibAndGetProcsV(
  83. PCWSTR pszLibPath,
  84. HMODULE* phModule,
  85. ...);
  86. HRESULT
  87. HrCreateEventWithWorldAccess(PCWSTR pszName, BOOL fManualReset,
  88. BOOL fInitialState, BOOL* pfAlreadyExists, HANDLE* phEvent);
  89. HRESULT
  90. HrCreateMutexWithWorldAccess(PCWSTR pszName, BOOL fInitialOwner,
  91. BOOL* pfAlreadyExists, HANDLE* phMutex);
  92. HRESULT
  93. HrCreateInstanceBase (REFCLSID rclsid, DWORD dwClsContext, REFIID riid, LPVOID * ppv);
  94. //+---------------------------------------------------------------------------
  95. //
  96. // Function: HrCreateInstance
  97. //
  98. // Purpose: Creates a COM object and sets default proxy settings.
  99. //
  100. // Arguments:
  101. // rclsid [in] See documentation for CoCreateInstance.
  102. // dwClsContext [in] ""
  103. // ppInter [out] Typed interface pointer using templates.
  104. //
  105. // Returns: S_OK on success. An error code otherwise.
  106. //
  107. // Author: mbend 1 Mar 2000
  108. //
  109. template <class Inter>
  110. inline HRESULT
  111. HrCreateInstance (
  112. REFCLSID rclsid,
  113. DWORD dwClsContext,
  114. Inter ** ppInter)
  115. {
  116. return HrCreateInstanceBase(rclsid, dwClsContext, __uuidof(Inter), reinterpret_cast<void**>(ppInter));
  117. }
  118. HRESULT
  119. HrQIAndSetProxyBlanketBase(IUnknown * pUnk, REFIID riid, void ** ppv);
  120. //+---------------------------------------------------------------------------
  121. //
  122. // Function: HrQIAndSetProxyBlanket
  123. //
  124. // Purpose: Performs QueryInterface and sets default proxy settings.
  125. //
  126. // Arguments:
  127. // pUnk [in] Interface pointer to perform QueryInterface on.
  128. // ppInter [out] Typed interface pointer using templates.
  129. //
  130. // Returns: S_OK on success. An error code otherwise.
  131. //
  132. // Author: mbend 1 Mar 2000
  133. //
  134. template <class Inter>
  135. inline HRESULT
  136. HrQIAndSetProxyBlanket (
  137. IUnknown * pUnk,
  138. Inter ** ppInter)
  139. {
  140. return HrQIAndSetProxyBlanketBase(pUnk, __uuidof(Inter), reinterpret_cast<void**>(ppInter));
  141. }
  142. #endif // _NCBASE_H_