Exemple #1
0
static FORCEINLINE VOID
__ThreadFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, THREAD_POOL);
}
Exemple #2
0
static FORCEINLINE VOID
__DebugFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, DEBUG_TAG);
}
Exemple #3
0
static FORCEINLINE VOID
__CacheFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, CACHE_TAG);
}
Exemple #4
0
static FORCEINLINE VOID
__EmulatedFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, EMULATED_TAG);
}
Exemple #5
0
static FORCEINLINE VOID
__RegistryFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, REGISTRY_POOL);
}
Exemple #6
0
static FORCEINLINE VOID
__VifFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, VIF_POOL);
}
Exemple #7
0
static FORCEINLINE VOID
__PdoFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, PDO_TAG);
}
Exemple #8
0
static FORCEINLINE VOID
__PoolFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, POOL_POOL);
}
Exemple #9
0
static FORCEINLINE PCHAR
#pragma warning(suppress: 28195)
__DriverFormatV(
    __in PCHAR       Fmt,
    __in va_list     Args
    )
{
    NTSTATUS    Status;
    PCHAR       Str;
    ULONG       Size = 32;

    for (;;) {
        Str = (PCHAR)__AllocateNonPagedPoolWithTag(__FUNCTION__, __LINE__, Size, FORMAT_POOL_TAG);
        if (!Str) {
            return NULL;
        }

        Status = RtlStringCchVPrintfA(Str, Size - 1, Fmt, Args);

        if (Status == STATUS_SUCCESS) {
            Str[Size - 1] = '\0';
            return Str;
        } 
        
        __FreePoolWithTag(Str, FORMAT_POOL_TAG);
        if (Status == STATUS_BUFFER_OVERFLOW) {
            Size *= 2;
        } else {
            return NULL;
        }
    }
}
Exemple #10
0
static FORCEINLINE VOID
__GnttabFree(
    IN  PVOID   Buffer
)
{
    __FreePoolWithTag(Buffer, GNTTAB_TAG);
}
Exemple #11
0
static FORCEINLINE VOID
__MacFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, MAC_POOL);
}
Exemple #12
0
static FORCEINLINE VOID
__NotifierFree(
    IN  PVOID   Buffer
    )
{
    __FreePoolWithTag(Buffer, NOTIFIER_POOL);
}
Exemple #13
0
static FORCEINLINE VOID
__BlockRingFree(
    IN  PVOID                       Buffer
    )
{
    if (Buffer)
        __FreePoolWithTag(Buffer, BLOCKRING_POOL_TAG);
}
Exemple #14
0
static DECLSPEC_NOINLINE VOID
__DriverParseParameterKey(
    )
{
    NTSTATUS    Status;
    PWCHAR      Options;
    PWCHAR      Value;

    // Set default parameters
    DriverParameters.SynthesizeInquiry = FALSE;
    DriverParameters.PVCDRom           = FALSE;

    // attempt to read registry for system start parameters
    Status = __DriverGetSystemStartParams(&Options);
    if (NT_SUCCESS(Status)) {
        Trace("Options = \"%ws\"\n", Options);

        // check each option
        if (__DriverGetOption(Options, L"XENVBD:SYNTH_INQ=", &Value)) {
            // Value may be NULL (it shouldnt be though!)
            if (Value) {
                if (wcscmp(Value, L"ON") == 0) {
                    DriverParameters.SynthesizeInquiry = TRUE;
                }
                __FreePoolWithTag(Value, XENVBD_POOL_TAG);
            }
        }

        if (__DriverGetOption(Options, L"XENVBD:PVCDROM=", &Value)) {
            // Value may be NULL (it shouldnt be though!)
            if (Value) {
                if (wcscmp(Value, L"ON") == 0) {
                    DriverParameters.PVCDRom = TRUE;
                }
                __FreePoolWithTag(Value, XENVBD_POOL_TAG);
            }
        }

        __FreePoolWithTag(Options, XENVBD_POOL_TAG);
    }

    Verbose("DriverParameters: %s%s\n", 
            DriverParameters.SynthesizeInquiry ? "SYNTH_INQ " : "",
            DriverParameters.PVCDRom ? "PV_CDROM " : "");
}
Exemple #15
0
static DECLSPEC_NOINLINE NTSTATUS
__DriverGetSystemStartParams(
    __out PWCHAR*               Options
    )
{
    UNICODE_STRING      Unicode;
    OBJECT_ATTRIBUTES   Attributes;
    HANDLE              Key;
    PKEY_VALUE_PARTIAL_INFORMATION  Value;
    ULONG               Size;
    NTSTATUS            Status;

    RtlInitUnicodeString(&Unicode, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control");
    InitializeObjectAttributes(&Attributes, &Unicode, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);

    Status = ZwOpenKey(&Key, KEY_READ, &Attributes);
    if (!NT_SUCCESS(Status))
        goto fail1;

    RtlInitUnicodeString(&Unicode, L"SystemStartOptions");
    Status = ZwQueryValueKey(Key, &Unicode, KeyValuePartialInformation, NULL, 0, &Size);
    if (Status != STATUS_BUFFER_TOO_SMALL &&
        Status != STATUS_BUFFER_OVERFLOW)
        goto fail2;

    Status = STATUS_NO_MEMORY;
#pragma prefast(suppress:6102)
    Value = (PKEY_VALUE_PARTIAL_INFORMATION)__AllocateNonPagedPoolWithTag(__FUNCTION__, __LINE__, Size, XENVBD_POOL_TAG);
    if (Value == NULL)
        goto fail3;

    Status = ZwQueryValueKey(Key, &Unicode, KeyValuePartialInformation, Value, Size, &Size);
    if (!NT_SUCCESS(Status))
        goto fail4;

    Status = STATUS_INVALID_PARAMETER;
    if (Value->Type != REG_SZ)
        goto fail5;

    Status = STATUS_NO_MEMORY;
    *Options = (PWCHAR)__AllocateNonPagedPoolWithTag(__FUNCTION__, __LINE__, Value->DataLength + sizeof(WCHAR), XENVBD_POOL_TAG);
    if (*Options == NULL)
        goto fail6;

    RtlCopyMemory(*Options, Value->Data, Value->DataLength);

    __FreePoolWithTag(Value, XENVBD_POOL_TAG);

    ZwClose(Key);
    return STATUS_SUCCESS;

fail6:
fail5:
fail4:
    __FreePoolWithTag(Value, XENVBD_POOL_TAG);
fail3:
fail2:
    ZwClose(Key);
fail1:
    *Options = NULL;
    return Status;
}