test: crecv.c Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# crecv.c

Go to the documentation of this file.

    00001 /****************************** Module Header ******************************\
    00002 * Module Name: crecv.c
    00003 *
    00004 * Copyright (c) 1985 - 1999, Microsoft Corporation
    00005 *
    00006 * Client side receiving stubs
    00007 *
    00008 * 07-06-91 ScottLu Created.
    00009 \***************************************************************************/
    00010
    00011 #include "precomp.h"
    00012 #pragma hdrstop
    00013
    00014 #include <dbt.h>
    00015
    00016 #define CALLBACKPROC 1
    00017 #define CLIENTSIDE 1
    00018
    00019 #include "callback.h"
    00020
    00021 /*
    00022  * Receive setup and control macros
    00023  */
    00024 #define RECVSIDE 1
    00025
    00026 #define RECVCALL(lower, upper) \
    00027     DWORD __ ## lower (upper *pmsg)
    00028
    00029 #define BEGINRECV(err, p, cb) \
    00030     CALLBACKSTATUS CallbackStatus;      \
    00031     NTSTATUS Status = STATUS_SUCCESS;   \
    00032     ULONG_PTR retval = (ULONG_PTR)err;    \
    00033     CallbackStatus.cbOutput = cb;       \
    00034     CallbackStatus.pOutput = p;
    00035
    00036 #define FIXUPPOINTERS() \
    00037     if (pmsg->CaptureBuf.cCapturedPointers &&           \
    00038             pmsg->CaptureBuf.pvVirtualAddress == NULL)  \
    00039         FixupCallbackPointers(&pmsg->CaptureBuf);
    00040
    00041 #if defined(_X86_) && !defined(BUILD_WOW6432)
    00042
    00043 NTSTATUS
    00044 FASTCALL
    00045 XyCallbackReturn(
    00046     IN PVOID Buffer,
    00047     IN ULONG Length,
    00048     IN NTSTATUS Status
    00049     );
    00050
    00051 #define ENDRECV() \
    00052     goto errorexit;                                                     \
    00053 errorexit:                                                              \
    00054     CallbackStatus.retval = retval;                                     \
    00055     return XyCallbackReturn(&CallbackStatus, sizeof(CallbackStatus),    \
    00056             Status)
    00057
    00058 #else
    00059
    00060 #define ENDRECV() \
    00061     goto errorexit;                                                     \
    00062 errorexit:                                                              \
    00063     CallbackStatus.retval = retval;                                     \
    00064     return NtCallbackReturn(&CallbackStatus, sizeof(CallbackStatus),    \
    00065             Status)
    00066
    00067 #endif
    00068
    00069 #define MSGERROR() \
    00070     goto errorexit
    00071
    00072 #define MSGERRORCODE(code) { \
    00073     RIPERR0(code, RIP_WARNING, "Unspecified error"); \
    00074     goto errorexit; }
    00075
    00076 #define MSGNTERRORCODE(code) { \
    00077     RIPNTERR0(code, RIP_WARNING, "Unspecified error"); \
    00078     goto errorexit; }
    00079
    00080 /*
    00081  * Callback parameter fixup macros
    00082  */
    00083 //#undef CALLPROC
    00084 //#define CALLPROC(p) FNID(p)
    00085
    00086 #define CALLDATA(x) (pmsg->x)
    00087 #define PCALLDATA(x) (&(pmsg->x))
    00088 #define PCALLDATAOPT(x) (pmsg->p ## x ? (PVOID)&(pmsg->x) : NULL)
    00089 #define FIRSTFIXUP(x) (pmsg->x)
    00090 #define FIXUPOPT(x) (pmsg->x)
    00091 #define FIRSTFIXUPOPT(x) FIXUPOPT(x)
    00092 #define FIXUP(x) (pmsg->x)
    00093 #define FIXUPID(x) (pmsg->x)
    00094 #define FIXUPIDOPT(x) (pmsg->x)
    00095 #define FIXUPSTRING(x) (pmsg->x.Buffer)
    00096 #define FIXUPSTRINGID(x) (pmsg->x.Buffer)
    00097 #define FIXUPSTRINGIDOPT(x) (pmsg->x.Buffer)
    00098
    00099 /***************************************************************************\
    00100 * FixupCallbackPointers
    00101 *
    00102 * Fixes up captured callback pointers.
    00103 *
    00104 * 03-13-95 JimA             Created.
    00105 \***************************************************************************/
    00106
    00107 VOID FixupCallbackPointers(
    00108     PCAPTUREBUF pcb)
    00109 {
    00110     DWORD i;
    00111     LPDWORD lpdwOffset;
    00112     PVOID *ppFixup;
    00113
    00114     lpdwOffset = (LPDWORD)((PBYTE)pcb + pcb->offPointers);
    00115     for (i = 0; i < pcb->cCapturedPointers; ++i, ++lpdwOffset) {
    00116         ppFixup = (PVOID *)((PBYTE)pcb + *lpdwOffset);
    00117         *ppFixup = (PBYTE)pcb + (LONG_PTR)*ppFixup;
    00118     }
    00119 }
    00120
    00121 /**************************************************************************\
    00122 *
    00123 * include the stub definition file
    00124 *
    00125 \**************************************************************************/
    00126
    00127 #include "ntcb.h"