-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows executable? #48
Comments
I made a 32 bit executable version that I used for testing decryption with this app off a Windows 7 box. Decrypted two drives without issue. The only bad news is that it will not to the best of my knowledge open Windows IO directly - //?/device/ - that means you have to image the drive onto a separate drive first (r-studio or any number of open source programs can do that), and then target the image. |
On Windows you will need to use forward slashes for those paths to work — that is, I can provide official binaries later. |
Thank you. I'll let people know about it. |
You may need to use
should list all the physical drives. I don't know, though; I don't have a physical Windows machine to test this on yet (once I back up my previous laptop's Linux partition I would, but IDK when that will happen). I wonder how I'm going to add knowledge of how to open drives on Windows to reallymine's documentation. |
Yeah I'd not known of the MS article but R-Studio indicates that under 'OS Object' so I tried that during initial testing. I brought it up to give another try, and clearly we're on the right track with that: I get the following errors, which would seem to indicate it can open the handle to the drive but is not able to properly read it as a block device.
I'll try a few things and see if I can get success... |
Heads up I verified I did put in two backslashes for \., I think the comment system wrote them out. |
So, I cracked out golang and my trusty old Delphi to compare. The following shows a working example in Delphi: I tried to write essentially the exact same thing in golang, and I seem to get the exact same error as reallymine gives: 'parameter is incorrect'. I looked over the source code for the windows system calls at https://golang.org/src/syscall/syscall_windows.go and I don't see anything wrong or different, no I'm really not certain why this wouldn't work. |
I guess we will have to see what |
As I say I traced it to syscall_windows.go which indicates syscall.open and syscall.read are just helper functions on syscall.CreateFile() and syscall.Readfile(). CreateFile() appears to work as expected, coming back with what appears to be an appropriate handle. readfile, however... Here's the definition of readfile in syscall - Here's the definition of readfile in Windows MSDN:
Note that the number of expressions differs - And here's what I did for a direct call attempt - tried different values for the 'done' value in case I could make it work:
Error occurs at Readfile(), which I'm guessing is not working the same way as it does in delphi. Again I'm no golang programmer, so I don't have a debugger or anything else that would let me solve this - maybe there's a better call than readFile.. What I can say is that reallymine uses an io.sectionreader, source available at https://golang.org/src/io/io.go. And the sectionreader reads with readat(), which uses pread(), which ends up using sysutils for io as well. |
io.SectionReader wraps an underlying io.ReaderAt. Everything should funnel down to a Your buffer in the Go program is 100 bytes. Try 2048 bytes like in your Delphi program? reallymine should already be using a multiple of 512 bytes, though, so... |
That's confirmed, changed line to just buffer := make([]byte, 512) and got the following:
I've confirmed the binary matches sec0 of the hard drive I specified. If I have the time I'll try going through the code for reallymine's hard disk IO and see if I can figure out what is causing the issue on that side with the same target input. If I get really adventurous I might rewrite the program in delphi or c++, as the copy speed on linux and windows is pretty abysmal at the moment. |
@m4sterful I'm working on improving the copy speed; see #38. That's correct; Windows seems to require disk access to be multiples of the sector size (judging from several random Stack Overflow questions I've seen in the past). But reallymine has always read 50MB at a time because it uses a sector count of 102400 so the buffers should always be 102400*512 bytes long (which is also equivalent to 12800*4096, so even those drives should work)... Unless there's some other limit I don't know about? |
error occurs on line 29 of disk.go, func Open(). filename is passed as a string and pushed to os.open(), then on 29 a call to OS.Seek(), which fails. It never gets to the point of the decryption loop, at that point you're still just attempting to find the size of the disk... |
I have confirmed that hacking a static value for realsize resolves the issue of opening a hard disk directly on Windows, that is, commenting out line 29 and setting realsize to the value of the hard disk size in bytes allowed it to continue and begin decryption successfully on a raw drive:
I'll figure out a windows safe way of figuring out the disk size later on. |
Hmmm. On Windows, Does s, err := f.Stat()
if err != nil {
return errfail(err)
}
realsize := s.Size() |
Unfortunately no, stat() comes back with a failure as it does not appear to have been made fully Windows compatible. I tried ricochet2200's go-disk-usage (https://github.com/ricochet2200/go-disk-usage) which is a cross-platform and had a few build issues unrelated to the software, but also I believe GetDiskFreeSpaceExW expects a folder rather than a physical drive name according to MSDN; that's how I've used it previously. Had to get back to paid work. I expect I can take another look later on tomorrow. The following stackoverflow document describes the method to get disk size in windows (ie that there is no existing cross-platform way in Golang and kernel32.dll's GetDiskFreeSpaceExW must be wrapped) |
What do you mean by |
stat() returned with an invalid file type error: in the windows implementation you can stat a file, not a drive. That's because it uses GetFileAttributesEx(), which does not support volumes, and clearly not raw drives (see https://golang.org/src/os/stat_windows.go line 78). From MSDN: |
I may have misunderstood, my understanding is that f.stat() works on linux to get the size of a drive as well as just files, does it not? If so, one might have the expectation of similar results on Windows via cross-compatibility, rather than this limitation. |
Yes, but that's because of how Unix and Windows evolved their concept of a file. Go could probably use |
@andlabs Do you think you could add a Windows exe file to the dowloads? I get a lot of requests for help from people who don't know how to use linux, and I send them here sometimes. I'd make one myself, but the newest version of Windows that I have is XP.
The text was updated successfully, but these errors were encountered: