DLL中主要代码
-
- NTSTATUS WINAPI MyZwQueryDirectoryFile(DWORD RetAddr,
- __pfnZwQueryDirectoryFile pfnZwQueryDirectoryFile,
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass,
- IN BOOLEAN ReturnSingleEntry,
- IN PUNICODE_STRING FileName OPTIONAL,
- IN BOOLEAN RestartScan
- )
- {
- LONG rret = pfnZwQueryDirectoryFile(
- FileHandle,
- Event ,
- ApcRoutine ,
- ApcContext ,
- IoStatusBlock,
- FileInformation,
- Length,
- FileInformationClass,
- ReturnSingleEntry,
- FileName ,
- RestartScan
- );
- if (!NT_SUCCESS(rret)) {
- return rret;
- }
- switch(FileInformationClass){
- case FileBothDirectoryInformation:
- {
- PFILE_BOTH_DIR_INFORMATION pFileInfo;
- BOOLEAN flag;
- pFileInfo = (PFILE_BOTH_DIR_INFORMATION)FileInformation;
- do {
- flag = !( pFileInfo->NextEntryOffset );
- pFileInfo->FileAttributes &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM ); //去除隐藏,系统属性
- pFileInfo = (PFILE_BOTH_DIR_INFORMATION)((char *)pFileInfo + pFileInfo->NextEntryOffset);
- } while (!flag);
- }
- break;
- case FileIdBothDirectoryInformation:
- {
- PFILE_ID_BOTH_DIR_INFORMATION pFileInfo;
- BOOLEAN flag;
- pFileInfo = (PFILE_ID_BOTH_DIR_INFORMATION)FileInformation;
- do {
- flag = !( pFileInfo->NextEntryOffset );
- pFileInfo->FileAttributes &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM );
- pFileInfo = (PFILE_ID_BOTH_DIR_INFORMATION)((char *)pFileInfo + pFileInfo->NextEntryOffset);
- } while (!flag);
- }
- break;
- case FileNamesInformation:
- break;
- }
- return rret;
- }
复制代码 |