Finding Start IOCTL value from CTL Code

Hello Everyone,

I am new to Windows drivers and need your help.
Could some one please help me in understanding how to find out IOCTL start value in Hex for a given CTL code.

It would be really helpful if someone can help me understanding with below example:
define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)

Thanks,
San

Do you mean taking a CTL_CODE statement and getting the hex value for the
IOCTL, if so see
https://msdn.microsoft.com/en-us/library/windows/hardware/ff543023(v=vs.85).
aspx Or do you mean taking a hex value for an IOCTL and getting back the
inputs to CTL_CODE if so use
http://www.osronline.com/article.cfm?article=229

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Sunday, February 07, 2016 11:53 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Finding Start IOCTL value from CTL Code

Hello Everyone,

I am new to Windows drivers and need your help.
Could some one please help me in understanding how to find out IOCTL start
value in Hex for a given CTL code.

It would be really helpful if someone can help me understanding with below
example:
define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012,
METHOD_BUFFERED, FILE_ANY_ACCESS)

Thanks,
San


NTDEV is sponsored by OSR

Visit the list online at:
http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at
http:</http:></http:></http:>

Hi sandeep,
Ctl_code has 32-bit , device_type from 0x0000 to 0x7ffff reserved for
Microsoft 0x8000 to 0xffff customer defined, required access like file
permission read/write , control code driver defined ioctl , transfer type
-buffer passing mechanism for this control code, you can create this 32 bit
guid in visual studio in create tool option ,its for giving the interface
from application to driver .its a type of system call .
On 07-Feb-2016 10:24 pm, wrote:

> Hello Everyone,
>
> I am new to Windows drivers and need your help.
> Could some one please help me in understanding how to find out IOCTL start
> value in Hex for a given CTL code.
>
> It would be really helpful if someone can help me understanding with below
> example:
> define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE,
> 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)
>
> Thanks,
> San
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:>

Thanks for Reply Don.

I am looking for steps for: “taking CTL_CODE statement and getting the hex value for the
IOCTL”

I have gone through the msdn link but could not reach to a conclusive answer from there, probably due to my inexperience.

It would be really useful if you could give me some hints how to get the hex value for below statement:

define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012,
METHOD_BUFFERED, FILE_ANY_ACCESS)

Regards,
San

It is a macro:

#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)

You should be able to take it from there.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Sunday, February 07, 2016 12:32 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Finding Start IOCTL value from CTL Code

Thanks for Reply Don.

I am looking for steps for: “taking CTL_CODE statement and getting the hex
value for the IOCTL”

I have gone through the msdn link but could not reach to a conclusive answer
from there, probably due to my inexperience.

It would be really useful if you could give me some hints how to get the hex
value for below statement:

define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012,
METHOD_BUFFERED, FILE_ANY_ACCESS)

Regards,
San


NTDEV is sponsored by OSR

Visit the list online at:
http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at
http:</http:></http:></http:>

I think there are several “Windows IOCTL calculators” on the web, both as a webpage (osronline.com has one) and IIRC as an EXE too.

IOCTL_DISK_BASE (first macro arg) goes to senior 16bit word.

0x0012 (the code itself) is multiplied by 4 (<<2) and goes to junior 16bit word.

METHOD_BUFFERED/IN/OUT_DIRECT/_NEITHER goes to 2 most junior bits.

Forgot (off-head) where the desired access requirement goes. Bits 14-15?


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Hello Everyone,
>
> I am new to Windows drivers and need your help.
> Could some one please help me in understanding how to find out IOCTL start value in Hex for a given CTL code.
>
> It would be really helpful if someone can help me understanding with below example:
> define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)
>
> Thanks,
> San
>

xxxxx@gmail.com wrote:

I am looking for steps for: “taking CTL_CODE statement and getting the hex value for the
IOCTL”

I have gone through the msdn link but could not reach to a conclusive answer from there, probably due to my inexperience.

It would be really useful if you could give me some hints how to get the hex value for below statement:

define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012,
METHOD_BUFFERED, FILE_ANY_ACCESS)

Did you take the time to look up the CTL_CODE macro in the include
files? All of those symbols are publicly defined.

This is a bit dated, but still mostly useful:
http://timr.probo.com/ioctls.html


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

> This is a bit dated, but still mostly useful:

http://timr.probo.com/ioctls.html

Here is another one:

http://social.technet.microsoft.com/wiki/contents/articles/24653.decoding-io-control-codes-ioctl-fsctl-and-deviceiocodes-with-table-of-known-values.aspx


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

Thanks a lot everyone for your help… I have got enough information to research further on this.
I will try to create a tool similar to http://www.osronline.com/article.cfm?article=229 where one can enter Device, Function, Access, Method values to generate IOCTL Value (Reverse of decoding)

xxxxx@gmail.com wrote:

Thanks a lot everyone for your help… I have got enough information to research further on this.
I will try to create a tool similar to http://www.osronline.com/article.cfm?article=229 where one can enter Device, Function, Access, Method values to generate IOCTL Value (Reverse of decoding)

Not sure it’s worth the trouble. The numerical values are not all that
useful unless you are debugging, and in that case in can be quicker just
to add a quick
KdPrint(( “IOCTL_SET_DEVICE_WAKE = %08x\n”, IOCTL_SET_DEVICE_WAKE ));
to your driver.


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

Thanks for the suggestion Tim
I am looking for numerical values as I need to pass it to my fuzzer as a parameter (to perform IOCTL fuzzing on the driver)

Regards,
San