Programmatically setting a registry key in "other driver's" hardware key

Discussion in 'Windows Vista Drivers' started by Spiro Trikaliotis, Oct 6, 2004.

  1. Hello,

    I need a way to programmatically set a registry key in a foreign
    driver's hardware registry key.

    What do I mean? I need to use IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT
    for a parallel port. On W2K and later, this IOCTL fails if
    HKLM\SYSTEM\CurrentControlSet\Enum\ACPI\PNP0401\4&5b55c8&0\Device
    Parameters\EnableConnectInterruptIoctl is not set to 1 (or PNP0400\...
    in case of a non-ECP parallel port)

    Until now (development), I'm setting this value by hand. Anyway, for
    production, I want to change this setting programmatically.

    Unfortunately, I found some more sophisticated parallel port cards do
    not have a hardware key on ACPI\PNP040x, but on
    HKLM/..../MF/PCI#VEN_131F&......./*/Device Parameters
    or
    HKLM\SYSTEM\CurrentControlSet\Enum\VSCOMBUS\BUS_0000&DEV_000B&FUN_0000\0000\Device Parameters
    HKLM\SYSTEM\CurrentControlSet\Enum\VSCOMBUS\BUS_0000&DEV_000B&FUN_0000\0001\Device Parameters

    Now, I ask myself how I could find out programmatically where these are
    located? I have searched the DDK Help, but I have not been able to find
    the appropriate call. I thought about IoGetDeviceProperty(), but it does
    not seem to help me (or I am totally overlooking something). I found a
    function to return the service (software) key. There, on
    HKLM\SYSTEM\Currentcontrolset\services\parport\enum\0, I found
    ACPI\PNP0400\5&324d5432&0 (for example). Is this what I am searching
    for, that is, append this to HKLM\System\CurrentControlSet\Enum? Or do I
    have to use another interface?

    Any input is appreciated,
    Spiro.
     
    Spiro Trikaliotis, Oct 6, 2004
    #1
    1. Advertisements

  2. open up the port you want to send the IOCTL to. send it a PIRP with
    IRP_MN_QUERY_DEVICE_RELATIONS / TargetDeviceRelations. This will give you
    the PDO for that stack. You can then use IoOpenDeviceRegistryKey and set
    the value

    http://msdn.microsoft.com/library/d..._94e53086-01ad-4b10-a128-3eae657c5fcc.xml.asp

    http://msdn.microsoft.com/library/d..._7b6ab819-56e3-4d4a-956a-51e4a83300f0.xml.asp

    beware of wrap. also, i don't know if the LPT driver inspects this value
    when the IOCTL is sent or when the stack is initially started. If it is
    when it is initially started, you will need to disable and then reenable the
    stack (which you can only do from user mode).

    d
     
    Doron Holan [MS], Oct 6, 2004
    #2
    1. Advertisements

  3. Hello Doron,

    [...]

    Thank you for your explanation, I will try and report if I had success.

    As I have changed this registry value by hand more than once ;-) I found
    out that it is checked on each IOCTL, so this is not a problem.

    Thank you very much!

    Regards,
    Spiro.
     
    Spiro Trikaliotis, Oct 6, 2004
    #3
  4. Hello Doron,

    Thanks, this works like a charm!

    Regards,
    Spiro.
     
    Spiro Trikaliotis, Oct 15, 2004
    #4
  5. Hello,

    Well, setting the registry key works, but I totally forgot that I have
    to do an additional element:

    I do not only have to set EnableConnectInterruptIoctl :DWORD to 1, but I
    have also to mimic what is done when a user lets the parallel port
    driver use an interrupt in the device manager. I found out that it
    essentially sets FilterResourceMethod :DWORD to 2. Unfortunately, the
    driver does not recognize this until a reboot is done, while it does
    accept it immediately when this is changed in the device manager.

    So, my question is: Can I mimic this? I think I have to let the bus
    driver reenumerate the device, this, that it is initialized again. I
    thought I could do this with IoInvalidateDeviceRelations(), but this
    does not work.

    Can anyone give me any hints? It does not matter if this solution is
    from user or from kernel mode, anything is highly appreciated. ;-)

    Regards,
    Spiro.
     
    Spiro Trikaliotis, Oct 15, 2004
    #5
  6. if you can do this in user mode, look at the devcon example for disable and
    then reenabling. it could be the property page is sending a
    DIF_PROPERTY_CHANGED which i think tears down and builds upt he stack again.

    d
     
    Doron Holan [MS], Oct 16, 2004
    #6
  7. Hello,

    I completely forgot to mention: Your hint was very good, it works as
    expected with DIF_PROPERTY_CHANGED.

    Thank you,
    Spiro.
     
    Spiro Trikaliotis, Oct 27, 2004
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.