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.

132 lines
3.3 KiB

  1. #include <sacstress.h>
  2. DWORD
  3. ChannelThreadOpenClose(
  4. PVOID Data
  5. )
  6. {
  7. SAC_CHANNEL_OPEN_ATTRIBUTES Attributes;
  8. SAC_CHANNEL_HANDLE SacChannelHandle;
  9. PCHANNEL_THREAD_DATA ChannelThreadData;
  10. DWORD Status;
  11. ULONG i;
  12. PUCHAR Buffer;
  13. BOOL bContinue;
  14. ULONG k;
  15. PWSTR Name;
  16. PWSTR Description;
  17. BOOL bSuccess;
  18. ChannelThreadData = (PCHANNEL_THREAD_DATA)Data;
  19. //
  20. // Perform thread work
  21. //
  22. bContinue = TRUE;
  23. while (bContinue) {
  24. //
  25. // See if we need to exit the thread
  26. //
  27. Status = WaitForSingleObject(
  28. ChannelThreadData->ExitEvent,
  29. THREAD_WAIT_TIMEOUT
  30. );
  31. if (Status != WAIT_TIMEOUT) {
  32. bContinue = FALSE;
  33. continue;
  34. }
  35. //
  36. // Configure the new channel
  37. //
  38. RtlZeroMemory(&Attributes, sizeof(SAC_CHANNEL_OPEN_ATTRIBUTES));
  39. //
  40. // generate a random name and description
  41. //
  42. // Note: we make the maxlength > than the allowed to test the driver, etc.
  43. //
  44. Name = GenerateRandomStringW(SAC_MAX_CHANNEL_NAME_LENGTH*2);
  45. Description = GenerateRandomStringW(SAC_MAX_CHANNEL_DESCRIPTION_LENGTH*2);
  46. Attributes.Type = ChannelTypeRaw;
  47. Attributes.Name = Name;
  48. Attributes.Description = Description;
  49. Attributes.Flags = 0;
  50. Attributes.CloseEvent = NULL;
  51. Attributes.HasNewDataEvent = NULL;
  52. Attributes.ApplicationType = NULL;
  53. //
  54. // Open the channel
  55. //
  56. bSuccess = SacChannelOpen(
  57. &SacChannelHandle,
  58. &Attributes
  59. );
  60. //
  61. // We are done with the random strings
  62. //
  63. free(Name);
  64. free(Description);
  65. if (bSuccess) {
  66. printf("%S: Successfully opened new channel\n", Attributes.Name);
  67. } else {
  68. printf("%S: Failed to open new channel\n", Attributes.Name);
  69. continue;
  70. }
  71. //
  72. // Close the channel
  73. //
  74. if (SacChannelClose(&SacChannelHandle)) {
  75. printf("%S: Successfully closed channel\n", Attributes.Name);
  76. } else {
  77. bContinue = FALSE;
  78. printf("%S: Failed to close channel\n", Attributes.Name);
  79. }
  80. }
  81. return 0;
  82. }
  83. DWORD (*ChannelTests[THREADCOUNT])(PVOID) = {
  84. ChannelThreadOpenClose,
  85. ChannelThreadOpenClose,
  86. ChannelThreadOpenClose,
  87. ChannelThreadOpenClose,
  88. ChannelThreadOpenClose,
  89. ChannelThreadOpenClose,
  90. ChannelThreadOpenClose,
  91. ChannelThreadOpenClose,
  92. ChannelThreadOpenClose,
  93. ChannelThreadOpenClose,
  94. ChannelThreadOpenClose,
  95. ChannelThreadOpenClose,
  96. ChannelThreadOpenClose,
  97. ChannelThreadOpenClose,
  98. ChannelThreadOpenClose,
  99. ChannelThreadOpenClose,
  100. };
  101. int _cdecl
  102. wmain(
  103. int argc,
  104. WCHAR **argv
  105. )
  106. {
  107. return RunStress(
  108. ChannelTests,
  109. THREADCOUNT
  110. );
  111. }