Windows NT 4.0 source code leak
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.

174 lines
4.3 KiB

4 years ago
  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. rpcssm.hxx
  5. Abstract:
  6. Private definitions for the rpcssm memory package
  7. Author:
  8. Ryszard K. Kott (ryszardk) created June 29, 1994.
  9. Revision History:
  10. -------------------------------------------------------------------*/
  11. #ifndef __RPCSSM_HXX__
  12. #define __RPCSSM_HXX__
  13. #define ALIGN_TO_8(x) (size_t)(((x)+7) & 0xfffffff8)
  14. #if defined( WIN ) || defined( DOS ) || defined( MAC )
  15. #define SIMPLE_BLOCK_LIST
  16. #endif
  17. #if defined( SIMPLE_BLOCK_LIST )
  18. #define InitializeCriticalSection(x)
  19. #define LeaveCriticalSection(x)
  20. #define EnterCriticalSection(x)
  21. #define DeleteCriticalSection(x)
  22. typedef struct _WIN16_ALLOCATION_BLOCK
  23. {
  24. struct _WIN16_ALLOCATION_BLOCK __RPC_FAR * NextBlock;
  25. struct _WIN16_ALLOCATION_BLOCK __RPC_FAR * PreviousBlock;
  26. } ALLOCATION_BLOCK, __RPC_FAR * PALLOCATION_BLOCK;
  27. #define ALLOCATION_BLOCK_SIZE_TO_8 ALIGN_TO_8(sizeof(ALLOCATION_BLOCK))
  28. #else // Page array allocation
  29. #define DESCR_ARRAY_SIZE 1024
  30. #define DESCR_ARRAY_INCR 1024
  31. #define ENABLE_STACK_SIZE 16
  32. #define ENABLE_STACK_INCR 16
  33. #endif
  34. // Enable stack keeps longs.
  35. // Descr block stack keeps descr blocks.
  36. typedef struct _ALLOC_BLOCK_DESCR
  37. {
  38. char __RPC_FAR * AllocationBlock;
  39. char __RPC_FAR * FirstFree;
  40. unsigned long SizeLeft;
  41. #if defined( DEBUGRPC )
  42. unsigned long Counter;
  43. #endif
  44. } ALLOC_BLOCK_DESCR, __RPC_FAR * PALLOC_BLOCK_DESCR;
  45. #if !defined( SIMPLE_BLOCK_LIST )
  46. // Initial boundle of Win32 stacks: we save an allocation at the expense
  47. // of keeping initial block around.
  48. // Of course we hope that initial block is good enough for most apps.
  49. typedef struct _INIT_STACKS_BLOCK
  50. {
  51. unsigned long EnableStack[ ENABLE_STACK_SIZE ];
  52. ALLOC_BLOCK_DESCR DescrStack[ DESCR_ARRAY_SIZE ];
  53. } INIT_STACKS_BLOCK;
  54. #endif
  55. typedef struct _ALLOCATION_CONTEXT
  56. {
  57. RPC_CLIENT_ALLOC __RPC_FAR * ClientAlloc;
  58. RPC_CLIENT_FREE __RPC_FAR * ClientFree;
  59. unsigned int EnableCount;
  60. #if defined( SIMPLE_BLOCK_LIST )
  61. PALLOCATION_BLOCK FirstBlock;
  62. #else // 32 bit now
  63. CRITICAL_SECTION CriticalSection;
  64. unsigned long ThreadCount;
  65. INIT_STACKS_BLOCK * pInitialStacks;
  66. unsigned long * pEnableStack;
  67. unsigned long StackMax;
  68. unsigned long StackTop;
  69. PALLOC_BLOCK_DESCR pBlockDescr;
  70. unsigned long DescrSize;
  71. unsigned long FFIndex;
  72. DWORD PageSize;
  73. DWORD Granularity;
  74. #endif
  75. } ALLOCATION_CONTEXT, __RPC_FAR * PALLOCATION_CONTEXT;
  76. #ifdef NEWNDR_INTERNAL
  77. #undef RequestGlobalMutex
  78. #undef ClearGlobalMutex
  79. #define RequestGlobalMutex()
  80. #define ClearGlobalMutex()
  81. #endif // NEWNDR_INTERNAL
  82. PALLOCATION_CONTEXT GetAllocContext ();
  83. void SetAllocContext ( IN PALLOCATION_CONTEXT AllocContext );
  84. #if defined(__RPC_WIN16__)
  85. //
  86. // For 16 bit Windows, we need to keep a dictionary of memory contexts
  87. // on per task basis.
  88. //
  89. #include <sdict2.hxx>
  90. #define TASK_ID_TYPE unsigned long
  91. class PALLOCATION_CONTEXT_DICT : public SIMPLE_DICT2
  92. {
  93. public:
  94. PALLOCATION_CONTEXT_DICT () {}
  95. ~PALLOCATION_CONTEXT_DICT () {}
  96. PALLOCATION_CONTEXT Find (TASK_ID_TYPE Key )
  97. {
  98. return (PALLOCATION_CONTEXT)
  99. SIMPLE_DICT2::Find( (void *)Key );
  100. }
  101. PALLOCATION_CONTEXT Delete(TASK_ID_TYPE Key)
  102. {
  103. return (PALLOCATION_CONTEXT)
  104. SIMPLE_DICT2::Delete( (void *)Key );
  105. }
  106. \
  107. int Insert( TASK_ID_TYPE Key, PALLOCATION_CONTEXT Item )
  108. {
  109. return( SIMPLE_DICT2::Insert((void *)Key, (void *)Item));
  110. }
  111. };
  112. #endif // win16 but not dos
  113. #endif // __RPCSSM_HXX__