Skip to content
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

is there a way to open disk devices in windows? #224

Open
whitequill opened this issue Jun 27, 2024 · 5 comments
Open

is there a way to open disk devices in windows? #224

whitequill opened this issue Jun 27, 2024 · 5 comments

Comments

@whitequill
Copy link

I was trying to open a device in hexyl with hexyl.exe \\?\Volume{0893efeb-32d9-46d8-bc15-34d18c0e669a}\
does it not have this functionality yet?
this is the error that I get in cmd:
Error: The system cannot find the path specified. (os error 3)

I am using Administrator.

@sharkdp
Copy link
Owner

sharkdp commented Jun 30, 2024

I was trying to open a device in hexyl with hexyl.exe \\?\Volume{0893efeb-32d9-46d8-bc15-34d18c0e669a}\
does it not have this functionality yet?

I'm not a Windows expert, so I don't really know what you expect this to do. Can other tools open this exact path?

@whitequill
Copy link
Author

I want to open a device like I would open hexyl /dev/hde1 on Linux.

@sharkdp
Copy link
Owner

sharkdp commented Jul 3, 2024

Can other tools open this exact path?

@sharifhsn
Copy link
Contributor

sharifhsn commented Jul 3, 2024

Checking Windows's own more utility, it returns the same error: The system cannot find the path specified.

This Stack Exchange thread gives more detail on why, but suffice it to say that unlike in Unix-like operating systems, Windows does not just let you access volumes/drives just like you can a file. I did some digging into the Windows file access methods and found that CreateFileW should allow you to access a drive as a file. The winsafe library provides a safe wrapper for this method through its own File::open method. Note that this File uses its own read which wraps ReadFile and does not implement std::io::Read, so in order for this to be implemented into hexyl one would have to create a wrapper struct for it and implement Read on it, in addition to writing logic that would recognize the file path as a drive and handle it as a special case.

EDIT: After some more research, I found the FileMapped struct which will open the drive as a [u8], which does implement Read. The only implementation details left would be handling the path and adding it as an additional variant of Input.

My access to Windows is limited and I would not be able to test this implementation, so I would not be able to contribute to it. However, @whitequill, if you're interested in getting this to work, I've provided all the necessary details here to implement this yourself.

@whitequill
Copy link
Author

I will give this some thought. As I need to look at the current hexyl code base and the Microsoft documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants