⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prpobj.c

📁 winddk src目录下的WDM源码压缩!
💻 C
📖 第 1 页 / 共 3 页
字号:
                RtlCopyMemory(
                    Data,
                    ((PUCHAR) fullInfo) + fullInfo->DataOffset,
                    fullInfo->DataLength
                    );
            }
            else {

                status = STATUS_INVALID_BUFFER_SIZE;
            }
        }            

        ExFreePool(fullInfo);

    }        
    
    return (status);

}



NTSTATUS
SetRegistryKeyValue(
   HANDLE hKey,
   PWCHAR pwszEntry, 
   LONG nValue
   )
{
    NTSTATUS status;
    UNICODE_STRING ustr;

    RtlInitUnicodeString(&ustr, pwszEntry);

    status =	      
        ZwSetValueKey(
		          hKey,
		          &ustr,
		          0,			/* optional */
		          REG_DWORD,
		          &nValue,
		          sizeof(nValue)
		          );         

   return status;
}


BOOL
GetPropertyValuesFromRegistry(
    PVOID pDC
    )
{
    NTSTATUS Status;
    HANDLE hPDOKey, hKeySettings;
    ULONG ulLength; 
    
    PINTELCAM_DEVICE_CONTEXT pDevExt = pDC;
    ulLength = sizeof(LONG);

    INTELCAM_KdPrint(MAX_TRACE, ("GetPropertyValuesFromRegistry \n"));

    //
    // Registry key: 
    //   Windows 2000:
    //   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\
    //   {6BDD1FC6-810F-11D0-BEC7-08002BE2092F\000x
    //
    // Win98:
    //    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Class\Image\000x
    // 
    Status = 
        IoOpenDeviceRegistryKey(
            pDevExt->pPnPDeviceObject, 
            PLUGPLAY_REGKEY_DRIVER,
            STANDARD_RIGHTS_READ, 
            &hPDOKey);

    ASSERT(Status == STATUS_SUCCESS);

    //
    // loop through our table of strings,
    // reading the registry for each.
    //
    if(NT_SUCCESS(Status)) {

        // Create or open the settings key
        Status =         
            CreateRegistrySubKey(
                hPDOKey,
                KEY_ALL_ACCESS,
                wszSettings,
                &hKeySettings
                );

        if(NT_SUCCESS(Status)) {

            // Brightness
            Status = GetRegistryKeyValue(
                hKeySettings, 
                wszBrightness, 
                sizeof(wszBrightness), 
                (PVOID) &pDevExt->CurrentProperty.Brightness, 
                &ulLength);

            INTELCAM_KdPrint(MAX_TRACE, ("Brightness Reg. Value = %d \n",
                                            pDevExt->CurrentProperty.Brightness));

            // Contrast
            Status = GetRegistryKeyValue(
                hKeySettings, 
                wszContrast, 
                sizeof(wszContrast), 
                (PVOID) &pDevExt->CurrentProperty.Contrast, 
                &ulLength);

            INTELCAM_KdPrint(MAX_TRACE, ("Contrast Reg. Value = %d \n",
                                            pDevExt->CurrentProperty.Contrast));

            // Saturation
            Status = GetRegistryKeyValue(
                hKeySettings, 
                wszSaturation, 
                sizeof(wszSaturation), 
                (PVOID) &pDevExt->CurrentProperty.Saturation, 
                &ulLength);

            INTELCAM_KdPrint(MAX_TRACE, ("Saturation Reg. Value = %d \n",
                                            pDevExt->CurrentProperty.Saturation));

            // Sharpness
            Status = GetRegistryKeyValue(
                hKeySettings, 
                wszSharpness, 
                sizeof(wszSharpness), 
                (PVOID) &pDevExt->CurrentProperty.Sharpness, 
                &ulLength);

            INTELCAM_KdPrint(MAX_TRACE, ("Sharpness Reg. Value = %d \n",
                                            pDevExt->CurrentProperty.Sharpness));

            // WhiteBalance
            Status = GetRegistryKeyValue(
                hKeySettings, 
                wszWhiteBalance, 
                sizeof(wszWhiteBalance), 
                (PVOID) &pDevExt->CurrentProperty.WhiteBalance, 
                &ulLength);

            INTELCAM_KdPrint(MAX_TRACE, ("WhiteBalance Reg. Value = %d \n",
                                            pDevExt->CurrentProperty.WhiteBalance));

            // close settings subkey and device key.

            ZwClose(hKeySettings);
            ZwClose(hPDOKey);

            return TRUE;

        } else {

            INTELCAM_KdPrint(MAX_TRACE, ("CreateRegistrySubKey failed with Status=%x\n", Status));
        }

        ZwClose(hPDOKey);

    } else {

        INTELCAM_KdPrint(MIN_TRACE, ("IoOpenDeviceRegistryKey failed with Status=%x\n", Status));

    }

    // Not implemented so always return FALSE to use the defaults.
    return FALSE;
}

//---------------------------------------------------------------------------
// INTELCAM_CameraToDriverDefaults
//---------------------------------------------------------------------------
NTSTATUS
INTELCAM_CameraToDriverDefaults(
    PDEVICE_OBJECT BusDeviceObject,
    PVOID pDeviceContext
    )
/*++

Routine Description:

Arguments:

    DeviceContext - points to the driver specific DeviceContext


Return Value:

    NT status code

--*/
{
    PINTELCAM_DEVICE_CONTEXT pDC = pDeviceContext;
    HW_STREAM_REQUEST_BLOCK Srb;
    STREAM_PROPERTY_DESCRIPTOR PropertyDescriptor;
    NTSTATUS ntStatus = STATUS_SUCCESS;
    BOOL status;
    KSPROPERTY_VIDEOPROCAMP_S Video; 

    //
    //  Reset videoprocamp values in dev. extension.
    // 
    
    pDC->CurrentProperty.Brightness     = -1;
    pDC->CurrentProperty.Sharpness      = -1;
    pDC->CurrentProperty.Contrast       = -1;
    pDC->CurrentProperty.WhiteBalance   = -1;
    pDC->CurrentProperty.Saturation     = -1;

    //
    // Get the actual values for the controls from registry.
    //

    status = GetPropertyValuesFromRegistry(pDC);

    //
	// Fill in Property Descriptor field
	//
    Srb.CommandData.PropertyInfo = &PropertyDescriptor;
	PropertyDescriptor.Property = &Video.Property;
	PropertyDescriptor.PropertyInfo = &Video;
	PropertyDescriptor.PropertyInputSize = sizeof(KSPROPERTY_VIDEOPROCAMP_S);
	PropertyDescriptor.PropertyOutputSize = sizeof(KSPROPERTY_VIDEOPROCAMP_S);
	
	Video.Property.Set = PROPSETID_VIDCAP_VIDEOPROCAMP;

    // set brightness
	Video.Property.Id = KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS;
    if ( (pDC->CurrentProperty.Brightness >= 0) &&  
        (pDC->CurrentProperty.Brightness <= MAX_BRIGHTNESS_IRE_UNITS) ) {
        Video.Value = pDC->CurrentProperty.Brightness;
    }
    else {
        Video.Value = BrightnessDefault;
	}
    // now set the camera to this value.
	SetPropertyCtrl(REQ_BRIGHTNESS, pDC, &Srb);

    // set White Balance
	Video.Property.Id = KSPROPERTY_VIDEOPROCAMP_WHITEBALANCE;
    if ( (pDC->CurrentProperty.WhiteBalance >= 0) &&  
        (pDC->CurrentProperty.WhiteBalance <= MAX_WHITEBALANCE_MISC_UNITS ) ) {
        Video.Value = pDC->CurrentProperty.WhiteBalance;
    }
    else {
        Video.Value = WhiteBalanceDefault;
	}
    // now set the camera to this value.
	SetPropertyCtrl(REQ_WHITEBALANCE, pDC, &Srb);

    // set Contrast
	Video.Property.Id = KSPROPERTY_VIDEOPROCAMP_CONTRAST;
    if ( (pDC->CurrentProperty.Contrast >= 0) &&  
        (pDC->CurrentProperty.Contrast <= MAX_CONTRAST_MISC_UNITS ) ) {
        Video.Value = pDC->CurrentProperty.Contrast;
    }
    else {
        Video.Value =  ContrastDefault;
	}
    // now set the camera to this value.
	SetPropertyCtrl(REQ_EXPOSURE, pDC, &Srb);

    // set Saturation
	Video.Property.Id = KSPROPERTY_VIDEOPROCAMP_SATURATION;
    if ( (pDC->CurrentProperty.Saturation >= 0) &&  
        (pDC->CurrentProperty.Saturation <= MAX_SATURATION_MISC_UNITS ) ) {
        Video.Value = pDC->CurrentProperty.Saturation;
    }
    else {
        Video.Value = SaturationDefault;
	}
    // now set the camera to this value.
	SetPropertyCtrl(REQ_SATURATION, pDC, &Srb);

    // set Sharpness
	Video.Property.Id = KSPROPERTY_VIDEOPROCAMP_SHARPNESS;
    if ( (pDC->CurrentProperty.Sharpness >= 0) &&  
        (pDC->CurrentProperty.Sharpness <= MAX_ENHANCEMENT_MISC_UNITS  ) ) {
        Video.Value = pDC->CurrentProperty.Sharpness;
    }
    else {
        Video.Value = SharpnessDefault;
	}
    // now set the camera to this value.
	SetPropertyCtrl(REQ_ENHANCEMENT, pDC, &Srb);

    return ntStatus = STATUS_SUCCESS;
}


//---------------------------------------------------------------------------
// INTELCAM_SaveControlsToRegistry
//---------------------------------------------------------------------------
NTSTATUS
INTELCAM_SaveControlsToRegistry(
    PDEVICE_OBJECT BusDeviceObject,
    PVOID pDeviceContext
    )
/*++

Routine Description:

    This function saves the camera controls - brightness,
	WhiteBalance, Saturation, Sharpness, and Contrast values
	to the registry.  These will be read by the driver at
	startchannel time and restored.

Arguments:

Return Value:

    NT status code

--*/
{
    PINTELCAM_DEVICE_CONTEXT pDC = pDeviceContext;
    NTSTATUS Status ;
    HANDLE hPDOKey, hKeySettings;

    INTELCAM_KdPrint(MAX_TRACE, ("SetPropertyValuesToRegistry \n"));

    //
    // Registry key: 
    //   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\
    //   {6BDD1FC6-810F-11D0-BEC7-08002BE2092F\000x
    //
    Status = 
        IoOpenDeviceRegistryKey(
            pDC->pPnPDeviceObject, 
            PLUGPLAY_REGKEY_DRIVER,
            STANDARD_RIGHTS_WRITE, 
            &hPDOKey);

    ASSERT(Status == STATUS_SUCCESS);

    //
    // loop through our table of strings,
    // reading the registry for each.
    //
    if(NT_SUCCESS(Status)) {

        // Create or open the settings key
        Status =         
            CreateRegistrySubKey(
                hPDOKey,
                KEY_ALL_ACCESS,
                wszSettings,
                &hKeySettings
                );

        if(NT_SUCCESS(Status)) {

            // Brightness
            Status = SetRegistryKeyValue(hKeySettings,wszBrightness,
                                         pDC->CurrentProperty.Brightness);
            INTELCAM_KdPrint(MAX_TRACE, ("Set Brightness Registry Value to %d \n",
                                            pDC->CurrentProperty.Brightness));
            // Contrast
            Status = SetRegistryKeyValue(hKeySettings,wszContrast,
                                         pDC->CurrentProperty.Contrast);
            INTELCAM_KdPrint(MAX_TRACE, ("Set Contrast Registry Value to %d \n",
                                            pDC->CurrentProperty.Contrast));

            // Saturation
            Status = SetRegistryKeyValue(hKeySettings,wszSaturation,
                                         pDC->CurrentProperty.Saturation);
            INTELCAM_KdPrint(MAX_TRACE, ("Set Saturation Registry Value to %d \n",
                                            pDC->CurrentProperty.Saturation));

            // Sharpness
            Status = SetRegistryKeyValue(hKeySettings,wszSharpness,
                                         pDC->CurrentProperty.Sharpness);
            INTELCAM_KdPrint(MAX_TRACE, ("Set Sharpness Registry Value to %d \n",
                                            pDC->CurrentProperty.Sharpness));

            // WhiteBalance
            Status = SetRegistryKeyValue(hKeySettings,wszWhiteBalance,
                                         pDC->CurrentProperty.WhiteBalance);
            INTELCAM_KdPrint(MAX_TRACE, ("Set WhiteBalance Registry Value to %d \n",
                                            pDC->CurrentProperty.WhiteBalance));

            // save settings subkey and device key.

            ZwClose(hKeySettings);
            ZwClose(hPDOKey);

            return TRUE;

        } else {
            INTELCAM_KdPrint(MIN_TRACE, ("CreateRegistrySubKey failed with Status=%x\n", Status));
        }

        ZwClose(hPDOKey);

    } else {
        INTELCAM_KdPrint(MIN_TRACE, ("IoOpenDeviceRegistryKey failed with Status=%x\n", Status));
    }

    return Status;
}










⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -