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.

164 lines
6.4 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. win32oneshot.h
  5. Abstract:
  6. one time initialization
  7. per process or per user or per machine
  8. optionally thread safe, if per process
  9. get code out of dllmain(dll_process_attach)
  10. get code out of setup (eliminate setup) (like, don't populate registry with defaults)
  11. Author:
  12. Jay Krell (JayKrell) August 2001
  13. design per discussion with Michael Grier (MGrier)
  14. Revision History:
  15. --*/
  16. #if !defined(WIN32_ONE_SHOT_H_INCLUDED_)
  17. #define WIN32_ONE_SHOT_H_INCLUDED_
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. //#include "nt.h"
  25. //#include "ntrtl.h"
  26. //#include "nturtl.h"
  27. #include "windows.h"
  28. struct _WIN32_ONE_SHOT_OPAQUE_STATIC_STATE;
  29. struct _WIN32_ONE_SHOT_CALL_IN;
  30. struct _WIN32_ONE_SHOT_CALL_OUT;
  31. struct _WIN32_ONE_SHOT_CALL_IN;
  32. struct _WIN32_ONE_SHOT_CALL_OUT;
  33. //
  34. // This is opaque and should be initialized by filling with zeros, as
  35. // static initialization provides. You need not call ZeroMemory on
  36. // static instances, in fact doing so partly defeats the purpose.
  37. //
  38. typedef struct _WIN32_ONE_SHOT_OPAQUE_STATIC_STATE {
  39. union {
  40. struct {
  41. DWORD_PTR WinbasePrivate_UserDefinedDisposition;
  42. LONG WinbasePrivate_NumberOfSuccesses;
  43. LONG WinbasePrivate_NumberOfFailures;
  44. } s;
  45. union {
  46. PVOID WinbasePrivate_LockCookie;
  47. LONG WinbasePrivate_NumberOfEntries;
  48. LONG WinbasePrivate_Done;
  49. } s2;
  50. DWORD_PTR Reserved[4]; // too big? too small? just right? - Goldi Locks circa 1850..
  51. } u;
  52. } WIN32_ONE_SHOT_OPAQUE_STATIC_STATE, *PWIN32_ONE_SHOT_OPAQUE_STATIC_STATE;
  53. typedef WIN32_ONE_SHOT_OPAQUE_STATIC_STATE const*PCWIN32_ONE_SHOT_OPAQUE_STATIC_STATE;
  54. typedef BOOL (CALLBACK * WIN32_ONE_SHOT_INITIALIZE_FUNCTION)(
  55. const struct _WIN32_ONE_SHOT_CALL_IN* in,
  56. struct _WIN32_ONE_SHOT_CALL_OUT* out
  57. );
  58. #define WIN32_ONE_SHOT_CALL_FLAG_IN_STATIC_STATE_VALID (0x00000001)
  59. #define WIN32_ONE_SHOT_CALL_FLAG_IN_FLAGS_OUT_VALID (0x00000002)
  60. #define WIN32_ONE_SHOT_CALL_FLAG_IN_USER_DEFINED_CONTEXT_VALID (0x00000004)
  61. #define WIN32_ONE_SHOT_CALL_FLAG_IN_USER_DEFINED_DISPOSITION_VALID (0x00000008)
  62. #define WIN32_ONE_SHOT_CALL_FLAG_IN_USER_DEFINED_INITIALIZER_VALID (0x00000010)
  63. #define WIN32_ONE_SHOT_CALL_FLAG_IN_EXACTLY_ONCE (0x00000020)
  64. #define WIN32_ONE_SHOT_CALL_FLAG_IN_AT_LEAST_ONCE (0x00000040)
  65. //#define WIN32_ONE_SHOT_CALL_FLAG_IN_SCOPE_QUALIFIER_IS_ASSEMBLY_IDENTITY (0x00000080)
  66. //#define WIN32_ONE_SHOT_CALL_FLAG_IN_SCOPE_QUALIFIER_IS_ASSEMBLY_DIRECTORY (0x00000100)
  67. //#define WIN32_ONE_SHOT_CALL_FLAG_IN_SCOPE_QUALIFIER_IS_HMODULE (0x00000200)
  68. //#define WIN32_ONE_SHOT_CALL_FLAG_IN_SCOPE_QUALIFIER_IS_ADDRESS_IN_DLL (0x00000400)
  69. #define WIN32_ONE_SHOT_CALL_FLAG_IN_RETRY_ON_FAILURE (0x00000800)
  70. #define WIN32_ONE_SHOT_CALL_FLAG_IN_ALWAYS_WANT_DETAILED_RESULTS (0x00001000)
  71. //#define WIN32_ONE_SHOT_CALL_FLAG_IN_UNINSTALL (0x00002000) /* must be combined with user or machine scope */
  72. //#define WIN32_ONE_SHOT_SCOPE1_PROCESS (0x00000001) /* the only one implemented so far */
  73. //#define WIN32_ONE_SHOT_SCOPE1_CURRENT_USER (0x00000002)
  74. //#define WIN32_ONE_SHOT_SCOPE1_LOCAL_MACHINE (0x00000004)
  75. //#define WIN32_ONE_SHOT_SCOPE2_COMPONENT_NO_VERSION (0x000000010)
  76. //#define WIN32_ONE_SHOT_SCOPE2_COMPONENT_WITH_VERSION (0x000000020)
  77. //#define WIN32_ONE_SHOT_SCOPE3_NOT_APPLICATION_SPECIFIC (0x000000040)
  78. //#define WIN32_ONE_SHOT_SCOPE3_PER_ACTIVATION_CONTEXT_ROOT (0x000000080)
  79. //#define WIN32_ONE_SHOT_SCOPE3_PER_ACTIVATION (0x000000100)
  80. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_THIS_TIME_RAN_CALLBACK (0x00000001)
  81. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_THIS_TIME_RAN_CALLBACK_RETRIED (0x00000002)
  82. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_THIS_TIME_CALLBACK_SUCCEEDED (0x00000004)
  83. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_THIS_TIME_CALLBACK_FAILED (0x00000008)
  84. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_ANY_CALLBACKS_FAILED (0x00000010) // mayb we
  85. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_ANY_CALLBACKS_SUCCEEDED (0x00000020) // should just
  86. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_MULTIPLE_CALLBACKS_FAILED (0x00000040) // provide the
  87. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_MULTIPLE_CALLBACKS_SUCCEEDED (0x00000080) // actual counts?
  88. #define WIN32_ONE_SHOT_CALL_FLAG_OUT_DETAILED_RESULTS_VALID (0x00000100) // or none of this?
  89. typedef struct _WIN32_ONE_SHOT_CALL_IN {
  90. SIZE_T dwSize;
  91. DWORD dwFlags; // describe what members in the struct are valid
  92. PWIN32_ONE_SHOT_OPAQUE_STATIC_STATE lpOpaqueStaticState;
  93. DWORD dwFlagsIn;
  94. WIN32_ONE_SHOT_INITIALIZE_FUNCTION lpfnUserDefinedInitializer;
  95. PVOID lpvUserDefinedContext;
  96. //
  97. // extensible scope...
  98. //
  99. //DWORD dwScope;
  100. //
  101. } WIN32_ONE_SHOT_CALL_IN, *PWIN32_ONE_SHOT_CALL_IN;
  102. typedef const WIN32_ONE_SHOT_CALL_IN *PCWIN32_ONE_SHOT_CALL_IN;
  103. typedef struct _WIN32_ONE_SHOT_CALL_OUT {
  104. SIZE_T dwSize; // describe what members in the struct are valid
  105. DWORD dwFlags;
  106. DWORD dwFlagsOut;
  107. DWORD_PTR dwUserDefinedDisposition;
  108. } WIN32_ONE_SHOT_CALL_OUT, *PWIN32_ONE_SHOT_CALL_OUT;
  109. typedef const WIN32_ONE_SHOT_CALL_OUT *PCWIN32_ONE_SHOT_CALL_OUT;
  110. // aka Win32DoOneTimeInitialization
  111. BOOL
  112. WINAPI
  113. Win32OneShotW( // W because "scope parameters" will contain strings
  114. PWIN32_ONE_SHOT_CALL_IN in,
  115. PWIN32_ONE_SHOT_CALL_OUT out
  116. );
  117. //
  118. // simpler interface, different implementation
  119. //
  120. #define WIN32_ENTER_ONE_SHOT_FLAG_EXACTLY_ONCE (0x00000001)
  121. #define WIN32_ENTER_ONE_SHOT_FLAG_AT_LEAST_ONCE (0x00000002)
  122. BOOL
  123. WINAPI
  124. Win32EnterOneShotW(
  125. DWORD dwFlags,
  126. PWIN32_ONE_SHOT_OPAQUE_STATIC_STATE pOneshot
  127. );
  128. VOID
  129. WINAPI
  130. Win32LeaveOneShotW(
  131. DWORD dwFlags,
  132. PWIN32_ONE_SHOT_OPAQUE_STATIC_STATE pOneshot
  133. );
  134. #ifdef __cplusplus
  135. }
  136. #endif
  137. #endif