reading registry

Hi,
I few parameters in INX under “legdev.NT.HW” section. The driver reads this parameter in add_device by opening registry using WdfDeviceOpenRegistryKey and query using WdfRegistryQueryULong API respetively. The WdfDeviceOpenRegistryKey takes wdfdevice as first parameter. Is there any possibility to read these registry parameter in Driver entry using a different API? Based on the value, the number of devices supported by the device is restricted.

On Dec 21, 2014, at 8:22 PM, xxxxx@yahoo.in wrote:

I few parameters in INX under “legdev.NT.HW” section. The driver reads this parameter in add_device by opening registry using WdfDeviceOpenRegistryKey and query using WdfRegistryQueryULong API respetively. The WdfDeviceOpenRegistryKey takes wdfdevice as first parameter. Is there any possibility to read these registry parameter in Driver entry using a different API? Based on the value, the number of devices supported by the device is restricted.

No, the .HW section is specifically designed for data that needs to be separate for each instance. That’s exactly the wrong place to put data that needs to be driver-global.

Instead, just put the parameter in the Services registry key. You can do that from the INF by putting the AddReg directive in the services section, and you can use WdfRegistrytOpenKey from DriverEntry to access it.

However, your description confuses me. What do you mean by “the number of devices supported by the device is restricted”?

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,
Thanks for the reply. In add_device routine the driver checks the mas devices supported by the driver and if the value reaches a value say 5, the routine returns without creating wdfdevice for the instance. And if parameters are in add reg directive under services section, could the parameters be changed through advanced property sheet?

Yes, anyone with admin rights can change it. Device manager runs as admin

d

Bent from my phone


From: xxxxx@yahoo.inmailto:xxxxx
Sent: ?12/?21/?2014 9:26 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] reading registry

Hi Tim,
Thanks for the reply. In add_device routine the driver checks the mas devices supported by the driver and if the value reaches a value say 5, the routine returns without creating wdfdevice for the instance. And if parameters are in add reg directive under services section, could the parameters be changed through advanced property sheet?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

Hi Doron,
Thanks. But when the add reg directive moved under services section, there are no registry entries created under “HKLM/System/CurrentControlSet/Enum/”. Below is the INF used
;
; legdev.inf
;

[Version]
Signature=“$WINDOWS NT$”
Class=legdev
ClassGuid={F7F1F0C5-0B4A-424C-AA8A-281845B7F5DC}

Provider=%ManufacturerName%
CatalogFile=legdev.cat
DriverVer= 1.0; TODO: set DriverVer in stampinf property pages

[DestinationDirs]
DriverDir=12
DllDir=11

; ================= Class section =====================

[ClassInstall32]
Addreg=TestClassReg

[TestClassReg]
HKR,0,%ClassName%
HKR,Icon,-5

[SourceDisksNames]
1 = %DiskName%,“”

[SourceDisksFiles]
legdev.sys = 1,
legproppage.dll =1,

;*****************************************
; Install Section
;*****************************************

[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$

[Standard.NT$ARCH$]
%legdev.DeviceDesc%=legdev_Device, Root\legdev_ll;{0695E116-AF9D-4D7F-A8A9-77EF791C6BDA} ; TODO: edit hw-id

[legdev_Device.NT]
CopyFiles=DriverDir,DllDir
AddReg = TestDevAdvanceSection

[TestDevAdvanceSection]
HKR,EnumPropPages32,“legproppage.dll,legPropPageProvider”

[DriverDir]
legdev.sys
[DllDir]
legproppage.dll

;-------------- Service installation
[legdev_Device.NT.Services]
AddService = legdev,%SPSVCINST_ASSOCSERVICE%, legdev_Service_Inst
AddReg=legdev_Device.NT.AddReg

; -------------- legdev driver install sections
[legdev_Service_Inst]
DisplayName = %legdev.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\legdev.sys
LoadOrderGroup = Extended Base

[legdev_Device.NT.AddReg]
HKR,DeviceCharacteristics,0x10001,0x0100 ; Use same security checks on relative opens
HKR,Security,“D:P(A;;GA;;;BA)(A;;GA;;;SY)” ; Allow generic-all access to Built-in administrators and Local system
HKR,MaxDevSupported,0x10001,0x1

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ManufacturerName=“prasanna” ; TODO: add ManufacturerName
ClassName=“Test” ; TODO: edit ClassName
DiskName = “legdev Installation Disk”
legdev.DeviceDesc = “legdev Device”
legdev.SVCDESC = “legdev Service”

It would not be under the enum key, rather it will show up under the service name itself

d

Bent from my phone


From: xxxxx@yahoo.inmailto:xxxxx
Sent: ?12/?21/?2014 11:32 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] reading registry

Hi Doron,
Thanks. But when the add reg directive moved under services section, there are no registry entries created under “HKLM/System/CurrentControlSet/Enum/”. Below is the INF used
;
; legdev.inf
;

[Version]
Signature=“$WINDOWS NT$”
Class=legdev
ClassGuid={F7F1F0C5-0B4A-424C-AA8A-281845B7F5DC}

Provider=%ManufacturerName%
CatalogFile=legdev.cat
DriverVer= 1.0; TODO: set DriverVer in stampinf property pages

[DestinationDirs]
DriverDir=12
DllDir=11

; ================= Class section =====================

[ClassInstall32]
Addreg=TestClassReg

[TestClassReg]
HKR,0,%ClassName%
HKR,Icon,-5

[SourceDisksNames]
1 = %DiskName%,“”

[SourceDisksFiles]
legdev.sys = 1,
legproppage.dll =1,

;
; Install Section
;


[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$

[Standard.NT$ARCH$]
%legdev.DeviceDesc%=legdev_Device, Root\legdev_ll;{0695E116-AF9D-4D7F-A8A9-77EF791C6BDA} ; TODO: edit hw-id

[legdev_Device.NT]
CopyFiles=DriverDir,DllDir
AddReg = TestDevAdvanceSection

[TestDevAdvanceSection]
HKR,EnumPropPages32,“legproppage.dll,legPropPageProvider”

[DriverDir]
legdev.sys
[DllDir]
legproppage.dll

;-------------- Service installation
[legdev_Device.NT.Services]
AddService = legdev,%SPSVCINST_ASSOCSERVICE%, legdev_Service_Inst
AddReg=legdev_Device.NT.AddReg

; -------------- legdev driver install sections
[legdev_Service_Inst]
DisplayName = %legdev.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\legdev.sys
LoadOrderGroup = Extended Base

[legdev_Device.NT.AddReg]
HKR,DeviceCharacteristics,0x10001,0x0100 ; Use same security checks on relative opens
HKR,Security,“D:P(A;;GA;;;BA)(A;;GA;;;SY)” ; Allow generic-all access to Built-in administrators and Local system
HKR,MaxDevSupported,0x10001,0x1

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ManufacturerName=“prasanna” ; TODO: add ManufacturerName
ClassName=“Test” ; TODO: edit ClassName
DiskName = “legdev Installation Disk”
legdev.DeviceDesc = “legdev Device”
legdev.SVCDESC = “legdev Service”


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

under HKLM/system/currentcontrolset/services, a service legdev is created but in parameters folder only wdf folder is present and the parameters mentioned in inx are missing. Is everything proper in inx?

On 22-Dec-2014 10:48, xxxxx@yahoo.in wrote:

under HKLM/system/currentcontrolset/services, a service legdev is created but in parameters folder only wdf folder is present and the parameters mentioned in inx are missing. Is everything proper in inx?

Return the addreg section back where it was, and add another one under
[legdev_Service_Inst]:

[legdev_Service_Inst]
DisplayName = %legdev.SVCDESC%

AddReg = stuff

[stuff]
HKR, Parameters, MaxDevSupported, 0x10001,5

Regards,
– pa

xxxxx@yahoo.in wrote:

In add_device routine the driver checks the mas devices supported by the driver and if the value reaches a value say 5, the routine returns without creating wdfdevice for the instance.

Why? If someone buys 6 of your devices, the extras just show up as a
yellow bang?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Once your WDFDRIVER object is created, you could use WdfDriverOpenParametersRegistryKey to open the “Parameters” subkey of your driver’s service key.

If the “Parameters” subkey does not exist, this function creates it.

http://msdn.microsoft.com/en-us/library/windows/hardware/ff547202(v=vs.85).aspx

Thank you pavel. It solved the issue.