예제 #1
0
void Run_NumericTests()
{
    HRESULT hr;

    CoreShimComActivation csact{ W("NETServer.dll"), W("NumericTesting") };

    ComSmartPtr<INumericTesting> numericTesting;
    THROW_IF_FAILED(::CoCreateInstance(CLSID_NumericTesting, nullptr, CLSCTX_INPROC, IID_INumericTesting, (void**)&numericTesting));

    int seed = 37;
    ::srand(seed);

    ::printf("Numeric RNG seed: %d\n", seed);

    int a = ::rand();
    int b = ::rand();

    MarshalByte(numericTesting, (byte)a, (byte)b);
    MarshalShort(numericTesting, (int16_t)a, (int16_t)b);
    MarshalUShort(numericTesting, (uint16_t)a, (uint16_t)b);
    MarshalInt(numericTesting, a, b);
    MarshalUInt(numericTesting, (uint32_t)a, (uint32_t)b);
    MarshalLong(numericTesting, (int64_t)a, (int64_t)b);
    MarshalULong(numericTesting, (uint64_t)a, (uint64_t)b);
    MarshalFloat(numericTesting, (float)a / 100.f, (float)b / 100.f);
    MarshalDouble(numericTesting, (double)a / 100.0, (double)b / 100.0);
    MarshalManyInts(numericTesting);
}
예제 #2
0
NTSTATUS
RdrSmb2EncodeReadRequest(
    PSMB_PACKET pPacket,
    PBYTE* ppCursor,
    PULONG pulRemaining,
    ULONG ulDataLength,
    LONG64 llDataOffset,
    PRDR_SMB2_FID pFid,
    ULONG ulMinimumCount,
    ULONG ulRemainingBytes
    )
{
    NTSTATUS status = STATUS_SUCCESS;
    PRDR_SMB2_READ_REQUEST_HEADER pHeader = NULL;

    pHeader = (PRDR_SMB2_READ_REQUEST_HEADER) *ppCursor;
    /* Advance cursor past header to ensure buffer space */
    status = Advance(ppCursor, pulRemaining, sizeof(*pHeader));
    BAIL_ON_NT_STATUS(status);

    pHeader->usLength = SMB_HTOL16(sizeof(*pHeader) | 0x1);
    pHeader->ucDataOffset = 0;
    pHeader->ucReserved = 0;
    pHeader->ulDataLength = SMB_HTOL32(ulDataLength);
    pHeader->ullFileOffset = SMB_HTOL64(llDataOffset);
    pHeader->fid.ullPersistentId = SMB_HTOL64(pFid->ullPersistentId);
    pHeader->fid.ullVolatileId = SMB_HTOL64(pFid->ullVolatileId);
    pHeader->ulMinimumCount = SMB_HTOL32(ulMinimumCount);
    pHeader->ulRemainingBytes = SMB_HTOL32(ulRemainingBytes);
    pHeader->usReadChannelInfoOffset = 0;
    pHeader->usReadChannelInfoLength = 0;

    /* We must put at least 1 byte into the read channel buffer */
    status = MarshalByte(ppCursor, pulRemaining, 0);
    BAIL_ON_NT_STATUS(status);

 cleanup:

    return status;

 error:

    goto cleanup;
}