Example #1
0
//
// Purpose: Read the specified file from the card.
//
//          The pbData parameter should be allocated
//          by the card module and freed by the CSP.  The card module
//          must set the cbData parameter to the size of the returned buffer.
//

#define WHERE "CardReadFile()"
DWORD WINAPI   CardReadFile
(
   __in                             PCARD_DATA  pCardData,
   __in                             LPSTR       pszDirectoryName,
   __in                             LPSTR       pszFileName,
   __in                             DWORD       dwFlags,
   __deref_out_bcount(*pcbData)     PBYTE      *ppbData,
   __out                            PDWORD      pcbData
)
{
   DWORD                dwReturn    = 0;
   int                  i           = 0;
   int                  DirFound    = 0;
   int                  FileFound   = 0;
	CONTAINER_MAP_RECORD cmr[2];
	BYTE                 pbSerialNumber[16];
	DWORD				      cbSerialNumber = sizeof(pbSerialNumber);
	DWORD				      cbDataLen;
	char					   szSerialNumber[33];
	char					   szContainerName[64];
	int					   iReturn;
Example #2
0
//    Binary serialization helper functions.
// </summary>
//-------------------------------------------------------------------------------------------------

#include "precomp.h"


// constants

#define BUFFER_INCREMENT 128


// helper function declarations

static HRESULT EnsureBufferSize(
    __deref_out_bcount(cbSize) BYTE** ppbBuffer,
    __in SIZE_T cbSize
    );


// functions

extern "C" HRESULT BuffReadNumber(
    __in_bcount(cbBuffer) const BYTE* pbBuffer,
    __in SIZE_T cbBuffer,
    __inout SIZE_T* piBuffer,
    __out DWORD* pdw
    )
{
    Assert(pbBuffer);
    Assert(piBuffer);
Example #3
0
    ExitOnFailure1(hr, "failed to load string resource id: %d", uID);

LExit:
    return hr;
}


/********************************************************************
ResReadData - returns a pointer to the specified resource data

NOTE:  there is no "free" function for this call
********************************************************************/
extern "C" HRESULT DAPI ResReadData(
    __in_opt HINSTANCE hinst,
    __in_z LPCSTR szDataName,
    __deref_out_bcount(*pcb) PVOID *ppv,
    __out DWORD *pcb
    )
{
    Assert(szDataName);
    Assert(ppv);

    HRESULT hr = S_OK;
    HRSRC hRsrc = NULL;
    HGLOBAL hData = NULL;
    DWORD cbData = 0;

#pragma prefast(push)
#pragma prefast(disable:25068)
    hRsrc = ::FindResourceExA(hinst, RT_RCDATA, szDataName, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
#pragma prefast(pop)
Example #4
0
NTSTATUS GetTransferMdl(__in WDFREQUEST Request,
                        __in WDF_REQUEST_TYPE RequestType,
                        __out PMDL* wdmMdl)
{
    return (RequestType == WdfRequestTypeWrite)
           ? WdfRequestRetrieveInputWdmMdl(Request, wdmMdl)
           : WdfRequestRetrieveOutputWdmMdl(Request, wdmMdl);
}

NTSTATUS GetTransferMemory(__in WDFREQUEST Request,
                           __in WDF_REQUEST_TYPE RequestType,
                           __out WDFMEMORY* wdfMemory)
{
    return (RequestType == WdfRequestTypeWrite)
           ? WdfRequestRetrieveInputMemory(Request, wdfMemory)
           : WdfRequestRetrieveOutputMemory(Request, wdfMemory);
}

NTSTATUS GetTransferBuffer(__in WDFREQUEST Request,
                           __in WDF_REQUEST_TYPE RequestType,
                           __in size_t MinimumRequiredLength,
                           __deref_out_bcount(*Length) PVOID* Buffer,
                           __out_opt size_t* Length)
{
    return (RequestType == WdfRequestTypeWrite)
           ? WdfRequestRetrieveInputBuffer(Request, MinimumRequiredLength, Buffer, Length)
           : WdfRequestRetrieveOutputBuffer(Request, MinimumRequiredLength, Buffer, Length);

}
            //

            if (*DiscInfo) 
            {
                CoTaskMemFreeAndNull (*DiscInfo);
            }
            *DiscInfoSize = 0;
        }
    }

    return hr;
}

HRESULT CMsftEraseSample::GetDiscCapabilities(
                                __in                                  IDiscRecorder2Ex* recorder,
                                __deref_out_bcount(*CapabilitiesSize) CDVD_CAPABILITIES_PAGE ** Capabilities, 
                                __out                                 ULONG * CapabilitiesSize,
                                                                      ULONG   RequiredSize
                                )
{
    HRESULT hr;

    if (Capabilities == NULL) 
    {
        return E_POINTER;
    }

    if (CapabilitiesSize == NULL) 
    {
        return E_POINTER;
    }
Example #6
0

extern "C" LPVOID DAPI MemReAlloc(
    __in LPVOID pv,
    __in SIZE_T cbSize,
    __in BOOL fZero
    )
{
//    AssertSz(vfMemInitialized, "MemInitialize() not called, this would normally crash");
    AssertSz(cbSize > 0, "MemReAlloc() called with invalid size");
    return ::HeapReAlloc(::GetProcessHeap(), fZero ? HEAP_ZERO_MEMORY : 0, pv, cbSize);
}


extern "C" HRESULT DAPI MemEnsureArraySize(
    __deref_out_bcount(cArray * cbArrayType) LPVOID* ppvArray,
    __in DWORD cArray,
    __in SIZE_T cbArrayType,
    __in DWORD dwGrowthCount
    )
{
    HRESULT hr = S_OK;
    DWORD cNew = 0;
    LPVOID pvNew = NULL;
    SIZE_T cbNew = 0;

    hr = ::DWordAdd(cArray, dwGrowthCount, &cNew);
    ExitOnFailure(hr, "Integer overflow when calculating new element count.");

    hr = ::SIZETMult(cNew, cbArrayType, &cbNew);
    ExitOnFailure(hr, "Integer overflow when calculating new block size.");