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.

236 lines
8.9 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name :
  4. RwpFunctions.hxx
  5. Abstract:
  6. Defines the behaviors of the "Rogue Worker Process"
  7. to test Application Manager
  8. Author:
  9. David Wang ( t-dwang ) 14-Jun-1999 Initial
  10. Satish Mohanakrishnan ( SatishM ) 11-Feb-2000 Separate out timers
  11. Project:
  12. Duct-Tape
  13. --*/
  14. /*********************************************************
  15. * Include Headers
  16. *********************************************************/
  17. #include "wptypes.hxx"
  18. #include "dbgutil.h"
  19. #include "wpipm.hxx"
  20. #ifndef _ROGUE_WORKER_PROCESS
  21. #define _ROGUE_WORKER_PROCESS
  22. /*********************************************************
  23. * Type Definitions
  24. *********************************************************/
  25. //
  26. // Opcodes to test
  27. //
  28. enum {
  29. RWP_IPM_OP_NONE,
  30. RWP_IPM_OP_GETPID,
  31. RWP_IPM_OP_PING_REPLY,
  32. RWP_IPM_OP_SEND_COUNTERS,
  33. RWP_IPM_OP_HRESULT,
  34. RWP_IPM_OP_WORKER_REQUESTS_SHUTDOWN,
  35. RWP_IPM_OP_INVALID
  36. };
  37. // These are the other possible values of DataPointerType
  38. const LONG RWP_DATA_POINTER_TYPE_VALID = 0;
  39. const LONG RWP_DATA_POINTER_TYPE_NULL = 1;
  40. const LONG RWP_DATA_POINTER_TYPE_INVALID = 2; // bogus non-NULL address
  41. const LONG RWP_DATA_POINTER_TYPE_INVALID_REASON = 3; // valid ptr to invalid reason (not pretty but useful)
  42. // Test completion status (read by test script component)
  43. const LONG RWP_TEST_STATUS_NOT_COMPLETE = 0;
  44. const LONG RWP_TEST_STATUS_COMPLETE = 1;
  45. const LONG RWP_TEST_STATUS_ERROR = 2;
  46. //
  47. // Various categories of rogue behavior
  48. //
  49. enum {
  50. RWP_PING,
  51. RWP_SHUTDOWN,
  52. RWP_STARTUP,
  53. RWP_ROTATION,
  54. RWP_PIPE,
  55. RWP_HEALTH
  56. };
  57. const LONG RWP_NO_MISBEHAVE = 0x00000000; //behave!
  58. //
  59. // Test(s) for opening app pool
  60. //
  61. const LONG RWP_APPPOOL_BOGUS = 0x00000001; // use a bogus name
  62. //
  63. //Ping misbehaviors
  64. //
  65. const LONG RWP_PING_NO_ANSWER = 0x00000001; //don't respond //wait 30 seconds
  66. const LONG RWP_PING_DELAY_ANSWER = 0x00000002; //wait and respond //wait 30 seconds
  67. const LONG RWP_PING_MULTI_ANSWER = 0x00000003; //respond many times //no waiting
  68. const LONG RWP_PING_MESSAGE_BODY = 0x00000004; //send a message body with ping
  69. //
  70. //Shutdown misbehaviors
  71. //
  72. const LONG RWP_SHUTDOWN_NOT_OBEY = 0x00000001; //won't shutdown //wait 30 seconds
  73. const LONG RWP_SHUTDOWN_DELAY = 0x00000002; //wait and shutdown //wait 30 seconds
  74. const LONG RWP_SHUTDOWN_MULTI = 0x00000003; //shutdown multiple times //no waiting
  75. //
  76. //Startup misbehaviors
  77. //
  78. const LONG RWP_STARTUP_NOT_OBEY = 0x00000001; //don't start //wait 10 seconds
  79. const LONG RWP_STARTUP_DELAY = 0x00000002; //wait and reg //wait 30 seconds
  80. const LONG RWP_STARTUP_NOT_REGISTER_FAIL = 0x00000003; //don't reg and fail //wait 10 seconds
  81. //
  82. //When you hit the rotation criteria, send a request for shut-down
  83. //
  84. const LONG RWP_ROTATION_INVALID_REASON = 0x00000001; //send an invalid shutdown reason
  85. const LONG RWP_ROTATION_REQUEST_MULTI = 0x00000002; //send request for shutdown multiple times
  86. const LONG RWP_ROTATION_MESSAGE_BODY = 0x00000003; //send a message body with shutdown request
  87. //
  88. // Pipe interactions - After n requests, do a misbehavior
  89. //
  90. const LONG RWP_PIPE_CLOSE = 0x00000001; //close the pipe
  91. const LONG RWP_PIPE_LESS_MESSAGE_LENGTH = 0x00000002; //send a message with incorrect message length
  92. const LONG RWP_PIPE_MORE_MESSAGE_LENGTH = 0x00000003; //send a message with incorrect message length
  93. const LONG RWP_PIPE_MESSAGE_POINTER_NULL = 0x00000004; //send a message pointing to NULL
  94. const LONG RWP_PIPE_MESSAGE_POINTER_READONLY = 0x00000005; //send a message pointing to read-only memory
  95. const LONG RWP_PIPE_MESSAGE_HUGE = 0x00000006; //send a huge message body
  96. const LONG RWP_PIPE_INVALID_OPCODE = 0x00000007; //send a message with invalid opcode
  97. const LONG RWP_PIPE_MESSAGE_EMPTY = 0x00000008; //send no message body, when opcode requires it
  98. //
  99. //WP Health-check
  100. //
  101. const LONG RWP_HEALTH_OK = 0x00000001;
  102. const LONG RWP_HEALTH_NOT_OK = 0x00000002;
  103. const LONG RWP_HEALTH_TERMINALLY_ILL = 0x00000003;
  104. //
  105. //N-services recycling
  106. //
  107. const LONG RWP_RECYCLE_NOT_OBEY = 0x00000001;
  108. const LONG RWP_RECYCLE_DELAY = 0x00000002;
  109. //adding new app or config group on the fly
  110. //gentle restart
  111. //Extra Debugging
  112. const LONG RWP_DEBUG_ON = 1;
  113. const LONG RWP_DEBUG_OFF = 0;
  114. const char RWP_NO_PING_MISBEHAVE_MSG[] = "- Pings behave normally\n";
  115. const char RWP_NO_SHUTDOWN_MISBEHAVE_MSG[] = "- Shutdown behave normally\n";
  116. const char RWP_NO_ROTATION_MISBEHAVE_MSG[] = "- Rotation behave normally\n";
  117. const char RWP_NO_STARTUP_MISBEHAVE_MSG[] = "- Startup behave normally\n";
  118. const char RWP_NO_HEALTH_MISBEHAVE_MSG[] = "- Health behave normally\n";
  119. const char RWP_NO_RECYCLE_MISBEHAVE_MSG[] = "- Recycles behave normally\n";
  120. const char RWP_PING_NO_ANSWER_MSG[] = "- Don't answer to pings\n";
  121. const char RWP_PING_DELAY_ANSWER_MSG[] = "- Answer pings with delay (in seconds) =";
  122. const char RWP_PING_MULTI_ANSWER_MSG[] = "- Answer N times per ping, where N =";
  123. const char RWP_SHUTDOWN_NOT_OBEY_MSG[] = "- Don't shutdown when demanded\n";
  124. const char RWP_SHUTDOWN_DELAY_MSG[] = "- Shutdown with delay (in seconds) =";
  125. const char RWP_ROTATION_INVALID_REASON_MSG[] = "- Request for shut-down, invalid reason";
  126. //don't start up fast enough and other timing issues
  127. const char RWP_STARTUP_NOT_OBEY_MSG[] = "- Don't start up (SIDS) after registering with UL\n";
  128. const char RWP_STARTUP_DELAY_MSG[] = "- Start up lazily with delay (in seconds) =";
  129. const char RWP_STARTUP_NOT_REGISTER_FAIL_MSG[] = "- Don't start up (SIDS) before registering with UL\n";
  130. //
  131. // NYI
  132. //
  133. const char RWP_HEALTH_OK_MSG[] = "- Health remains OK\n";
  134. const char RWP_HEALTH_NOT_OK_MSG[] = "- Health remains not OK\n";
  135. const char RWP_HEALTH_TERMINALLY_ILL_MSG[] = "- Health remains terminally ill\n";
  136. const char RWP_RECYCLE_NOT_OBEY_MSG[] = "- Don't recycle process after N services\n";
  137. const char RWP_RECYCLE_DELAY_MSG[] = "- Recycle process, but delay after services =";
  138. //
  139. //the registry location of the RogueWP configuration info
  140. //
  141. //Store it in HKLM
  142. const WCHAR RWP_CONFIG_OPCODE_TO_TEST[] = L"OpCodeToTest";
  143. const WCHAR RWP_CONFIG_IPM_DATA_LENGTH[] = L"DataLength";
  144. const WCHAR RWP_CONFIG_IPM_USE_DATA_LENGTH[] = L"UseDataLength";
  145. const WCHAR RWP_CONFIG_IPM_POINTER_TYPE[] = L"DataPointerType";
  146. const WCHAR RWP_CONFIG_NUMBER_OF_CALLS[] = L"NumberOfCalls";
  147. const WCHAR RWP_CONFIG_ATTACK_DURATION[] = L"AttackDuration";
  148. const WCHAR RWP_CONFIG_TEST_STARTED[] = L"TestStarted";
  149. const WCHAR RWP_CONFIG_TEST_COMPLETION_STATUS[] = L"TestCompletionStatus";
  150. const WCHAR RWP_CONFIG_USE_ALTERNATE_APP_POOL[] = L"UseAlternateAppPool";
  151. const WCHAR RWP_CONFIG_ALTERNATE_APP_POOL_NAME[] = L"AlternateAppPoolName";
  152. const WCHAR RWP_CONFIG_LOCATION[] = L"Software\\Microsoft\\IISTest\\RwpConfig";
  153. const WCHAR RWP_CONFIG_PING_BEHAVIOR[] = L"PingBehavior";
  154. const WCHAR RWP_CONFIG_SHUTDOWN_BEHAVIOR[] = L"ShutdownBehavior";
  155. const WCHAR RWP_CONFIG_ROTATION_BEHAVIOR[] = L"RotationBehavior";
  156. const WCHAR RWP_CONFIG_STARTUP_BEHAVIOR[] = L"StartupBehavior";
  157. const WCHAR RWP_CONFIG_HEALTH_BEHAVIOR[] = L"HealthBehavior";
  158. const WCHAR RWP_CONFIG_RECYCLE_BEHAVIOR[] = L"RecycleBehavior";
  159. const WCHAR RWP_CONFIG_APP_POOL_BEHAVIOR[] = L"AppPoolBehavior";
  160. const WCHAR RWP_CONFIG_PING_COUNT[] = L"PingCount";
  161. const WCHAR RWP_CONFIG_SHUTDOWN_COUNT[] = L"ShutdownCount";
  162. const WCHAR RWP_CONFIG_ROTATION_COUNT[] = L"RotationCount";
  163. const WCHAR RWP_CONFIG_STARTUP_COUNT[] = L"StartupCount";
  164. const WCHAR RWP_CONFIG_HEALTH_COUNT[] = L"HealthCount";
  165. const WCHAR RWP_CONFIG_RECYCLE_COUNT[] = L"RecycleCount";
  166. const WCHAR RWP_CONFIG_EXTRA_DEBUG[] = L"Debug";
  167. //
  168. //Globals
  169. //
  170. extern LONG RwpBehaviorExhibited;
  171. //
  172. //Default behavior = no misbehave (behave normally)
  173. //
  174. //
  175. //Functions
  176. //
  177. LONG RWP_AppPoolTest(void);
  178. LONG RWP_IPM_BadParamTest(LONG OpCode, HRESULT* phr, IPM_MESSAGE_PIPE* pPipe) ;
  179. LONG RWP_Ping_Behavior(HRESULT* hr, IPM_MESSAGE_PIPE* pPipe);
  180. LONG RWP_Shutdown_Behavior(HRESULT* hr);
  181. LONG RWP_Startup_Behavior(HRESULT* pHr);
  182. LONG RWP_Rotation_Behavior(HRESULT* hr, IPM_MESSAGE_PIPE* pPipe);
  183. LONG RWP_Health_Behavior();
  184. LONG RWP_Recycle_Behavior();
  185. LONG RWP_Get_Behavior(LONG lBehavior);
  186. BOOL RWP_Read_Config(const WCHAR* szRegKey);
  187. void RWP_Sleep_For(LONG lTime);
  188. void RWP_Output_String_And_LONG(LONG lLong, char* szString);
  189. #endif