Hi,

I'm using EnumDeviceDrivers API to enumerate all loaded drivers, all working
fine in a 64-bit application, but when I'm using same code in a 32-bit
application I'm always getting the same result: the return value is 0 and
last error result is 0x08.

Anyone can help in order to make it work this API in a 32-bit application ?

RE: EnumDeviceDrivers issue on 64-bit platform by resqware

resqware
Tue Jun 12 18:17:00 CDT 2007

Robert,

I have seen the function return both zero and non-zero when the buffer was
not large enough. I believe it is a bug in the API which is behaving
differently from the other device manager functions. The best thing to do is
work around the bug by always determining the buffer size in advance by
calling the function with NULL for the buffer pointer and zero for size. Here
is a sample similar to what I use for both 32 and 64 bit usage.

void DumpDrivers()
{
DWORD cbNeeded = 0;

BOOL bRet = EnumDeviceDrivers( NULL, 0, &cbNeeded);
if ( bRet || GetLastError() == ERROR_NOT_ENOUGH_MEMORY ) {

int cDrivers = cbNeeded/sizeof(LPVOID);
LPVOID *drivers = new LPVOID[ cDrivers ];
TCHAR szDriver[ NAME_LEN ];

DWORD cbReturned;
if( EnumDeviceDrivers( drivers, cbNeeded, &cbReturned) )
{
_tprintf(TEXT("There are %d drivers:\n"), cDrivers);
for (int i=0; i < cDrivers; i++ )
{
if(GetDeviceDriverBaseName(drivers[i], szDriver, NAME_LEN) )
_tprintf(TEXT("%d: %s\n"), i+1, szDriver);
}
}
else {
_tprintf(TEXT("EnumDeviceDrivers failed, error = %d; array size
needed is %d\n"), GetLastError(), cDrivers);
}
delete [] drivers;
}
else {
_tprintf(TEXT("EnumDeviceDrivers failed, error = %d\n"), GetLastError()
);
}
}


--
John Hensley
www.resqware.com


"Robert Bacs" wrote:

> Hi,
>
> I'm using EnumDeviceDrivers API to enumerate all loaded drivers, all working
> fine in a 64-bit application, but when I'm using same code in a 32-bit
> application I'm always getting the same result: the return value is 0 and
> last error result is 0x08.
>
> Anyone can help in order to make it work this API in a 32-bit application ?

Re: EnumDeviceDrivers issue on 64-bit platform by boby

boby
Mon Jun 18 09:37:47 CDT 2007


Thanks,

I already tired this solution, but it didn't worked, I can send you a
test application.
It works only when I create an x64 executable.

Best regards,
Boby


Re: EnumDeviceDrivers issue on 64-bit platform by resqware

resqware
Mon Jun 18 10:01:00 CDT 2007

You can send it to me at john AT resqware DOT com.

--
John Hensley
www.resqware.com


"boby" wrote:

>
> Thanks,
>
> I already tired this solution, but it didn't worked, I can send you a
> test application.
> It works only when I create an x64 executable.
>
> Best regards,
> Boby
>
>

Re: EnumDeviceDrivers issue on 64-bit platform by boby

boby
Mon Jun 18 10:18:48 CDT 2007


You can download a test project from the following link:

http://codeguru.earthweb.com/forum/showthread.php?p=1589583#post1589583


Re: EnumDeviceDrivers issue on 64-bit platform by resqware

resqware
Mon Jun 18 13:06:00 CDT 2007

I built the project for Win32 and EnumDeviceDrivers() is returning 1 on the 2
XP x32 and 1 Vista x32 machine that I ran it on. Here is a sample of output
displayed in the result dialog on one of the machines.

Size needed=668, result=1, lastError=0x0

Have you seen EnumDeviceDrivers() return 0 on more than one machine? When
the function returns 0 what is it returning in dwSizeNeeded?

--
John Hensley
www.resqware.com


"boby" wrote:

>
> You can download a test project from the following link:
>
> http://codeguru.earthweb.com/forum/showthread.php?p=1589583#post1589583
>
>

Re: EnumDeviceDrivers issue on 64-bit platform by boby

boby
Tue Jun 19 08:28:23 CDT 2007

Can you please try it on XP x64 ?

On x32 this function is working fine :), on x64 only in a 64-bit
application, when I'm using it in a 32-bit application it returns 0
and it sets dwSizeNeeded to 0.

Thanks for your help !

Best regards,
Boby

John Hensley a scris:
> I built the project for Win32 and EnumDeviceDrivers() is returning 1 on the 2
> XP x32 and 1 Vista x32 machine that I ran it on. Here is a sample of output
> displayed in the result dialog on one of the machines.
>
> Size needed=668, result=1, lastError=0x0
>
> Have you seen EnumDeviceDrivers() return 0 on more than one machine? When
> the function returns 0 what is it returning in dwSizeNeeded?
>
> --
> John Hensley
> www.resqware.com
>
>
> "boby" wrote:
>
> >
> > You can download a test project from the following link:
> >
> > http://codeguru.earthweb.com/forum/showthread.php?p=1589583#post1589583
> >
> >


Re: EnumDeviceDrivers issue on 64-bit platform by resqware

resqware
Tue Jun 19 13:01:05 CDT 2007

Here is the result when I build the app for 32 bits and run the 32 bit app on
a Vista x64 machine.

Size needed=516, result=1, lastError=0x0


I don't have an XP x64 system available so I can't try it on that platform.

--
John Hensley
www.resqware.com


"boby" wrote:

> Can you please try it on XP x64 ?
>
> On x32 this function is working fine :), on x64 only in a 64-bit
> application, when I'm using it in a 32-bit application it returns 0
> and it sets dwSizeNeeded to 0.
>
> Thanks for your help !
>
> Best regards,
> Boby
>
> John Hensley a scris:
> > I built the project for Win32 and EnumDeviceDrivers() is returning 1 on the 2
> > XP x32 and 1 Vista x32 machine that I ran it on. Here is a sample of output
> > displayed in the result dialog on one of the machines.
> >
> > Size needed=668, result=1, lastError=0x0
> >
> > Have you seen EnumDeviceDrivers() return 0 on more than one machine? When
> > the function returns 0 what is it returning in dwSizeNeeded?
> >
> > --
> > John Hensley
> > www.resqware.com
> >
> >
> > "boby" wrote:
> >
> > >
> > > You can download a test project from the following link:
> > >
> > > http://codeguru.earthweb.com/forum/showthread.php?p=1589583#post1589583
> > >
> > >
>
>

Re: EnumDeviceDrivers issue on 64-bit platform by boby

boby
Wed Jun 20 12:14:18 CDT 2007


yes indeed I've just tested on Vista x64 and it's working fine, so I
guess there is a bug on XP x64.

Thanks for your help !

Best regards,
Boby

John Hensley a scris:
> Here is the result when I build the app for 32 bits and run the 32 bit app on
> a Vista x64 machine.
>
> Size needed=516, result=1, lastError=0x0
>
>
> I don't have an XP x64 system available so I can't try it on that platform.
>
> --
> John Hensley
> www.resqware.com
>
>
> "boby" wrote:
>
> > Can you please try it on XP x64 ?
> >
> > On x32 this function is working fine :), on x64 only in a 64-bit
> > application, when I'm using it in a 32-bit application it returns 0
> > and it sets dwSizeNeeded to 0.
> >
> > Thanks for your help !
> >
> > Best regards,
> > Boby
> >
> > John Hensley a scris:
> > > I built the project for Win32 and EnumDeviceDrivers() is returning 1 on the 2
> > > XP x32 and 1 Vista x32 machine that I ran it on. Here is a sample of output
> > > displayed in the result dialog on one of the machines.
> > >
> > > Size needed=668, result=1, lastError=0x0
> > >
> > > Have you seen EnumDeviceDrivers() return 0 on more than one machine? When
> > > the function returns 0 what is it returning in dwSizeNeeded?
> > >
> > > --
> > > John Hensley
> > > www.resqware.com
> > >
> > >
> > > "boby" wrote:
> > >
> > > >
> > > > You can download a test project from the following link:
> > > >
> > > > http://codeguru.earthweb.com/forum/showthread.php?p=1589583#post1589583
> > > >
> > > >
> >
> >