阅读:1232回复:0
How to read info from a file in filter driver?
I just want to read some config infomation from my config file.
I put the code into driverentry and some place else,but the return value from ZwReadFile is always not success, what shoud I do? Are there any easy way to get info from file in filter driver? // RtlInitUnicodeString(&filename,L\"\\\\DosDevices\\\\C:\\\\config.dat\"); InitializeObjectAttributes( &attributes,&filename, OBJ_CASE_INSENSITIVE,NULL,NULL); status = ZwOpenFile(&hFile,FILE_READ_DATA,&attributes,&sb,FILE_SHARE_READ,FILE_NON_DIRECTORY_FILE); if (!NT_SUCCESS(status)) { ret = 0; goto OUTWAY; } buffer = ExAllocatePoolWithTag( NonPagedPool, buflen, FILESPY_POOL_TAG ); if (NULL == buffer){ ret = 0; goto OUTWAY; } status = ZwReadFile(hFile,NULL,NULL,NULL,&sb,buffer,buflen,NULL,NULL); if (!NT_SUCCESS(status)) { ret = 0; //always go here, why? how can I correct it? goto OUTWAY; } |
|