динамическая загрузка драйвера
- From
- Genadi Zawidowski (2:5020/175.2)
- To
- Kirill Neznamov
- Date
- 2002-01-13T17:25:54Z
- Area
- SU.WINDOWS.NT.PROG
From: "Genadi Zawidowski" <dolphin@infopro.spb.su>
KN> могло открыть мой драйвер по CreateFile()?(например как ком порт?)Здесь
KN> что-то не работает..
KN> После CreateFile() GetLastError() возвращает ERROR_INVALID_FUNCTION.Где
KN> предположительно могут быть грабли?
DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
создать линк на себя:
// Create WIN32 name of this device
_snwprintf(win32namebuf, arraysize(win32namebuf),
L"\\DosDevices\\SEND4M%ld", thisDevConut);
::RtlInitUnicodeString(& win32DeviceName, win32namebuf);
// Make a copy of the win32 device name
pdx->win32DeviceName.Buffer = (PWCHAR) ExAllocatePool(NonPagedPool,
win32DeviceName.MaximumLength);
if (!pdx->win32DeviceName.Buffer)
{ // can't allocate buffer
status = STATUS_INSUFFICIENT_RESOURCES;
KdPrint((DRIVERNAME " - Unable to allocate %d bytes for copy of name\n",
win32DeviceName.MaximumLength));
__leave;
} // can't allocate buffer
pdx->win32DeviceName.MaximumLength = win32DeviceName.MaximumLength;
RtlCopyUnicodeString(&pdx->win32DeviceName, &win32DeviceName);
status = IoCreateSymbolicLink( &pdx->win32DeviceName, &pdx->devname );
//status = IoCreateUnprotectedSymbolicLink( &pdx->win32DeviceName,
&pdx->devname );
if (!NT_SUCCESS(status)) // If we we couldn't create the link then
{ // abort installation.
KdPrint((DRIVERNAME " - IoCreateSymbolicLink failed\n"));
status = STATUS_INSUFFICIENT_RESOURCES;
__leave;
}
и не забыть упрать link при выгрузке:
status = IoDeleteSymbolicLink(&pdx->win32DeviceName);
if (!NT_SUCCESS(status)) // If we we couldn't create the link then
{ // abort installation.
KdPrint((DRIVERNAME " - IoDeleteSymbolicLink failed\n"));
}
RtlFreeUnicodeString(&pdx->win32DeviceName);
Генка
--- ifmail v.2.15
* Origin: FidoNet Online - http://www.fido-online.com (2:5020/175.2)