Problem in the calling the dll functions

A

ashutosh

hi,

i am making the dll for clamav antivirus libraray so that i can make
activex control for windows.

i complied the library successfully and make the Libclamav.dll file using
win32 Api project in debug mode.

this dll file exports all the 21 function which is needed for clamscan.

now i am making the MFC project in which i am calling these function.

the function in which i am loading the database dir crash with the

Error Message : Unhandled exception at 0x0008686a in export.exe: 0xC0000005:
Access violation reading location 0x0008686a.

note: here export.exe is my program executable file.

Please help me to sort out the problem . i want to know :
a. where is the actual problem?
In the application program or in the dll

what should be the approach to find out the error . i am new in the vc++
programing environment. so please try to give me detail information about
this problem.
 
O

Oleg Starodumov

Error Message : Unhandled exception at 0x0008686a in export.exe: 0xC0000005:
Access violation reading location 0x0008686a.

Here are some possible reasons:
1) Buffer overwrite in a function (thus jumping to incorrect address when returning;
check arrays declared as local variables and make sure that the code does not write
past their boundaries)
2) Function call through an invalid pointer
3) Heap corruption
4) Some other reasons are possible, but less likely
what should be the approach to find out the error

Try to step through the code in the debugger, it is very likely
that you will find the problem this way. If you attached the debugger
only after the exception, check the call stack - it can tell what functions
were called recently (though it is possible that the call stack will not be available).

Also, since you write the code, use tracing and insert as many trace statements
into the application and the DLL as possible (at least, trace all function calls).
The trace log will tell you what functions have been executing just before
the problem occurred, therefore you will know where to look for the problem.
You can use OutputDebugString, TRACE, ATLTRACE, or other tracing libraries
(e.g. see CodeGuru.com).

Check that all DLL functions are properly declared, and the declarations
are up-to-date in the DLL and in the client application.
Make sure that the up-to-date version of the DLL is used
(check the location it is loaded from).

If you use VS.NET, make sure that /RTC1 and /GS compiler options are enabled.

If you call functions through pointers, verify all pointers before calling the functions.

If it does not help, there are other approaches that can be applied.

Regards,
Oleg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top