|
-
January 26th, 2004, 02:01 AM
#1
Access Violation error
Hi Everyone,
I am using SetWindowLong() function to override the default window proc of another application.
Everything works fine I am able to process some of the message sent to the application.
Now I want to automaticaly setback the Orignal window proc using SetWindowLong() the application unloads my dll.
I have tried putting the code(SetwindowLong) in DllMain()--under DLL_PROCESS_DETACH. but the application crashes. When I do this.
While I run it in Debug mode
I am getting a Access Violation Error.
please help.....
drk76
-
January 26th, 2004, 03:34 AM
#2
From MSDN on DLL initialization/termination tasks:
Calling imported functions other than those located in Kernel32.dll may result in problems that are difficult to diagnose. For example, calling User, Shell, and COM functions can cause access violation errors, because some functions in their DLLs call LoadLibrary to load other system components. Conversely, calling those functions during termination can cause access violation errors because the corresponding component may already have been unloaded or uninitialized.
-
January 26th, 2004, 01:13 PM
#3
Sets a new address for the window procedure.
Windows NT/2000 or later: You cannot change this attribute if the window does not belong to the same process as the calling thread.
From MSDN
-
January 26th, 2004, 11:30 PM
#4
The window does belong to the same process as the calling thread because his DLL is loaded in the address space of that process, so a thread in that process is running his code.
The problem is calling SetWindowLong() from the DLL_PROCESS_DETATCH notification, as Microsoft states not to. DLL initialization/termination handlers should perform simple tasks only, and should not rely on DLL's other than kernel32.dll.
Last edited by Myself dot NET; January 26th, 2004 at 11:43 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|