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.

127 lines
3.5 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: crecv.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Client side receiving stubs
  7. *
  8. * 07-06-91 ScottLu Created.
  9. \***************************************************************************/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. #include <dbt.h>
  13. #define CALLBACKPROC 1
  14. #define CLIENTSIDE 1
  15. #include "callback.h"
  16. /*
  17. * Receive setup and control macros
  18. */
  19. #define RECVSIDE 1
  20. #define RECVCALL(lower, upper) \
  21. DWORD __ ## lower (upper *pmsg)
  22. #define BEGINRECV(err, p, cb) \
  23. CALLBACKSTATUS CallbackStatus; \
  24. NTSTATUS Status = STATUS_SUCCESS; \
  25. ULONG_PTR retval = (ULONG_PTR)err; \
  26. CallbackStatus.cbOutput = cb; \
  27. CallbackStatus.pOutput = p;
  28. #define FIXUPPOINTERS() \
  29. if (pmsg->CaptureBuf.cCapturedPointers && \
  30. pmsg->CaptureBuf.pvVirtualAddress == NULL) \
  31. FixupCallbackPointers(&pmsg->CaptureBuf);
  32. #if defined(_X86_) && !defined(BUILD_WOW6432)
  33. NTSTATUS
  34. FASTCALL
  35. XyCallbackReturn(
  36. IN PVOID Buffer,
  37. IN ULONG Length,
  38. IN NTSTATUS Status
  39. );
  40. #define ENDRECV() \
  41. goto errorexit; \
  42. errorexit: \
  43. CallbackStatus.retval = retval; \
  44. return XyCallbackReturn(&CallbackStatus, sizeof(CallbackStatus), \
  45. Status)
  46. #else
  47. #define ENDRECV() \
  48. goto errorexit; \
  49. errorexit: \
  50. CallbackStatus.retval = retval; \
  51. return NtCallbackReturn(&CallbackStatus, sizeof(CallbackStatus), \
  52. Status)
  53. #endif
  54. #define MSGERROR() \
  55. goto errorexit
  56. #define MSGERRORCODE(code) { \
  57. RIPERR0(code, RIP_WARNING, "Unspecified error"); \
  58. goto errorexit; }
  59. #define MSGNTERRORCODE(code) { \
  60. RIPNTERR0(code, RIP_WARNING, "Unspecified error"); \
  61. goto errorexit; }
  62. /*
  63. * Callback parameter fixup macros
  64. */
  65. //#undef CALLPROC
  66. //#define CALLPROC(p) FNID(p)
  67. #define CALLDATA(x) (pmsg->x)
  68. #define PCALLDATA(x) (&(pmsg->x))
  69. #define PCALLDATAOPT(x) (pmsg->p ## x ? (PVOID)&(pmsg->x) : NULL)
  70. #define FIRSTFIXUP(x) (pmsg->x)
  71. #define FIXUPOPT(x) (pmsg->x)
  72. #define FIRSTFIXUPOPT(x) FIXUPOPT(x)
  73. #define FIXUP(x) (pmsg->x)
  74. #define FIXUPID(x) (pmsg->x)
  75. #define FIXUPIDOPT(x) (pmsg->x)
  76. #define FIXUPSTRING(x) (pmsg->x.Buffer)
  77. #define FIXUPSTRINGID(x) (pmsg->x.Buffer)
  78. #define FIXUPSTRINGIDOPT(x) (pmsg->x.Buffer)
  79. /***************************************************************************\
  80. * FixupCallbackPointers
  81. *
  82. * Fixes up captured callback pointers.
  83. *
  84. * 03-13-95 JimA Created.
  85. \***************************************************************************/
  86. VOID FixupCallbackPointers(
  87. PCAPTUREBUF pcb)
  88. {
  89. DWORD i;
  90. LPDWORD lpdwOffset;
  91. PVOID *ppFixup;
  92. lpdwOffset = (LPDWORD)((PBYTE)pcb + pcb->offPointers);
  93. for (i = 0; i < pcb->cCapturedPointers; ++i, ++lpdwOffset) {
  94. ppFixup = (PVOID *)((PBYTE)pcb + *lpdwOffset);
  95. *ppFixup = (PBYTE)pcb + (LONG_PTR)*ppFixup;
  96. }
  97. }
  98. /**************************************************************************\
  99. *
  100. * include the stub definition file
  101. *
  102. \**************************************************************************/
  103. #include "ntcb.h"