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

ssend.c File Reference

#include "precomp.h"
#include "callback.h"
#include "ntcb.h"

Go to the source code of this file.

Defines

#define CALLBACKPROC   1
#define SERVERSIDE   1
#define SENDSIDE   1
#define CBBUFSIZE   512
#define PADSIZE   (sizeof(ULONG_PTR) - 1)
#define SMESSAGECALL(api)
#define SETUP(api)
#define SETUPDC(api)
#define SETUPPWND(api)
#define CALC_SIZE_IN(cb, pstr)
#define CALC_SIZE_OUT(cb, pstr)
#define BEGINSEND(api)
#define BEGINSENDCAPTURE(api, cCapturePointers, cCaptureBytes, fInput)
#define BEGINSENDCAPTUREVOIDDC(api, cCapturePointers, cCaptureBytes, fInput)
#define BEGINSENDCAPTUREDC(api, cCapturePointers, cCaptureBytes, fInput)
#define LOCKPWND()
#define UNLOCKPWND()
#define MAKECALL(api)
#define MAKECALLCAPTURE(api)
#define MAKECALLCAPTUREDC(api)
#define CHECKRETURN()
#define ENDSEND(type, error)
#define CLEANUPSENDCAPTURECOMMONDC()
#define BEGIN_ENDSENDCAPTURE(type, error)   exit:
#define _ENDSENDCAPTURE(type, error)
#define END_ENDSENDCAPTURE(type, error)   return (type)error
#define ENDSENDCAPTUREDC(type, error)
#define ENDSENDCAPTURE(type, error)
#define BEGIN_ENDSENDCAPTUREVOID()   errorexit:
#define _ENDSENDCAPTUREVOID()
#define END_ENDSENDCAPTUREVOID()   return
#define ENDSENDCAPTUREVOIDDC()
#define ENDSENDCAPTUREVOID()
#define ENDSENDVOID()
#define MSGERROR()   goto errorexit
#define MSGDATA()   (mp)
#define COPYSTRUCTOPT(x)
#define COPYCONSTRECTSTRUCTOPT(x)
#define COPYBYTES(p, cb)
#define COPYBYTESOPT(p, cb)
#define LARGECOPYBYTES(p, cb)
#define LARGECOPYBYTES2(src, cb, dest)
#define COPYSTRING(s)
#define COPYSTRINGOPT(s)
#define COPYSTRINGID(s)
#define LARGECOPYSTRINGLPWSTR(ps, psz)
#define LARGECOPYSTRINGLPSTR(ps, psz)
#define LARGECOPYSTRINGLPWSTRA(ps, psz)
#define LARGECOPYSTRINGLPSTRW(ps, psz)
#define LARGECOPYSTRINGLPWSTROPT(ps, psz)
#define LARGECOPYSTRINGLPSTROPT(ps, psz)
#define LARGECOPYSTRINGLPWSTROPTA(ps, psz)
#define BEGINCOPYOUT()
#define ENDCOPYOUT()   }
#define OUTSTRUCT(pstruct, type)
#define OUTBITMASK(pstruct, type, mask)
#define COPYOUTLPWSTRLIMIT(pstr, cch)
#define RESERVEBYTES(cb, dest, cbdest)

Functions

PVOID AllocCallbackMessage (DWORD cbBaseMsg, DWORD cPointers, SIZE_T cbCapture, PBYTE pStackBuffer, BOOL fInput)
NTSTATUS CaptureCallbackData (PCAPTUREBUF pcb, PVOID pData, DWORD cbData, PVOID *ppDest)
NTSTATUS AllocateCallbackData (PCAPTUREBUF pcb, DWORD cbData, PVOID *ppDest)
NTSTATUS CaptureAnsiCallbackData (PCAPTUREBUF pcb, PVOID pData, DWORD cbData, PVOID *ppDest)
NTSTATUS CaptureUnicodeCallbackData (PCAPTUREBUF pcb, PVOID pData, DWORD cbData, PVOID *ppDest)
VOID CopyOutputString (PCALLBACKSTATUS pcbs, PLARGE_STRING pstr, UINT cchLimit, BOOL fAnsi)


Define Documentation

#define _ENDSENDCAPTURE type,
error   ) 
 

Value:

if (mp != &m && (PVOID)mp != (PVOID)Buffer) { \ if (mp->CaptureBuf.pvVirtualAddress) { \ NTSTATUS Status; \ SIZE_T ulRegionSize = 0; \ \ Status = ZwFreeVirtualMemory(NtCurrentProcess(),\ &mp->CaptureBuf.pvVirtualAddress, \ &ulRegionSize, \ MEM_RELEASE); \ UserAssert(NT_SUCCESS(Status)); \ } \ ThreadUnlockAndFreePool(ptiCurrent, &tlPool); \ } \ return (type)retval; \ goto errorexit; \ } \ errorexit: \ retval = error; \ goto exit; \ errorexitnofreemp:

Definition at line 218 of file ssend.c.

 
#define _ENDSENDCAPTUREVOID  ) 
 

Value:

if (mp != &m && (PVOID)mp != (PVOID)Buffer) { \ if (mp->CaptureBuf.pvVirtualAddress) { \ NTSTATUS Status; \ SIZE_T ulRegionSize = 0; \ \ Status = ZwFreeVirtualMemory(NtCurrentProcess(),\ &mp->CaptureBuf.pvVirtualAddress, \ &ulRegionSize, \ MEM_RELEASE); \ UserAssert(NT_SUCCESS(Status)); \ } \ ThreadUnlockAndFreePool(ptiCurrent, &tlPool); \ } \ return; \ } \ errorexitnofreemp:

Definition at line 288 of file ssend.c.

#define BEGIN_ENDSENDCAPTURE type,
error   )     exit:
 

Definition at line 216 of file ssend.c.

 
#define BEGIN_ENDSENDCAPTUREVOID  )     errorexit:
 

Definition at line 286 of file ssend.c.

 
#define BEGINCOPYOUT  ) 
 

Value:

if ((psms == NULL || ((psms->flags & (SMF_SENDERDIED | SMF_REPLY)) == 0)) \ && !(dwSCMSFlags & SCMS_FLAGS_INONLY)) {

Definition at line 484 of file ssend.c.

#define BEGINSEND api   ) 
 

Value:

mp = &m; \ Buffer; \ {

Definition at line 98 of file ssend.c.

#define BEGINSENDCAPTURE api,
cCapturePointers,
cCaptureBytes,
fInput   ) 
 

Value:

if (cCapturePointers) { \ mp = AllocCallbackMessage(sizeof(m), \ (cCapturePointers), \ (cCaptureBytes), \ Buffer, \ fInput); \ if (mp == NULL) \ goto errorexitnofreemp; \ } else { \ m.CaptureBuf.cbCallback = sizeof(m); \ m.CaptureBuf.cbCapture = 0; \ m.CaptureBuf.cCapturedPointers = 0; \ mp = &m; \ } \ { \ PTHREADINFO ptiCurrent = PtiCurrent(); \ TL tlPool; \ \ if (mp != &m && (PVOID)mp != (PVOID)Buffer) \ ThreadLockPool(ptiCurrent, mp, &tlPool);

Definition at line 103 of file ssend.c.

#define BEGINSENDCAPTUREDC api,
cCapturePointers,
cCaptureBytes,
fInput   ) 
 

Value:

hdcUse = CreateCompatiblePublicDC(hdc,&hbmDCGray); \ if (hdcUse == (HDC)NULL) { \ return FALSE; \ } \ BEGINSENDCAPTURE(api, cCapturePointers, cCaptureBytes, fInput); \

Definition at line 132 of file ssend.c.

#define BEGINSENDCAPTUREVOIDDC api,
cCapturePointers,
cCaptureBytes,
fInput   ) 
 

Value:

hdcUse = CreateCompatiblePublicDC(hdc,&hbmDCGray); \ if (hdcUse == (HDC)NULL) { \ return; \ } \ BEGINSENDCAPTURE(api, cCapturePointers, cCaptureBytes, fInput); \

Definition at line 125 of file ssend.c.

#define CALC_SIZE_IN cb,
pstr   ) 
 

Value:

cb = (pstr)->Length + sizeof(WCHAR); \ if ((pstr)->bAnsi && !fAnsiReceiver) \ cb *= sizeof(WCHAR);

Definition at line 69 of file ssend.c.

#define CALC_SIZE_OUT cb,
pstr   ) 
 

Value:

cb = (pstr)->MaximumLength + sizeof(WCHAR); \ if ((pstr)->bAnsi && !fAnsiReceiver) \ cb *= sizeof(WCHAR);

Definition at line 74 of file ssend.c.

#define CALLBACKPROC   1
 

Definition at line 14 of file ssend.c.

#define CBBUFSIZE   512
 

Definition at line 21 of file ssend.c.

Referenced by AllocCallbackMessage().

 
#define CHECKRETURN  ) 
 

Value:

if (!NT_SUCCESS(Status) || \ cbCBStatus != sizeof(*pcbs)) { \ goto errorexit; \ } \ try { \ retval = ProbeAndReadStructure(&pcbs->retval, ULONG_PTR); \ } except (W32ExceptionHandler(FALSE, RIP_ERROR)) { \ MSGERROR(); \ }

Definition at line 189 of file ssend.c.

 
#define CLEANUPSENDCAPTURECOMMONDC  ) 
 

Value:

if(iDC) { \ GreRestoreDC(hdc, iDC); \ } \ if (hdcUse != hdc) { \ GreDeleteDC(hdcUse); \ GreDeleteObject(hbmDCGray); \ } \

Definition at line 207 of file ssend.c.

#define COPYBYTES p,
cb   ) 
 

Value:

if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, p, cb, &mp->p))) \ goto errorexit;

Definition at line 364 of file ssend.c.

#define COPYBYTESOPT p,
cb   ) 
 

Value:

if (p) { \ if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, p, cb, &mp->p))) \ goto errorexit; \ } else { \ mp->p = NULL; \ }

Definition at line 368 of file ssend.c.

#define COPYCONSTRECTSTRUCTOPT  ) 
 

Value:

MSGDATA()->p ## x = (LPRECT)(p ## x); \ if (p ## x) MSGDATA()->x = *(p ## x);

Definition at line 360 of file ssend.c.

#define COPYOUTLPWSTRLIMIT pstr,
cch   ) 
 

Value:

try { \ CopyOutputString(pcbs, pstr, cch, fAnsiReceiver); \ } except (W32ExceptionHandler(FALSE, RIP_ERROR)) { \ MSGERROR(); \ }

Definition at line 522 of file ssend.c.

#define COPYSTRING  ) 
 

Value:

mp->s.Length = (p ## s)->Length; \ mp->s.MaximumLength = (p ## s)->MaximumLength; \ if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, \ (p ## s)->Buffer, \ (p ## s)->Length + sizeof(WCHAR), \ &mp->s.Buffer))) \ goto errorexit;

Definition at line 384 of file ssend.c.

#define COPYSTRINGID  ) 
 

Value:

mp->s.Length = (p ## s)->Length; \ mp->s.MaximumLength = (p ## s)->MaximumLength; \ if (mp->s.MaximumLength) { \ if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, \ (p ## s)->Buffer, \ (p ## s)->Length + sizeof(WCHAR), \ &mp->s.Buffer))) \ goto errorexit; \ } else { \ mp->s.Buffer = (p ## s)->Buffer; \ }

Definition at line 407 of file ssend.c.

#define COPYSTRINGOPT  ) 
 

Value:

if (p ## s) { \ mp->s.Length = (p ## s)->Length; \ mp->s.MaximumLength = (p ## s)->MaximumLength; \ if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, \ (p ## s)->Buffer, \ (p ## s)->Length + sizeof(WCHAR), \ &mp->s.Buffer))) \ goto errorexit; \ } else { \ mp->s.Length = 0; \ mp->s.Buffer = NULL; \ }

Definition at line 393 of file ssend.c.

#define COPYSTRUCTOPT  ) 
 

Value:

MSGDATA()->p ## x = (p ## x); \ if (p ## x) MSGDATA()->x = *(p ## x);

Definition at line 356 of file ssend.c.

#define END_ENDSENDCAPTURE type,
error   )     return (type)error
 

Definition at line 239 of file ssend.c.

 
#define END_ENDSENDCAPTUREVOID  )     return
 

Definition at line 305 of file ssend.c.

 
#define ENDCOPYOUT  )     }
 

Definition at line 488 of file ssend.c.

#define ENDSEND type,
error   ) 
 

Value:

return (type)retval; \ goto errorexit; \ } \ errorexit: \ return (type)error

Definition at line 200 of file ssend.c.

#define ENDSENDCAPTURE type,
error   ) 
 

Value:

BEGIN_ENDSENDCAPTURE(type, error); \ _ENDSENDCAPTURE(type, error); \ END_ENDSENDCAPTURE(type, error)

Definition at line 250 of file ssend.c.

#define ENDSENDCAPTUREDC type,
error   ) 
 

Value:

Definition at line 243 of file ssend.c.

 
#define ENDSENDCAPTUREVOID  ) 
 

Value:

BEGIN_ENDSENDCAPTUREVOID(); \ CLEANUPSENDCAPTURECOMMON(); \ _ENDSENDCAPTUREVOID(); \ CLEANUPSENDCAPTURECOMMON(); \ END_ENDSENDCAPTUREVOID()

Definition at line 315 of file ssend.c.

 
#define ENDSENDCAPTUREVOIDDC  ) 
 

Value:

Definition at line 308 of file ssend.c.

 
#define ENDSENDVOID  ) 
 

Value:

} \ return

Definition at line 323 of file ssend.c.

#define LARGECOPYBYTES p,
cb   ) 
 

Value:

if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, p, cb, &mp->p))) \ goto errorexit;

Definition at line 376 of file ssend.c.

#define LARGECOPYBYTES2 src,
cb,
dest   ) 
 

Value:

if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, src, cb, &mp->dest))) \ goto errorexit;

Definition at line 380 of file ssend.c.

#define LARGECOPYSTRINGLPSTR ps,
psz   ) 
 

Value:

if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, \ (ps)->Buffer, \ (ps)->Length + 1, \ (PVOID *)&mp->psz))) \ goto errorexit;

Definition at line 427 of file ssend.c.

#define LARGECOPYSTRINGLPSTROPT ps,
psz   ) 
 

Value:

if (ps) { \ if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, \ (ps)->Buffer, \ (ps)->Length + sizeof(UCHAR), \ (PVOID *)&mp->psz))) \ goto errorexit; \ } else { \ mp->psz = NULL; \ }

Definition at line 459 of file ssend.c.

#define LARGECOPYSTRINGLPSTRW ps,
psz   ) 
 

Value:

if (!NT_SUCCESS(CaptureUnicodeCallbackData(&mp->CaptureBuf, \ (ps)->Buffer, \ ((ps)->Length + 1) * sizeof(WCHAR), \ (PVOID *)&mp->psz))) \ goto errorexit; \

Definition at line 441 of file ssend.c.

#define LARGECOPYSTRINGLPWSTR ps,
psz   ) 
 

Value:

if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, \ (ps)->Buffer, \ (ps)->Length + sizeof(WCHAR), \ (PVOID *)&mp->psz))) \ goto errorexit;

Definition at line 420 of file ssend.c.

#define LARGECOPYSTRINGLPWSTRA ps,
psz   ) 
 

Value:

if (!NT_SUCCESS(CaptureAnsiCallbackData(&mp->CaptureBuf, \ (ps)->Buffer, \ ((ps)->Length / sizeof(WCHAR)) + 1, \ (PVOID *)&mp->psz))) \ goto errorexit;

Definition at line 434 of file ssend.c.

#define LARGECOPYSTRINGLPWSTROPT ps,
psz   ) 
 

Value:

if (ps) { \ if (!NT_SUCCESS(CaptureCallbackData(&mp->CaptureBuf, \ (ps)->Buffer, \ (ps)->Length + sizeof(WCHAR), \ (PVOID *)&mp->psz))) \ goto errorexit; \ } else { \ mp->psz = NULL; \ }

Definition at line 448 of file ssend.c.

#define LARGECOPYSTRINGLPWSTROPTA ps,
psz   ) 
 

Value:

if (ps) { \ if (!NT_SUCCESS(CaptureAnsiCallbackData(&mp->CaptureBuf, \ (ps)->Buffer, \ ((ps)->Length / sizeof(WCHAR)) + 1, \ (PVOID *)&mp->psz))) \ goto errorexit; \ } else { \ mp->psz = NULL; \ }

Definition at line 470 of file ssend.c.

 
#define LOCKPWND  ) 
 

Value:

ThreadLock(pwnd, &tlpwnd); \ cbwin = pci->CallbackWnd; \ pci->CallbackWnd.pwnd = pwndClient; \ pci->CallbackWnd.hwnd = HW(pwnd);

Definition at line 139 of file ssend.c.

#define MAKECALL api   ) 
 

Value:

UserAssert(!(PtiCurrent()->TIF_flags & TIF_INCLEANUP)); \ LeaveCrit(); \ Status = KeUserModeCallback( \ FI_ ## api, \ mp, \ sizeof(*mp), \ &pcbs, \ &cbCBStatus); \ EnterCrit();

Definition at line 149 of file ssend.c.

#define MAKECALLCAPTURE api   ) 
 

Value:

UserAssert(!(PtiCurrent()->TIF_flags & TIF_INCLEANUP)); \ LeaveCrit(); \ Status = (DWORD)KeUserModeCallback( \ FI_ ## api, \ mp, \ mp->CaptureBuf.cbCallback, \ &pcbs, \ &cbCBStatus); \ EnterCrit();

Definition at line 160 of file ssend.c.

#define MAKECALLCAPTUREDC api   ) 
 

Value:

iDC = GreSaveDC(hdc); \ MAKECALLCAPTURE(api) \ GreRestoreDC(hdc, iDC); \ iDC = 0; \ if ((hdcUse != hdc) && NT_SUCCESS(Status)) { \ GreBitBlt(hdc, \ 0, \ 0, \ gpDispInfo->cxGray, \ gpDispInfo->cyGray, \ hdcUse, \ 0, \ 0, \ SRCCOPY, \ 0); \ }

Definition at line 171 of file ssend.c.

 
#define MSGDATA  )     (mp)
 

Definition at line 354 of file ssend.c.

 
#define MSGERROR  )     goto errorexit
 

Definition at line 327 of file ssend.c.

#define OUTBITMASK pstruct,
type,
mask   ) 
 

Value:

try { \ type flags = ProbeAndReadStructure(((type *)pcbs->pOutput), type); \ COPY_FLAG(*(pstruct), flags, mask); \ } except (W32ExceptionHandler(FALSE, RIP_ERROR)) { \ MSGERROR(); \ }

Definition at line 504 of file ssend.c.

#define OUTSTRUCT pstruct,
type   ) 
 

Value:

try { \ *(pstruct) = ProbeAndReadStructure(((type *)pcbs->pOutput), type); \ } except (W32ExceptionHandler(FALSE, RIP_ERROR)) { \ MSGERROR(); \ }

Definition at line 494 of file ssend.c.

#define PADSIZE   (sizeof(ULONG_PTR) - 1)
 

Definition at line 23 of file ssend.c.

Referenced by AllocateCallbackData(), AllocCallbackMessage(), CaptureAnsiCallbackData(), CaptureCallbackData(), and CaptureUnicodeCallbackData().

#define RESERVEBYTES cb,
dest,
cbdest   ) 
 

Value:

if (!NT_SUCCESS(AllocateCallbackData(&mp->CaptureBuf, \ cb, (PVOID *)&mp->dest))) \ goto errorexit; \ mp->cbdest = cb;

Definition at line 530 of file ssend.c.

#define SENDSIDE   1
 

Definition at line 19 of file ssend.c.

#define SERVERSIDE   1
 

Definition at line 15 of file ssend.c.

#define SETUP api   ) 
 

Value:

api ## MSG m; \ api ## MSG *mp = &m; \ BYTE Buffer[CBBUFSIZE]; \ PCALLBACKSTATUS pcbs; \ ULONG cbCBStatus; \ ULONG_PTR retval; \ NTSTATUS Status;

Definition at line 39 of file ssend.c.

#define SETUPDC api   ) 
 

Value:

SETUP(api) \ int iDC = 0; \ HDC hdcUse; \ HBITMAP hbmDCGray = NULL;

Definition at line 48 of file ssend.c.

#define SETUPPWND api   ) 
 

Value:

api ## MSG m; \ api ## MSG *mp = &m; \ BYTE Buffer[CBBUFSIZE]; \ PCALLBACKSTATUS pcbs; \ ULONG cbCBStatus; \ ULONG_PTR retval; \ NTSTATUS Status; \ TL tlpwnd; \ CALLBACKWND cbwin; \ PCLIENTINFO pci = PtiCurrent()->pClientInfo; \ PWND pwndClient = pwnd ? (PWND)((PBYTE)pwnd - pci->ulClientDelta) : NULL; \ UserAssert(pci->ulClientDelta != 0);

Definition at line 55 of file ssend.c.

#define SMESSAGECALL api   ) 
 

Value:

LRESULT Sfn ## api( \ PWND pwnd, \ UINT msg, \ WPARAM wParam, \ LPARAM lParam, \ ULONG_PTR xParam, \ PROC xpfnProc, \ DWORD dwSCMSFlags, \ PSMS psms)

Definition at line 28 of file ssend.c.

 
#define UNLOCKPWND  ) 
 

Value:

pci->CallbackWnd = cbwin; \ ThreadUnlock(&tlpwnd);

Definition at line 145 of file ssend.c.


Function Documentation

NTSTATUS AllocateCallbackData PCAPTUREBUF  pcb,
DWORD  cbData,
PVOID *  ppDest
 

Definition at line 695 of file ssend.c.

References _CAPTUREBUF::cbCapture, _CAPTUREBUF::cCapturedPointers, DWORD, NTSTATUS(), _CAPTUREBUF::offPointers, PADSIZE, _CAPTUREBUF::pbFree, PBYTE, and _CAPTUREBUF::pvVirtualAddress.

00699 { 00700 PBYTE pbBuffer; 00701 00702 /* 00703 * Allocate space from the message buffer 00704 */ 00705 if (cbData > pcb->cbCapture) { 00706 return STATUS_BUFFER_OVERFLOW; 00707 } 00708 00709 pbBuffer = pcb->pbFree; 00710 pcb->pbFree = pbBuffer + ((cbData + PADSIZE) & ~PADSIZE); 00711 00712 /* 00713 * Fix up offsets to data. If the data is going into a section 00714 * use the real pointer and don't compute offsets. 00715 */ 00716 if (pcb->pvVirtualAddress) 00717 *ppDest = pbBuffer; 00718 else { 00719 *ppDest = (PBYTE)(pbBuffer - (PBYTE)pcb); 00720 ((LPDWORD)((PBYTE)pcb + pcb->offPointers))[pcb->cCapturedPointers++] = 00721 (DWORD)((PBYTE)ppDest - (PBYTE)pcb); 00722 } 00723 00724 return STATUS_SUCCESS; 00725 }

PVOID AllocCallbackMessage DWORD  cbBaseMsg,
DWORD  cPointers,
SIZE_T  cbCapture,
PBYTE  pStackBuffer,
BOOL  fInput
 

Definition at line 545 of file ssend.c.

References CALLBACKSTACKLIMIT, CBBUFSIZE, _CAPTUREBUF::cbCallback, _CAPTUREBUF::cbCapture, _CAPTUREBUF::cCapturedPointers, NT_SUCCESS, NTSTATUS(), NULL, _CAPTUREBUF::offPointers, PADSIZE, _CAPTUREBUF::pbFree, PBYTE, PCAPTUREBUF, _CAPTUREBUF::pvVirtualAddress, and Status.

00551 { 00552 PCAPTUREBUF pcb; 00553 00554 if (cPointers == 0) 00555 return NULL; 00556 00557 /* 00558 * Compute allocation sizes 00559 */ 00560 cbBaseMsg = (cbBaseMsg + PADSIZE) & ~PADSIZE; 00561 cbBaseMsg += (cPointers * sizeof(PVOID)); 00562 cbCapture = (cbCapture + (PADSIZE * cPointers)) & ~PADSIZE; 00563 00564 /* 00565 * If the captured data is greater than a page, place it 00566 * in a section. Otherwise, put the message and the 00567 * data in a single block of pool 00568 */ 00569 if (cbCapture > CALLBACKSTACKLIMIT) { 00570 NTSTATUS Status; 00571 00572 /* 00573 * Allocate the message buffer 00574 */ 00575 pcb = UserAllocPoolWithQuota(cbBaseMsg, TAG_CALLBACK); 00576 if (pcb == NULL) 00577 return NULL; 00578 00579 /* 00580 * Allocate the virtual memory 00581 */ 00582 pcb->pvVirtualAddress = NULL; 00583 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), 00584 &pcb->pvVirtualAddress, 0, &cbCapture, 00585 MEM_COMMIT, PAGE_READWRITE); 00586 if (!NT_SUCCESS(Status)) { 00587 RIPMSG2(RIP_WARNING, "AllocCallbackMessage: ZwAllocateVirtualMemory failed. Status:%#lx. Size:%#lx", 00588 Status, cbCapture); 00589 UserFreePool(pcb); 00590 return NULL; 00591 } 00592 pcb->pbFree = pcb->pvVirtualAddress; 00593 pcb->cbCallback = cbBaseMsg; 00594 } else { 00595 00596 /* 00597 * If the message is too big to save on the stack, allocate 00598 * the buffer from pool. 00599 */ 00600 if (cbBaseMsg + cbCapture > CBBUFSIZE) { 00601 pcb = UserAllocPoolWithQuota((ULONG)(cbBaseMsg + cbCapture), TAG_CALLBACK); 00602 if (pcb == NULL) 00603 return NULL; 00604 } else { 00605 pcb = (PCAPTUREBUF)pStackBuffer; 00606 } 00607 pcb->pbFree = (PBYTE)pcb + cbBaseMsg; 00608 pcb->pvVirtualAddress = NULL; 00609 00610 /* 00611 * If this callback is passing data to the client, include the 00612 * captured data in the message. Otherwise, only pass the message. 00613 */ 00614 if (fInput) 00615 pcb->cbCallback = cbBaseMsg + (ULONG)cbCapture; 00616 else 00617 pcb->cbCallback = cbBaseMsg; 00618 } 00619 00620 /* 00621 * Initialize the capture buffer 00622 */ 00623 pcb->cbCapture = (ULONG)cbCapture; 00624 pcb->cCapturedPointers = 0; 00625 pcb->offPointers = cbBaseMsg - (cPointers * sizeof(PVOID)); 00626 00627 return (PVOID)pcb; 00628 }

NTSTATUS CaptureAnsiCallbackData PCAPTUREBUF  pcb,
PVOID  pData,
DWORD  cbData,
PVOID *  ppDest
 

Definition at line 736 of file ssend.c.

References _CAPTUREBUF::cbCapture, _CAPTUREBUF::cCapturedPointers, DBCS_CHARSIZE, DWORD, FALSE, IS_DBCS_ENABLED, NT_SUCCESS, NTSTATUS(), NULL, _CAPTUREBUF::offPointers, PADSIZE, _CAPTUREBUF::pbFree, PBYTE, _CAPTUREBUF::pvVirtualAddress, and RtlUnicodeToMultiByteN().

00741 { 00742 PBYTE pbBuffer; 00743 ULONG nCharsInAnsiString; 00744 00745 /* 00746 * If the data pointer is NULL, the out pointer will be 00747 * NULL 00748 */ 00749 if (pData == NULL) { 00750 *ppDest = NULL; 00751 return STATUS_SUCCESS; 00752 } 00753 00754 /* 00755 * Allocate space from the message buffer 00756 */ 00757 #ifdef FE_SB // CaptureAnsiCallbackData() 00758 /* 00759 * Reserve enough space for DBCS. 00760 */ 00761 if ((cbData * sizeof(WORD)) > pcb->cbCapture) { 00762 #else 00763 if (cbData > pcb->cbCapture) { 00764 #endif // FE_SB 00765 return STATUS_BUFFER_OVERFLOW; 00766 } 00767 00768 pbBuffer = pcb->pbFree; 00769 00770 /* 00771 * Convert the unicode string to ANSI 00772 */ 00773 try { 00774 #ifdef FE_SB // CaptureAnsiCallbackData() 00775 /* 00776 * Enough space for keep DBCS string. 00777 */ 00778 if (!NT_SUCCESS(RtlUnicodeToMultiByteN( 00779 (PCH)pbBuffer, 00780 IS_DBCS_ENABLED() ? cbData * DBCS_CHARSIZE : cbData, 00781 &nCharsInAnsiString, 00782 (PWCH)pData, 00783 cbData * sizeof(WCHAR) 00784 ))) { 00785 #else 00786 if (!NT_SUCCESS(RtlUnicodeToMultiByteN( 00787 (PCH)pbBuffer, 00788 cbData, 00789 &nCharsInAnsiString, 00790 (PWCH)pData, 00791 cbData * sizeof(WCHAR) 00792 ))) { 00793 #endif // FE_SB 00794 return STATUS_UNSUCCESSFUL; 00795 } 00796 } except (W32ExceptionHandler(FALSE, RIP_WARNING)) { 00797 return STATUS_ACCESS_VIOLATION; 00798 } 00799 00800 /* 00801 * Translation succeeded. 00802 */ 00803 #ifdef FE_SB // CaptureAnsiCallbackData() 00804 /* 00805 * nCharsInAnsiString is actual bytes wriiten in message area. 00806 */ 00807 pcb->pbFree = pbBuffer + ((nCharsInAnsiString + PADSIZE) & ~PADSIZE); 00808 pcb->cbCapture -= nCharsInAnsiString; 00809 #else 00810 pcb->pbFree = pbBuffer + ((cbData + PADSIZE) & ~PADSIZE); 00811 pcb->cbCapture -= cbData; 00812 #endif // FE_SB 00813 00814 /* 00815 * Fix up offsets to data. If the data is going into a section 00816 * use the real pointer and don't compute offsets. 00817 */ 00818 if (pcb->pvVirtualAddress) 00819 *ppDest = pbBuffer; 00820 else { 00821 *ppDest = (PBYTE)(pbBuffer - (PBYTE)pcb); 00822 ((LPDWORD)((PBYTE)pcb + pcb->offPointers))[pcb->cCapturedPointers++] = 00823 (DWORD)((PBYTE)ppDest - (PBYTE)pcb); 00824 } 00825 00826 return STATUS_SUCCESS; 00827 }

NTSTATUS CaptureCallbackData PCAPTUREBUF  pcb,
PVOID  pData,
DWORD  cbData,
PVOID *  ppDest
 

Definition at line 639 of file ssend.c.

References _CAPTUREBUF::cbCapture, _CAPTUREBUF::cCapturedPointers, DWORD, FALSE, NTSTATUS(), NULL, _CAPTUREBUF::offPointers, PADSIZE, _CAPTUREBUF::pbFree, PBYTE, and _CAPTUREBUF::pvVirtualAddress.

00644 { 00645 PBYTE pbBuffer; 00646 00647 /* 00648 * If the data pointer is NULL, the out pointer will be 00649 * NULL 00650 */ 00651 if (pData == NULL) { 00652 *ppDest = NULL; 00653 return STATUS_SUCCESS; 00654 } 00655 00656 /* 00657 * Allocate space from the message buffer 00658 */ 00659 if (cbData > pcb->cbCapture) { 00660 return STATUS_BUFFER_OVERFLOW; 00661 } 00662 00663 pbBuffer = pcb->pbFree; 00664 pcb->pbFree = pbBuffer + ((cbData + PADSIZE) & ~PADSIZE); 00665 00666 try { 00667 RtlCopyMemory(pbBuffer, pData, cbData); 00668 } except (W32ExceptionHandler(FALSE, RIP_WARNING)) { 00669 return STATUS_ACCESS_VIOLATION; 00670 } 00671 00672 /* 00673 * Fix up offsets to data. If the data is going into a section 00674 * use the real pointer and don't compute offsets. 00675 */ 00676 if (pcb->pvVirtualAddress) 00677 *ppDest = pbBuffer; 00678 else { 00679 *ppDest = (PBYTE)(pbBuffer - (PBYTE)pcb); 00680 ((LPDWORD)((PBYTE)pcb + pcb->offPointers))[pcb->cCapturedPointers++] = 00681 (DWORD)((PBYTE)ppDest - (PBYTE)pcb); 00682 } 00683 00684 return STATUS_SUCCESS; 00685 }

NTSTATUS CaptureUnicodeCallbackData PCAPTUREBUF  pcb,
PVOID  pData,
DWORD  cbData,
PVOID *  ppDest
 

Definition at line 839 of file ssend.c.

References _CAPTUREBUF::cbCapture, _CAPTUREBUF::cCapturedPointers, DWORD, FALSE, NT_SUCCESS, NTSTATUS(), NULL, _CAPTUREBUF::offPointers, PADSIZE, _CAPTUREBUF::pbFree, PBYTE, _CAPTUREBUF::pvVirtualAddress, and RtlMultiByteToUnicodeN().

00844 { 00845 PBYTE pbBuffer; 00846 ULONG nCharsInUnicodeString; 00847 00848 /* 00849 * If the data pointer is NULL, the out pointer will be 00850 * NULL 00851 */ 00852 if (pData == NULL) { 00853 *ppDest = NULL; 00854 return STATUS_SUCCESS; 00855 } 00856 00857 /* 00858 * Allocate space from the message buffer 00859 */ 00860 if (cbData > pcb->cbCapture) { 00861 return STATUS_BUFFER_OVERFLOW; 00862 } 00863 00864 pbBuffer = pcb->pbFree; 00865 00866 /* 00867 * Convert the ANSI string to unicode 00868 */ 00869 try { 00870 if (!NT_SUCCESS(RtlMultiByteToUnicodeN( 00871 (PWCH)pbBuffer, 00872 cbData, 00873 &nCharsInUnicodeString, 00874 (PCH)pData, 00875 cbData / sizeof(WCHAR) 00876 ))) { 00877 return STATUS_UNSUCCESSFUL; 00878 } 00879 } except (W32ExceptionHandler(FALSE, RIP_WARNING)) { 00880 return STATUS_ACCESS_VIOLATION; 00881 } 00882 00883 /* 00884 * Translation succeeded. 00885 */ 00886 pcb->pbFree = pbBuffer + ((cbData + PADSIZE) & ~PADSIZE); 00887 pcb->cbCapture -= cbData; 00888 00889 /* 00890 * Fix up offsets to data. If the data is going into a section 00891 * use the real pointer and don't compute offsets. 00892 */ 00893 if (pcb->pvVirtualAddress) 00894 *ppDest = pbBuffer; 00895 else { 00896 *ppDest = (PBYTE)(pbBuffer - (PBYTE)pcb); 00897 ((LPDWORD)((PBYTE)pcb + pcb->offPointers))[pcb->cCapturedPointers++] = 00898 (DWORD)((PBYTE)ppDest - (PBYTE)pcb); 00899 } 00900 00901 return STATUS_SUCCESS; 00902 }

VOID CopyOutputString PCALLBACKSTATUS  pcbs,
PLARGE_STRING  pstr,
UINT  cchLimit,
BOOL  fAnsi
 

Definition at line 922 of file ssend.c.

References _LARGE_STRING::bAnsi, _LARGE_STRING::Buffer, BYTE, FALSE, _LARGE_STRING::Length, PCALLBACKSTATUS, pcbs, ProbeForRead, strncpycch(), UINT, VOID(), and wcsncpycch().

00927 { 00928 UINT cch; 00929 00930 ProbeForRead(pcbs->pOutput, pcbs->cbOutput, 00931 fAnsi ? sizeof(BYTE) : sizeof(WORD)); 00932 if (!pstr->bAnsi) { 00933 if (fAnsi) { 00934 cch = MBToWCS((LPSTR)pcbs->pOutput, (UINT)pcbs->retval, 00935 (LPWSTR *)&pstr->Buffer, cchLimit, FALSE); 00936 if (cch < cchLimit) { 00937 /* 00938 * Add a null terminator and ensure an accurate pstr->Length 00939 */ 00940 ((LPWSTR)pstr->Buffer)[cch] = 0; 00941 cchLimit = cch; 00942 } 00943 } else { 00944 cchLimit = wcsncpycch(pstr->Buffer, (LPWSTR)pcbs->pOutput, cchLimit); 00945 // wcsncpy(pstr->Buffer, (LPWSTR)pcbs->pOutput, cchLimit); 00946 } 00947 pstr->Length = cchLimit * sizeof(WCHAR); 00948 } else { 00949 if (fAnsi) { 00950 cchLimit = strncpycch((LPSTR)pstr->Buffer, 00951 // strncpy((LPSTR)pstr->Buffer, 00952 (LPSTR)pcbs->pOutput, cchLimit); 00953 } else { 00954 cch = WCSToMB((LPWSTR)pcbs->pOutput, (UINT)pcbs->retval, 00955 (LPSTR *)&pstr->Buffer, cchLimit, FALSE); 00956 if (cch < cchLimit) { 00957 /* 00958 * Add a null terminator and ensure an accurate pstr->Length 00959 */ 00960 ((LPSTR)pstr->Buffer)[cch] = 0; 00961 cchLimit = cch; 00962 } 00963 } 00964 pstr->Length = cchLimit; 00965 } 00966 }


Generated on Sat May 15 19:45:40 2004 for test by doxygen 1.3.7