USB Safely Remove Can't Stop SATA Drive in Mobile Tray

mysteryman
Posts: 17
Joined: Dec 31st, 2007, 8:33 am

Post by mysteryman »

After the program stopped crashing (thanks igor) I was able to test if the device stopping worked on "unsupported" sata devices.

When I told them to stop, the window popped up saying "trying to stop USB Devices" (that should probably say "Trying to stop Device(s)" ... since its capable of more than usb now.

Anyway, once the window popped up, it just sat there. The program was not "unresponsive" persay, because I could still cancel it at any time. However, it WAS stuck in some very long retry loop. Upon a closer look at the log, it appears that it was a permission problem.

First off, you should be able to detect if permission is denied, and give a warning. Secondly, I found you a couple documents about how to code your app to invoke admin level access temporarilly.

1. http://developersoven.blogspot.com/2007 ... -part.html
2. http://pascalfonteneau.developpez.com/a ... Delphi.pdf

Basicly, you need to execute one section of your program in a separate dll/exe (i didn't read it thouroughly) and when that dll/exe is called in a certian way, it will call the UAC box. It may be possible to call your own exe file again, but it looked like it was a compiled in option, so second exe/dll may be required.

here is the exact error:

Code: Select all

12.07.2008 15:24:44:020   --------------------------------------------------------
New exception:
Delphi exception, type Exception, message: Os Error: 5 (Access is denied)
Exception code: 250477278
Exception flags: 3
Number of parameters: 7
(no debug info) Find error: 75FE42EB
call stack - 0 : (no debug info) Find error: 0052B8CF
call stack - 1 : (no debug info) Find error: 0052E270
call stack - 2 : (no debug info) Find error: 0052D138
call stack - 3 : (no debug info) Find error: 0052D2D3
call stack - 4 : (no debug info) Find error: 00532734
call stack - 5 : (no debug info) Find error: 00429C55
call stack - 6 : (no debug info) Find error: 004052FE
call stack - 7 : (no debug info) Find error: 75FE490D
call stack - 8 : (no debug info) Find error: 76F8E4B2
call stack - 9 : (no debug info) Find error: 76F8E485
call stack - 10 : (no debug info) Find error: FFFFFFFC
I also saw a great number of these, every couple of seconds

Code: Select all

12.07.2008 15:24:44:019   --------------------------------------------------------
New exception:
Exception code: 2460516
Exception flags: 1677721600
Number of parameters: 1360477
(no debug info) Find error: E58B0000
As a side note, running as administrator (though not ideal) DOES allow you to eject sata devices on unsupported drives. One question though... it appears that you are "disabling" the device. This causes windows to remember that the device is disabled. When you insert the drive again, it is still disabled.

You have made up for that with a routine that will re-enable certian drives that have been previously ejected. When the drive is reinserted, the program says the device is "returned" at this time the program "re-enables it" ... was it not possible to do the "uninstall" option? if it was, it would be one less step to potentially cause problems. (see later)

Imagine that re-enable routine not activating, and some angry user gets on the forum, or emails you threatening to sue, because his drive has been "broken" by your software... yes, it is VERY easily fixed (by re-enabling in device manager) ... but the angry user doesn't know that.

At very least you should add a comment about re-enabling in device manager if anything goes wrong to the initial warning about stopping an unsupported device.

Speaking of, sorry for making this really long, but I just found one such bug in the re-enable routine. It sametimes does not remember it re-enabled the drive. I just ejected the same device twice (eject, power down, insert, eject) and it reenabled it instantly... before I had a chance to power it down. This may be due to the failed ejects made earlier as that did not have permissions. I tried it once or twice more, and it seemed to function correctly.
Last edited by mysteryman on Jul 19th, 2008, 6:40 am, edited 1 time in total.
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Post by Igor »

Hi Mysteryman,
Thanks a lot for so detailed feedback!


mysteryman wrote:After the program started crashing (thanks igor)
Did you mean "stopped crashing"? :)
[/quote]
mysteryman wrote:
Anyway, once the window popped up, it just sat there. The program was not "unresponsive" persay, because I could still cancel it at any time. However, it WAS stuck in some very long retry loop. Upon a closer look at the log, it appears that it was a permission problem.

First off, you should be able to detect if permission is denied, and give a warning. Secondly, I found you a couple documents about how to code your app to invoke admin level access temporarilly.
Yes, current version of USB Safely Remove doesn't support UAC. Thanks a lot for your recommendations, we will add UAC support in the final version.

mysteryman wrote: Imagine that re-enable routine not activating, and some angry user gets on the forum, or emails you threatening to sue, because his drive has been "broken" by your software... yes, it is VERY easily fixed (by re-enabling in device manager) ... but the angry user doesn't know that.
At very least you should add a comment about re-enabling in device manager if anything goes wrong to the initial warning about stopping an unsupported device.
We'd prefer to not overload a user with extra information. So if this case happen the user has 2 choices: 1) He just will see that the device is still in disabled state and he will click to the device so that he can re-enable it.
2) (The preferred way for us) He will start emailing us, post messages at the forum and etc. Then we will get a bug-report from him and fix this bug.
mysteryman wrote: Speaking of, sorry for making this really long, but I just found one such bug in the re-enable routine. It sametimes does not remember it re-enabled the drive. I just ejected the same device twice (eject, power down, insert, eject) and it reenabled it instantly... before I had a chance to power it down. This may be due to the failed ejects made earlier as that did not have permissions. I tried it once or twice more, and it seemed to function correctly.
Can you describe your sequence of actions a little bit more detailed, please? I didn't understand enough what does "eject" action mean. Is it our "stop" device ability?
mysteryman
Posts: 17
Joined: Dec 31st, 2007, 8:33 am

Post by mysteryman »

Oops on the "started crashing" part...musta been tired. :) Yes, when I said eject I meant the stop (disable) routine in the program. I will also mean the disable routine throughout this post when I say eject.

I will try to describe what I did that time to reproduce it, but I only had it happen once, so I will do some further testing in the next couple days to re-verify the bug. It was a lot of work making it work last time, and I didn't want to solve two bugs that night, so I just wrote down what I thought I did. :)

If it happened the way I remember (for the reasons I remember) that would most likely mean that you store a list of drives that need to be restored... somewhere. This list of drives is most likely not checked for duplicates.

The first couple times I was trying the eject feature, I was running as a standard user, and it would not work. I believe it was adding the drive to the list before it is confirmed as disabled. When I later ran the eject feature as administrator, It added the successful drive (the same one) to the list a second time. This created two duplicate entries on the list.

Upon reinsertion, it cleared one off of that list. Then when I ejected (disabled in program) it, the duplicate was still on this list. The program decided it should re-insert it again.

Anyway, that is a theory, I will try it again in that way, and see if it does it again, and if it doesn't I will try to find a way to force it to do it wrong... then tell you how I did it.

I like breaking things... :)
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Post by Igor »

mysteryman wrote:Oops on the "started crashing" part...musta been tired. :) Yes, when I said eject I meant the stop (disable) routine in the program. I will also mean the disable routine throughout this post when I say eject.

Anyway, that is a theory, I will try it again in that way, and see if it does it again, and if it doesn't I will try to find a way to force it to do it wrong... then tell you how I did it.
Thanks a lot for your comment! Yes, please inform me if you reproduce this bug. And of course it would be appreciated if you tell me the steps to reproduce it.
I like breaking things... :)
It seems that you are a programmer, aren't you? :)
mysteryman
Posts: 17
Joined: Dec 31st, 2007, 8:33 am

Post by mysteryman »

Not really a programmer, mostly because I rarely take the time to finish a programming project... but I have learned most the basics of a few languages, and do some pretty advanced bash/tcl/bat scripts from time to time :)

I'll let you know when I get a few minutes to test it out.
LNH
Posts: 5
Joined: May 1st, 2008, 2:56 pm

Post by LNH »

I also got caught by the drive being disabled, and initially panicked. But then thought to go to device manager and see what was happening.

For what it's worth, for now I'm using a freeware utility that allows me to safely remove my external SATA drives. I don't know how it works, but it doesn't seem to disable the drive as a way of making it safe to remove. It's only a command line you run from a command prompt (I've set it up with a desktop shortcut to a batch file) and the software isn't running when you initially startup the drive. It might be worth looking at how this programmer solved the problem. The website for the utility is: http://www.uwe-sieber.de/drivetools_e.html#RemoveDrive

He has a programmers discussion of the problem at:
http://www.codeproject.com/KB/system/Re ... etter.aspx
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Post by Igor »

LNH wrote:I also got caught by the drive being disabled, and initially panicked. But then thought to go to device manager and see what was happening.

For what it's worth, for now I'm using a freeware utility that allows me to safely remove my external SATA drives. I don't know how it works, but it doesn't seem to disable the drive as a way of making it safe to remove. It's only a command line you run from a command prompt (I've set it up with a desktop shortcut to a batch file) and the software isn't running when you initially startup the drive. It might be worth looking at how this programmer solved the problem. The website for the utility is: http://www.uwe-sieber.de/drivetools_e.html#RemoveDrive

He has a programmers discussion of the problem at:
http://www.codeproject.com/KB/system/Re ... etter.aspx
LNH, thanks for the links! And sorry for the long response!

Some SATA drives allows to be disconnected via "safe removal" as well as USB devices. AFAIK this tool uses safe removal and nothing else.

Am I understand right that you can disconnect your SATA device only with RemoveDrive tool? Neither USB Safely Remove, nor native Windows tool let you see\stop your drive?
LNH
Posts: 5
Joined: May 1st, 2008, 2:56 pm

Post by LNH »

Igor,

I can disconnect my sata drives by using the RemoveDrive tool mentioned in the previous note. The beta of SafelyRemove also worked but via a stopping and removing the drive (e.g. similar to Device Manager). The Windows built-in Safely Remove Hardware utility does not list my SATA drives so it doesn't work.

I don't know if it's a coincidence or not, but after removing the SafelyRemove beta, my system no longer sees and mounts my compact flash reader. No icons for the reader show up on "My Computer". It doesn't matter if a CF card is in the reader or not. When I plugged in another reader I have (different brand) it sees it just fine.
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Post by Igor »

LNH wrote: I can disconnect my sata drives by using the RemoveDrive tool mentioned in the previous note. The beta of SafelyRemove also worked but via a stopping and removing the drive (e.g. similar to Device Manager). The Windows built-in Safely Remove Hardware utility does not list my SATA drives so it doesn't work.
LNH, thanks for the information!
LNH wrote: I don't know if it's a coincidence or not, but after removing the SafelyRemove beta, my system no longer sees and mounts my compact flash reader. No icons for the reader show up on "My Computer". It doesn't matter if a CF card is in the reader or not. When I plugged in another reader I have (different brand) it sees it just fine.
One of the previous beta-versions (4.0.4.690 - 691) hasn't uninstall itself properly. Please try to download the beta 6, install it and just uninstall it.

Please let me know if it helps or not.
Post Reply