2,643
社区成员
发帖
与我相关
我的任务
分享
#include <ntddk.h>
#include <ntstrsafe.h>
#define SERIAL_MAX_COUNT 32
void GetSerialDev(ULONG id,PDEVICE_OBJECT *device)
{
WCHAR szName[32]={0};
UNICODE_STRING usName;
NTSTATUS status;
PFILE_OBJECT fileobj=NULL;
//PDEVICE_OBJECT dveobj=NULL;
RtlStringCchPrintfW(szName,32,L"\\Device\\Serial%d",id);
RtlInitUnicodeString(&usName,szName);
status = IoGetDeviceObjectPointer(&usName,FILE_ALL_ACCESS,&fileobj,device);
if(status == STATUS_SUCCESS)
{
ObDereferenceObject(fileobj);
}
}
void DriverUnload(PDRIVER_OBJECT driver)
{
}
NTSTATUS DriverEntry(PDRIVER_OBJECT driver,PUNICODE_STRING reg_path)
{
PDEVICE_OBJECT devobjs[SERIAL_MAX_COUNT] = {0};
ULONG i = 0;
#if DBG
_asm int 3
#endif
for (i=0;i<SERIAL_MAX_COUNT;i++)
{
GetSerialDev(i,&devobjs[i]);
}
driver->DriverUnload = DriverUnload;
return STATUS_SUCCESS;
}