Prev Previous Post   Next Post Next
Old 21st May 2014, 08:28   #1
simplix
Junior Member
 
Join Date: May 2014
Posts: 22
Reading physical drive

Good day!

I'm trying to read a physical drive, but I get an error. Please tell me how to do it?

code:
;File Access Modes
!define GENERIC_READ 0x80000000
!define GENERIC_WRITE 0x40000000
;File Sharing Modes
!define FILE_SHARE_READ 0x00000001
!define FILE_SHARE_WRITE 0x00000002
;File Creation Flags
!define OPEN_EXISTING 3
!define INVALID_HANDLE_VALUE -1

Section Main

StrCpy $3 "\\?\PhysicalDrive0"
System::Call "kernel32::CreateFile(t r3, i ${GENERIC_READ}|${GENERIC_WRITE}, \
i ${FILE_SHARE_READ}|${FILE_SHARE_WRITE}, i 0, i ${OPEN_EXISTING}, i 0, i 0) i .r2"
${If} $2 != ${INVALID_HANDLE_VALUE}
System::Alloc 1
Pop $0

System::Call "kernel32::ReadFile (i r2, i r0, i 1, *i .r4, i 0) ?e"
Pop $5

System::Call "kernel32::GetLastError() i() .r1"
MessageBox MB_ICONINFORMATION|MB_OK "Return code: $5, Error code: $1"

System::Free $0
System::Call "kernel32::CloseHandle(i r2) i.r3"
${Else}
StrCpy $5 "Error: CreateFile failed for \\?\PhysicalDrive0"
${EndIf}

SectionEnd



ReadFile must return non-zero, but it returns 0 and GetLastError returns 80.

Thanks for your help!
simplix 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