Exemplo n.º 1
0
    public static byte DeviceDsmValidateInput([NativeTypeName("PDEVICE_DSM_DEFINITION")] DEVICE_DSM_DEFINITION *Definition, [NativeTypeName("PDEVICE_DSM_INPUT")] DEVICE_MANAGE_DATA_SET_ATTRIBUTES *Input, [NativeTypeName("DWORD")] uint InputLength)
    {
        uint Max = 0;

        uint Min   = 0;
        byte Valid = 0;

        if (Definition->Action != Input->Action)
        {
            goto Cleanup;
        }

        if (Definition->ParameterBlockLength != 0)
        {
            Min = unchecked ((uint)(sizeof(DEVICE_MANAGE_DATA_SET_ATTRIBUTES)));
            Max = InputLength;
            if (Input->ParameterBlockOffset < Min || Input->ParameterBlockOffset > Max || (Input->ParameterBlockOffset % Definition->ParameterBlockAlignment) != 0)
            {
                goto Cleanup;
            }

            Min = Definition->ParameterBlockLength;
            Max = InputLength - Input->ParameterBlockOffset;
            if (Input->ParameterBlockLength < Min || Input->ParameterBlockLength > Max)
            {
                goto Cleanup;
            }
        }

        if ((Input->Flags & 0x00000001) == 0)
        {
            Min = unchecked ((uint)(sizeof(DEVICE_MANAGE_DATA_SET_ATTRIBUTES)));
            Max = InputLength;
            if (Input->DataSetRangesOffset < Min || Input->DataSetRangesOffset > Max || (Input->DataSetRangesOffset % 8) != 0)
            {
                goto Cleanup;
            }

            Min = unchecked ((uint)(sizeof(DEVICE_DATA_SET_RANGE)));
            Max = InputLength - Input->DataSetRangesOffset;
            if (Input->DataSetRangesLength < Min || Input->DataSetRangesLength > Max || (Input->DataSetRangesLength % Min) != 0)
            {
                goto Cleanup;
            }

            if ((Definition->SingleRange) != 0 && Input->DataSetRangesLength != Min)
            {
                goto Cleanup;
            }
        }
        else
        {
            if (Input->DataSetRangesOffset != 0 || Input->DataSetRangesLength != 0)
            {
                goto Cleanup;
            }
        }

        if (Input->ParameterBlockOffset < Input->DataSetRangesOffset && Input->ParameterBlockOffset + Input->ParameterBlockLength > Input->DataSetRangesOffset)
        {
            goto Cleanup;
        }

        if (Input->DataSetRangesOffset < Input->ParameterBlockOffset && Input->DataSetRangesOffset + Input->DataSetRangesLength > Input->ParameterBlockOffset)
        {
            goto Cleanup;
        }

        Valid = 1;
Cleanup:
        return(Valid);
    }
Exemplo n.º 2
0
 public static DEVICE_DATA_SET_RANGE *DeviceDsmDataSetRanges([NativeTypeName("PDEVICE_DSM_INPUT")] DEVICE_MANAGE_DATA_SET_ATTRIBUTES *Input)
 {
     return((DEVICE_DATA_SET_RANGE *)((nuint)(Input) + Input->DataSetRangesOffset));
 }
Exemplo n.º 3
0
    /// <include file='Windows.xml' path='doc/member[@name="Windows.DeviceDsmInitializeInput"]/*' />
    public static void DeviceDsmInitializeInput([NativeTypeName("PDEVICE_DSM_DEFINITION")] DEVICE_DSM_DEFINITION *Definition, [NativeTypeName("PDEVICE_DSM_INPUT")] DEVICE_MANAGE_DATA_SET_ATTRIBUTES *Input, [NativeTypeName("DWORD")] uint InputLength, [NativeTypeName("DWORD")] uint Flags, [NativeTypeName("PVOID")] void *Parameters, [NativeTypeName("DWORD")] uint ParameterBlockLength)
    {
        uint Bytes = 28;

        Unsafe.InitBlockUnaligned((Input), 0, (InputLength));
        Input->Size   = unchecked (Bytes);
        Input->Action = Definition->Action;
        Input->Flags  = Flags;
        if (ParameterBlockLength == 0)
        {
            goto Cleanup;
        }

        unchecked (Bytes)           = unchecked (((Bytes) + ((Definition->ParameterBlockAlignment) - 1)) / (Definition->ParameterBlockAlignment) * (Definition->ParameterBlockAlignment));
        Input->ParameterBlockOffset = unchecked (Bytes);
        Input->ParameterBlockLength = ParameterBlockLength;
        if (Parameters == null)
        {
            goto Cleanup;
        }

        Unsafe.CopyBlockUnaligned((DeviceDsmParameterBlock(Input)), (Parameters), (Input->ParameterBlockLength));
Cleanup:
        return;
    }
Exemplo n.º 4
0
 public static void *DeviceDsmParameterBlock([NativeTypeName("PDEVICE_DSM_INPUT")] DEVICE_MANAGE_DATA_SET_ATTRIBUTES *Input)
 {
     return((void *)((nuint)(Input) + Input->ParameterBlockOffset));
 }