S
Senapathy
Environment: WinXP, VC++ 7.1 Standard Edition
~~~~~~~~~~~
I have a set of functions that I invoke from main() function of a sample
console app.
These are the functions:
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
HANDLE hLogFile = CreateFile(_T("D:\\Temp\\dump.txt"),
GENERIC_WRITE|GENERIC_READ,0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
NULL);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, hLogFile);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, hLogFile);
These are supposed to catch memory leaks and array bounds overflow etc and
then dump the data into the designated text file.
My console app is built with /RTC1 ( = /RTCsu ) flag to detect stack /
buffer overflows.
Now if I introduce a buffer overflow (accessing over last element of a C
style array), the error is properly redirected to the text file and I can
see the results in the txt file.
Problem:
---------
Obviously, I have many such exes where I wish to introduce this run time
debug checks. So the idea was to have a common dll which everyone uses and
then put these calls from within the DllMain of the dll. So if any exe just
links against this dll, it automatically has called these functions through
the DllMain.
I coded these functions in the PROCESS_ATTACH part of the common dll. When
the exe runs, I can see that the DllMain and these functions are getting
called. However, now when the program terminates, there is no dump
generated.
I can see that one thing: if the leak is in main() module, the check
functions have to be called from there.
If the leak / overflow is there in the Dll, the calls have to be made from
within the Dll.
Is there any way in which I can make the call within the Dll and not expect
every exe to also change?
~~~~~~~~~~~
I have a set of functions that I invoke from main() function of a sample
console app.
These are the functions:
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
HANDLE hLogFile = CreateFile(_T("D:\\Temp\\dump.txt"),
GENERIC_WRITE|GENERIC_READ,0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
NULL);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, hLogFile);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, hLogFile);
These are supposed to catch memory leaks and array bounds overflow etc and
then dump the data into the designated text file.
My console app is built with /RTC1 ( = /RTCsu ) flag to detect stack /
buffer overflows.
Now if I introduce a buffer overflow (accessing over last element of a C
style array), the error is properly redirected to the text file and I can
see the results in the txt file.
Problem:
---------
Obviously, I have many such exes where I wish to introduce this run time
debug checks. So the idea was to have a common dll which everyone uses and
then put these calls from within the DllMain of the dll. So if any exe just
links against this dll, it automatically has called these functions through
the DllMain.
I coded these functions in the PROCESS_ATTACH part of the common dll. When
the exe runs, I can see that the DllMain and these functions are getting
called. However, now when the program terminates, there is no dump
generated.
I can see that one thing: if the leak is in main() module, the check
functions have to be called from there.
If the leak / overflow is there in the Dll, the calls have to be made from
within the Dll.
Is there any way in which I can make the call within the Dll and not expect
every exe to also change?