TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Device Drivers

Linking issue with DiInstallDriver

Microsoft Device Drivers

 
 
Thread Tools Display Modes
Unread 03-12-2007, 08:01 PM   #1
Eric Boudrand
Guest
 
Posts: n/a
Linking issue with DiInstallDriver

Hello,

I am writing a setup application for installing a driver under Vista. I
would like to use DiInstallDriver function, but I meet an error during
linking phase. My code is very simple. I am just checking the API :

#define WINVER 0x0600
#define _WIN32_WINNT 0x0600

#include <windows.h>
#include <newdev.h>
#include <stdio.h>

int wmain()
{
LPCTSTR pInf=L"C:\\Users\\Eric\\dev\\ndistgb.inf";
int ret = DiInstallDriver(NULL,pInf,0,FALSE);
switch(ret)
{
case ERROR_ACCESS_DENIED:
printf("access denied.\n");
default:
printf("installed.\n");
}
return 0;
}

Compilation output is (in french) :

Compilation en cours...
Compilateur d'optimisation Microsoft (R) 32 bits C/C++ version
14.00.50727.762 pour 80x86
Copyright (C) Microsoft Corporation. Tous droits réservés.
cl /Od /I "C:\WinDDK\6000\inc\api" /D "WIN32" /D "_DEBUG" /D "_CONSOLE"
/D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\"
/Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TC /FC .\insdrv.cpp
insdrv.cpp
Édition des liens en cours...
Recherche en cours des bibliothèques
Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
[ removed ]
Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
Fin de la recherche des bibliothèques
insdrv.obj : error LNK2019: symbole externe non résolu _DiInstallDriverW
référencé dans la fonction _wmain
[ or insdrv.obj : error LNK2019: unresolved external symbol
_DiInstallDriverW referenced in function _wmain ]
C:\Users\Eric\Documents\Projets\insdrv\Debug\insdr v.exe : fatal error
LNK1120: 1 externes non résolus

I have also compiled with /TP and I got the same result. newdev.lib is
set in additionnal dependancies. I must have forgotten something but I
have no idea for resolving this issue. Any advice is welcomed. Thanks.

Eric
 
Unread 03-12-2007, 08:02 PM   #2
Gianluca Varenni
Guest
 
Posts: n/a
Re: Linking issue with DiInstallDriver

I think there's something wrong with the include file newdev.h in the WDK
from MS.

The function prototype for DiInstallDriverA/W is not decorated as usual with
the calling convention (WINAPI), but the function in the lib and dll is
using the WINAPI calling convention. So the linker doesn't resolve
"_DiInstallDriverW", the only available one is _DiInstallDriverW@16.

Please try to create a local copy of newdev.h in your sources folder, modify
the prototype definition of DiInstallDriverW to

BOOL
WINAPI
DiInstallDriverW(
__in_opt HWND hwndParent,
__in LPCWSTR InfPath,
__in DWORD Flags,
__out_opt PBOOL NeedReboot
);

BOOL
WINAPI
DiInstallDriverA(
__in HWND hwndParent,
__in LPCSTR InfPath,
__in DWORD Flags,
__out_opt PBOOL NeedReboot
);


and in your source file
#include <newdev.h> to #include "newdev.h"


Hope it helps
GV





"Eric Boudrand" <ebo2002fr@yahoo.fr> wrote in message
news:46571604$0$19923$426a74cc@news.free.fr...
> Hello,
>
> I am writing a setup application for installing a driver under Vista. I
> would like to use DiInstallDriver function, but I meet an error during
> linking phase. My code is very simple. I am just checking the API :
>
> #define WINVER 0x0600
> #define _WIN32_WINNT 0x0600
>
> #include <windows.h>
> #include <newdev.h>
> #include <stdio.h>
>
> int wmain()
> {
> LPCTSTR pInf=L"C:\\Users\\Eric\\dev\\ndistgb.inf";
> int ret = DiInstallDriver(NULL,pInf,0,FALSE);
> switch(ret)
> {
> case ERROR_ACCESS_DENIED:
> printf("access denied.\n");
> default:
> printf("installed.\n");
> }
> return 0;
> }
>
> Compilation output is (in french) :
>
> Compilation en cours...
> Compilateur d'optimisation Microsoft (R) 32 bits C/C++ version
> 14.00.50727.762 pour 80x86
> Copyright (C) Microsoft Corporation. Tous droits réservés.
> cl /Od /I "C:\WinDDK\6000\inc\api" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D
> "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\"
> /Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TC /FC .\insdrv.cpp
> insdrv.cpp
> Édition des liens en cours...
> Recherche en cours des bibliothèques
> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
> [ removed ]
> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
> Fin de la recherche des bibliothèques
> insdrv.obj : error LNK2019: symbole externe non résolu _DiInstallDriverW
> référencé dans la fonction _wmain
> [ or insdrv.obj : error LNK2019: unresolved external symbol
> _DiInstallDriverW referenced in function _wmain ]
> C:\Users\Eric\Documents\Projets\insdrv\Debug\insdr v.exe : fatal error
> LNK1120: 1 externes non résolus
>
> I have also compiled with /TP and I got the same result. newdev.lib is set
> in additionnal dependancies. I must have forgotten something but I have no
> idea for resolving this issue. Any advice is welcomed. Thanks.
>
> Eric



 
Unread 03-12-2007, 08:07 PM   #3
Pavel A.
Guest
 
Posts: n/a
Re: Linking issue with DiInstallDriver

The OP needs to set calling convention = stdcall in the project.
The default in VS is cdecl.


Regards,
--PA


"Gianluca Varenni" <gianluca.varenni@community.nospam> wrote in message news:u7b6TUwnHHA.1244@TK2MSFTNGP04.phx.gbl...
>I think there's something wrong with the include file newdev.h in the WDK from MS.
>
> The function prototype for DiInstallDriverA/W is not decorated as usual with the calling convention (WINAPI), but the function
> in the lib and dll is using the WINAPI calling convention. So the linker doesn't resolve "_DiInstallDriverW", the only
> available one is _DiInstallDriverW@16.
>
> Please try to create a local copy of newdev.h in your sources folder, modify the prototype definition of DiInstallDriverW to
>
> BOOL
> WINAPI
> DiInstallDriverW(
> __in_opt HWND hwndParent,
> __in LPCWSTR InfPath,
> __in DWORD Flags,
> __out_opt PBOOL NeedReboot
> );
>
> BOOL
> WINAPI
> DiInstallDriverA(
> __in HWND hwndParent,
> __in LPCSTR InfPath,
> __in DWORD Flags,
> __out_opt PBOOL NeedReboot
> );
>
>
> and in your source file
> #include <newdev.h> to #include "newdev.h"
>
>
> Hope it helps
> GV
>
>
>
>
>
> "Eric Boudrand" <ebo2002fr@yahoo.fr> wrote in message news:46571604$0$19923$426a74cc@news.free.fr...
>> Hello,
>>
>> I am writing a setup application for installing a driver under Vista. I would like to use DiInstallDriver function, but I
>> meet an error during linking phase. My code is very simple. I am just checking the API :
>>
>> #define WINVER 0x0600
>> #define _WIN32_WINNT 0x0600
>>
>> #include <windows.h>
>> #include <newdev.h>
>> #include <stdio.h>
>>
>> int wmain()
>> {
>> LPCTSTR pInf=L"C:\\Users\\Eric\\dev\\ndistgb.inf";
>> int ret = DiInstallDriver(NULL,pInf,0,FALSE);
>> switch(ret)
>> {
>> case ERROR_ACCESS_DENIED:
>> printf("access denied.\n");
>> default:
>> printf("installed.\n");
>> }
>> return 0;
>> }
>>
>> Compilation output is (in french) :
>>
>> Compilation en cours...
>> Compilateur d'optimisation Microsoft (R) 32 bits C/C++ version 14.00.50727.762 pour 80x86
>> Copyright (C) Microsoft Corporation. Tous droits réservés.
>> cl /Od /I "C:\WinDDK\6000\inc\api" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd
>> /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TC /FC .\insdrv.cpp
>> insdrv.cpp
>> Édition des liens en cours...
>> Recherche en cours des bibliothèques
>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
>> [ removed ]
>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
>> Fin de la recherche des bibliothèques
>> insdrv.obj : error LNK2019: symbole externe non résolu _DiInstallDriverW référencé dans la fonction _wmain
>> [ or insdrv.obj : error LNK2019: unresolved external symbol _DiInstallDriverW referenced in function _wmain ]
>> C:\Users\Eric\Documents\Projets\insdrv\Debug\insdr v.exe : fatal error LNK1120: 1 externes non résolus
>>
>> I have also compiled with /TP and I got the same result. newdev.lib is set in additionnal dependancies. I must have forgotten
>> something but I have no idea for resolving this issue. Any advice is welcomed. Thanks.
>>
>> Eric

>
>



 
Unread 03-12-2007, 08:08 PM   #4
Eric Boudrand
Guest
 
Posts: n/a
Re: Linking issue with DiInstallDriver

Hi,

> I think there's something wrong with the include file newdev.h in the WDK
> from MS.
>
> The function prototype for DiInstallDriverA/W is not decorated as usual with
> the calling convention (WINAPI), but the function in the lib and dll is
> using the WINAPI calling convention. So the linker doesn't resolve
> "_DiInstallDriverW", the only available one is _DiInstallDriverW@16.


You were right. I have added "WINAPI" and now it links. Thanks.

Regards.

Eric
 
Unread 03-12-2007, 08:08 PM   #5
Eric Boudrand
Guest
 
Posts: n/a
Re: Linking issue with DiInstallDriver

Hi Pavel,

> The OP needs to set calling convention = stdcall in the project.
> The default in VS is cdecl.


Yes. I have selected /Gz and keep original header. It links. Thanks.

Regards.

Eric
 
Unread 03-12-2007, 08:08 PM   #6
Gianluca Varenni
Guest
 
Posts: n/a
Re: Linking issue with DiInstallDriver


"Pavel A." <pavel_a@NOwritemeNO.com> wrote in message
news:OSE22lLoHHA.4772@TK2MSFTNGP06.phx.gbl...
> The OP needs to set calling convention = stdcall in the project.
> The default in VS is cdecl.
>


This would solve the problem of the OP, *but* I think the MS header is wrong
in any case. I generally don't want to be forced to change by global project
calling convention because someone changed the default calling convention in
their headers and forgot to put the needed decoration...

Just my two cents
GV


>
> Regards,
> --PA
>
>
> "Gianluca Varenni" <gianluca.varenni@community.nospam> wrote in message
> news:u7b6TUwnHHA.1244@TK2MSFTNGP04.phx.gbl...
>>I think there's something wrong with the include file newdev.h in the WDK
>>from MS.
>>
>> The function prototype for DiInstallDriverA/W is not decorated as usual
>> with the calling convention (WINAPI), but the function in the lib and dll
>> is using the WINAPI calling convention. So the linker doesn't resolve
>> "_DiInstallDriverW", the only available one is _DiInstallDriverW@16.
>>
>> Please try to create a local copy of newdev.h in your sources folder,
>> modify the prototype definition of DiInstallDriverW to
>>
>> BOOL
>> WINAPI
>> DiInstallDriverW(
>> __in_opt HWND hwndParent,
>> __in LPCWSTR InfPath,
>> __in DWORD Flags,
>> __out_opt PBOOL NeedReboot
>> );
>>
>> BOOL
>> WINAPI
>> DiInstallDriverA(
>> __in HWND hwndParent,
>> __in LPCSTR InfPath,
>> __in DWORD Flags,
>> __out_opt PBOOL NeedReboot
>> );
>>
>>
>> and in your source file
>> #include <newdev.h> to #include "newdev.h"
>>
>>
>> Hope it helps
>> GV
>>
>>
>>
>>
>>
>> "Eric Boudrand" <ebo2002fr@yahoo.fr> wrote in message
>> news:46571604$0$19923$426a74cc@news.free.fr...
>>> Hello,
>>>
>>> I am writing a setup application for installing a driver under Vista. I
>>> would like to use DiInstallDriver function, but I meet an error during
>>> linking phase. My code is very simple. I am just checking the API :
>>>
>>> #define WINVER 0x0600
>>> #define _WIN32_WINNT 0x0600
>>>
>>> #include <windows.h>
>>> #include <newdev.h>
>>> #include <stdio.h>
>>>
>>> int wmain()
>>> {
>>> LPCTSTR pInf=L"C:\\Users\\Eric\\dev\\ndistgb.inf";
>>> int ret = DiInstallDriver(NULL,pInf,0,FALSE);
>>> switch(ret)
>>> {
>>> case ERROR_ACCESS_DENIED:
>>> printf("access denied.\n");
>>> default:
>>> printf("installed.\n");
>>> }
>>> return 0;
>>> }
>>>
>>> Compilation output is (in french) :
>>>
>>> Compilation en cours...
>>> Compilateur d'optimisation Microsoft (R) 32 bits C/C++ version
>>> 14.00.50727.762 pour 80x86
>>> Copyright (C) Microsoft Corporation. Tous droits réservés.
>>> cl /Od /I "C:\WinDDK\6000\inc\api" /D "WIN32" /D "_DEBUG" /D "_CONSOLE"
>>> /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\"
>>> /Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TC /FC .\insdrv.cpp
>>> insdrv.cpp
>>> Édition des liens en cours...
>>> Recherche en cours des bibliothèques
>>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
>>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
>>> [ removed ]
>>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\newdev.lib :
>>> Recherche en cours C:\WinDDK\6000\lib\wlh\i386\setupapi.lib :
>>> Fin de la recherche des bibliothèques
>>> insdrv.obj : error LNK2019: symbole externe non résolu _DiInstallDriverW
>>> référencé dans la fonction _wmain
>>> [ or insdrv.obj : error LNK2019: unresolved external symbol
>>> _DiInstallDriverW referenced in function _wmain ]
>>> C:\Users\Eric\Documents\Projets\insdrv\Debug\insdr v.exe : fatal error
>>> LNK1120: 1 externes non résolus
>>>
>>> I have also compiled with /TP and I got the same result. newdev.lib is
>>> set in additionnal dependancies. I must have forgotten something but I
>>> have no idea for resolving this issue. Any advice is welcomed. Thanks.
>>>
>>> Eric

>>
>>

>
>



 
Unread 03-12-2007, 08:11 PM   #7
Eliyas Yakub [MSFT]
Guest
 
Posts: n/a
Re: Linking issue with DiInstallDriver

The owner of this API acknowledged this one as a bug in the header file. It
will be fixed in the next release.

Thanks for bringing this up.

-Eliyas

 
 

Thread Tools
Display Modes



< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 08:25 AM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional