- Can I programmatically roll back a driver?
- Posted by Michael on June 27th, 2006
Can I programmatically roll back a driver?
tks,
MH
- Posted by Eliyas Yakub [MSFT] on June 28th, 2006
When I last checked couple of years ago, there wasn't any API to do that.
I'm going to check to see if anything new got added to Vista.
If you know the INF used for the previous package then you can do an
UpdateDriverForPlugAndPlayDevice specifiying that inf.
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/driver/tips/default.mspx
- Posted by Eliyas Yakub [MSFT] on June 28th, 2006
On Vista, the newdev.dll which exports UpdateDriverForPlugAndPlayDevices
contains a new function called DiRollbackDriver that you can use to
rollback.
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/driver/tips/default.mspx
- Posted by Michael on June 28th, 2006
Eliyas,
thanks a lot, I'll have a look at it 
MH
"Eliyas Yakub [MSFT]" <eliyasy@online.microsoft.com> wrote in message
news:eai2zSumGHA.1596@TK2MSFTNGP04.phx.gbl...
- Posted by Michael on July 14th, 2006
Eliyas,
Is this only available via unmanaged code? I'm working in C#.
Thanks,
Michael
"Michael" <mhugh@domain.com> wrote in message
news:%23R$FQDvmGHA.4836@TK2MSFTNGP05.phx.gbl...
- Posted by Eliyas Yakub [MSFT] on July 14th, 2006
Yes.
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/driver/tips/default.mspx
- Posted by on July 14th, 2006
SetupDI is fairly easy to access through PInvoke though.
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Eliyas Yakub [MSFT]" <eliyasy@online.microsoft.com> wrote in message
news:uW11dSupGHA.1592@TK2MSFTNGP04.phx.gbl...
- Posted by Gary G. Little on July 14th, 2006
I can agree with that, having spent many weeks wallowing in a manged stye.
--
The personal opinion of
Gary G. Little
<peterwie@online.microsoft.com> wrote in message
news:%23UsBA12pGHA.2148@TK2MSFTNGP03.phx.gbl...
- Posted by Michael on July 20th, 2006
*<peterwie@online.microsoft.com> wrote
* SetupDI is fairly easy to access through PInvoke though.
*
Does this SetupDi allow for rolling back drivers ?
-MH
- Posted by Michael on July 20th, 2006
* "Michael" <mhugh@domain.com> wrote
* *<peterwie@online.microsoft.com> wrote
* * SetupDI is fairly easy to access through PInvoke though.
* *
*
* Does this SetupDi allow for rolling back drivers ?
*
*
* -MH
*
Oh, and also can any of you point me in the right direction for
disabling/enabling a device using managed code (C#) ??
Thanks,
MH
- Posted by on July 20th, 2006
I believe there's an API in Vista for doing this - DiRollbackDriver exposed
by newdev.dll & prototyped in newdev.h.
BOOL
DiRollbackDriver(
__in HDEVINFO DeviceInfoSet,
__in PSP_DEVINFO_DATA DeviceInfoData,
__in_opt HWND hwndParent,
__in DWORD Flags,
__out_opt PBOOL NeedReboot
);
Downlevel there's no good way. Quoth one of our SetupDi folks: "the logic
is hardcoded into device manager and the data about the last driver is
stored in undocumented places".
-p
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michael" <mhugh@domain.com> wrote in message
news:ORgkGJ5qGHA.4684@TK2MSFTNGP05.phx.gbl...
- Posted by Michael on July 21st, 2006
* <peterwie@online.microsoft.com> scribed
* I believe there's an API in Vista for doing this - DiRollbackDriver
exposed
* by newdev.dll & prototyped in newdev.h.
*
* BOOL
* DiRollbackDriver(
* __in HDEVINFO DeviceInfoSet,
* __in PSP_DEVINFO_DATA DeviceInfoData,
* __in_opt HWND hwndParent,
* __in DWORD Flags,
* __out_opt PBOOL NeedReboot
* );
*
*
* Downlevel there's no good way. Quoth one of our SetupDi folks: "the logic
* is hardcoded into device manager and the data about the last driver is
* stored in undocumented places".
*
* -p
*
* --
* Please do not send e-mail directly to this alias. this alias is for
* newsgroup purposes only.
* This posting is provided "AS IS" with no warranties, and confers no
rights.
*
Peter,
Do you have any experience in using the setupapi functions in managed code?
I ran by some code you wrote while searching SetupDi* within our source
indexer earlier today
..
-MH
- Posted by Gary G. Little on July 21st, 2006
Use the SetupDi via P/Invoke.
--
The personal opinion of
Gary G. Little
"Michael" <mhugh@domain.com> wrote in message
news:%23ktlcR5qGHA.2440@TK2MSFTNGP03.phx.gbl...
- Posted by on July 21st, 2006
I've done it before as a Sunday project. It was quite a while ago though.
What i remember is that it's pretty straightforward - if you define structs
in c# for things like SP_DEVINFO_DATA, use the marshalling functions to fill
in the cbSize field in all the structures and use INTPTR for handles like
HDEVINFO you're okay. Handling the functions that return PVOID or PBYTE
takes more swizzling but also can be done.
the nice thing about SetupDi is that it doesn't hold onto any of the
pointers you give it outside of the single function call, so you don't need
to worry so much about pinning buffers.
I was able to write a program which listed out all of the CDROMs in the
computer (the first part of a project I abandoned) before i stopped. After
that invoking rollback shouldn't be too bad.
Good luck.
-p
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michael" <mhugh@domain.com> wrote in message
news:ev7luOGrGHA.4932@TK2MSFTNGP05.phx.gbl...
- Posted by Michael on July 21st, 2006
**** <peterwie@online.microsoft.com> wrote
**** SetupDI is fairly easy to access through PInvoke though.
****
****
*** "Michael" <mhugh@domain.com> wrote in message
***
*** Does this SetupDi allow for rolling back drivers ?
***
***
** * -MH
***
***
** Oh, and also can any of you point me in the right direction for
** disabling/enabling a device using managed code (C#) ??
**
** Thanks,
** MH
**
* "Gary G. Little" <gary.g.little@seagate.com> wrote
* Use the SetupDi via P/Invoke.
*
* --
* The personal opinion of
* Gary G. Little
*
Gary, I'm not a P/Invoke wizard so I ask, does this look
appropriate/correct?
internal struct SP_DEVINFO_DATA
{
internal uint cbSize;
internal Guid ClassGuid;
internal uint DevInst;
internal IntPtr Reserved;
}
[DllImport("setupapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
private static extern bool SetupDiCallClassInstaller(
[In] uint InstallFunction,
[In] IntPtr DeviceInfoSet,
[In] ref SP_DEVINFO_DATA DeviceInfoData
);
Thanks
MH
- Posted by Michael on July 21st, 2006
....
<editted>
....
* <peterwie@online.microsoft.com> wrote in message> I've done it before as a
Sunday project. It was quite a while ago though.
*
* What i remember is that it's pretty straightforward - if you define
structs
* in c# for things like SP_DEVINFO_DATA, use the marshalling functions to
fill
* in the cbSize field in all the structures and use INTPTR for handles like
* HDEVINFO you're okay. Handling the functions that return PVOID or PBYTE
* takes more swizzling but also can be done.
*
* the nice thing about SetupDi is that it doesn't hold onto any of the
* pointers you give it outside of the single function call, so you don't
need
* to worry so much about pinning buffers.
*
* I was able to write a program which listed out all of the CDROMs in the
* computer (the first part of a project I abandoned) before i stopped.
After
* that invoking rollback shouldn't be too bad.
*
* Good luck.
*
* -p
*
* --
* Please do not send e-mail directly to this alias. this alias is for
* newsgroup purposes only.
*This posting is provided "AS IS" with no warranties, and confers no rights.
*
*
Peter,
Thanks for the insight, I'll continue plugging away at this.
-MH
- Posted by Gary G. Little on July 24th, 2006
Does it compile? I'm not familiar with "internal" but from a desk-check
perspective it looks fine to me. I'd wrap the whole thing with :
namespace MyWrapper
I went on to define a class, which the docs recommend, that I used to
reference the invoked funtionality.
--
The personal opinion of
Gary G. Little
"Michael" <mhugh@domain.com> wrote in message
news:uyjsQRRrGHA.2256@TK2MSFTNGP03.phx.gbl...