Exemple #1
0
PVOID
WINAPI
FlatBuf_Arg_ReserveAlignPointer(IN PVOID Position,
                                IN PSIZE_T FreeSize,
                                IN SIZE_T Size)
{
    /* Just a little helper that we use */
    return FlatBuf_Arg_Reserve(Position, FreeSize, Size, sizeof(PVOID));
}
Exemple #2
0
PVOID
WINAPI
FlatBuf_Arg_CopyMemory(IN OUT PULONG_PTR Position,
                       IN OUT PSIZE_T FreeSize,
                       IN PVOID Buffer,
                       IN SIZE_T Size,
                       IN ULONG Align)
{
    PVOID Destination;

    /* First reserve the memory */
    Destination = FlatBuf_Arg_Reserve(Position, FreeSize, Size, Align);
    if (Destination)
    {
        /* We have space, do the copy */
        RtlCopyMemory(Destination, Buffer, Size);
    }

    /* Return the pointer to the data */
    return Destination;
}
Exemple #3
0
PVOID
WINAPI
FlatBuf_Arg_WriteString(IN OUT PULONG_PTR Position,
                        IN OUT PSIZE_T FreeSize,
                        IN PVOID String,
                        IN BOOLEAN IsUnicode)
{
    PVOID Destination;
    SIZE_T StringLength;
    ULONG Align;

    /* Calculate the string length */
    if (IsUnicode)
    {
        /* Get the length in bytes and use WCHAR alignment */
        StringLength = (wcslen((LPWSTR)String) + 1) * sizeof(WCHAR);
        Align = sizeof(WCHAR);
    }
    else
    {
        /* Get the length in bytes and use CHAR alignment */
        StringLength = strlen((LPSTR)String) + 1;
        Align = sizeof(CHAR);
    }

    /* Now reserve the memory */
    Destination = FlatBuf_Arg_Reserve(Position, FreeSize, StringLength, Align);
    if (Destination)
    {
        /* We have space, do the copy */
        RtlCopyMemory(Destination, String, StringLength);
    }

    /* Return the pointer to the data */
    return Destination;
}