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.

89 lines
1.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 2000
  3. Module Name:
  4. Context.hxx
  5. Abstract:
  6. Defines common stuff for context handles.
  7. Author:
  8. Kamen Moutafov [KamenM]
  9. Revision History:
  10. --*/
  11. #if _MSC_VER > 1000
  12. #pragma once
  13. #endif // _MSC_VER > 1000
  14. #ifndef _CONTEXT_H
  15. #define _CONTEXT_H
  16. // uncomment this for unit tests
  17. //#define SCONTEXT_UNIT_TESTS
  18. inline long GetRandomLong (void)
  19. {
  20. long RndNum;
  21. // this is for unit tests only - ignore return value
  22. (void) GenerateRandomNumber((unsigned char *)&RndNum, sizeof(long));
  23. return RndNum;
  24. }
  25. class WIRE_CONTEXT;
  26. extern WIRE_CONTEXT NullContext;
  27. class WIRE_CONTEXT
  28. {
  29. public:
  30. inline BOOL
  31. IsNullContext (
  32. void
  33. )
  34. {
  35. return (RpcpMemoryCompare(this, &NullContext, sizeof(WIRE_CONTEXT)) == 0);
  36. }
  37. inline ULONGLONG
  38. GetDebugULongLong1 (
  39. void
  40. )
  41. {
  42. return *((ULONGLONG UNALIGNED *)&ContextUuid);
  43. }
  44. inline ULONGLONG
  45. GetDebugULongLong2 (
  46. void
  47. )
  48. {
  49. return *(((ULONGLONG UNALIGNED *)&ContextUuid) + 1);
  50. }
  51. inline void
  52. SetToNull (
  53. void
  54. )
  55. {
  56. RpcpMemorySet(this, 0, sizeof(WIRE_CONTEXT));
  57. }
  58. inline void
  59. CopyToBuffer (
  60. OUT PVOID Buffer
  61. )
  62. {
  63. RpcpMemoryCopy(Buffer, this, sizeof(WIRE_CONTEXT));
  64. }
  65. unsigned long ContextType;
  66. UUID ContextUuid;
  67. };
  68. #endif