mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
visual leak detector: update add patch for msvc10
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38809 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b0716b0f13
commit
16bf5dabb7
@ -1,12 +1,36 @@
|
||||
Visual Leak Detector (VLD) Version 1.9f (beta)
|
||||
Visual Leak Detector (VLD) Version 1.9h (beta)
|
||||
|
||||
Change Log / Release Notes
|
||||
|
||||
Enhancements:
|
||||
+ Added support to work with Visual Studio 2010.
|
||||
|
||||
1.9h beta (24 February 2009)
|
||||
----------------------------
|
||||
Enhancements:
|
||||
+ Added support to work with Visual Studio 2008.
|
||||
|
||||
Known Bugs/Restrictions:
|
||||
+ Same bugs/restrictions as version 1.9f.
|
||||
|
||||
|
||||
1.9g beta (16 April 2008)
|
||||
----------------------------
|
||||
Bugs Fixed:
|
||||
+ Another deadlock condition may occur when loading DLLs into the process
|
||||
being debugged. Special thanks to Eric Bissonnette and Kristian Paradis for
|
||||
contributing this patch.
|
||||
|
||||
Known Bugs/Restrictions:
|
||||
+ Same bugs/restrictions as version 1.9f.
|
||||
|
||||
|
||||
1.9f beta (18 November 2006)
|
||||
----------------------------
|
||||
Bugs Fixed:
|
||||
+ Deadlocks or access violations may occur when loading DLLs into
|
||||
multithreaded processes.
|
||||
|
||||
+ In multithreaded programs, if the main thread terminates before other
|
||||
threads in the process, then Visual Leak Detector may cause an access
|
||||
violation while generating the memory leak report.
|
||||
@ -14,15 +38,19 @@ Visual Leak Detector (VLD) Version 1.9f (beta)
|
||||
Known Bugs/Restrictions:
|
||||
+ Memory allocations made through calls to functions loaded from a DLL using
|
||||
delayed loading may not be detected.
|
||||
|
||||
+ Support for programs that use MFC 7.0 or MFC 7.1 is not complete yet. Some
|
||||
memory leaks from such MFC-based programs may not be detected.
|
||||
|
||||
+ Visual Leak Detector may report leaks internal to Visual Leak Detector
|
||||
if the main thread of the process terminates while other threads are still
|
||||
running.
|
||||
|
||||
+ If more than one copy of the same C Runtime DLL is loaded in the process at
|
||||
the same time, then some leaks may go undetected (note that loading more
|
||||
than one copy of the C Runtime DLL into a process at the same time is
|
||||
probably a bad idea to begin with).
|
||||
|
||||
|
||||
1.9e beta (16 November 2006)
|
||||
----------------------------
|
||||
@ -34,12 +62,15 @@ Visual Leak Detector (VLD) Version 1.9f (beta)
|
||||
+ Numerous deadlock situations. The multithread synchronization scheme has
|
||||
been completely re-written which should make deadlocks in VLD much less
|
||||
likey to happen.
|
||||
|
||||
+ An access violation will occur in VLD if GetProcAddress is called to obtain
|
||||
an export's address by ordinal, for certain libraries.
|
||||
|
||||
+ Problems may potentially occur when the program being debugged exits due to
|
||||
the Debug Help Library having been detached from the process too early.
|
||||
Symptoms might include access violation exceptions or other erratic behavior
|
||||
just as the program exits and while VLD is generating the leak report.
|
||||
|
||||
+ The copy of vld.ini installed in VLD's installation directory overrides any
|
||||
other copies of vld.ini that are created, even copies placed in the
|
||||
working directory of the program being debugged.
|
||||
@ -47,35 +78,46 @@ Visual Leak Detector (VLD) Version 1.9f (beta)
|
||||
Known Bugs/Restrictions:
|
||||
+ Memory allocations made through calls to functions loaded from a DLL using
|
||||
delayed loading may not be detected.
|
||||
|
||||
+ Support for programs that use MFC 7.0 or MFC 7.1 is not complete yet. Some
|
||||
memory leaks from such MFC-based programs may not be detected.
|
||||
|
||||
+ If more than one copy of the same C Runtime DLL is loaded in the process at
|
||||
the same time, then some leaks may go undetected (note that loading more
|
||||
than one copy of the C Runtime DLL into a process at the same time is
|
||||
probably a bad idea to begin with).
|
||||
|
||||
|
||||
1.9d beta (12 November 2006)
|
||||
----------------------------
|
||||
Bugs Fixed:
|
||||
+ Failed assertion "freed == TRUE" pops up when running a program with VLD
|
||||
without the debugger attached.
|
||||
|
||||
+ Some, but not all, multithreaded programs that dynamically load and unload
|
||||
many DLLs have been known to experience problems, such as deadlocks or
|
||||
exceptions, when used with VLD.
|
||||
|
||||
+ Failed assertion "exportmodule != NULL" pops up when running some programs
|
||||
with VLD.
|
||||
|
||||
+ VLD fails to show file names or function names in the memory leak report for
|
||||
some programs that are linked with the dynamic CRT library.
|
||||
|
||||
+ Access violation exceptions are thrown, but caught by the operating system,
|
||||
when running some programs with VLD.
|
||||
|
||||
|
||||
1.9c beta (6 November 2006)
|
||||
---------------------------
|
||||
New Features/Enhancments:
|
||||
+ New NSIS installer makes setting up and using VLD much easier.
|
||||
|
||||
+ No need to manually copy dbghelp.dll to the right location, VLD will always
|
||||
find the right version.
|
||||
|
||||
+ MFC 8.0 is now fully supported.
|
||||
|
||||
+ The memory leak report is now written to the output window much faster.
|
||||
Support has been added, through a new configuration option, to slow down
|
||||
the report output for older versions of Visual Studio that have trouble
|
||||
@ -83,16 +125,22 @@ Visual Leak Detector (VLD) Version 1.9f (beta)
|
||||
|
||||
Bugs Fixed:
|
||||
+ All known compatibilities with Visual Studio 2005 have been eliminated.
|
||||
|
||||
+ Leaks from calloc may go undetected.
|
||||
|
||||
+ Leaks from vector new operator may go undetected.
|
||||
|
||||
+ VLDDisable and VLDEnable do not work as expected; some memory leaks that
|
||||
should be ignored by VLD due to a previous call to VLDDisable are still
|
||||
reported.
|
||||
|
||||
+ Unloading and reloading a previously loaded module may cause leaks that
|
||||
occur in the module after it was reloaded to go undetected.
|
||||
|
||||
+ If vld.h is included in a release build, then the compiler will generate
|
||||
errors if the VLDEnable or VLDDisable APIs have been used.
|
||||
|
||||
|
||||
1.9b beta (26 October 2006)
|
||||
---------------------------
|
||||
Bugs Fixed:
|
||||
@ -114,6 +162,7 @@ Visual Leak Detector (VLD) Version 1.9f (beta)
|
||||
This restriction does not apply to programs that use MFC 4.2, which is fully
|
||||
supported.
|
||||
|
||||
|
||||
1.9a beta (9 March 2006)
|
||||
------------------------
|
||||
New Features/Enhancments:
|
||||
|
@ -170,6 +170,10 @@
|
||||
blockquote {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
form {
|
||||
margin: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<title>Visual Leak Detector (Beta)</title>
|
||||
@ -183,7 +187,7 @@
|
||||
|
||||
<div id="masthead">
|
||||
|
||||
<h1>Visual Leak Detector 1.9f (Beta)</h1>
|
||||
<h1>Visual Leak Detector 1.9h (Beta)</h1>
|
||||
|
||||
<p id="slogan">Enhanced Memory Leak Detection for Visual C++</p>
|
||||
|
||||
@ -215,9 +219,13 @@
|
||||
|
||||
<li><a href="#restrictions">Known Restrictions</a></li>
|
||||
|
||||
<li><a href="#contibuting">Contributing</a></li>
|
||||
|
||||
<li><a href="#license">License</a></li>
|
||||
|
||||
<li><a href="#contact">Contacting the Author</a></li>
|
||||
|
||||
<li><a href="#help-wanted">Additional Developers Wanted</a></li>
|
||||
</ul>
|
||||
|
||||
</div> <!-- #toc -->
|
||||
@ -268,7 +276,7 @@
|
||||
Detector include and library directories to the Visual C++ include and library directory search paths:</p>
|
||||
|
||||
<ul>
|
||||
<li><strong>Visual C++ 8</strong>: Go to Tools -> Options -> Projects and Solutions -> VC++ Directories.
|
||||
<li><strong>Visual C++ 8 and 9</strong>: Go to Tools -> Options -> Projects and Solutions -> VC++ Directories.
|
||||
Select "Include files" from the "Show Directories For" drop-down menu. Add the
|
||||
<span class="filename">include</span> subdirectory from the Visual Leak Detector installation directory. Move it
|
||||
to the bottom of the list. Then select "Library files" from the drop-down menu and add the
|
||||
@ -529,16 +537,25 @@
|
||||
<h2 id="build">Building Visual Leak Detector from Source</h2>
|
||||
|
||||
<p>Because Visual Leak Detector is open source, it can be built from source if you want to tweak it to your
|
||||
liking. The most difficult part about building VLD from source is getting your build environment correctly set up.
|
||||
liking. As of Visual Studio 2008, the source can usually be built out-of-the-box without downloading or installing
|
||||
any other tools. If you are using Visual Studio 2008 (or later), you can skip ahead to
|
||||
<a href="#exec">Executing Your Built vld.dll</a>.
|
||||
|
||||
<p>Users with older versions of Visual Studio should continue reading here and follow the instructions in the next
|
||||
subsection.</p>
|
||||
|
||||
<h3>For Older Versions of Visual Studio</h3>
|
||||
|
||||
<p>The most difficult part about building VLD from source is getting your build environment correctly set up.
|
||||
But if you follow these instructions carefully, the process should be fairly painless.</p>
|
||||
|
||||
<ol>
|
||||
<li>VLD depends on the Debug Help Library. This library is part of
|
||||
<a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx">Debugging Tools for Windows</a> (DTfW).
|
||||
Download and install DTfW in order to install the required headers and libraries. I recommend installing version
|
||||
6.5 of DTfW. Newer versions may also work, but older versions will probably not work. Be sure to manually select
|
||||
to install the SDK files during the DTfW installation or the headers and libraries will not be installed (they
|
||||
are not installed with a default installation).</li>
|
||||
6.5 of DTfW, or later. Newer versions tend to work fine, but older versions will probably not work. Be sure to
|
||||
manually select to install the SDK files during the DTfW installation or the headers and libraries will not be
|
||||
installed (they are not always installed with a default installation).</li>
|
||||
|
||||
<li>Visual C++ will need to be made aware of where it can find the Debug Help Library header and library files.
|
||||
Add the <span class="filename">sdk\inc</span> and <span class="filename">sdk\lib</span> subdirectories from the
|
||||
@ -589,6 +606,8 @@
|
||||
<p>Once you have completed all of the above steps, your build environment should be ready. To build VLD, just open the
|
||||
<span class="filename">vld.sln</span> solution file and do a full build.</p>
|
||||
|
||||
<h3 id="exec">Executing Your Built vld.dll</h3>
|
||||
|
||||
<p>When actually running the built project, <span class="filename">vld.dll</span> will expect to find the Debug Help
|
||||
Library as a private assembly. The private assembly must be located in the same directory as
|
||||
<span class="filename">vld.dll</span> (either the <span class="filename">Release</span> or
|
||||
@ -607,17 +626,10 @@
|
||||
|
||||
<h2 id="x64">Windows x64 Support</h2>
|
||||
|
||||
<p>The VLD source code has been modified to add support for x64-based 64-bit Windows. However, the binary contained in
|
||||
the distributed version of VLD is 32-bit only. To take advantage of the 64-bit support, you'll need to build a 64-bit
|
||||
version of VLD from source. To build the 64-bit version, follow the instructions for <a href="#build">building VLD
|
||||
from source</a>. So long as it is built using a x64-compatible compiler in 64-bit mode, the resulting DLL will be a
|
||||
64-bit binary.</p>
|
||||
|
||||
<p class="note"><strong>Note:</strong> I have not personally tested the 64-bit extensions so they are not absolutely
|
||||
guaranteed to work out-of-the-box. There may be a few lingering 64-bit compiler errors that still need to be worked
|
||||
out. If you need 64-bit support and run into problems trying to build the source in 64-bit mode, please
|
||||
<a href="mailto:dmoulding@gmail.com">let me know</a>. I'll be glad to assist in getting the 64-bit code working
|
||||
properly.</p>
|
||||
<p>Currently VLD will not build on x64 due to limitations of the x64 compiler. Some efforts have been undertaken to
|
||||
get it working in a 64-bit environment, but have not yet been successful. If you need 64-bit support and run into
|
||||
problems trying to build the source in 64-bit mode, please <a href="mailto:dmoulding@gmail.com">let me know</a>.
|
||||
I'll be glad to assist in getting the 64-bit code working properly, if at all possible.</p>
|
||||
|
||||
|
||||
|
||||
@ -659,17 +671,17 @@
|
||||
DLLs in memory leak detection, by setting the <span class="option">ForceIncludeModules</span> configuration
|
||||
option to: "mfc70d.dll mfc71d.dll" and explicitly adding <span class="filename">vld.lib</span> as an input file
|
||||
on the linker command line (can be added through project settings by adding it to the list of library modules in
|
||||
the linker options). This restriction does not apply to programs that use MFC 4.2 or MFC 8.0 which are both fully
|
||||
supported.</li>
|
||||
the linker options). This restriction does not apply to programs that use MFC 4.2, MFC 8.0, or MFC 9.0, which are
|
||||
all fully supported.</li>
|
||||
|
||||
<li>Visual Leak Detector may report leaks internal to Visual Leak Detector if the main thread of the process
|
||||
terminates while other threads are still running.</li>
|
||||
|
||||
<li>On Windows 2000 and earlier operating systems, you may need to manually add the
|
||||
<span class="filename">bin\Microsoft.VC80.CRT</span> subdirectory from the Visual Leak Detector installation
|
||||
directory to the system PATH environment variable. Also, <span class="filename">dbghelp.dll</span> will probably
|
||||
need to be manually copied to the directory where the program being debugged resides. Otherwise the system may
|
||||
not find the required DLLs when running VLD.</li>
|
||||
<span class="filename">bin</span> subdirectory from the Visual Leak Detector installation directory to the system
|
||||
PATH environment variable. Also, <span class="filename">dbghelp.dll</span> will probably need to be manually copied
|
||||
to the directory where the program being debugged resides. Otherwise the system may not find the required DLLs when
|
||||
running VLD.</li>
|
||||
|
||||
<li>If more than one copy of the same C Runtime DLL is loaded in the process at the same time, then some leaks may
|
||||
go undetected (note that loading more than one copy of the C Runtime DLL at the same time is probably a bad idea
|
||||
@ -678,6 +690,15 @@
|
||||
|
||||
|
||||
|
||||
<h2 id="contibuting">Contributing</h2>
|
||||
|
||||
<p>I encourage developers who've added their own features, or fixed bugs they've found, to contribute to the project.
|
||||
The full version-controlled source tree is available publicly via Git at the URL below. Feel free to clone from this
|
||||
URL and submit patches for consideration for inclusion in future versions. You can also hop onto
|
||||
<a href="http://github.com">GitHub</a> (accounts are free) and issue pull requests for changes that you've made and
|
||||
would like to share.</p>
|
||||
|
||||
<p>Git Repository URL: git://github.com/dmoulding/vld.git</p>
|
||||
|
||||
<h2 id="license">License</h2>
|
||||
|
||||
@ -733,12 +754,24 @@ BWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbG
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<h2 id="help-wanted">Additional Developers Wanted</h2>
|
||||
|
||||
<p>This project is looking for additional developers who have the time, knowledge, and talent, to help make VLD continue
|
||||
to be a useful utility for the Windows developer community. If you feel that you or someone you know would be
|
||||
interested in becoming an active member of the Visual Leak Detector development team, please let me know.</p>
|
||||
|
||||
|
||||
|
||||
<p id="compliance">
|
||||
<a href="http://validator.w3.org"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a>
|
||||
<a href="http://jigsaw.w3.org/css-validator"><img id="valid-css" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>
|
||||
</p>
|
||||
|
||||
<p id="copyright">Copyright © 2005-2006 Dan Moulding</p>
|
||||
|
||||
|
||||
<p id="copyright">Copyright © 2005-2009 Dan Moulding</p>
|
||||
|
||||
</div> <!-- #content -->
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: callstack.cpp,v 1.20 2006/11/18 03:12:34 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - CallStack Class Implementations
|
||||
// Copyright (c) 2005-2006 Dan Moulding
|
||||
// Copyright (c) 2005-2009 Dan Moulding
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -24,7 +23,9 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <windows.h>
|
||||
#ifndef __out_xcount
|
||||
#define __out_xcount(x) // Workaround for the specstrings.h bug in the Platform SDK.
|
||||
#endif
|
||||
#define DBGHELP_TRANSLATE_TCHAR
|
||||
#include <dbghelp.h> // Provides symbol handling services.
|
||||
#define VLDBUILD
|
||||
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: callstack.h,v 1.10 2006/11/18 03:12:34 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - CallStack Class Definitions
|
||||
// Copyright (c) 2005-2006 Dan Moulding
|
||||
@ -114,4 +113,4 @@ class SafeCallStack : public CallStack
|
||||
{
|
||||
public:
|
||||
VOID getstacktrace (UINT32 maxdepth, SIZE_T *framepointer);
|
||||
};
|
||||
};
|
||||
|
965
development/Win32/vld/src/crtmfcpatch.h
Normal file
965
development/Win32/vld/src/crtmfcpatch.h
Normal file
@ -0,0 +1,965 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual Leak Detector - CRT and MFC IAT Patch Functions Header
|
||||
// Copyright (c) 2009 Dan Moulding
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
// See COPYING.txt for the full terms of the GNU Lesser General Public License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef VLDBUILD
|
||||
#error \
|
||||
"This header should only be included by Visual Leak Detector when building it from source. \
|
||||
Applications should never include this header."
|
||||
#endif
|
||||
|
||||
#include "vldint.h"
|
||||
extern __declspec(dllexport) VisualLeakDetector vld;
|
||||
|
||||
#define TEMPLATE_HEADER \
|
||||
template<wchar_t const *crtddll, wchar_t const *mfcddll, wchar_t const *mfcuddll,\
|
||||
char const *crtd_vector_new_name, char const *crtd_vector_new_dbg_name,\
|
||||
char const *crtd_scalar_new_name, char const *crtd_scalar_new_dbg_name,\
|
||||
int mfcd_vector_new_ordinal, int mfcd_vector_new_dbg_4p_ordinal, int mfcd_vector_new_dbg_3p_ordinal,\
|
||||
int mfcd_scalar_new_ordinal, int mfcd_scalar_new_dbg_4p_ordinal, int mfcd_scalar_new_dbg_3p_ordinal,\
|
||||
int mfcud_vector_new_ordinal, int mfcud_vector_new_dbg_4p_ordinal, int mfcud_vector_new_dbg_3p_ordinal,\
|
||||
int mfcud_scalar_new_ordinal, int mfcud_scalar_new_dbg_4p_ordinal, int mfcud_scalar_new_dbg_3p_ordinal>
|
||||
|
||||
#define TEMPLATE_ARGS \
|
||||
crtddll, mfcddll, mfcuddll,\
|
||||
crtd_vector_new_name, crtd_vector_new_dbg_name,\
|
||||
crtd_scalar_new_name, crtd_scalar_new_dbg_name,\
|
||||
mfcd_vector_new_ordinal, mfcd_vector_new_dbg_4p_ordinal, mfcd_vector_new_dbg_3p_ordinal,\
|
||||
mfcd_scalar_new_ordinal, mfcd_scalar_new_dbg_4p_ordinal, mfcd_scalar_new_dbg_3p_ordinal,\
|
||||
mfcud_vector_new_ordinal, mfcud_vector_new_dbg_4p_ordinal, mfcud_vector_new_dbg_3p_ordinal,\
|
||||
mfcud_scalar_new_ordinal, mfcud_scalar_new_dbg_4p_ordinal, mfcud_scalar_new_dbg_3p_ordinal
|
||||
|
||||
TEMPLATE_HEADER
|
||||
class CrtMfcPatch
|
||||
{
|
||||
public:
|
||||
static void* __cdecl crtd__calloc_dbg (size_t num, size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl crtd__malloc_dbg (size_t size, int type, const char *file, int line);
|
||||
static void* __cdecl crtd__realloc_dbg (void *mem, size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl crtd__scalar_new_dbg (size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl crtd__vector_new_dbg (size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl crtd_calloc (size_t num, size_t size);
|
||||
static void* __cdecl crtd_malloc (size_t size);
|
||||
static void* __cdecl crtd_realloc (void *mem, size_t size);
|
||||
static void* __cdecl crtd_scalar_new (size_t size);
|
||||
static void* __cdecl crtd_vector_new (size_t size);
|
||||
|
||||
template<char const *procname>
|
||||
static void* __cdecl crtd_new_dbg (SIZE_T fp, size_t size, int type, char const *file, int line);
|
||||
template<char const *procname>
|
||||
static void* __cdecl crtd_new (SIZE_T fp, size_t size);
|
||||
|
||||
static void* __cdecl mfcd_vector_new (size_t size);
|
||||
static void* __cdecl mfcd__vector_new_dbg_4p (size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl mfcd__vector_new_dbg_3p (size_t size, char const *file, int line);
|
||||
static void* __cdecl mfcd_scalar_new (size_t size);
|
||||
static void* __cdecl mfcd__scalar_new_dbg_4p (size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl mfcd__scalar_new_dbg_3p (size_t size, char const *file, int line);
|
||||
static void* __cdecl mfcud_vector_new (size_t size);
|
||||
static void* __cdecl mfcud__vector_new_dbg_4p (size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl mfcud__vector_new_dbg_3p (size_t size, char const *file, int line);
|
||||
static void* __cdecl mfcud_scalar_new (size_t size);
|
||||
static void* __cdecl mfcud__scalar_new_dbg_4p (size_t size, int type, char const *file, int line);
|
||||
static void* __cdecl mfcud__scalar_new_dbg_3p (size_t size, char const *file, int line);
|
||||
|
||||
template<wchar_t const *mfcdll, int ordinal>
|
||||
static void* __cdecl mfcd_new_dbg (SIZE_T fp, size_t size, int type, char const *file, int line);
|
||||
template<wchar_t const *mfcdll, int ordinal>
|
||||
static void* __cdecl mfcd_new_dbg (SIZE_T fp, size_t size, char const *file, int line);
|
||||
template<wchar_t const *mfcdll, int ordinal>
|
||||
static void* __cdecl mfcd_new (SIZE_T fp, size_t size);
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual Studio DLLs
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// crtd__calloc_dbg - Calls to _calloc_dbg from msvcrXXd.dll are patched
|
||||
// through to this function.
|
||||
//
|
||||
// - mem (IN): Pointer to the memory block to be reallocated.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The CRT "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by _calloc_dbg.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__calloc_dbg (size_t num,
|
||||
size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
static _calloc_dbg_t pcrtxxd__calloc_dbg = NULL;
|
||||
|
||||
SIZE_T fp;
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
if (pcrtxxd__calloc_dbg == NULL) {
|
||||
// This is the first call to this function. Link to the real
|
||||
// _calloc_dbg.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd__calloc_dbg = (_calloc_dbg_t)GetProcAddress(msvcrxxd, "_calloc_dbg");
|
||||
}
|
||||
|
||||
return vld.__calloc_dbg(pcrtxxd__calloc_dbg, fp, num, size, type, file, line);
|
||||
}
|
||||
|
||||
// crtd__malloc_dbg - Calls to _malloc_dbg from msvcrXXd.dll are patched
|
||||
// through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The CRT "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by _malloc_dbg.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__malloc_dbg (size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
static _malloc_dbg_t pcrtxxd__malloc_dbg = NULL;
|
||||
|
||||
SIZE_T fp;
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
if (pcrtxxd__malloc_dbg == NULL) {
|
||||
// This is the first call to this function. Link to the real
|
||||
// _malloc_dbg.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd__malloc_dbg = (_malloc_dbg_t)GetProcAddress(msvcrxxd, "_malloc_dbg");
|
||||
}
|
||||
|
||||
return vld.__malloc_dbg(pcrtxxd__malloc_dbg, fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// crtd__realloc_dbg - Calls to _realloc_dbg from msvcrXXd.dll are patched
|
||||
// through to this function.
|
||||
//
|
||||
// - mem (IN): Pointer to the memory block to be reallocated.
|
||||
//
|
||||
// - size (IN): The size of the memory block to reallocate.
|
||||
//
|
||||
// - type (IN): The CRT "use type" of the block to be reallocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by _realloc_dbg.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__realloc_dbg (void *mem,
|
||||
size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
static _realloc_dbg_t pcrtxxd__realloc_dbg = NULL;
|
||||
|
||||
SIZE_T fp;
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
if (pcrtxxd__realloc_dbg == NULL) {
|
||||
// This is the first call to this function. Link to the real
|
||||
// _realloc_dbg.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd__realloc_dbg = (_realloc_dbg_t)GetProcAddress(msvcrxxd, "_realloc_dbg");
|
||||
}
|
||||
|
||||
return vld.__realloc_dbg(pcrtxxd__realloc_dbg, fp, mem, size, type, file, line);
|
||||
}
|
||||
|
||||
// crtd__scalar_new_dbg - Calls to the CRT's debug scalar new operator from
|
||||
// msvcrXXd.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The CRT "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the CRT debug scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__scalar_new_dbg (size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return crtd_new_dbg<crtd_scalar_new_dbg_name>(fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// crtd__vector_new_dbg - Calls to the CRT's debug vector new operator from
|
||||
// msvcrXXd.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The CRT "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the CRT debug vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__vector_new_dbg (size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return crtd_new_dbg<crtd_vector_new_dbg_name>(fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// crtd_calloc - Calls to calloc from msvcrXXd.dll are patched through to
|
||||
// this function.
|
||||
//
|
||||
// - dll (IN): The name of the dll
|
||||
//
|
||||
// - num (IN): The number of blocks, of size 'size', to be allocated.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the valued returned from calloc.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_calloc (size_t num, size_t size)
|
||||
{
|
||||
static calloc_t pcrtxxd_calloc = NULL;
|
||||
|
||||
SIZE_T fp;
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
if (pcrtxxd_calloc == NULL) {
|
||||
// This is the first call to this function. Link to the real malloc.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd_calloc = (calloc_t)GetProcAddress(msvcrxxd, "calloc");
|
||||
}
|
||||
|
||||
return vld._calloc(pcrtxxd_calloc, fp, num, size);
|
||||
}
|
||||
|
||||
// crtd_malloc - Calls to malloc from msvcrXXd.dll are patched through to
|
||||
// this function.
|
||||
//
|
||||
// - dll (IN): The name of the dll
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the valued returned from malloc.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_malloc (size_t size)
|
||||
{
|
||||
static malloc_t pcrtxxd_malloc = NULL;
|
||||
|
||||
SIZE_T fp;
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
if (pcrtxxd_malloc == NULL) {
|
||||
// This is the first call to this function. Link to the real malloc.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd_malloc = (malloc_t)GetProcAddress(msvcrxxd, "malloc");
|
||||
}
|
||||
|
||||
return vld._malloc(pcrtxxd_malloc, fp, size);
|
||||
}
|
||||
|
||||
// crtd_realloc - Calls to realloc from msvcrXXd.dll are patched through to
|
||||
// this function.
|
||||
//
|
||||
// - dll (IN): The name of the dll
|
||||
//
|
||||
// - mem (IN): Pointer to the memory block to reallocate.
|
||||
//
|
||||
// - size (IN): Size of the memory block to reallocate.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned from realloc.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_realloc (void *mem, size_t size)
|
||||
{
|
||||
static realloc_t pcrtxxd_realloc = NULL;
|
||||
|
||||
SIZE_T fp;
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
if (pcrtxxd_realloc == NULL) {
|
||||
// This is the first call to this function. Link to the real realloc.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd_realloc = (realloc_t)GetProcAddress(msvcrxxd, "realloc");
|
||||
}
|
||||
|
||||
return vld._realloc(pcrtxxd_realloc, fp, mem, size);
|
||||
}
|
||||
|
||||
// crtd_scalar_new - Calls to the CRT's scalar new operator from msvcrXXd.dll
|
||||
// are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the CRT scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_scalar_new (size_t size)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return crtd_new<crtd_scalar_new_name>(fp, size);
|
||||
}
|
||||
|
||||
// crtd_vector_new - Calls to the CRT's vector new operator from msvcrXXd.dll
|
||||
// are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the CRT vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_vector_new (size_t size)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return crtd_new<crtd_vector_new_name>(fp, size);
|
||||
}
|
||||
|
||||
// crtd_new_dbg - A template function for implementation of patch functions to
|
||||
// the CRT's debug new operator from msvcrXXd.dll
|
||||
//
|
||||
// - procname (IN): The debug new operator's name
|
||||
//
|
||||
// - fp (IN): Frame pointer from the call that initiated this allocation.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The CRT "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the CRT debug new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
template<char const *procname>
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_new_dbg (SIZE_T fp,
|
||||
size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
static new_dbg_crt_t pcrtxxd_new_dbg = NULL;
|
||||
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
if (pcrtxxd_new_dbg == NULL) {
|
||||
// This is the first call to this function. Link to the real CRT debug
|
||||
// new operator.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd_new_dbg = (new_dbg_crt_t)GetProcAddress(msvcrxxd, procname);
|
||||
}
|
||||
|
||||
return vld.new_dbg_crt(pcrtxxd_new_dbg, fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// crt_new - A template function for implementing patch functions to the
|
||||
// CRT's new operator from msvcrXXd.dll
|
||||
//
|
||||
// - dll (IN): The name of the dll
|
||||
//
|
||||
// - procname (IN): The debug new operator's name
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the CRT new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
template<char const *procname>
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_new (SIZE_T fp, size_t size)
|
||||
{
|
||||
static new_t pcrtxxd_scalar_new = NULL;
|
||||
|
||||
HMODULE msvcrxxd;
|
||||
|
||||
if (pcrtxxd_scalar_new == NULL) {
|
||||
// This is the first call to this function. Link to the real CRT new
|
||||
// operator.
|
||||
msvcrxxd = GetModuleHandle(crtddll);
|
||||
pcrtxxd_scalar_new = (new_t)GetProcAddress(msvcrxxd, procname);
|
||||
}
|
||||
|
||||
return vld._new(pcrtxxd_scalar_new, fp, size);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MFC DLLs
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// mfcd__scalar_new_dbg_3p - Calls to the MFC debug scalar new operator from
|
||||
// mfcXXd.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__scalar_new_dbg_4p (size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcddll, mfcd_scalar_new_dbg_4p_ordinal>
|
||||
(fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// mfcd__scalar_new_dbg_3p - Calls to the MFC debug scalar new operator from
|
||||
// mfcXXd.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__scalar_new_dbg_3p (size_t size,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcddll, mfcd_scalar_new_dbg_3p_ordinal>
|
||||
(fp, size, file, line);
|
||||
}
|
||||
|
||||
// mfcd__vector_new_dbg_4p - Calls to the MFC debug vector new operator from
|
||||
// mfcXXd.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__vector_new_dbg_4p (size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcddll, mfcd_vector_new_dbg_4p_ordinal>
|
||||
(fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// mfcd__vector_new_dbg_3p - Calls to the MFC debug vector new operator from
|
||||
// mfcXXd.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__vector_new_dbg_3p (size_t size,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcddll, mfcd_vector_new_dbg_3p_ordinal>
|
||||
(fp, size, file, line);
|
||||
}
|
||||
|
||||
// mfcd_scalar_new - Calls to the MFC scalar new operator from mfcXXd.dll are
|
||||
// patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_scalar_new (size_t size)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new<mfcddll, mfcd_scalar_new_ordinal>(fp, size);
|
||||
}
|
||||
|
||||
// mfcd_vector_new - Calls to the MFC vector new operator from mfcXXd.dll are
|
||||
// patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_vector_new (size_t size)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new<mfcddll, mfcd_vector_new_ordinal>(fp, size);
|
||||
}
|
||||
|
||||
// mfcud__scalar_new_dbg_4p - Calls to the MFC debug scalar new operator from
|
||||
// mfcXXud.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__scalar_new_dbg_4p (size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcuddll, mfcud_scalar_new_dbg_4p_ordinal>
|
||||
(fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// mfcud__scalar_new_dbg_3p - Calls to the MFC debug scalar new operator from
|
||||
// mfcXXud.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__scalar_new_dbg_3p (size_t size,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcuddll, mfcud_scalar_new_dbg_3p_ordinal>
|
||||
(fp, size, file, line);
|
||||
}
|
||||
|
||||
// mfcud__vector_new_dbg_4p - Calls to the MFC debug vector new operator from
|
||||
// mfcXXud.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - type (IN): The "use type" of the block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__vector_new_dbg_4p (size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcuddll, mfcud_vector_new_dbg_4p_ordinal>
|
||||
(fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// mfcud__vector_new_dbg_3p - Calls to the MFC debug vector new operator from
|
||||
// mfcXXud.dll are patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__vector_new_dbg_3p (size_t size,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new_dbg<mfcuddll, mfcud_vector_new_dbg_3p_ordinal>
|
||||
(fp, size, file, line);
|
||||
}
|
||||
|
||||
// mfcud_scalar_new - Calls to the MFC scalar new operator from mfcXXud.dll are
|
||||
// patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC scalar new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud_scalar_new (size_t size)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new<mfcuddll, mfcud_scalar_new_ordinal>(fp, size);
|
||||
}
|
||||
|
||||
// mfcud_vector_new - Calls to the MFC vector new operator from mfcXXud.dll are
|
||||
// patched through to this function.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC vector new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud_vector_new (size_t size)
|
||||
{
|
||||
SIZE_T fp;
|
||||
FRAMEPOINTER(fp);
|
||||
|
||||
return mfcd_new<mfcuddll, mfcud_vector_new_ordinal>(fp, size);
|
||||
}
|
||||
|
||||
// mfcd_new_dbg - A generic function for implementing patch functions to the MFC
|
||||
// debug new operators:
|
||||
// void* __cdecl operator new[](size_t size, int type, char const *file, int line)
|
||||
// void* __cdecl operator new(size_t size, int type, char const *file, int line)
|
||||
//
|
||||
// - mfcdll (IN): The name of the MFC DLL
|
||||
//
|
||||
// - ordinal (IN): The debug new operator's ordinal value
|
||||
//
|
||||
// - type (IN): The "use type" of the block to be allocated.
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
template<wchar_t const *mfcdll, int ordinal>
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_new_dbg (SIZE_T fp,
|
||||
size_t size,
|
||||
int type,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
static new_dbg_crt_t pmfcxxd__new_dbg = NULL;
|
||||
|
||||
HMODULE mfcxxd;
|
||||
|
||||
if (pmfcxxd__new_dbg == NULL) {
|
||||
// This is the first call to this function. Link to the real MFC debug
|
||||
// new operator.
|
||||
mfcxxd = GetModuleHandle(mfcdll);
|
||||
pmfcxxd__new_dbg = (new_dbg_crt_t)GetProcAddress(mfcxxd, (LPCSTR)ordinal);
|
||||
}
|
||||
|
||||
return vld.new_dbg_mfc(pmfcxxd__new_dbg, fp, size, type, file, line);
|
||||
}
|
||||
|
||||
// mfcd_new_dbg - A generic function for implementing patch functions to the MFC
|
||||
// debug new operators:
|
||||
// void* __cdecl operator new[](size_t size, char const *file, int line)
|
||||
// void* __cdecl operator new(size_t size, char const *file, int line)
|
||||
//
|
||||
// - mfcdll (IN): The name of the MFC DLL
|
||||
//
|
||||
// - ordinal (IN): The debug new operator's ordinal value
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// - file (IN): The name of the file from which this function is being called.
|
||||
//
|
||||
// - line (IN): The line number, in the above file, at which this function is
|
||||
// being called.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC debug new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
template<wchar_t const *mfcdll, int ordinal>
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_new_dbg (SIZE_T fp,
|
||||
size_t size,
|
||||
char const *file,
|
||||
int line)
|
||||
{
|
||||
static new_dbg_mfc_t pmfcxxd__new_dbg = NULL;
|
||||
|
||||
HMODULE mfcxxd;
|
||||
|
||||
if (pmfcxxd__new_dbg == NULL) {
|
||||
// This is the first call to this function. Link to the real MFC debug
|
||||
// new operator.
|
||||
mfcxxd = GetModuleHandle(mfcdll);
|
||||
pmfcxxd__new_dbg = (new_dbg_mfc_t)GetProcAddress(mfcxxd, (LPCSTR)ordinal);
|
||||
}
|
||||
|
||||
return vld.new_dbg_mfc(pmfcxxd__new_dbg, fp, size, file, line);
|
||||
}
|
||||
|
||||
// mfcd_new - A generic function for implementing patch functions to the MFC new
|
||||
// operators.
|
||||
//
|
||||
// - mfcdll (IN): The name of the MFC DLL
|
||||
//
|
||||
// - ordinal (IN): The new operator's ordinal value
|
||||
//
|
||||
// - size (IN): The size, in bytes, of the memory block to be allocated.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the value returned by the MFC new operator.
|
||||
//
|
||||
TEMPLATE_HEADER
|
||||
template<wchar_t const *mfcdll, int ordinal>
|
||||
void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_new (SIZE_T fp, size_t size)
|
||||
{
|
||||
static new_t pmfcxxd_new = NULL;
|
||||
|
||||
HMODULE mfcxxd;
|
||||
|
||||
if (pmfcxxd_new == NULL) {
|
||||
// This is the first call to this function. Link to the real CRT new
|
||||
// operator.
|
||||
mfcxxd = GetModuleHandle(mfcdll);
|
||||
pmfcxxd_new = (new_t)GetProcAddress(mfcxxd, (LPCSTR)ordinal);
|
||||
}
|
||||
|
||||
return vld._new(pmfcxxd_new, fp, size);
|
||||
}
|
||||
|
||||
#undef TEMPLATE_HEADER
|
||||
#undef TEMPLATE_ARGS
|
||||
|
||||
const extern char scalar_new_dbg_name[] = "??2@YAPAXIHPBDH@Z";
|
||||
const extern char vector_new_dbg_name[] = "??_U@YAPAXIHPBDH@Z";
|
||||
const extern char scalar_new_name[] = "??2@YAPAXI@Z";
|
||||
const extern char vector_new_name[] = "??_U@YAPAXI@Z";
|
||||
const extern wchar_t msvcrtd_dll[] = L"msvcrtd.dll";
|
||||
const extern wchar_t mfc42d_dll[] = L"mfc42d.dll";
|
||||
const extern wchar_t mfc42ud_dll[] = L"mfc42ud.dll";
|
||||
const extern wchar_t msvcr70d_dll[] = L"msvcr70d.dll";
|
||||
const extern wchar_t mfc70d_dll[] = L"mfc70d.dll";
|
||||
const extern wchar_t mfc70ud_dll[] = L"mfc70ud.dll";
|
||||
const extern wchar_t msvcr71d_dll[] = L"msvcr71d.dll";
|
||||
const extern wchar_t mfc71d_dll[] = L"mfc71d.dll";
|
||||
const extern wchar_t mfc71ud_dll[] = L"mfc71ud.dll";
|
||||
const extern wchar_t msvcr80d_dll[] = L"msvcr80d.dll";
|
||||
const extern wchar_t mfc80d_dll[] = L"mfc80d.dll";
|
||||
const extern wchar_t mfc80ud_dll[] = L"mfc80ud.dll";
|
||||
const extern wchar_t msvcr90d_dll[] = L"msvcr90d.dll";
|
||||
const extern wchar_t mfc90d_dll[] = L"mfc90d.dll";
|
||||
const extern wchar_t mfc90ud_dll[] = L"mfc90ud.dll";
|
||||
const extern wchar_t msvcr100d_dll[] = L"msvcr100d.dll";
|
||||
const extern wchar_t mfc100d_dll[] = L"mfc100d.dll";
|
||||
const extern wchar_t mfc100ud_dll[] = L"mfc100ud.dll";
|
||||
|
||||
// Visual Studio 6.0
|
||||
typedef CrtMfcPatch<msvcrtd_dll, mfc42d_dll, mfc42ud_dll,
|
||||
vector_new_name, vector_new_dbg_name,
|
||||
scalar_new_name, scalar_new_dbg_name,
|
||||
0, 0, 0, 711, 712, 714,
|
||||
0, 0, 0, 711, 712, 714>
|
||||
VS60;
|
||||
// Visual Studio .NET 2002
|
||||
typedef CrtMfcPatch<msvcr70d_dll, mfc70d_dll, mfc70ud_dll,
|
||||
vector_new_name, vector_new_dbg_name,
|
||||
scalar_new_name, scalar_new_dbg_name,
|
||||
257, 258, 259, 832, 833, 834,
|
||||
258, 259, 260, 833, 834, 835>
|
||||
VS70;
|
||||
// Visual Studio .NET 2003
|
||||
typedef CrtMfcPatch<msvcr71d_dll, mfc71d_dll, mfc71ud_dll,
|
||||
vector_new_name, vector_new_dbg_name,
|
||||
scalar_new_name, scalar_new_dbg_name,
|
||||
267, 268, 269, 893, 894, 895,
|
||||
267, 268, 269, 893, 894, 895>
|
||||
VS71;
|
||||
// Visual Studio 2005
|
||||
typedef CrtMfcPatch<msvcr80d_dll, mfc80d_dll, mfc80ud_dll,
|
||||
vector_new_name, vector_new_dbg_name,
|
||||
scalar_new_name, scalar_new_dbg_name,
|
||||
267, 268, 269, 893, 894, 895,
|
||||
267, 268, 269, 893, 894, 895>
|
||||
VS80;
|
||||
// Visual Studio 2008
|
||||
typedef CrtMfcPatch<msvcr90d_dll, mfc90d_dll, mfc90ud_dll,
|
||||
vector_new_name, vector_new_dbg_name,
|
||||
scalar_new_name, scalar_new_dbg_name,
|
||||
267, 268, 269, 931, 932, 933,
|
||||
267, 268, 269, 935, 936, 937>
|
||||
VS90;
|
||||
|
||||
// Visual Studio 2010
|
||||
typedef CrtMfcPatch<msvcr100d_dll, mfc100d_dll, mfc100ud_dll,
|
||||
vector_new_name, vector_new_dbg_name,
|
||||
scalar_new_name, scalar_new_dbg_name,
|
||||
267, 268, 269, 1405, 1406, 1407,
|
||||
267, 268, 269, 1412, 1413, 1414>
|
||||
VS100;
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: map.h,v 1.10 2006/11/18 03:12:34 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Lightweight STL-like Map Template
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: ntapi.cpp,v 1.7 2006/11/18 03:12:34 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Global NT API Function Pointers
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
@ -30,4 +29,4 @@
|
||||
LdrLoadDll_t LdrLoadDll;
|
||||
RtlAllocateHeap_t RtlAllocateHeap;
|
||||
RtlFreeHeap_t RtlFreeHeap;
|
||||
RtlReAllocateHeap_t RtlReAllocateHeap;
|
||||
RtlReAllocateHeap_t RtlReAllocateHeap;
|
||||
|
@ -1,8 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: ntapi.h,v 1.8 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - NT API Definitions
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
// Copyright (c) 2006-2009 Dan Moulding
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -33,7 +32,7 @@ Applications should never include this header."
|
||||
#include <windows.h>
|
||||
|
||||
// Return code type used by LdrLoadDll.
|
||||
typedef ULONG NTSTATUS;
|
||||
typedef LONG NTSTATUS;
|
||||
#define STATUS_SUCCESS 0
|
||||
|
||||
// Unicode string structure used by NT APIs.
|
||||
|
14
development/Win32/vld/src/resource.h
Normal file
14
development/Win32/vld/src/resource.h
Normal file
@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by vld.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: set.h,v 1.9 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Lightweight STL-like Set Template
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: tree.h,v 1.13 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Red-black Tree Template
|
||||
// Copyright (c) 2005-2006 Dan Moulding
|
||||
|
@ -1,8 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: utility.cpp,v 1.24 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Various Utility Functions
|
||||
// Copyright (c) 2005-2006 Dan Moulding
|
||||
// Copyright (c) 2005-2009 Dan Moulding
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -25,7 +24,12 @@
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <windows.h>
|
||||
#if _WIN32_WINNT > 0x0600 // Windows XP or earlier, no GetProcessIdOfThread()
|
||||
#include <winternl.h>
|
||||
#endif
|
||||
#ifndef __out_xcount
|
||||
#define __out_xcount(x) // Workaround for the specstrings.h bug in the Platform SDK.
|
||||
#endif
|
||||
#define DBGHELP_TRANSLATE_TCHAR
|
||||
#include <dbghelp.h> // Provides portable executable (PE) image access functions.
|
||||
#define VLDBUILD // Declares that we are building Visual Leak Detector.
|
||||
@ -779,3 +783,58 @@ BOOL strtobool (LPCWSTR s) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// _GetProcessIdOfThread - Returns the ID of the process owns the thread.
|
||||
//
|
||||
// - thread (IN): The handle to the thread.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// Returns the ID of the process that owns the thread. Otherwise returns 0.
|
||||
//
|
||||
DWORD _GetProcessIdOfThread (HANDLE thread)
|
||||
{
|
||||
typedef struct _CLIENT_ID {
|
||||
HANDLE UniqueProcess;
|
||||
HANDLE UniqueThread;
|
||||
} CLIENT_ID, *PCLIENT_ID;
|
||||
|
||||
typedef LONG NTSTATUS;
|
||||
typedef LONG KPRIORITY;
|
||||
|
||||
typedef struct _THREAD_BASIC_INFORMATION {
|
||||
NTSTATUS ExitStatus;
|
||||
PVOID TebBaseAddress;
|
||||
CLIENT_ID ClientId;
|
||||
KAFFINITY AffinityMask;
|
||||
KPRIORITY Priority;
|
||||
KPRIORITY BasePriority;
|
||||
} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
|
||||
|
||||
const static THREADINFOCLASS ThreadBasicInformation = (THREADINFOCLASS)0;
|
||||
|
||||
typedef NTSTATUS (WINAPI *PNtQueryInformationThread) (HANDLE thread,
|
||||
THREADINFOCLASS infoclass, PVOID buffer, ULONG buffersize,
|
||||
PULONG used);
|
||||
|
||||
static PNtQueryInformationThread NtQueryInformationThread = NULL;
|
||||
|
||||
THREAD_BASIC_INFORMATION tbi;
|
||||
NTSTATUS status;
|
||||
HMODULE ntdll;
|
||||
if (NtQueryInformationThread == NULL) {
|
||||
ntdll = GetModuleHandle(L"ntdll.dll");
|
||||
NtQueryInformationThread = (PNtQueryInformationThread)GetProcAddress(ntdll, "NtQueryInformationThread");
|
||||
if (NtQueryInformationThread == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
status = NtQueryInformationThread(thread, ThreadBasicInformation, &tbi, sizeof(tbi), NULL);
|
||||
if(status < 0) {
|
||||
// Shall we go through all the trouble of setting last error?
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (DWORD)tbi.ClientId.UniqueProcess;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: utility.h,v 1.19 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Various Utility Definitions
|
||||
// Copyright (c) 2005-2006 Dan Moulding
|
||||
@ -59,7 +58,7 @@ Applications should never include this header."
|
||||
#endif // _M_IX86
|
||||
|
||||
#if defined(_M_IX86) || defined (_M_X64)
|
||||
#define FRAMEPOINTER(fp) __asm mov fp, BPREG // Copies the current frame pointer to the supplied variable.
|
||||
#define FRAMEPOINTER(fp) __asm {mov fp, BPREG} // Copies the current frame pointer to the supplied variable.
|
||||
#else
|
||||
// If you want to retarget Visual Leak Detector to another processor
|
||||
// architecture then you'll need to provide an architecture-specific macro to
|
||||
@ -107,3 +106,7 @@ VOID setreportencoding (encoding_e encoding);
|
||||
VOID setreportfile (FILE *file, BOOL copydebugger);
|
||||
VOID strapp (LPWSTR *dest, LPCWSTR source);
|
||||
BOOL strtobool (LPCWSTR s);
|
||||
#if _WIN32_WINNT < 0x0600 // Windows XP or earlier, no GetProcessIdOfThread()
|
||||
DWORD _GetProcessIdOfThread (HANDLE thread);
|
||||
#define GetProcessIdOfThread _GetProcessIdOfThread
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,106 +1,97 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual Leak Detector - Import Library Header
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
// See COPYING.txt for the full terms of the GNU Lesser General Public License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef VLD_BUILD
|
||||
#define VLD_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
|
||||
#define VLD_EXPORT __declspec(dllimport)
|
||||
|
||||
#pragma comment(lib, "vld.lib")
|
||||
|
||||
// Force a symbolic reference to the global VisualLeakDetector class object from
|
||||
// the DLL. This enusres that the DLL is loaded and linked with the program,
|
||||
// even if no code otherwise imports any of the DLL's exports.
|
||||
#pragma comment(linker, "/include:__imp_?vld@@3VVisualLeakDetector@@A")
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual Leak Detector APIs
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
// VLDDisable - Disables Visual Leak Detector's memory leak detection at
|
||||
// runtime. If memory leak detection is already disabled, then calling this
|
||||
// function has no effect.
|
||||
//
|
||||
// Note: In multithreaded programs, this function operates on a per-thread
|
||||
// basis. In other words, if you call this function from one thread, then
|
||||
// memory leak detection is only disabled for that thread. If memory leak
|
||||
// detection is enabled for other threads, then it will remain enabled for
|
||||
// those other threads. It was designed to work this way to insulate you,
|
||||
// the programmer, from having to ensure thread synchronization when calling
|
||||
// VLDEnable() and VLDDisable(). Without this, calling these two functions
|
||||
// unsychronized could result in unpredictable and unintended behavior.
|
||||
// But this also means that if you want to disable memory leak detection
|
||||
// process-wide, then you need to call this function from every thread in
|
||||
// the process.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// None.
|
||||
//
|
||||
VLD_EXPORT void VLDDisable ();
|
||||
|
||||
// VLDEnable - Enables Visual Leak Detector's memory leak detection at runtime.
|
||||
// If memory leak detection is already enabled, which it is by default, then
|
||||
// calling this function has no effect.
|
||||
//
|
||||
// Note: In multithreaded programs, this function operates on a per-thread
|
||||
// basis. In other words, if you call this function from one thread, then
|
||||
// memory leak detection is only enabled for that thread. If memory leak
|
||||
// detection is disabled for other threads, then it will remain disabled for
|
||||
// those other threads. It was designed to work this way to insulate you,
|
||||
// the programmer, from having to ensure thread synchronization when calling
|
||||
// VLDEnable() and VLDDisable(). Without this, calling these two functions
|
||||
// unsychronized could result in unpredictable and unintended behavior.
|
||||
// But this also means that if you want to enable memory leak detection
|
||||
// process-wide, then you need to call this function from every thread in
|
||||
// the process.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// None.
|
||||
//
|
||||
VLD_EXPORT void VLDEnable ();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#else // !_DEBUG
|
||||
|
||||
#define VLDEnable()
|
||||
#define VLDDisable()
|
||||
|
||||
#endif // _DEBUG
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual Leak Detector - Import Library Header
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
// See COPYING.txt for the full terms of the GNU Lesser General Public License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#pragma comment(lib, "vld.lib")
|
||||
|
||||
// Force a symbolic reference to the global VisualLeakDetector class object from
|
||||
// the DLL. This enusres that the DLL is loaded and linked with the program,
|
||||
// even if no code otherwise imports any of the DLL's exports.
|
||||
#pragma comment(linker, "/include:__imp_?vld@@3VVisualLeakDetector@@A")
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual Leak Detector APIs
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
// VLDDisable - Disables Visual Leak Detector's memory leak detection at
|
||||
// runtime. If memory leak detection is already disabled, then calling this
|
||||
// function has no effect.
|
||||
//
|
||||
// Note: In multithreaded programs, this function operates on a per-thread
|
||||
// basis. In other words, if you call this function from one thread, then
|
||||
// memory leak detection is only disabled for that thread. If memory leak
|
||||
// detection is enabled for other threads, then it will remain enabled for
|
||||
// those other threads. It was designed to work this way to insulate you,
|
||||
// the programmer, from having to ensure thread synchronization when calling
|
||||
// VLDEnable() and VLDDisable(). Without this, calling these two functions
|
||||
// unsychronized could result in unpredictable and unintended behavior.
|
||||
// But this also means that if you want to disable memory leak detection
|
||||
// process-wide, then you need to call this function from every thread in
|
||||
// the process.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// None.
|
||||
//
|
||||
__declspec(dllimport) void VLDDisable ();
|
||||
|
||||
// VLDEnable - Enables Visual Leak Detector's memory leak detection at runtime.
|
||||
// If memory leak detection is already enabled, which it is by default, then
|
||||
// calling this function has no effect.
|
||||
//
|
||||
// Note: In multithreaded programs, this function operates on a per-thread
|
||||
// basis. In other words, if you call this function from one thread, then
|
||||
// memory leak detection is only enabled for that thread. If memory leak
|
||||
// detection is disabled for other threads, then it will remain disabled for
|
||||
// those other threads. It was designed to work this way to insulate you,
|
||||
// the programmer, from having to ensure thread synchronization when calling
|
||||
// VLDEnable() and VLDDisable(). Without this, calling these two functions
|
||||
// unsychronized could result in unpredictable and unintended behavior.
|
||||
// But this also means that if you want to enable memory leak detection
|
||||
// process-wide, then you need to call this function from every thread in
|
||||
// the process.
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// None.
|
||||
//
|
||||
__declspec(dllimport) void VLDEnable ();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#else // !_DEBUG
|
||||
|
||||
#define VLDEnable()
|
||||
#define VLDDisable()
|
||||
|
||||
#endif // _DEBUG
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: vldapi.cpp,v 1.19 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Exported APIs
|
||||
// Copyright (c) 2005-2006 Dan Moulding
|
||||
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: vldheap.cpp,v 1.13 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Internal C++ Heap Management
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
@ -35,7 +34,7 @@ CRITICAL_SECTION vldheaplock; // Serializes access to VLD's private hea
|
||||
|
||||
// Local helper functions.
|
||||
static inline void vlddelete (void *block);
|
||||
static inline void* vldnew (unsigned int size, const char *file, int line);
|
||||
static inline void* vldnew (size_t size, const char *file, int line);
|
||||
|
||||
// scalar delete operator - Delete operator used to free internally used memory
|
||||
// back to VLD's private heap.
|
||||
@ -105,7 +104,7 @@ void operator delete [] (void *block, const char *, int)
|
||||
// If the allocation succeeds, a pointer to the allocated memory block is
|
||||
// returned. If the allocation fails, NULL is returned.
|
||||
//
|
||||
void* operator new (unsigned int size, const char *file, int line)
|
||||
void* operator new (size_t size, const char *file, int line)
|
||||
{
|
||||
return vldnew(size, file, line);
|
||||
}
|
||||
@ -126,7 +125,7 @@ void* operator new (unsigned int size, const char *file, int line)
|
||||
// If the allocation succeeds, a pointer to the allocated memory block is
|
||||
// returned. If the allocation fails, NULL is returned.
|
||||
//
|
||||
void* operator new [] (unsigned int size, const char *file, int line)
|
||||
void* operator new [] (size_t size, const char *file, int line)
|
||||
{
|
||||
return vldnew(size, file, line);
|
||||
}
|
||||
@ -182,7 +181,7 @@ void vlddelete (void *block)
|
||||
// If the memory allocation succeeds, a pointer to the allocated memory
|
||||
// block is returned. If the allocation fails, NULL is returned.
|
||||
//
|
||||
void* vldnew (unsigned int size, const char *file, int line)
|
||||
void* vldnew (size_t size, const char *file, int line)
|
||||
{
|
||||
vldblockheader_t *header = (vldblockheader_t*)RtlAllocateHeap(vldheap, 0x0, size + sizeof(vldblockheader_t));
|
||||
static SIZE_T serialnumber = 0;
|
||||
@ -210,4 +209,4 @@ void* vldnew (unsigned int size, const char *file, int line)
|
||||
|
||||
// Return a pointer to the beginning of the data section of the block.
|
||||
return (void*)VLDBLOCKDATA(header);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: vldheap.h,v 1.11 2006/11/18 03:12:35 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - Internal C++ Heap Management Definitions
|
||||
// Copyright (c) 2006 Dan Moulding
|
||||
@ -72,7 +71,7 @@ typedef struct vldblockheader_s
|
||||
struct vldblockheader_s *prev; // Pointer to the preceding block in the list of internally allocated blocks.
|
||||
const char *file; // Name of the file where this block was allocated.
|
||||
int line; // Line number within the above file where this block was allocated.
|
||||
unsigned int size; // The size of this memory block, not including this header.
|
||||
size_t size; // The size of this memory block, not including this header.
|
||||
SIZE_T serialnumber; // Each block is assigned a unique serial number, starting from zero.
|
||||
} vldblockheader_t;
|
||||
|
||||
@ -87,8 +86,8 @@ void operator delete (void *block);
|
||||
void operator delete [] (void *block);
|
||||
void operator delete (void *block, const char *file, int line);
|
||||
void operator delete [] (void *block, const char *file, int line);
|
||||
void* operator new (unsigned int size, const char *file, int line);
|
||||
void* operator new [] (unsigned int size, const char *file, int line);
|
||||
void* operator new (size_t size, const char *file, int line);
|
||||
void* operator new [] (size_t size, const char *file, int line);
|
||||
|
||||
// All calls to the new operator from within VLD are mapped to the version of
|
||||
// new that allocates from VLD's private heap.
|
||||
|
@ -1,8 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: vldint.h,v 1.45 2006/11/18 05:17:09 dmouldin Exp $
|
||||
//
|
||||
// Visual Leak Detector - VisualLeakDetector Class Definition
|
||||
// Copyright (c) 2005-2006 Dan Moulding
|
||||
// Copyright (c) 2005-2009 Dan Moulding
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -42,12 +41,27 @@ Applications should never include this header."
|
||||
#define SELFTESTTEXTA "Memory Leak Self-Test"
|
||||
#define SELFTESTTEXTW L"Memory Leak Self-Test"
|
||||
#define VLDREGKEYPRODUCT L"Software\\Visual Leak Detector"
|
||||
#define VLDVERSION L"1.9f"
|
||||
#define VLDVERSION L"1.9h"
|
||||
|
||||
// The Visual Leak Detector APIs.
|
||||
extern "C" __declspec(dllexport) void VLDDisable ();
|
||||
extern "C" __declspec(dllexport) void VLDEnable ();
|
||||
|
||||
// Function pointer types for explicit dynamic linking with functions listed in
|
||||
// the import patch table.
|
||||
typedef void* (__cdecl *_calloc_dbg_t) (size_t, size_t, int, const char*, int);
|
||||
typedef void* (__cdecl *_malloc_dbg_t) (size_t, int, const char *, int);
|
||||
typedef void* (__cdecl *_realloc_dbg_t) (void *, size_t, int, const char *, int);
|
||||
typedef void* (__cdecl *calloc_t) (size_t, size_t);
|
||||
typedef HRESULT (__stdcall *CoGetMalloc_t) (DWORD, LPMALLOC *);
|
||||
typedef LPVOID (__stdcall *CoTaskMemAlloc_t) (ULONG);
|
||||
typedef LPVOID (__stdcall *CoTaskMemRealloc_t) (LPVOID, ULONG);
|
||||
typedef void* (__cdecl *malloc_t) (size_t);
|
||||
typedef void* (__cdecl *new_t) (size_t);
|
||||
typedef void* (__cdecl *new_dbg_crt_t) (size_t, int, const char *, int);
|
||||
typedef void* (__cdecl *new_dbg_mfc_t) (size_t, const char *, int);
|
||||
typedef void* (__cdecl *realloc_t) (void *, size_t);
|
||||
|
||||
// Data is collected for every block allocated from any heap in the process.
|
||||
// The data is stored in this structure and these structures are stored in
|
||||
// a BlockMap which maps each of these structures to its corresponding memory
|
||||
@ -100,7 +114,7 @@ typedef struct moduleinfo_s {
|
||||
typedef Set<moduleinfo_t> ModuleSet;
|
||||
|
||||
// Thread local storage structure. Every thread in the process gets its own copy
|
||||
// of this structure. Thread specific information, such as the currentl leak
|
||||
// of this structure. Thread specific information, such as the current leak
|
||||
// detection status (enabled or disabled) and the address that initiated the
|
||||
// current allocation is stored here.
|
||||
typedef struct tls_s {
|
||||
@ -148,73 +162,88 @@ public:
|
||||
VisualLeakDetector();
|
||||
~VisualLeakDetector();
|
||||
|
||||
// Public IMalloc methods - for support of COM-based memory leak detection.
|
||||
ULONG __stdcall AddRef ();
|
||||
LPVOID __stdcall Alloc (ULONG size);
|
||||
INT __stdcall DidAlloc (LPVOID mem);
|
||||
VOID __stdcall Free (LPVOID mem);
|
||||
ULONG __stdcall GetSize (LPVOID mem);
|
||||
VOID __stdcall HeapMinimize ();
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Public CRT and MFC Common Handlers
|
||||
//
|
||||
// Many heap functions are indirectly rerouted to these handlers. One common
|
||||
// function exists for each heap function with a given signature. These
|
||||
// handlers are not direct IAT replacements, but are called by the individual
|
||||
// IAT replacement functions.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Standard CRT and MFC common handlers
|
||||
void* _calloc (calloc_t pcalloc, SIZE_T fp, size_t num, size_t size);
|
||||
void* _malloc (malloc_t pmalloc, SIZE_T fp, size_t size);
|
||||
void* _new (new_t pnew, SIZE_T fp, size_t size);
|
||||
void* _realloc (realloc_t prealloc, SIZE_T fp, void *mem, size_t size);
|
||||
|
||||
// Debug CRT and MFC common handlers
|
||||
void* __calloc_dbg (_calloc_dbg_t p_calloc_dbg, SIZE_T fp, size_t num, size_t size, int type, char const *file, int line);
|
||||
void* __malloc_dbg (_malloc_dbg_t p_malloc_dbg, SIZE_T fp, size_t size, int type, char const *file, int line);
|
||||
void* new_dbg_crt (new_dbg_crt_t pnew_dbg_crt, SIZE_T fp, size_t size, int type, char const *file, int line);
|
||||
void* new_dbg_mfc (new_dbg_crt_t pnew_dbg, SIZE_T fp, size_t size, int type, char const *file, int line);
|
||||
void* new_dbg_mfc (new_dbg_mfc_t pnew_dbg_mfc, SIZE_T fp, size_t size, char const *file, int line);
|
||||
void* __realloc_dbg (_realloc_dbg_t p_realloc_dbg, SIZE_T fp, void *mem, size_t size, int type, char const *file, int line);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Public IMalloc methods - for support of COM-based memory leak detection.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ULONG __stdcall AddRef ();
|
||||
LPVOID __stdcall Alloc (ULONG size);
|
||||
INT __stdcall DidAlloc (LPVOID mem);
|
||||
VOID __stdcall Free (LPVOID mem);
|
||||
ULONG __stdcall GetSize (LPVOID mem);
|
||||
VOID __stdcall HeapMinimize ();
|
||||
HRESULT __stdcall QueryInterface (REFIID iid, LPVOID *object);
|
||||
LPVOID __stdcall Realloc (LPVOID mem, ULONG size);
|
||||
ULONG __stdcall Release ();
|
||||
LPVOID __stdcall Realloc (LPVOID mem, ULONG size);
|
||||
ULONG __stdcall Release ();
|
||||
|
||||
private:
|
||||
// Import patching replacement functions - see each function definition for details.
|
||||
static HRESULT __stdcall _CoGetMalloc (DWORD context, LPMALLOC *imalloc);
|
||||
static LPVOID __stdcall _CoTaskMemAlloc (ULONG size);
|
||||
static LPVOID __stdcall _CoTaskMemRealloc (LPVOID mem, ULONG size);
|
||||
static void* __cdecl _crt80d__calloc_dbg (size_t num, size_t size, int type, const char *file, int line);
|
||||
static void* __cdecl _crt80d__malloc_dbg (size_t size, int type, const char *file, int line);
|
||||
static void* __cdecl _crt80d__realloc_dbg (void *mem, size_t size, int type, const char *file, int line);
|
||||
static void* __cdecl _crt80d__scalar_new_dbg (unsigned int size, int type, const char *file, int line);
|
||||
static void* __cdecl _crt80d__vector_new_dbg (unsigned int size, int type, const char *file, int line);
|
||||
static void* __cdecl _crt80d_calloc (size_t num, size_t size);
|
||||
static void* __cdecl _crt80d_malloc (size_t size);
|
||||
static void* __cdecl _crt80d_realloc (void *mem, size_t size);
|
||||
static void* __cdecl _crt80d_scalar_new (unsigned int size);
|
||||
static void* __cdecl _crt80d_vector_new (unsigned int size);
|
||||
static void* __cdecl _crtd__calloc_dbg (size_t num, size_t size, int type, const char *file, int line);
|
||||
static void* __cdecl _crtd__malloc_dbg (size_t size, int type, const char *file, int line);
|
||||
static void* __cdecl _crtd__realloc_dbg (void *mem, size_t size, int type, const char *file, int line);
|
||||
static void* __cdecl _crtd__scalar_new_dbg (unsigned int size, int type, const char *file, int line);
|
||||
static void* __cdecl _crtd_calloc (size_t num, size_t size);
|
||||
static void* __cdecl _crtd_malloc (size_t size);
|
||||
static void* __cdecl _crtd_realloc (void *mem, size_t size);
|
||||
static void* __cdecl _crtd_scalar_new (unsigned int size);
|
||||
static FARPROC __stdcall _GetProcAddress(HMODULE module, LPCSTR procname);
|
||||
static HANDLE __stdcall _HeapCreate (DWORD options, SIZE_T initsize, SIZE_T maxsize);
|
||||
static BOOL __stdcall _HeapDestroy (HANDLE heap);
|
||||
static NTSTATUS __stdcall _LdrLoadDll (LPWSTR searchpath, PDWORD flags, unicodestring_t *modulename,
|
||||
PHANDLE modulehandle);
|
||||
static void* __cdecl _mfc42d__scalar_new_dbg (unsigned int size, const char *file, int line);
|
||||
static void* __cdecl _mfc42d_scalar_new (unsigned int size);
|
||||
static void* __cdecl _mfc80d__scalar_new_dbg (unsigned int size, const char *file, int line);
|
||||
static void* __cdecl _mfc80d__vector_new_dbg (unsigned int size, const char *file, int line);
|
||||
static void* __cdecl _mfc80d_scalar_new (unsigned int size);
|
||||
static void* __cdecl _mfc80d_vector_new (unsigned int size);
|
||||
static LPVOID __stdcall _RtlAllocateHeap (HANDLE heap, DWORD flags, SIZE_T size);
|
||||
static BOOL __stdcall _RtlFreeHeap (HANDLE heap, DWORD flags, LPVOID mem);
|
||||
static LPVOID __stdcall _RtlReAllocateHeap (HANDLE heap, DWORD flags, LPVOID mem, SIZE_T size);
|
||||
|
||||
// Private functions - see each function definition for details.
|
||||
static BOOL __stdcall addloadedmodule (PCWSTR modulepath, DWORD64 modulebase, ULONG modulesize, PVOID context);
|
||||
VOID attachtoloadedmodules (ModuleSet *newmodules);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private leak detection functions - see each function definition for details.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
VOID attachtoloadedmodules (ModuleSet *newmodules);
|
||||
LPWSTR buildsymbolsearchpath ();
|
||||
VOID configure ();
|
||||
static BOOL __stdcall detachfrommodule (PCWSTR modulepath, DWORD64 modulebase, ULONG modulesize, PVOID context);
|
||||
BOOL enabled ();
|
||||
VOID configure ();
|
||||
BOOL enabled ();
|
||||
SIZE_T eraseduplicates (const BlockMap::Iterator &element);
|
||||
tls_t* gettls ();
|
||||
VOID mapblock (HANDLE heap, LPCVOID mem, SIZE_T size, SIZE_T framepointer, BOOL crtalloc);
|
||||
VOID mapheap (HANDLE heap);
|
||||
VOID remapblock (HANDLE heap, LPCVOID mem, LPCVOID newmem, SIZE_T size, SIZE_T framepointer, BOOL crtalloc);
|
||||
VOID reportconfig ();
|
||||
VOID reportleaks (HANDLE heap);
|
||||
VOID unmapblock (HANDLE heap, LPCVOID mem);
|
||||
VOID unmapheap (HANDLE heap);
|
||||
VOID mapblock (HANDLE heap, LPCVOID mem, SIZE_T size, SIZE_T framepointer, BOOL crtalloc);
|
||||
VOID mapheap (HANDLE heap);
|
||||
VOID remapblock (HANDLE heap, LPCVOID mem, LPCVOID newmem, SIZE_T size, SIZE_T framepointer, BOOL crtalloc);
|
||||
VOID reportconfig ();
|
||||
VOID reportleaks (HANDLE heap);
|
||||
VOID unmapblock (HANDLE heap, LPCVOID mem);
|
||||
VOID unmapheap (HANDLE heap);
|
||||
|
||||
// Private data.
|
||||
// Static functions (callbacks)
|
||||
static BOOL __stdcall addloadedmodule (PCWSTR modulepath, DWORD64 modulebase, ULONG modulesize, PVOID context);
|
||||
static BOOL __stdcall detachfrommodule (PCWSTR modulepath, DWORD64 modulebase, ULONG modulesize, PVOID context);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// IAT replacement functions - see each function definition for details.
|
||||
//
|
||||
// Because there are so many virtually identical CRT and MFC replacement
|
||||
// functions, they are excluded from the class to reduce the amount of noise
|
||||
// within this class's code. See crtmfcpatch.cpp for those functions.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Win32 IAT replacement functions
|
||||
static FARPROC __stdcall _GetProcAddress (HMODULE module, LPCSTR procname);
|
||||
static HANDLE __stdcall _HeapCreate (DWORD options, SIZE_T initsize, SIZE_T maxsize);
|
||||
static BOOL __stdcall _HeapDestroy (HANDLE heap);
|
||||
static NTSTATUS __stdcall _LdrLoadDll (LPWSTR searchpath, PDWORD flags, unicodestring_t *modulename,
|
||||
PHANDLE modulehandle);
|
||||
static LPVOID __stdcall _RtlAllocateHeap (HANDLE heap, DWORD flags, SIZE_T size);
|
||||
static BOOL __stdcall _RtlFreeHeap (HANDLE heap, DWORD flags, LPVOID mem);
|
||||
static LPVOID __stdcall _RtlReAllocateHeap (HANDLE heap, DWORD flags, LPVOID mem, SIZE_T size);
|
||||
|
||||
// COM IAT replacement functions
|
||||
static HRESULT __stdcall _CoGetMalloc (DWORD context, LPMALLOC *imalloc);
|
||||
static LPVOID __stdcall _CoTaskMemAlloc (ULONG size);
|
||||
static LPVOID __stdcall _CoTaskMemRealloc (LPVOID mem, ULONG size);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Private data
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
WCHAR m_forcedmodulelist [MAXMODULELISTLENGTH]; // List of modules to be forcefully included in leak detection.
|
||||
HeapMap *m_heapmap; // Map of all active heaps in the process.
|
||||
IMalloc *m_imalloc; // Pointer to the system implementation of IMalloc.
|
||||
@ -258,6 +287,6 @@ private:
|
||||
};
|
||||
|
||||
// Configuration option default values
|
||||
#define VLD_DEFAULT_MAX_DATA_DUMP 0xffffffff
|
||||
#define VLD_DEFAULT_MAX_TRACE_FRAMES 0xffffffff
|
||||
#define VLD_DEFAULT_MAX_DATA_DUMP 256
|
||||
#define VLD_DEFAULT_MAX_TRACE_FRAMES 64
|
||||
#define VLD_DEFAULT_REPORT_FILE_NAME L".\\memory_leak_report.txt"
|
||||
|
@ -22,6 +22,8 @@
|
||||
#//
|
||||
#////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
cmake_minimum_required(VERSION 2.6.4)
|
||||
|
||||
project(vld)
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
@ -44,10 +46,14 @@ if (NOT HAVE_DEBUGGING_TOOLS_FOR_WINDOWS)
|
||||
message(FATAL_ERROR "")
|
||||
endif (NOT HAVE_DEBUGGING_TOOLS_FOR_WINDOWS)
|
||||
|
||||
set(vld_path ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||
|
||||
file(GLOB vld_sources ${vld_path}/src/*.cpp)
|
||||
file(GLOB vld_headers ${vld_path}/src/*.h)
|
||||
|
||||
add_definitions(-DVLD_BUILD -DUNICODE -D_UNICODE)
|
||||
|
||||
add_library(vld SHARED ${vld_sources} ${vld_headers} ${vld_path}/include/vld.h)
|
||||
|
||||
add_library(vld SHARED ${vld_sources} ${vld_headers})
|
||||
|
||||
|
||||
|
@ -23,9 +23,5 @@
|
||||
#////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
# This triggers the useage of vld in all other projects
|
||||
include_directories(${vld_path}/include)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /FIvld.h")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /FIvld.h")
|
||||
set(vld_dll vld)
|
||||
|
||||
add_subdirectory(${vld_path}/tools/cmake ${CMAKE_BINARY_DIR}/vld)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /FI${vld_path}/src/vld.h")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /FI${vld_path}/src/vld.h")
|
||||
|
@ -1,5 +1,4 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; $Id: vld.ini,v 1.7 2006/11/18 03:12:35 dmouldin Exp $
|
||||
;;
|
||||
;; Visual Leak Detector - Initialization/Configuration File
|
||||
;; Copyright (c) 2006 Dan Moulding
|
||||
|
Loading…
Reference in New Issue
Block a user