How access my driver using CreateFile() api?

Ask your beginner questions here.

How access my driver using CreateFile() api?

Postby fl4shc0d3r » Sat Aug 12, 2017 3:41 pm

I have a Delphi code where i want send a command to my driver, but CreateFile() cannot find device location.

here is my use of CreateFile():

Code: Select all
hDevice := CreateFileW('\\.\XXX', GENERIC_ALL, 0,

and in my device with symbolic link:

Code: Select all
const WCHAR deviceNameBuffer[] = L"\\Device\\XXX";
const WCHAR deviceSymLinkBuffer[] = L"\\??\\XXX";

/////////////////// DriverEntry() /////////////////////

UNICODE_STRING deviceNameUnicodeString, deviceSymLinkUnicodeString;
 // Normalize name and symbolic link.
 RtlInitUnicodeString (&deviceNameUnicodeString,
 RtlInitUnicodeString (&deviceSymLinkUnicodeString,
 // Create the device.
 ntStatus = IoCreateDevice ( pDriverObject,
   0, // For driver extension
 // Create the symbolic link
 ntStatus = IoCreateSymbolicLink(&deviceSymLinkUnicodeString,
Posts: 29
Joined: Fri Jan 20, 2017 3:10 am
Reputation point: -1

Re: How access my driver using CreateFile() api?

Postby Vrtule » Sat Aug 12, 2017 6:00 pm


you do not seem to check NTSTATUS values returned by IoCreateDevice and IoCreateSymbolicLink, so it is not clear whether your device or its symbolic link are actually created.

Do not pass FILE_DEVICE_UNKNOWN as device characteristics, since this constant is a device type, not device characteristic. Pass zero instead, for example.

User avatar
Posts: 412
Joined: Sat Mar 13, 2010 9:14 pm
Location: Czech Republic
Reputation point: 92

Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot] and 2 guests