I need to change driver entry point from DriverEntry to my own function.
The documentation says to use ‘/ENTRY:symbol’ and pass it in through
LINKER_FLAGS in my 'sources ’ file. But this does not work. I am using latest WDK
(6000). Please help!
Why ? The name of the entrypoint really should be DriverEntry if you are using the /Gs compiler flag. If you are writing a KMDF driver, KMDF requires you to use /Gs on your driver, so you need to use DriverEntry if that is the case.
You can use DRIVER_ENTRY= in your sources file to override the driver’s entrypoint
No, I am writing a regular WDK without /Gs (or BUFFER_OVERFLOW_CHECKS = 0).
I need to write my own entry point that takes only one parameter. So this module could be
used as a driver or by my other application. The ‘DRIVER_ENTRY’ did not change the
entry point. Just don’t know what to do next!
So, you want a single .sys file to be both a kernel-mode driver and a user-mode DLL? That sounds like a lot of pain, for little gain. A better approach would be to compile the same sources into two different modules – one a kernel-mode driver, the other a user-mode DLL.
They really are completely different environments. Only the most trivial of DLLs would be reusable in both environments.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Wednesday, March 14, 2007 6:00 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to change driver entry point
No, I am writing a regular WDK without /Gs (or BUFFER_OVERFLOW_CHECKS = 0).
I need to write my own entry point that takes only one parameter. So this module could be
used as a driver or by my other application. The ‘DRIVER_ENTRY’ did not change the
entry point. Just don’t know what to do next!
Every attempt I have seen to share code between a driver and an
application, except for the simplest of items (such as a pure calculation
with no function calls) has ended in a disaster. DriverEntry is there to
initialize the basics of the driver, what in the world do you think you can
do that could be shared with an application.
wrote in message news:xxxxx@ntdev… > No, I am writing a regular WDK without /Gs (or BUFFER_OVERFLOW_CHECKS = > 0). > I need to write my own entry point that takes only one parameter. So this > module could be > used as a driver or by my other application. The ‘DRIVER_ENTRY’ did not > change the > entry point. Just don’t know what to do next! >
Thank you for your advise guys but I am compiling into a Driver .sys not a DLL and despite the
reasons why and how it will work, I am simply asking for help on how to change the entry point in the PE executable (.sys) WDK 6000 linker.
But you still have not said anything about “why”. What problem are you trying to solve?
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Wednesday, March 14, 2007 6:34 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to change driver entry point
Thank you for your advise guys but I am compiling into a Driver .sys not a DLL and despite the
reasons why and how it will work, I am simply asking for help on how to change the entry point in the PE executable (.sys) WDK 6000 linker.
I will use this .sys module as a driver at certain times (for testing) and by my other driver app.
The problem I am trying to solve is this:
The WDK linker simply ignores my
LINKER_FLAGS = /ENTRY:Entry
or
DRIVER_ENTRY = Entry
flags in the ‘sources’ file and uses ‘/entry:DriverEntry’ instead.
Why? How can I change this?
> I need to write my own entry point that takes only one parameter.
The driver’s entry point, regardless of its name has a fixed signature, typedef NTSTATUS (*PFN_DRIVER_ENTRY)(PDRIVER_OBJECT Driver, PUNICODE_STRING RegistryString).
Forget about this idea. You make life difficult for no reason.
I have quite few code files used in both driver and user mode. I have source
files and headers which are used in WDK kernel project to build driver. I
have same source files and headers used VS/SDK project to build dll. I have
to take care about which combinations of DDK/SDK functions are used and
sometimes wrapper for impedance mismatch with a preprocessor token to select
either kernel or user mode but this is no more than trivial use of simple
enough tools.
It is simple to do. It just works.
wrote in message news:xxxxx@ntdev… > Hi, > > I need to change driver entry point from DriverEntry to my own function. > The documentation says to use ‘/ENTRY:symbol’ and pass it in through > LINKER_FLAGS in my 'sources ’ file. But this does not work. I am using > latest WDK > (6000). Please help! > > >
Uhm, why don’t you create a kernel level DLL that contains the whole
functionality, and then a tiny driver whose driverentry just invokes your
custom driverentry in the kernel level DLL?
I always assume that by “other driver app” you mean another kernel level
component, nothing running in user mode.
Hope it helps
GV
----- Original Message -----
From: To: “Windows System Software Devs Interest List” Sent: Wednesday, March 14, 2007 3:51 PM Subject: RE:[ntdev] How to change driver entry point
>I will use this .sys module as a driver at certain times (for testing) and >by my other driver app. > The problem I am trying to solve is this: > The WDK linker simply ignores my > > LINKER_FLAGS = /ENTRY:Entry > or > DRIVER_ENTRY = Entry > > flags in the ‘sources’ file and uses ‘/entry:DriverEntry’ instead. > Why? How can I change this? > > > — > Questions? First check the Kernel Driver FAQ at > http://www.osronline.com/article.cfm?id=256 > > To unsubscribe, visit the List Server section of OSR Online at > http://www.osronline.com/page.cfm?name=ListServer
More than likely it is failing due to name decoration. grep the OBJ file for Entry and you may see an identifier like Entry@8. Pass this name to the linker.
There is an easier way. Just add the below snippet to your source file. It will be called when loaded from kernel mode and invokes your common entrypoint. When loaded as a DLL it won’t get used.