Prev Previous Post   Next Post Next
Old 22nd May 2014, 12:55   #21
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
Quote:
RequestExecutionLevel admin
Section Main
!include LogicLib.nsh
!define GENERIC_READ 0x80000000
!define OPEN_EXISTING 3
!define FILE_SHARE_READ 0x00000001
!define FILE_SHARE_WRITE 0x00000002
!define INVALID_HANDLE_VALUE -1
StrCpy $3 "\\.\C:" ; Using "\\.\PhysicalDrive0" will succeed but it seems ReadFile only gives you a zero filled buffer?
System::Call "kernel32::CreateFile(t r3, i ${GENERIC_READ}, i ${FILE_SHARE_READ}|${FILE_SHARE_WRITE}, i 0, i ${OPEN_EXISTING}, i 0, i 0)i.r2 ?e"
Pop $5
${If} $2 <> ${INVALID_HANDLE_VALUE}
System::Call "kernel32::ReadFile(i r2, m.r0, i 512, *i.r4, i 0)i.r3 ?e" ; A read request < 512 bytes here will fail on my Win8 system
Pop $5
${If} $3 <> 0
DetailPrint "Read $4 bytes, ASCII-Data=$0|"
${Else}
DetailPrint "ReadFile failed: GetLastError=$5"
${EndIf}
System::Call "kernel32::CloseHandle(i r2)"
${Else}
DetailPrint "CreateFile failed: GetLastError=$5"
${EndIf}
SectionEnd
This gives me "...NTFS...".

Writing this type of low-level code with the system plugin is not a good idea, working with binary data or whatever you are reading is painful.

What are you really trying to do? Detect the filesystem type or something else?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
 
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump