Source code of Windows XP (NT5)
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.

134 lines
3.8 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. attack.c
  5. Abstract :
  6. This file contains code for the ndr correlation checks related to attacks
  7. on the marshaling buffer.
  8. Author :
  9. Ryszard K. Kott (ryszardk) Sep 1997
  10. Revision History :
  11. ---------------------------------------------------------------------*/
  12. #include "ndrp.h"
  13. #include "hndl.h"
  14. #include "ndrole.h"
  15. #if !defined(__ATTACK_H__)
  16. #define __ATTACK_H__
  17. #define NO_CORRELATION
  18. #define CORRELATION_RESOURCE_SAVE \
  19. uchar * pCorrMemorySave;
  20. #define F_CORRELATION_CHECK (pStubMsg->pCorrInfo != 0)
  21. #define SAVE_CORRELATION_MEMORY() \
  22. pCorrMemorySave = pStubMsg->pCorrMemory;
  23. #define SET_CORRELATION_MEMORY( pMem ) \
  24. pCorrMemorySave = pStubMsg->pCorrMemory; \
  25. pStubMsg->pCorrMemory = pMem;
  26. #define RESET_CORRELATION_MEMORY() \
  27. pStubMsg->pCorrMemory = pCorrMemorySave;
  28. #define NDR_CORR_EXTENSION_SIZE 2
  29. #define CORRELATION_DESC_INCREMENT( pFormat ) \
  30. if ( pStubMsg->fHasNewCorrDesc ) \
  31. pFormat += NDR_CORR_EXTENSION_SIZE;
  32. #define FC_CORR_NORMAL_CONFORMANCE (FC_NORMAL_CONFORMANCE >> 4 /* 0 */)
  33. #define FC_CORR_POINTER_CONFORMANCE (FC_TOP_LEVEL_CONFORMANCE >> 4 /* 1 */)
  34. #define FC_CORR_TOP_LEVEL_CONFORMANCE (FC_TOP_LEVEL_CONFORMANCE >> 4 /* 2 */)
  35. #define FC_CORR_CONSTANT_CONFORMANCE (FC_TOP_LEVEL_CONFORMANCE >> 4 /* 4 */)
  36. #define FC_CORR_TOP_LEVEL_MULTID_CONFORMANCE (FC_TOP_LEVEL_MULTID_CONFORMANCE >> 4 /* 8 */)
  37. #define NDR_CHECK_CONFORMANCE 0
  38. #define NDR_CHECK_VARIANCE 1
  39. #define NDR_CHECK_OFFSET 2
  40. #define NDR_RESET_VALUE 8 // This can be or'd with one of the above
  41. typedef struct _NDR_FCDEF_CORRELATION
  42. {
  43. unsigned short Type : 4;
  44. unsigned short Kind : 4;
  45. unsigned short Operation : 8;
  46. short Offset;
  47. NDR_CORRELATION_FLAGS CorrFlags;
  48. unsigned short Reserved : 8;
  49. } NDR_FCDEF_CORRELATION, *PNDR_FCDEF_CORRELATION;
  50. typedef struct _NDR_CORRELATION_INFO_HEADER
  51. {
  52. struct _NDR_CORRELATION_INFO * pCache;
  53. struct _NDR_CORRELATION_INFO * pInfo;
  54. long DataSize;
  55. long DataLen;
  56. } NDR_CORRELATION_INFO_HEADER;
  57. typedef struct _NDR_CORRELATION_INFO_DATA
  58. {
  59. unsigned char * pMemoryObject;
  60. PFORMAT_STRING pCorrDesc;
  61. LONG_PTR Value;
  62. long CheckKind;
  63. #if defined(__RPC_WIN64__)
  64. long Reserve64;
  65. #endif
  66. } NDR_CORRELATION_INFO_DATA;
  67. typedef struct _NDR_CORRELATION_INFO
  68. {
  69. NDR_CORRELATION_INFO_HEADER Header;
  70. NDR_CORRELATION_INFO_DATA Data[1];
  71. } NDR_CORRELATION_INFO, *PNDR_CORRELATION_INFO;
  72. typedef struct _NDR_DEF_FC_RANGE
  73. {
  74. unsigned char FcToken;
  75. unsigned char Type : 4;
  76. unsigned char ConfFlags : 4;
  77. unsigned long Low;
  78. unsigned long High;
  79. } NDR_DEF_FC_RANGE, *PNDR_DEF_FC_RANGE;
  80. void
  81. NdrpCheckCorrelation(
  82. PMIDL_STUB_MESSAGE pStubMsg,
  83. LONG_PTR Value,
  84. PFORMAT_STRING pFormat,
  85. int CheckKind );
  86. void
  87. NdrpAddCorrelationData(
  88. PMIDL_STUB_MESSAGE pStubMsg,
  89. uchar * pMemory,
  90. PFORMAT_STRING pFormat,
  91. LONG_PTR Value,
  92. int CheckKind );
  93. void
  94. NdrpValidateCorrelatedValue (
  95. PMIDL_STUB_MESSAGE pStubMsg,
  96. uchar * pMemory,
  97. PFORMAT_STRING pFormat,
  98. LONG_PTR Value,
  99. int CheckKind );
  100. #endif // __ATTACK_H__