0

I can find:

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

in winioctl.h. However, I still can't understand this control code. For instance, what is a DeviceType of 0x8335? I just can't find such DeviceType in this header file. Or did I misunderstand this CTL_CODE macro?

This control code is frequently used in sysinternals handle.exe. It seems to use this control code in DeviceIoControl to query file handle information. I want to integrate this function in my application but I can't figure out how to use this IOCTL. I failed to find helpful information in either Microsoft Learn.

This super user post mentioned this code but very shortly and I still don't know how to use it.

So finally what does this code do and how can I use it in my application?

asked Dec 6, 2023 at 14:22
9
  • 4
    What are you really trying to do? What is the actual problem you need to solve? Why do you think the DeviceControl function would solve it? Right now this is too much of an XY problem to be able to write a meaningful answer. Commented Dec 6, 2023 at 14:25
  • I'd guess its an undocumented part of the windows internals which is why you can't find any documentation on it Commented Dec 6, 2023 at 14:45
  • 2
    That is just one of the IOCTLs used to communicate with the sysinternals driver. The actual value is somewhat arbitrary as long as both sides agree on what it is. Commented Dec 6, 2023 at 15:05
  • 2
    According to Defining I/O Control Codes: "[Device Type] Values of 0x8000 and higher can be used by vendors. Note that the vendor-assigned values set the Common bit." 0x8335 has the Common bit set. Specifying Device Types also says: "If a type of hardware does not match any of the defined types, specify a value of either FILE_DEVICE_UNKNOWN, or a value within the range of 32768 through 65535." Commented Dec 6, 2023 at 17:49
  • As for what it does, it looks like the driver primarily calls ObQueryNameString and returns the result to the client. Commented Dec 6, 2023 at 18:37

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.