Say I have a DLL which includes stdlib.h
and allocates some memory using malloc
and later frees it using free
. Is it possible for my main application to define a malloc
function and a free
function such that the DLL's malloc
and free
calls result in my main application's malloc
and free
functions being called?
If these functions I want to capture were not system calls and if I had control over my modules, I would have gone with the approaches in this thread.
I am trying to develop an application which links with certain modules. I do not want my main application itself to be affected by undefined behaviours in any module. Assuming it is possible for me to identify functions that need to be captured (like memory allocations/frees), is it possible to do such a thing portably?
I am currently working in Windows running Visual Studio 2010.