SHARE
TWEET

Untitled

a guest Jan 2nd, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _WIN32_WINNT &h0602
  2.  
  3. #include "crt.bi"
  4. #include "windows.bi"
  5. #include "win\wintern2.bi"
  6.  
  7. #define Fatal() sleep:system
  8. #define DEBUG_MsgTrace printf
  9.  
  10. #if 1 'ndef GetFileInformationByHandleEx
  11.   #define P1 hFile                as HANDLE
  12.   #define P2 FileInformationClass as FILE_INFO_BY_HANDLE_CLASS
  13.   #define P3 lpFileInformation    as LPVOID
  14.   #define P4 dwBufferSize         as DWORD
  15.   function GetFileInformationByHandleEx2(P1, P2, P3, P4) as BOOL export
  16.     dim status as NTSTATUS
  17.     dim io as IO_STATUS_BLOCK
  18.  
  19.     #define CASE_NOTIMPL _
  20.     FileStreamInfo, FileCompressionInfo, FileAttributeTagInfo, _
  21.     FileRemoteProtocolInfo, FileFullDirectoryInfo, FileFullDirectoryRestartInfo, _
  22.     FileStorageInfo, FileAlignmentInfo, FileIdExtdDirectoryInfo, _
  23.     FileIdExtdDirectoryRestartInfo
  24.    
  25.     #define CASE_BADPARAM _
  26.     FileRenameInfo, FileDispositionInfo, FileAllocationInfo, _
  27.     FileIoPriorityHintInfo, FileEndOfFileInfo, else
  28.    
  29.     select case as const FileInformationClass
  30.       case CASE_NOTIMPL
  31.         DEBUG_MsgTrace("%p, %u, %p, %u\n", hFile, FileInformationClass, lpFileInformation, dwBufferSize )
  32.         SetLastError(ERROR_CALL_NOT_IMPLEMENTED)
  33.         return FALSE
  34.       case FileBasicInfo
  35.         status = NtQueryInformationFile(hFile, @io, lpFileInformation, dwBufferSize, FileBasicInformation)
  36.       case FileStandardInfo
  37.         status = NtQueryInformationFile(hFile, @io, lpFileInformation, dwBufferSize, FileStandardInformation)
  38.       case FileNameInfo
  39.         status = NtQueryInformationFile(hFile, @io, lpFileInformation, dwBufferSize, FileNameInformation)
  40.       case FileIdInfo
  41.         status = NtQueryInformationFile(hFile, @io, lpFileInformation, dwBufferSize, FileIdInformation)
  42.       case FileIdBothDirectoryRestartInfo, FileIdBothDirectoryInfo
  43.         status = NtQueryDirectoryFile(hFile, NULL, NULL, NULL, @io, lpFileInformation, dwBufferSize, FileIdBothDirectoryInformation, FALSE, NULL, (FileInformationClass = FileIdBothDirectoryRestartInfo))
  44.       case else 'CASE_BADPARAM
  45.         SetLastError(ERROR_INVALID_PARAMETER)
  46.         return FALSE
  47.     end select
  48.  
  49.     if status <> STATUS_SUCCESS then
  50.       SetLastError(RtlNtStatusToDosError(status))
  51.       return FALSE
  52.     end if
  53.     return TRUE
  54.   end function
  55. #endif
  56.  
  57. dim as HANDLE hPipeRead,hPipeWrite
  58. dim as SECURITY_ATTRIBUTES tAttr = (sizeof(SECURITY_ATTRIBUTES),NULL,TRUE)
  59. if CreatePipe( @hPipeRead , @hPipeWrite , @tAttr , 0 ) = FALSE then
  60.   puts("Failed to create pipe!")
  61.   Fatal()
  62. end if
  63.  
  64. 'var hFile = CreateFile("hardwareview.bas",0,0,0,OPEN_EXISTING,0,0)
  65. 'print hFile,hPipeWrite
  66.  
  67. dim as wstring*MAX_PATH wBuff
  68. print GetFileInformationByHandleEx2( hPipeWrite , FileNameInfo , @wBuff , sizeof(wBuff) )
  69. var pTemp = cptr( FILE_NAME_INFORMATION ptr , @wBuff )
  70. with *pTemp
  71.   print "["+.FileName+"]"
  72. end with
  73. sleep
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top