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.

183 lines
4.9 KiB

  1. //************************************************************************
  2. // compress.h
  3. //
  4. // Header for MPPC compression for RDP.
  5. //
  6. // Copyright (C) 1994-2000 Microsoft Corporation
  7. //************************************************************************
  8. #ifndef __COMPRESS_H
  9. #define __COMPRESS_H
  10. #ifndef BASETYPES
  11. #define BASETYPES
  12. typedef unsigned long ULONG;
  13. typedef ULONG *PULONG;
  14. typedef unsigned short USHORT;
  15. typedef USHORT *PUSHORT;
  16. typedef unsigned char UCHAR;
  17. typedef UCHAR *PUCHAR;
  18. typedef char *PSZ;
  19. #endif /* !BASETYPES */
  20. // History buffer sizes for various compression levels.
  21. #define HISTORY_SIZE_8K (8192L)
  22. #define HISTORY_SIZE_64K (65536L)
  23. #ifndef OS_WINCE
  24. // Enabling the compression instrumentation only for debug bits.
  25. #ifdef DC_DEBUG
  26. #define COMPR_DEBUG 1
  27. #endif
  28. #endif
  29. // Server-only items. The Win16 client compile will complain otherwise.
  30. //#if defined(DLL_WD) || defined(DLL_DISP)
  31. // Hash table number of entries used on the compress side.
  32. #define HASH_TABLE_SIZE 32768
  33. typedef struct SendContext {
  34. UCHAR History [HISTORY_SIZE_64K];
  35. int CurrentIndex; // how far into the history buffer we are
  36. PUCHAR ValidHistory; // how much of history is valid
  37. unsigned ClientComprType; // The compression types supported by decompress.
  38. ULONG HistorySize; // History size used based on ComprType.
  39. USHORT HashTable[HASH_TABLE_SIZE]; // 16 bits=max 64K for HistorySize.
  40. } SendContext;
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif // __cplusplus
  44. void initsendcontext(SendContext *, unsigned);
  45. UCHAR compress(UCHAR *, UCHAR *, ULONG *, SendContext *);
  46. #ifdef __cplusplus
  47. }
  48. #endif // __cplusplus
  49. //#else //(DLL_WD) || (DLL_DISP)
  50. // We split the receive context into two pieces to deal with the Win16
  51. // client's inability to malloc over 64K without using a nasty HUGE pointer.
  52. typedef struct RecvContext1 {
  53. UCHAR FAR *CurrentPtr; // how far into the history buffer we are
  54. } RecvContext1;
  55. //
  56. // 64K decompression context
  57. //
  58. typedef struct RecvContext2_64K {
  59. // We use one less byte to allow this struct to be allocated with
  60. // LocalAlloc() on the Win16 client.
  61. ULONG cbSize;
  62. ULONG cbHistorySize;
  63. UCHAR History[HISTORY_SIZE_64K - 1];
  64. // Won't work if on Win16.
  65. // Debug Fence code only works for 64K contexts
  66. #ifdef COMPR_DEBUG
  67. #define DEBUG_FENCE_16K_VALUE 0xABABABAB
  68. ULONG Debug16kFence;
  69. #endif
  70. } RecvContext2_64K;
  71. //
  72. // 8K decompression context
  73. //
  74. typedef struct RecvContext2_8K {
  75. // We use one less byte to allow this struct to be allocated with
  76. // LocalAlloc() on the Win16 client.
  77. ULONG cbSize;
  78. ULONG cbHistorySize;
  79. UCHAR History[HISTORY_SIZE_8K - 1];
  80. #ifdef COMPR_DEBUG
  81. #define DEBUG_FENCE_8K_VALUE 0xABCABCAB
  82. ULONG Debug8kFence;
  83. #endif
  84. } RecvContext2_8K;
  85. //
  86. // Generic decompression context.
  87. // This is the 'type' we use when passing around
  88. // compression contexts as parameters
  89. // size field tells us which one we're using
  90. //
  91. //
  92. // IMPORTANT: Field ordering must match exactly
  93. // Between the Generic type and any
  94. // size specific contexts.
  95. typedef struct RecvContext2_Generic {
  96. ULONG cbSize;
  97. ULONG cbHistorySize;
  98. UCHAR History[1];
  99. } RecvContext2_Generic;
  100. #ifdef __cplusplus
  101. extern "C" {
  102. #endif // __cplusplus
  103. int initrecvcontext(RecvContext1 *, RecvContext2_Generic *, unsigned ComprType);
  104. int decompress(
  105. UCHAR FAR *inbuf,
  106. int inlen,
  107. int start,
  108. UCHAR FAR * FAR *output,
  109. int *outlen,
  110. RecvContext1 *context1,
  111. RecvContext2_Generic *context2,
  112. unsigned ComprType);
  113. #ifdef __cplusplus
  114. }
  115. #endif // __cplusplus
  116. //#endif // DLL_WD | DLL_DISP
  117. //
  118. // Other defines
  119. //
  120. // There are 8 bits of packet data in the generalCompressedType field of the
  121. // SHAREDATAHEADER. Note that PACKET_ENCRYPTED is unused (therefore
  122. // reusable in the future).
  123. #define PACKET_FLUSHED 0x80
  124. #define PACKET_AT_FRONT 0x40
  125. #define PACKET_COMPRESSED 0x20
  126. #define PACKET_ENCRYPTED 0x10
  127. // Defines which of 16 potential compression types we are using.
  128. // 8K corresponds to the TSE4 client and server. 64K is the newer re-optimized
  129. // version used in TSE5. Note that the type values are re-used in the
  130. // GCC conference client capability set. Any client advertising support for
  131. // type N must support types 0..(N-1) since it could be talking to an older
  132. // server and receive any older type.
  133. #define PACKET_COMPR_TYPE_MASK 0x0F
  134. #define PACKET_COMPR_TYPE_8K 0
  135. #define PACKET_COMPR_TYPE_64K 1
  136. #define PACKET_COMPR_TYPE_MAX 1
  137. // VC compression options take up bytes 5 of the VC header flags field
  138. #define VC_FLAG_COMPRESS_MASK 0xFF
  139. #define VC_FLAG_COMPRESS_SHIFT 16
  140. #define VC_FLAG_PRIVATE_PROTOCOL_MASK 0xFFFF0000
  141. #endif // __COMPRESS_H