How access my driver using CreateFile() api?
PostPosted: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():
here is my use of CreateFile():
Code: Select all
and in my device with symbolic link:hDevice := CreateFileW('\\.\XXX', GENERIC_ALL, 0,
PSECURITY_DESCRIPTOR(nil), OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
Code: Select all
const WCHAR deviceNameBuffer[] = L"\\Device\\XXX";
const WCHAR deviceSymLinkBuffer[] = L"\\??\\XXX";
PDEVICE_OBJECT g_MyDevice
/////////////////// DriverEntry() /////////////////////
UNICODE_STRING deviceNameUnicodeString, deviceSymLinkUnicodeString;
// Normalize name and symbolic link.
RtlInitUnicodeString (&deviceNameUnicodeString,
deviceNameBuffer);
RtlInitUnicodeString (&deviceSymLinkUnicodeString,
deviceSymLinkBuffer);
// Create the device.
ntStatus = IoCreateDevice ( pDriverObject,
0, // For driver extension
&deviceNameUnicodeString,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_UNKNOWN,
FALSE,
&g_MyDevice);
// Create the symbolic link
ntStatus = IoCreateSymbolicLink(&deviceSymLinkUnicodeString,
&deviceNameUnicodeString);