how can i call a DLL in Kernel Mode Driver?

hi,everyone
is it necessary for DLL to be a Kernel Mode one? how can i write? is
there any sample?
What if i have a static library?Can it be easily used in my Kernel Mode
Driver.
thanks in advance.

paul


Express yourself with the new version of MSN Messenger! Download today -
it’s FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Hello,
this article
http://www.wd-3.com/archive/KernelDlls.htm
and
http://www.google.com
will help you
Kind regards
Burkhardt Braun

“paul chen”

m> cc:
Sent by: Subject: [ntdev] how can i call a DLL in Kernel Mode Driver?
bounce-176649-14814@li
sts.osr.com

27.05.04 10:47
Please respond to
“Windows System
Software Devs Interest
List”

hi,everyone
is it necessary for DLL to be a Kernel Mode one? how can i write? is
there any sample?
What if i have a static library?Can it be easily used in my Kernel Mode
Driver.
thanks in advance.

paul

_________________________________________________________________
Express yourself with the new version of MSN Messenger! Download today -
it’s FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@alcatel.de
To unsubscribe send a blank email to xxxxx@lists.osr.com

Can I use Kernel DLLs using something like to “GetProcAddress” where I do
not need of a static library?

wrote in message news:xxxxx@ntdev…
>
> Hello,
> this article
> http://www.wd-3.com/archive/KernelDlls.htm
> and
> http://www.google.com
> will help you
> Kind regards
> Burkhardt Braun
>
>
>
>
> “paul chen”
> System Software Devs Interest List"
> m> cc:
> Sent by: Subject: [ntdev] how
can i call a DLL in Kernel Mode Driver?
> bounce-176649-14814@li
> sts.osr.com
>
>
> 27.05.04 10:47
> Please respond to
> “Windows System

> Software Devs Interest
> List”
>
>
>
>
>
>
> hi,everyone
> is it necessary for DLL to be a Kernel Mode one? how can i write? is
> there any sample?
> What if i have a static library?Can it be easily used in my Kernel Mode
> Driver.
> thanks in advance.
>
> paul
>
> _________________________________________________________________
> Express yourself with the new version of MSN Messenger! Download today -
> it’s FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@alcatel.de
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>
>

There is no equivalent of GetProcAddress in the kernel.
MmGetSystemRoutineAddress exists, but it will only dynamically resolve
exports from ntoskrnl or the HAL. If you link against a driver DLL, you
must make sure the DLL is present on the system. Once present, you can
create your own version of query interface if you like, but you have to
make sure the DLL and interfaces are valid for the lifetime of your
device objects and drivers.

D

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Fernando Roberto
da Silva
Sent: Thursday, May 27, 2004 7:40 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?

Can I use Kernel DLLs using something like to “GetProcAddress” where I
do
not need of a static library?

wrote in message news:xxxxx@ntdev…
>
> Hello,
> this article
> http://www.wd-3.com/archive/KernelDlls.htm
> and
> http://www.google.com
> will help you
> Kind regards
> Burkhardt Braun
>
>
>
>
> “paul chen”
> System Software Devs Interest List"
> m> cc:
> Sent by: Subject: [ntdev]
how
can i call a DLL in Kernel Mode Driver?
> bounce-176649-14814@li
> sts.osr.com
>
>
> 27.05.04 10:47
> Please respond to
> “Windows System

> Software Devs Interest
> List”
>
>
>
>
>
>
> hi,everyone
> is it necessary for DLL to be a Kernel Mode one? how can i write?
is
> there any sample?
> What if i have a static library?Can it be easily used in my Kernel
Mode
> Driver.
> thanks in advance.
>
> paul
>
> _________________________________________________________________
> Express yourself with the new version of MSN Messenger! Download today
-
> it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@alcatel.de
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Parse the PE header yourself, and find the export by name.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Fernando Roberto da Silva”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Thursday, May 27, 2004 3:40 PM
Subject: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?

> Can I use Kernel DLLs using something like to “GetProcAddress” where I do
> not need of a static library?
>
> wrote in message news:xxxxx@ntdev…
> >
> > Hello,
> > this article
> > http://www.wd-3.com/archive/KernelDlls.htm
> > and
> > http://www.google.com
> > will help you
> > Kind regards
> > Burkhardt Braun
> >
> >
> >
> >
> > “paul chen”
> > > System Software Devs Interest List"
> > m> cc:
> > Sent by: Subject: [ntdev] how
> can i call a DLL in Kernel Mode Driver?
> > bounce-176649-14814@li
> > sts.osr.com
> >
> >
> > 27.05.04 10:47
> > Please respond to
> > “Windows System
>
> > Software Devs Interest
> > List”
> >
> >
> >
> >
> >
> >
> > hi,everyone
> > is it necessary for DLL to be a Kernel Mode one? how can i write? is
> > there any sample?
> > What if i have a static library?Can it be easily used in my Kernel Mode
> > Driver.
> > thanks in advance.
> >
> > paul
> >
> > _________________________________________________________________
> > Express yourself with the new version of MSN Messenger! Download today -
> > it’s FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@alcatel.de
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Call the dll/driver using a standard IOCTL which instantiates a class and
returns an interface pointer. Then call that object methods the normal
way. One of the methods can be used for freeing the object.
The header file should only have pure abstract methods.

George

At 04:54 AM 5/27/2004, Maxim S. Shatskih wrote:

Parse the PE header yourself, and find the export by name.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Fernando Roberto da Silva”
>Newsgroups: ntdev
>To: “Windows System Software Devs Interest List”
>Sent: Thursday, May 27, 2004 3:40 PM
>Subject: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?
>
>
> > Can I use Kernel DLLs using something like to “GetProcAddress” where I do
> > not need of a static library?
> >
> > wrote in message news:xxxxx@ntdev…
> > >
> > > Hello,
> > > this article
> > > http://www.wd-3.com/archive/KernelDlls.htm
> > > and
> > > http://www.google.com
> > > will help you
> > > Kind regards
> > > Burkhardt Braun
> > >
> > >
> > >
> > >
> > > “paul chen”
> > > > > System Software Devs Interest List"
> > > m> cc:
> > > Sent by: Subject: [ntdev] how
> > can i call a DLL in Kernel Mode Driver?
> > > bounce-176649-14814@li
> > > sts.osr.com
> > >
> > >
> > > 27.05.04 10:47
> > > Please respond to
> > > “Windows System
> >
> > > Software Devs Interest
> > > List”
> > >
> > >
> > >
> > >
> > >
> > >
> > > hi,everyone
> > > is it necessary for DLL to be a Kernel Mode one? how can i write? is
> > > there any sample?
> > > What if i have a static library?Can it be easily used in my Kernel Mode
> > > Driver.
> > > thanks in advance.
> > >
> > > paul
> > >
> > > _________________________________________________________________
> > > Express yourself with the new version of MSN Messenger! Download today -
> > > it’s FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > >
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > You are currently subscribed to ntdev as: xxxxx@alcatel.de
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

Read about IRP_MN_QUERY_INTERFACE in the DDK for a “clean” way to do
this.

Mat

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of George Blat
Sent: Thursday, May 27, 2004 1:29 PM
To: Windows System Software Devs Interest List
Subject: Re: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?

Call the dll/driver using a standard IOCTL which instantiates a class
and
returns an interface pointer. Then call that object methods the normal
way. One of the methods can be used for freeing the object.
The header file should only have pure abstract methods.

George

At 04:54 AM 5/27/2004, Maxim S. Shatskih wrote:

Parse the PE header yourself, and find the export by name.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Fernando Roberto da Silva”
>Newsgroups: ntdev
>To: “Windows System Software Devs Interest List”
>Sent: Thursday, May 27, 2004 3:40 PM
>Subject: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?
>
>
> > Can I use Kernel DLLs using something like to “GetProcAddress” where
I do
> > not need of a static library?
> >
> > wrote in message news:xxxxx@ntdev…
> > >
> > > Hello,
> > > this article
> > > http://www.wd-3.com/archive/KernelDlls.htm
> > > and
> > > http://www.google.com
> > > will help you
> > > Kind regards
> > > Burkhardt Braun
> > >
> > >
> > >
> > >
> > > “paul chen”
> > > “Windows
> > System Software Devs Interest List”
> > > m> cc:
> > > Sent by: Subject:
[ntdev] how
> > can i call a DLL in Kernel Mode Driver?
> > > bounce-176649-14814@li
> > > sts.osr.com
> > >
> > >
> > > 27.05.04 10:47
> > > Please respond to
> > > “Windows System
> >
> > > Software Devs Interest
> > > List”
> > >
> > >
> > >
> > >
> > >
> > >
> > > hi,everyone
> > > is it necessary for DLL to be a Kernel Mode one? how can i
write? is
> > > there any sample?
> > > What if i have a static library?Can it be easily used in my Kernel
Mode
> > > Driver.
> > > thanks in advance.
> > >
> > > paul
> > >
> > > _________________________________________________________________
> > > Express yourself with the new version of MSN Messenger! Download
today -
> > > it’s FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > >
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > You are currently subscribed to ntdev as:
xxxxx@alcatel.de
> > > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@cvdsinc.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

hi, everyone,
first thanks for ur reply. Maybe i dont’ make myself clear, the
situation is now i have a static library, which is developed with the Wizard
in VC6.0 by choosing the Win32 Static Library. When i included it into my
kernel driver project as we usually do in developing Win32 programs, I got
link error when compiling. Is it possible to link such a static library into
kernel driver?How?

best regards
paul chen


FREE pop-up blocking with the new MSN Toolbar – get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

Hello Paul Chean,
what linker error is it in particular?
To link a static library to a kernel driver is possible in general.
Kind regards
Burkhardt Braun

=

“paul chen” =

System Software Devs Interest List" =

m> cc: =
=

Sent by: Subject: Re:[ntdev=
] how can i call a DLL in Kernel Mode Driver? =

bounce-176763-14814@li =
=

sts.osr.com =
=

=
=

=
=

28.05.04 10:30 =
=

Please respond to =
=

“Windows System =
=

Software Devs Interest =
=

List” =
=

=
=

=
=

hi, everyone,
first thanks for ur reply. Maybe i dont’ make myself clear, the
situation is now i have a static library, which is developed with the
Wizard
in VC6.0 by choosing the Win32 Static Library. When i included it into =
my
kernel driver project as we usually do in developing Win32 programs, I =
got
link error when compiling. Is it possible to link such a static library=

into
kernel driver?How?

best regards
paul chen

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar ? get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=3D256

You are currently subscribed to ntdev as: xxxxx@alcatel.de
To unsubscribe send a blank email to xxxxx@lists.osr.com

=

Hi,Burkhardt.Braun

No , you can’t .

======= 2004-05-28 16:40:52 You wrote=======

Hello Paul Chean,
what linker error is it in particular?
To link a static library to a kernel driver is possible in general.
Kind regards
Burkhardt Braun

“paul chen”

> m> cc:
> Sent by: Subject: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?
> bounce-176763-14814@li
> sts.osr.com
>
>
> 28.05.04 10:30
> Please respond to
> “Windows System
> Software Devs Interest
> List”
>
>
>
>
>
>
>hi, everyone,
> first thanks for ur reply. Maybe i dont’ make myself clear, the
>situation is now i have a static library, which is developed with the
>Wizard
>in VC6.0 by choosing the Win32 Static Library. When i included it into my
>kernel driver project as we usually do in developing Win32 programs, I got
>link error when compiling. Is it possible to link such a static library
>into
>kernel driver?How?
>
>best regards
>paul chen
>
> _________________________________________________________________
>FREE pop-up blocking with the new MSN Toolbar ? get it now!
>http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@alcatel.de
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@sinfors.com.cn
>To unsubscribe send a blank email to xxxxx@lists.osr.com

= = = = = = = = = = = = = = = = = = = =

Crasher Guo
xxxxx@sinfors.com.cn
2004-05-28

Hello Crasher Guo,
I am frequently linking static libraries to a kernel driver.
Yesterday I did it the last time.
I really do my very best to avoid references to the Win32-Subsystem in user
mode.
Kind regards
Burkhardt Braun

“Crasher Guo”
To: “Windows System Software Devs Interest List”
Sent by: cc:
bounce-176765-14814@li Subject: Re: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?
sts.osr.com

28.05.04 10:54
Please respond to
“Windows System
Software Devs Interest
List”

Hi,Burkhardt.Braun

No , you can’t .

======= 2004-05-28 16:40:52 You wrote=======

>
>Hello Paul Chean,
>what linker error is it in particular?
>To link a static library to a kernel driver is possible in general.
>Kind regards
>Burkhardt Braun
>
>
>
>
>

> “paul chen”

> System Software Devs Interest List"
> m> cc:

> Sent by: Subject: Re:[ntdev]
how can i call a DLL in Kernel Mode Driver?
> bounce-176763-14814@li

> sts.osr.com

>

>

> 28.05.04 10:30

> Please respond to

> “Windows System

> Software Devs Interest

> List”

>

>

>
>
>
>
>hi, everyone,
> first thanks for ur reply. Maybe i dont’ make myself clear, the
>situation is now i have a static library, which is developed with the
>Wizard
>in VC6.0 by choosing the Win32 Static Library. When i included it into my
>kernel driver project as we usually do in developing Win32 programs, I got
>link error when compiling. Is it possible to link such a static library
>into
>kernel driver?How?
>
>best regards
>paul chen
>
> _________________________________________________________________
>FREE pop-up blocking with the new MSN Toolbar ? get it now!
>http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@alcatel.de
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@sinfors.com.cn
>To unsubscribe send a blank email to xxxxx@lists.osr.com

= = = = = = = = = = = = = = = = = = = =

Crasher Guo
xxxxx@sinfors.com.cn
2004-05-28


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@alcatel.de
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi,Burkhardt.Braun

Sorry,
I say “No you cann’t” to the question "how can i call a DLL in Kernel Mode Driver? "

======= 2004-05-28 16:50:14 You wrote=======

Hello Crasher Guo,
I am frequently linking static libraries to a kernel driver.
Yesterday I did it the last time.
I really do my very best to avoid references to the Win32-Subsystem in user
mode.
Kind regards
Burkhardt Braun

“Crasher Guo”
To: “Windows System Software Devs Interest List”
> Sent by: cc:
> bounce-176765-14814@li Subject: Re: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?
> sts.osr.com
>
>
> 28.05.04 10:54
> Please respond to
> “Windows System
> Software Devs Interest
> List”
>
>
>
>
>
>
>Hi,Burkhardt.Braun
>
>No , you can’t .
>
>======= 2004-05-28 16:40:52 You wrote=======
>
>>
>>Hello Paul Chean,
>>what linker error is it in particular?
>>To link a static library to a kernel driver is possible in general.
>>Kind regards
>>Burkhardt Braun
>>
>>
>>
>>
>>
>
>> “paul chen”
>
>> >System Software Devs Interest List"
>> m> cc:
>
>> Sent by: Subject: Re:[ntdev]
>how can i call a DLL in Kernel Mode Driver?
>> bounce-176763-14814@li
>
>> sts.osr.com
>
>>
>
>>
>
>> 28.05.04 10:30
>
>> Please respond to
>
>> “Windows System
>
>> Software Devs Interest
>
>> List”
>
>>
>
>>
>
>>
>>
>>
>>
>>hi, everyone,
>> first thanks for ur reply. Maybe i dont’ make myself clear, the
>>situation is now i have a static library, which is developed with the
>>Wizard
>>in VC6.0 by choosing the Win32 Static Library. When i included it into my
>>kernel driver project as we usually do in developing Win32 programs, I got
>>link error when compiling. Is it possible to link such a static library
>>into
>>kernel driver?How?
>>
>>best regards
>>paul chen
>>
>> _________________________________________________________________
>>FREE pop-up blocking with the new MSN Toolbar ? get it now!
>>http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>>
>>
>>—
>>Questions? First check the Kernel Driver FAQ at
>>http://www.osronline.com/article.cfm?id=256
>>
>>You are currently subscribed to ntdev as: xxxxx@alcatel.de
>>To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>>
>>
>>
>>
>>
>>—
>>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>>
>>You are currently subscribed to ntdev as: xxxxx@sinfors.com.cn
>>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>= = = = = = = = = = = = = = = = = = = =
>
>
>Crasher Guo
>xxxxx@sinfors.com.cn
>2004-05-28
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@alcatel.de
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@sinfors.com.cn
>To unsubscribe send a blank email to xxxxx@lists.osr.com

= = = = = = = = = = = = = = = = = = = =

Crasher Guo
xxxxx@sinfors.com.cn
2004-05-28

This horse is now well-beaten. Here is the consensus:

* There are no issues specific to kernel mode that preclude the use of
static and dynamic libraries.

* Obviously, Win32 / user mode / non-native functions may not be used in
kernel mode regardless of whether calls to said functions originate from
your driver code, your static library, or your DLL.

* According to the article http://www.wd-3.com/archive/KernelDlls.htm
posted by Burkhardt, you can use automatic binding for DLLs in kernel
mode.

* According to Maxim, you can manually bind DLL functions if you
interpret the PE header of the DLL manually.

Clearly, any code in a static or dynamic library must be appropriate for
kernel mode if you’re going to be calling functions from said library in
kernel mode. You may also have to consider subtle differences in the
runtime environment. For example, if your static library requires
construction of global C++ objects, you may need to take steps to
explicitly handle this.

If the OP cares to provide specific information, such as exactly what
linker error is occurring, maybe someone can provide specific help.

Chuck

----- Original Message -----
From: “Crasher Guo”
To: “Windows System Software Devs Interest List”
Sent: Friday, May 28, 2004 4:40 PM
Subject: Re: Re: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?

> Hi,Burkhardt.Braun
>
> Sorry,
> I say “No you cann’t” to the question "how can i call a DLL in
Kernel Mode Driver? "

Chuck,

Good summary.

I’d like to add that there are other “implicit support calls” that can be
generated by the compiler. Stack checking, overflow checking, as well as
explicit calls to runtime libraries and such. If you make ANY call that
isn’t suitable for the kernel environment, of course you’re going to get
linker errors, because the runtime support for kernel mode is quite
different from the runtime support for user mode.

It’s quite clear that linking for Kernel mode should work the same way as
for user mode, but there are runtime differences that must be solved by
coding in a way that the kernel static/dynamic library (or driver itself)
doesn’t call upon anything that isn’t clean Kernel code.


Mats

-----Original Message-----
From: Chuck Batson [mailto:xxxxx@cbatson.com]
Sent: Friday, May 28, 2004 11:09 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?

This horse is now well-beaten. Here is the consensus:

* There are no issues specific to kernel mode that preclude the use of
static and dynamic libraries.

* Obviously, Win32 / user mode / non-native functions may not
be used in
kernel mode regardless of whether calls to said functions
originate from
your driver code, your static library, or your DLL.

* According to the article http://www.wd-3.com/archive/KernelDlls.htm
posted by Burkhardt, you can use automatic binding for DLLs in kernel
mode.

* According to Maxim, you can manually bind DLL functions if you
interpret the PE header of the DLL manually.

Clearly, any code in a static or dynamic library must be
appropriate for
kernel mode if you’re going to be calling functions from said
library in
kernel mode. You may also have to consider subtle differences in the
runtime environment. For example, if your static library requires
construction of global C++ objects, you may need to take steps to
explicitly handle this.

If the OP cares to provide specific information, such as exactly what
linker error is occurring, maybe someone can provide specific help.

Chuck

----- Original Message -----
From: “Crasher Guo”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, May 28, 2004 4:40 PM
> Subject: Re: Re: Re:[ntdev] how can i call a DLL in Kernel
> Mode Driver?
>
>
> > Hi,Burkhardt.Braun
> >
> > Sorry,
> > I say “No you cann’t” to the question "how can i call a DLL in
> Kernel Mode Driver? "
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

No. You will have lots of unresolved imports.

The kernel is not a full general-purpose programming environment, if has,
for instance, no fopen(), and no Win32 functions. So, your library will need
major redesign to be usable for the kernel.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “paul chen”
To: “Windows System Software Devs Interest List”
Sent: Friday, May 28, 2004 12:30 PM
Subject: Re:[ntdev] how can i call a DLL in Kernel Mode Driver?

> hi, everyone,
> first thanks for ur reply. Maybe i dont’ make myself clear, the
> situation is now i have a static library, which is developed with the Wizard
> in VC6.0 by choosing the Win32 Static Library. When i included it into my
> kernel driver project as we usually do in developing Win32 programs, I got
> link error when compiling. Is it possible to link such a static library into
> kernel driver?How?
>
> best regards
> paul chen
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar ? get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

It’s quite unlikely you’ll succeed with a DLL created that way. The
fundamental problem is that your DLL is likely to have references to other
things, and they cannot be resolved in the kernel.

For what you want, the proper approach is to build something called an
EXPORT_DRIVER. You would build via the DDK and not Visual Studio. The
resulting file will be another .sys executable, but it’s really a DLL. Your
first driver can import from this export driver.


James Antognini
Windows DDK Support

This posting is provided “AS IS” with no warranties, and confers no rights.

“paul chen” wrote in message news:xxxxx@ntdev…
> hi, everyone,
> first thanks for ur reply. Maybe i dont’ make myself clear, the
> situation is now i have a static library, which is developed with the
Wizard
> in VC6.0 by choosing the Win32 Static Library. When i included it into my
> kernel driver project as we usually do in developing Win32 programs, I got
> link error when compiling. Is it possible to link such a static library
into
> kernel driver?How?
>
> best regards
> paul chen
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar - get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>

first thanks for your all reply.

hi,Burkhardt Braun
the link errors are unresolved symbols which i have defined in my
static library.
how do u link static libraries to a kernel driver? is the static
libraries build via DDK and not Visual Studio as James has told? or u
doesn’t refer to any function depends on any runtime library that kernel
mode supports?
thanks.
paul


Is your PC infected? Get a FREE online computer virus scan from McAfee®
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

You should be able to build static libraries fairly normally. They are
Win32 DLLs (for a 32 bit system). You need to avoid any MFC trash, and
don’t call any functions in ntdll.dll, or the other user-mode support
functions. Pretty much you can only link against Kernel and Hal.

If your link errors are complaints about functions defined IN your static
library, then it seems there is something wrong with how you must have built
it. I mean, those functions are there, so they should be usable. A
possibility is you have the calling conventions wrong. This changes the
name of the function, often causing a link failure.

Loren

“paul chen” wrote in message news:xxxxx@ntdev…
>
> the link errors are unresolved symbols which i have defined in my
> static library.
> how do u link static libraries to a kernel driver? is the static
> libraries build via DDK and not Visual Studio as James has told? or u
> doesn’t refer to any function depends on any runtime library that kernel
> mode supports?

If your static library needs to call other functions which it
does not define, then it can obviously only call functions that
can be used by kernel-mode code. If all the functions in your
library only depend on other functions in the library, there
should be no problem. It ought to be possible to make sure you
don’t include inappropriate references when building with Visual
Studio, but it’s very unlikely that any wizard will set it up
for you. You’ll have to study the compiler and linker options
and set everything up appropriately.

It will probably be much easier to make sure you meet all the
necessary restrictions by using the DDK build utility to build
your library, using a TARGETTYPE of DRIVER_LIBRARY.

Hello,

how do u link static libraries to a kernel driver? is the static
I link them the way I add the static library to be linked to the linker
options.
libraries build via DDK and not Visual Studio as James has told? or u
You can do both, it doesn’t matter.
doesn’t refer to any function depends on any runtime library that kernel
mode supports?
All references in the dll are references to kernel mode functions.

To make things easier, I “developed” two DSP and DSW pairs related to an
old
OSR example ( Master and slave ).
I’ll send this zip file ( < 4k ) to you. Anyone else who likes to have them
might
email me, so that I can send them back.
Please note:

  • you have to adapt the post build settings to your needs
  • I expect some INCLUDE or PATH settings might be invalid
  • this email address ( ATalcatelDOTde ) will be invalid from July on.
    Kind regards
    Burkhardt Braun