Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

using WdfIoTargetSendIoctlSynchronously to send Ioctls

michaeljaplinmichaeljaplin Member Posts: 4

Hello im a newbie when i comes to windows kernel drivers, and im eager to learn this new topic,
im trying to send ATA/SCSI IOCTLS to Harddrives/SSDs/USB connected devices from kernel driver.
i researched abit and found WdfIoTargetSendIoctlSynchronously function, but im unable to understand how to fill the function it self in order to succeed with sending ATA/SCSI IOCTLs
i was able to send ATA/SCSI commands from userspace using DeviceIoControl, now im trying to do it from the kernel instead
I've researched for few days and still couldn't understand on how to achieve my goal, any help is appreciated .
TL;DR: Can't figure how to send ATA/SCSI commands to connected PhysicalDrives from Windows Kernel Drivers (WDF)

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,163

    Anything that CAN be done in user mode SHOULD be done in user mode. Don't use the kernel just because it's fun. Kernel code is always more dangerous, because bugs have such drastic consequences.

    Having said that, WdfIoTargetSendIoctlSynchronously is one of the simplest KMDF functions. It builds the IRP for you and handles all of the completion and cancellation details for you. The parameters are practically the same as the user mode DeviceIoControl call. What is giving you trouble?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • michaeljaplinmichaeljaplin Member Posts: 4

    @Tim_Roberts said:
    Anything that CAN be done in user mode SHOULD be done in user mode. Don't use the kernel just because it's fun. Kernel code is always more dangerous, because bugs have such drastic consequences.

    Having said that, WdfIoTargetSendIoctlSynchronously is one of the simplest KMDF functions. It builds the IRP for you and handles all of the completion and cancellation details for you. The parameters are practically the same as the user mode DeviceIoControl call. What is giving you trouble?

    I understand the situation and how dangerous it is, this research is for curiosity and see what's possible and what isn't

    Initially what gives me trouble is initializing IoTarget, and Request parameters, and understanding how to set a "PhysicallDriveX" as my target

  • michaeljaplinmichaeljaplin Member Posts: 4

    @michaeljaplin said:

    @Tim_Roberts said:
    Anything that CAN be done in user mode SHOULD be done in user mode. Don't use the kernel just because it's fun. Kernel code is always more dangerous, because bugs have such drastic consequences.

    Having said that, WdfIoTargetSendIoctlSynchronously is one of the simplest KMDF functions. It builds the IRP for you and handles all of the completion and cancellation details for you. The parameters are practically the same as the user mode DeviceIoControl call. What is giving you trouble?

    I understand the situation and how dangerous it is, this research is for curiosity and see what's possible and what isn't

    Initially what gives me trouble is initializing IoTarget, and Request parameters, and understanding how to set a "PhysicallDriveX" as my target

    i have found that in order to target PhysicalDrives, i need to use the SymLink of \Device\Harddisk\DR?, where do I initialize this Target?

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,784

    where do I initialize this Target?

    I don’t understand the question.

    Call WdfIoTargetOpen sometime before you need to use the Target.

    Enter

    Peter Viscarola
    OSR
    @OSRDrivers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 24 January 2022 Live, Online
Internals & Software Drivers 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online
Developing Minifilters 23 May 2022 Live, Online