![]() |
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: ReadFile must return non-zero, but it returns 0 and GetLastError returns 80. Thanks for your help! |
You've used ?e for your ReadFile call which means $5 contains the last error code already. Calling GetLastError yourself will not return what you expect as something else since your System call (or even the System plug-in itself) will have either cleared or set the last error code. Use i .s on the end of your ReadFile call instead of ?e (or use i .r5 and remove the Pop $5).
Stu |
Afrow UK, thank you. If I replace it to next code:
code: When "$5" = "error". |
A physical drive is named: \\.\PhysicalDrive... (so a dot instead of questionmark)
And as you have to escape the backslash, use code: |
Remove the space after ReadFile and before the (.
Stu |
Quote:
Stu |
Thanks for help.
Quote:
|
I don't think this is possible any more:
http://support.microsoft.com/kb/942448 What exactly are you trying to do? Stu |
I'm trying read drive on WinXP, but function must work on any system. I think this KB does not matter, because there is considered newer systems. In addition exists utilities that successfully read and write drive on any system, but don't have all needed functions, which can be implemented independently.
Quote:
|
Quote:
Anyway, this is where I got the idea of escaping: http://forums.winamp.com/showpost.ph...41&postcount=2 It seems to have been working for f0rt |
Quote:
Stu |
Quote:
In order to access a disk directly on Vista and above it looks like you will need to be running as LOCAL SYSTEM, e.g. as a Windows service (or you can use PsExec). Stu |
Quote:
Quote:
Thank you all for your help, it is very valuable. |
Does it work on XP but not on 7? Or does it work on neither?
This is the my code (ReadFile fails with 87 - invalid parameter). Stucode: |
|
I found new exemple here and ReadFile works fine with files, but then I adapted this code to read drive - ReadFile fails.
|
Quote:
Stu |
System::Call "kernel32::ReadFile(i r2, t .r0, i 32, i .r4, i 0) ?e" should probably be *i.r4.
|
Quote:
Stu |
I found working code in C here (Posted by nullptr: 09 January 2011 at 11:20am), which compiled in RAD Studio and successfully works even on Win7 x64. But still do not understand why it does not work in NSIS.
|
Quote:
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? |
Anders, thank you very much. The problem was that my request is less 512 bytes.
Quote:
|
Well, I think it would be much better to write a plugin, I don't see how all that system::call code is going to be manageable when the codebase gets larger...
|
Personally for me, much better to use WinAPI, because I do not know C, and any changes I make in the code immediately, without waiting for the author of the plugin.
|
IMHO you basically have to understand C and the WinAPI to really use the system plugin. You have to be able to transform the function declarations listed on MSDN or in a .h file and convert it to system syntax and you have to understand how C strings work and how pointers work if you are going to be reading anything other than strings from a text file.
Messing with the MBR is not something most people should be doing and certainly not if you don't have a basic understanding of C and it's structure layout/padding semantics and how it differs from the system plugin struct syntax. Also, as you have seen, reading from a disk at this low level might have alignment and/or buffer restrictions, you cannot just treat it as a normal file. I personally would not trust a MBR tool if I knew it was written in NSIS. |
| All times are GMT. The time now is 17:18. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.