CreateDC fails and returns NULL

Hi Guys,

I am very new to the driver community and have run into a
vague problem. The problem description is as under

  1. I used the MS plotter driver sample code to write a
    new print driver.
  2. I customize the printer graphics dll ( plotter.dll ),
    to output my own set of instructions instead of HP-GL.
  3. I install the driver, and all works fine. I can debug
    through the callbacks etc.

Now I make some more changes into the dll, build it again(
a checked build ), and I physically replace the dll at the position
where it was installed.

Still things work fine. The application can get the device
context for this driver.

But after a while doing the same thing, from the
application CreateDC returns NULL. Checking GetLastError, tells me
"The operation completed successfully":-). So that does not help me. I
check the devmode, and devname... they appear to be fine. So what
could be the problem?

I have some thinking lines

  1. I should not be physically replacing the dll?
  2. There are some registry entries which might be invalid?
  3. I am linking to a C++ file with extern "C" linkage, does
    that create a problem? There is a related query here, I cannot use new
    and delete, what compiler flag is missing in the source file?
  4. The checked build just bloats up the driver, and GDI
    can't load it into memory?

Can someone help me with this? If anyone has any pointers, it
will be of immense help.

Thanks,

Kartik

============================================================
"A slow sort of country!" said the Queen. "Now, HERE, you see, it
takes all the running YOU can do, to keep in the same place.
If you want to get somewhere else, you must run at least twice as
fast as that."
-Lewis Carroll

I think your data structures have gone inconsistent between driver
graphics DLL and the interface DLL.
There could be even an access violation that could be happening even
internally. Normally if the data structures are consistent across the
DLLs then there shouldn't be any problem replacing the DLL. I do copy
the DLL all the time.

Thanks
Vipin

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kartik Jayaraman
Sent: Friday, October 08, 2004 10:06 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] CreateDC fails and returns NULL

Hi Guys,

I am very new to the driver community and have run into a
vague problem. The problem description is as under

  1. I used the MS plotter driver sample code to write a new
    print driver.
  2. I customize the printer graphics dll ( plotter.dll ), to
    output my own set of instructions instead of HP-GL.
  3. I install the driver, and all works fine. I can debug
    through the callbacks etc.

Now I make some more changes into the dll, build it again( a
checked build ), and I physically replace the dll at the position where
it was installed.

Still things work fine. The application can get the device
context for this driver.

But after a while doing the same thing, from the application
CreateDC returns NULL. Checking GetLastError, tells me "The operation
completed successfully":-). So that does not help me. I check the
devmode, and devname... they appear to be fine. So what could be the
problem?

I have some thinking lines

  1. I should not be physically replacing the dll?
  2. There are some registry entries which might be invalid?
  3. I am linking to a C++ file with extern "C" linkage, does
    that create a problem? There is a related query here, I cannot use new
    and delete, what compiler flag is missing in the source file?
  4. The checked build just bloats up the driver, and GDI can't
    load it into memory?

Can someone help me with this? If anyone has any pointers, it
will be of immense help.

Thanks,

Kartik

============================================================
"A slow sort of country!" said the Queen. "Now, HERE, you see, it takes
all the running YOU can do, to keep in the same place. If you want to
get somewhere else, you must run at least twice as
fast as that."
-Lewis Carroll


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

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

I got the answer, by driver had a dependent dll which wasn’t found in
the path! Now that was stoopid of me:-)

Thanks Vipin for your response… yes I had trouble due to the
inconsistent data structures too, but that got resolved( as you said
), by copying the dll.

Regards,

Kartik

On Sun, 10 Oct 2004 15:24:36 +0530, xxxxx@wipro.com
wrote:
> I think your data structures have gone inconsistent between driver
> graphics DLL and the interface DLL.
> There could be even an access violation that could be happening even
> internally. Normally if the data structures are consistent across the
> DLLs then there shouldn’t be any problem replacing the DLL. I do copy
> the DLL all the time.
>
> Thanks
> Vipin
>
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Kartik Jayaraman
> Sent: Friday, October 08, 2004 10:06 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] CreateDC fails and returns NULL
>
> Hi Guys,
>
> I am very new to the driver community and have run into a
> vague problem. The problem description is as under
>
> 1. I used the MS plotter driver sample code to write a new
> print driver.
> 2. I customize the printer graphics dll ( plotter.dll ), to
> output my own set of instructions instead of HP-GL.
> 3. I install the driver, and all works fine. I can debug
> through the callbacks etc.
>
> Now I make some more changes into the dll, build it again( a
> checked build ), and I physically replace the dll at the position where
> it was installed.
>
> Still things work fine. The application can get the device
> context for this driver.
>
> But after a while doing the same thing, from the application
> CreateDC returns NULL. Checking GetLastError, tells me “The operation
> completed successfully”:-). So that does not help me. I check the
> devmode, and devname… they appear to be fine. So what could be the
> problem?
>
> I have some thinking lines
>
> 1. I should not be physically replacing the dll?
> 2. There are some registry entries which might be invalid?
> 3. I am linking to a C++ file with extern “C” linkage, does
> that create a problem? There is a related query here, I cannot use new
> and delete, what compiler flag is missing in the source file?
> 4. The checked build just bloats up the driver, and GDI can’t
> load it into memory?
>
> Can someone help me with this? If anyone has any pointers, it
> will be of immense help.
>
> Thanks,
>
> Kartik
> –
>
> ============================================================
> “A slow sort of country!” said the Queen. “Now, HERE, you see, it takes
> all the running YOU can do, to keep in the same place. If you want to
> get somewhere else, you must run at least twice as
> fast as that.”
> -Lewis Carroll
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@wipro.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: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>



============================================================
“A slow sort of country!” said the Queen. “Now, HERE, you see, it
takes all the running YOU can do, to keep in the same place.
If you want to get somewhere else, you must run at least twice as
fast as that.”
-Lewis Carroll