1 ////////////////////////////////////////////////////////////////////////////////
\r
3 // Visual Leak Detector - CRT and MFC IAT Patch Functions Header
\r
4 // Copyright (c) 2009 Dan Moulding
\r
6 // This library is free software; you can redistribute it and/or
\r
7 // modify it under the terms of the GNU Lesser General Public
\r
8 // License as published by the Free Software Foundation; either
\r
9 // version 2.1 of the License, or (at your option) any later version.
\r
11 // This library is distributed in the hope that it will be useful,
\r
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
14 // Lesser General Public License for more details.
\r
16 // You should have received a copy of the GNU Lesser General Public
\r
17 // License along with this library; if not, write to the Free Software
\r
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
20 // See COPYING.txt for the full terms of the GNU Lesser General Public License.
\r
22 ////////////////////////////////////////////////////////////////////////////////
\r
28 "This header should only be included by Visual Leak Detector when building it from source. \
\r
29 Applications should never include this header."
\r
33 extern __declspec(dllexport) VisualLeakDetector vld;
\r
35 #define TEMPLATE_HEADER \
\r
36 template<wchar_t const *crtddll, wchar_t const *mfcddll, wchar_t const *mfcuddll,\
\r
37 char const *crtd_vector_new_name, char const *crtd_vector_new_dbg_name,\
\r
38 char const *crtd_scalar_new_name, char const *crtd_scalar_new_dbg_name,\
\r
39 int mfcd_vector_new_ordinal, int mfcd_vector_new_dbg_4p_ordinal, int mfcd_vector_new_dbg_3p_ordinal,\
\r
40 int mfcd_scalar_new_ordinal, int mfcd_scalar_new_dbg_4p_ordinal, int mfcd_scalar_new_dbg_3p_ordinal,\
\r
41 int mfcud_vector_new_ordinal, int mfcud_vector_new_dbg_4p_ordinal, int mfcud_vector_new_dbg_3p_ordinal,\
\r
42 int mfcud_scalar_new_ordinal, int mfcud_scalar_new_dbg_4p_ordinal, int mfcud_scalar_new_dbg_3p_ordinal>
\r
44 #define TEMPLATE_ARGS \
\r
45 crtddll, mfcddll, mfcuddll,\
\r
46 crtd_vector_new_name, crtd_vector_new_dbg_name,\
\r
47 crtd_scalar_new_name, crtd_scalar_new_dbg_name,\
\r
48 mfcd_vector_new_ordinal, mfcd_vector_new_dbg_4p_ordinal, mfcd_vector_new_dbg_3p_ordinal,\
\r
49 mfcd_scalar_new_ordinal, mfcd_scalar_new_dbg_4p_ordinal, mfcd_scalar_new_dbg_3p_ordinal,\
\r
50 mfcud_vector_new_ordinal, mfcud_vector_new_dbg_4p_ordinal, mfcud_vector_new_dbg_3p_ordinal,\
\r
51 mfcud_scalar_new_ordinal, mfcud_scalar_new_dbg_4p_ordinal, mfcud_scalar_new_dbg_3p_ordinal
\r
57 static void* __cdecl crtd__calloc_dbg (size_t num, size_t size, int type, char const *file, int line);
\r
58 static void* __cdecl crtd__malloc_dbg (size_t size, int type, const char *file, int line);
\r
59 static void* __cdecl crtd__realloc_dbg (void *mem, size_t size, int type, char const *file, int line);
\r
60 static void* __cdecl crtd__scalar_new_dbg (size_t size, int type, char const *file, int line);
\r
61 static void* __cdecl crtd__vector_new_dbg (size_t size, int type, char const *file, int line);
\r
62 static void* __cdecl crtd_calloc (size_t num, size_t size);
\r
63 static void* __cdecl crtd_malloc (size_t size);
\r
64 static void* __cdecl crtd_realloc (void *mem, size_t size);
\r
65 static void* __cdecl crtd_scalar_new (size_t size);
\r
66 static void* __cdecl crtd_vector_new (size_t size);
\r
68 template<char const *procname>
\r
69 static void* __cdecl crtd_new_dbg (SIZE_T fp, size_t size, int type, char const *file, int line);
\r
70 template<char const *procname>
\r
71 static void* __cdecl crtd_new (SIZE_T fp, size_t size);
\r
73 static void* __cdecl mfcd_vector_new (size_t size);
\r
74 static void* __cdecl mfcd__vector_new_dbg_4p (size_t size, int type, char const *file, int line);
\r
75 static void* __cdecl mfcd__vector_new_dbg_3p (size_t size, char const *file, int line);
\r
76 static void* __cdecl mfcd_scalar_new (size_t size);
\r
77 static void* __cdecl mfcd__scalar_new_dbg_4p (size_t size, int type, char const *file, int line);
\r
78 static void* __cdecl mfcd__scalar_new_dbg_3p (size_t size, char const *file, int line);
\r
79 static void* __cdecl mfcud_vector_new (size_t size);
\r
80 static void* __cdecl mfcud__vector_new_dbg_4p (size_t size, int type, char const *file, int line);
\r
81 static void* __cdecl mfcud__vector_new_dbg_3p (size_t size, char const *file, int line);
\r
82 static void* __cdecl mfcud_scalar_new (size_t size);
\r
83 static void* __cdecl mfcud__scalar_new_dbg_4p (size_t size, int type, char const *file, int line);
\r
84 static void* __cdecl mfcud__scalar_new_dbg_3p (size_t size, char const *file, int line);
\r
86 template<wchar_t const *mfcdll, int ordinal>
\r
87 static void* __cdecl mfcd_new_dbg (SIZE_T fp, size_t size, int type, char const *file, int line);
\r
88 template<wchar_t const *mfcdll, int ordinal>
\r
89 static void* __cdecl mfcd_new_dbg (SIZE_T fp, size_t size, char const *file, int line);
\r
90 template<wchar_t const *mfcdll, int ordinal>
\r
91 static void* __cdecl mfcd_new (SIZE_T fp, size_t size);
\r
95 ////////////////////////////////////////////////////////////////////////////////
\r
97 // Visual Studio DLLs
\r
99 ////////////////////////////////////////////////////////////////////////////////
\r
101 // crtd__calloc_dbg - Calls to _calloc_dbg from msvcrXXd.dll are patched
\r
102 // through to this function.
\r
104 // - mem (IN): Pointer to the memory block to be reallocated.
\r
106 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
108 // - type (IN): The CRT "use type" of the block to be allocated.
\r
110 // - file (IN): The name of the file from which this function is being called.
\r
112 // - line (IN): The line number, in the above file, at which this function is
\r
117 // Returns the value returned by _calloc_dbg.
\r
120 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__calloc_dbg (size_t num,
\r
126 static _calloc_dbg_t pcrtxxd__calloc_dbg = NULL;
\r
133 if (pcrtxxd__calloc_dbg == NULL) {
\r
134 // This is the first call to this function. Link to the real
\r
136 msvcrxxd = GetModuleHandle(crtddll);
\r
137 pcrtxxd__calloc_dbg = (_calloc_dbg_t)GetProcAddress(msvcrxxd, "_calloc_dbg");
\r
140 return vld.__calloc_dbg(pcrtxxd__calloc_dbg, fp, num, size, type, file, line);
\r
143 // crtd__malloc_dbg - Calls to _malloc_dbg from msvcrXXd.dll are patched
\r
144 // through to this function.
\r
146 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
148 // - type (IN): The CRT "use type" of the block to be allocated.
\r
150 // - file (IN): The name of the file from which this function is being called.
\r
152 // - line (IN): The line number, in the above file, at which this function is
\r
157 // Returns the value returned by _malloc_dbg.
\r
160 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__malloc_dbg (size_t size,
\r
165 static _malloc_dbg_t pcrtxxd__malloc_dbg = NULL;
\r
172 if (pcrtxxd__malloc_dbg == NULL) {
\r
173 // This is the first call to this function. Link to the real
\r
175 msvcrxxd = GetModuleHandle(crtddll);
\r
176 pcrtxxd__malloc_dbg = (_malloc_dbg_t)GetProcAddress(msvcrxxd, "_malloc_dbg");
\r
179 return vld.__malloc_dbg(pcrtxxd__malloc_dbg, fp, size, type, file, line);
\r
182 // crtd__realloc_dbg - Calls to _realloc_dbg from msvcrXXd.dll are patched
\r
183 // through to this function.
\r
185 // - mem (IN): Pointer to the memory block to be reallocated.
\r
187 // - size (IN): The size of the memory block to reallocate.
\r
189 // - type (IN): The CRT "use type" of the block to be reallocated.
\r
191 // - file (IN): The name of the file from which this function is being called.
\r
193 // - line (IN): The line number, in the above file, at which this function is
\r
198 // Returns the value returned by _realloc_dbg.
\r
201 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__realloc_dbg (void *mem,
\r
207 static _realloc_dbg_t pcrtxxd__realloc_dbg = NULL;
\r
214 if (pcrtxxd__realloc_dbg == NULL) {
\r
215 // This is the first call to this function. Link to the real
\r
217 msvcrxxd = GetModuleHandle(crtddll);
\r
218 pcrtxxd__realloc_dbg = (_realloc_dbg_t)GetProcAddress(msvcrxxd, "_realloc_dbg");
\r
221 return vld.__realloc_dbg(pcrtxxd__realloc_dbg, fp, mem, size, type, file, line);
\r
224 // crtd__scalar_new_dbg - Calls to the CRT's debug scalar new operator from
\r
225 // msvcrXXd.dll are patched through to this function.
\r
227 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
229 // - type (IN): The CRT "use type" of the block to be allocated.
\r
231 // - file (IN): The name of the file from which this function is being called.
\r
233 // - line (IN): The line number, in the above file, at which this function is
\r
238 // Returns the value returned by the CRT debug scalar new operator.
\r
241 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__scalar_new_dbg (size_t size,
\r
249 return crtd_new_dbg<crtd_scalar_new_dbg_name>(fp, size, type, file, line);
\r
252 // crtd__vector_new_dbg - Calls to the CRT's debug vector new operator from
\r
253 // msvcrXXd.dll are patched through to this function.
\r
255 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
257 // - type (IN): The CRT "use type" of the block to be allocated.
\r
259 // - file (IN): The name of the file from which this function is being called.
\r
261 // - line (IN): The line number, in the above file, at which this function is
\r
266 // Returns the value returned by the CRT debug vector new operator.
\r
269 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd__vector_new_dbg (size_t size,
\r
277 return crtd_new_dbg<crtd_vector_new_dbg_name>(fp, size, type, file, line);
\r
280 // crtd_calloc - Calls to calloc from msvcrXXd.dll are patched through to
\r
283 // - dll (IN): The name of the dll
\r
285 // - num (IN): The number of blocks, of size 'size', to be allocated.
\r
287 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
291 // Returns the valued returned from calloc.
\r
294 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_calloc (size_t num, size_t size)
\r
296 static calloc_t pcrtxxd_calloc = NULL;
\r
303 if (pcrtxxd_calloc == NULL) {
\r
304 // This is the first call to this function. Link to the real malloc.
\r
305 msvcrxxd = GetModuleHandle(crtddll);
\r
306 pcrtxxd_calloc = (calloc_t)GetProcAddress(msvcrxxd, "calloc");
\r
309 return vld._calloc(pcrtxxd_calloc, fp, num, size);
\r
312 // crtd_malloc - Calls to malloc from msvcrXXd.dll are patched through to
\r
315 // - dll (IN): The name of the dll
\r
317 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
321 // Returns the valued returned from malloc.
\r
324 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_malloc (size_t size)
\r
326 static malloc_t pcrtxxd_malloc = NULL;
\r
333 if (pcrtxxd_malloc == NULL) {
\r
334 // This is the first call to this function. Link to the real malloc.
\r
335 msvcrxxd = GetModuleHandle(crtddll);
\r
336 pcrtxxd_malloc = (malloc_t)GetProcAddress(msvcrxxd, "malloc");
\r
339 return vld._malloc(pcrtxxd_malloc, fp, size);
\r
342 // crtd_realloc - Calls to realloc from msvcrXXd.dll are patched through to
\r
345 // - dll (IN): The name of the dll
\r
347 // - mem (IN): Pointer to the memory block to reallocate.
\r
349 // - size (IN): Size of the memory block to reallocate.
\r
353 // Returns the value returned from realloc.
\r
356 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_realloc (void *mem, size_t size)
\r
358 static realloc_t pcrtxxd_realloc = NULL;
\r
365 if (pcrtxxd_realloc == NULL) {
\r
366 // This is the first call to this function. Link to the real realloc.
\r
367 msvcrxxd = GetModuleHandle(crtddll);
\r
368 pcrtxxd_realloc = (realloc_t)GetProcAddress(msvcrxxd, "realloc");
\r
371 return vld._realloc(pcrtxxd_realloc, fp, mem, size);
\r
374 // crtd_scalar_new - Calls to the CRT's scalar new operator from msvcrXXd.dll
\r
375 // are patched through to this function.
\r
377 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
381 // Returns the value returned by the CRT scalar new operator.
\r
384 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_scalar_new (size_t size)
\r
389 return crtd_new<crtd_scalar_new_name>(fp, size);
\r
392 // crtd_vector_new - Calls to the CRT's vector new operator from msvcrXXd.dll
\r
393 // are patched through to this function.
\r
395 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
399 // Returns the value returned by the CRT vector new operator.
\r
402 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_vector_new (size_t size)
\r
407 return crtd_new<crtd_vector_new_name>(fp, size);
\r
410 // crtd_new_dbg - A template function for implementation of patch functions to
\r
411 // the CRT's debug new operator from msvcrXXd.dll
\r
413 // - procname (IN): The debug new operator's name
\r
415 // - fp (IN): Frame pointer from the call that initiated this allocation.
\r
417 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
419 // - type (IN): The CRT "use type" of the block to be allocated.
\r
421 // - file (IN): The name of the file from which this function is being called.
\r
423 // - line (IN): The line number, in the above file, at which this function is
\r
428 // Returns the value returned by the CRT debug new operator.
\r
431 template<char const *procname>
\r
432 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_new_dbg (SIZE_T fp,
\r
438 static new_dbg_crt_t pcrtxxd_new_dbg = NULL;
\r
442 if (pcrtxxd_new_dbg == NULL) {
\r
443 // This is the first call to this function. Link to the real CRT debug
\r
445 msvcrxxd = GetModuleHandle(crtddll);
\r
446 pcrtxxd_new_dbg = (new_dbg_crt_t)GetProcAddress(msvcrxxd, procname);
\r
449 return vld.new_dbg_crt(pcrtxxd_new_dbg, fp, size, type, file, line);
\r
452 // crt_new - A template function for implementing patch functions to the
\r
453 // CRT's new operator from msvcrXXd.dll
\r
455 // - dll (IN): The name of the dll
\r
457 // - procname (IN): The debug new operator's name
\r
459 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
463 // Returns the value returned by the CRT new operator.
\r
466 template<char const *procname>
\r
467 void* CrtMfcPatch<TEMPLATE_ARGS>::crtd_new (SIZE_T fp, size_t size)
\r
469 static new_t pcrtxxd_scalar_new = NULL;
\r
473 if (pcrtxxd_scalar_new == NULL) {
\r
474 // This is the first call to this function. Link to the real CRT new
\r
476 msvcrxxd = GetModuleHandle(crtddll);
\r
477 pcrtxxd_scalar_new = (new_t)GetProcAddress(msvcrxxd, procname);
\r
480 return vld._new(pcrtxxd_scalar_new, fp, size);
\r
483 ////////////////////////////////////////////////////////////////////////////////
\r
487 ////////////////////////////////////////////////////////////////////////////////
\r
489 // mfcd__scalar_new_dbg_3p - Calls to the MFC debug scalar new operator from
\r
490 // mfcXXd.dll are patched through to this function.
\r
492 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
494 // - type (IN): The "use type" of the block to be allocated.
\r
496 // - file (IN): The name of the file from which this function is being called.
\r
498 // - line (IN): The line number, in the above file, at which this function is
\r
503 // Returns the value returned by the MFC debug scalar new operator.
\r
506 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__scalar_new_dbg_4p (size_t size,
\r
514 return mfcd_new_dbg<mfcddll, mfcd_scalar_new_dbg_4p_ordinal>
\r
515 (fp, size, type, file, line);
\r
518 // mfcd__scalar_new_dbg_3p - Calls to the MFC debug scalar new operator from
\r
519 // mfcXXd.dll are patched through to this function.
\r
521 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
523 // - file (IN): The name of the file from which this function is being called.
\r
525 // - line (IN): The line number, in the above file, at which this function is
\r
530 // Returns the value returned by the MFC debug scalar new operator.
\r
533 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__scalar_new_dbg_3p (size_t size,
\r
540 return mfcd_new_dbg<mfcddll, mfcd_scalar_new_dbg_3p_ordinal>
\r
541 (fp, size, file, line);
\r
544 // mfcd__vector_new_dbg_4p - Calls to the MFC debug vector new operator from
\r
545 // mfcXXd.dll are patched through to this function.
\r
547 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
549 // - type (IN): The "use type" of the block to be allocated.
\r
551 // - file (IN): The name of the file from which this function is being called.
\r
553 // - line (IN): The line number, in the above file, at which this function is
\r
558 // Returns the value returned by the MFC debug vector new operator.
\r
561 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__vector_new_dbg_4p (size_t size,
\r
569 return mfcd_new_dbg<mfcddll, mfcd_vector_new_dbg_4p_ordinal>
\r
570 (fp, size, type, file, line);
\r
573 // mfcd__vector_new_dbg_3p - Calls to the MFC debug vector new operator from
\r
574 // mfcXXd.dll are patched through to this function.
\r
576 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
578 // - file (IN): The name of the file from which this function is being called.
\r
580 // - line (IN): The line number, in the above file, at which this function is
\r
585 // Returns the value returned by the MFC debug vector new operator.
\r
588 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd__vector_new_dbg_3p (size_t size,
\r
595 return mfcd_new_dbg<mfcddll, mfcd_vector_new_dbg_3p_ordinal>
\r
596 (fp, size, file, line);
\r
599 // mfcd_scalar_new - Calls to the MFC scalar new operator from mfcXXd.dll are
\r
600 // patched through to this function.
\r
602 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
606 // Returns the value returned by the MFC scalar new operator.
\r
609 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_scalar_new (size_t size)
\r
614 return mfcd_new<mfcddll, mfcd_scalar_new_ordinal>(fp, size);
\r
617 // mfcd_vector_new - Calls to the MFC vector new operator from mfcXXd.dll are
\r
618 // patched through to this function.
\r
620 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
624 // Returns the value returned by the MFC vector new operator.
\r
627 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_vector_new (size_t size)
\r
632 return mfcd_new<mfcddll, mfcd_vector_new_ordinal>(fp, size);
\r
635 // mfcud__scalar_new_dbg_4p - Calls to the MFC debug scalar new operator from
\r
636 // mfcXXud.dll are patched through to this function.
\r
638 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
640 // - type (IN): The "use type" of the block to be allocated.
\r
642 // - file (IN): The name of the file from which this function is being called.
\r
644 // - line (IN): The line number, in the above file, at which this function is
\r
649 // Returns the value returned by the MFC debug scalar new operator.
\r
652 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__scalar_new_dbg_4p (size_t size,
\r
660 return mfcd_new_dbg<mfcuddll, mfcud_scalar_new_dbg_4p_ordinal>
\r
661 (fp, size, type, file, line);
\r
664 // mfcud__scalar_new_dbg_3p - Calls to the MFC debug scalar new operator from
\r
665 // mfcXXud.dll are patched through to this function.
\r
667 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
669 // - file (IN): The name of the file from which this function is being called.
\r
671 // - line (IN): The line number, in the above file, at which this function is
\r
676 // Returns the value returned by the MFC debug scalar new operator.
\r
679 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__scalar_new_dbg_3p (size_t size,
\r
686 return mfcd_new_dbg<mfcuddll, mfcud_scalar_new_dbg_3p_ordinal>
\r
687 (fp, size, file, line);
\r
690 // mfcud__vector_new_dbg_4p - Calls to the MFC debug vector new operator from
\r
691 // mfcXXud.dll are patched through to this function.
\r
693 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
695 // - type (IN): The "use type" of the block to be allocated.
\r
697 // - file (IN): The name of the file from which this function is being called.
\r
699 // - line (IN): The line number, in the above file, at which this function is
\r
704 // Returns the value returned by the MFC debug vector new operator.
\r
707 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__vector_new_dbg_4p (size_t size,
\r
715 return mfcd_new_dbg<mfcuddll, mfcud_vector_new_dbg_4p_ordinal>
\r
716 (fp, size, type, file, line);
\r
719 // mfcud__vector_new_dbg_3p - Calls to the MFC debug vector new operator from
\r
720 // mfcXXud.dll are patched through to this function.
\r
722 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
724 // - file (IN): The name of the file from which this function is being called.
\r
726 // - line (IN): The line number, in the above file, at which this function is
\r
731 // Returns the value returned by the MFC debug vector new operator.
\r
734 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud__vector_new_dbg_3p (size_t size,
\r
741 return mfcd_new_dbg<mfcuddll, mfcud_vector_new_dbg_3p_ordinal>
\r
742 (fp, size, file, line);
\r
745 // mfcud_scalar_new - Calls to the MFC scalar new operator from mfcXXud.dll are
\r
746 // patched through to this function.
\r
748 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
752 // Returns the value returned by the MFC scalar new operator.
\r
755 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud_scalar_new (size_t size)
\r
760 return mfcd_new<mfcuddll, mfcud_scalar_new_ordinal>(fp, size);
\r
763 // mfcud_vector_new - Calls to the MFC vector new operator from mfcXXud.dll are
\r
764 // patched through to this function.
\r
766 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
770 // Returns the value returned by the MFC vector new operator.
\r
773 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcud_vector_new (size_t size)
\r
778 return mfcd_new<mfcuddll, mfcud_vector_new_ordinal>(fp, size);
\r
781 // mfcd_new_dbg - A generic function for implementing patch functions to the MFC
\r
782 // debug new operators:
\r
783 // void* __cdecl operator new[](size_t size, int type, char const *file, int line)
\r
784 // void* __cdecl operator new(size_t size, int type, char const *file, int line)
\r
786 // - mfcdll (IN): The name of the MFC DLL
\r
788 // - ordinal (IN): The debug new operator's ordinal value
\r
790 // - type (IN): The "use type" of the block to be allocated.
\r
792 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
794 // - file (IN): The name of the file from which this function is being called.
\r
796 // - line (IN): The line number, in the above file, at which this function is
\r
801 // Returns the value returned by the MFC debug new operator.
\r
804 template<wchar_t const *mfcdll, int ordinal>
\r
805 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_new_dbg (SIZE_T fp,
\r
811 static new_dbg_crt_t pmfcxxd__new_dbg = NULL;
\r
815 if (pmfcxxd__new_dbg == NULL) {
\r
816 // This is the first call to this function. Link to the real MFC debug
\r
818 mfcxxd = GetModuleHandle(mfcdll);
\r
819 pmfcxxd__new_dbg = (new_dbg_crt_t)GetProcAddress(mfcxxd, (LPCSTR)ordinal);
\r
822 return vld.new_dbg_mfc(pmfcxxd__new_dbg, fp, size, type, file, line);
\r
825 // mfcd_new_dbg - A generic function for implementing patch functions to the MFC
\r
826 // debug new operators:
\r
827 // void* __cdecl operator new[](size_t size, char const *file, int line)
\r
828 // void* __cdecl operator new(size_t size, char const *file, int line)
\r
830 // - mfcdll (IN): The name of the MFC DLL
\r
832 // - ordinal (IN): The debug new operator's ordinal value
\r
834 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
836 // - file (IN): The name of the file from which this function is being called.
\r
838 // - line (IN): The line number, in the above file, at which this function is
\r
843 // Returns the value returned by the MFC debug new operator.
\r
846 template<wchar_t const *mfcdll, int ordinal>
\r
847 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_new_dbg (SIZE_T fp,
\r
852 static new_dbg_mfc_t pmfcxxd__new_dbg = NULL;
\r
856 if (pmfcxxd__new_dbg == NULL) {
\r
857 // This is the first call to this function. Link to the real MFC debug
\r
859 mfcxxd = GetModuleHandle(mfcdll);
\r
860 pmfcxxd__new_dbg = (new_dbg_mfc_t)GetProcAddress(mfcxxd, (LPCSTR)ordinal);
\r
863 return vld.new_dbg_mfc(pmfcxxd__new_dbg, fp, size, file, line);
\r
866 // mfcd_new - A generic function for implementing patch functions to the MFC new
\r
869 // - mfcdll (IN): The name of the MFC DLL
\r
871 // - ordinal (IN): The new operator's ordinal value
\r
873 // - size (IN): The size, in bytes, of the memory block to be allocated.
\r
877 // Returns the value returned by the MFC new operator.
\r
880 template<wchar_t const *mfcdll, int ordinal>
\r
881 void* CrtMfcPatch<TEMPLATE_ARGS>::mfcd_new (SIZE_T fp, size_t size)
\r
883 static new_t pmfcxxd_new = NULL;
\r
887 if (pmfcxxd_new == NULL) {
\r
888 // This is the first call to this function. Link to the real CRT new
\r
890 mfcxxd = GetModuleHandle(mfcdll);
\r
891 pmfcxxd_new = (new_t)GetProcAddress(mfcxxd, (LPCSTR)ordinal);
\r
894 return vld._new(pmfcxxd_new, fp, size);
\r
897 #undef TEMPLATE_HEADER
\r
898 #undef TEMPLATE_ARGS
\r
900 const extern char scalar_new_dbg_name[] = "??2@YAPAXIHPBDH@Z";
\r
901 const extern char vector_new_dbg_name[] = "??_U@YAPAXIHPBDH@Z";
\r
902 const extern char scalar_new_name[] = "??2@YAPAXI@Z";
\r
903 const extern char vector_new_name[] = "??_U@YAPAXI@Z";
\r
904 const extern wchar_t msvcrtd_dll[] = L"msvcrtd.dll";
\r
905 const extern wchar_t mfc42d_dll[] = L"mfc42d.dll";
\r
906 const extern wchar_t mfc42ud_dll[] = L"mfc42ud.dll";
\r
907 const extern wchar_t msvcr70d_dll[] = L"msvcr70d.dll";
\r
908 const extern wchar_t mfc70d_dll[] = L"mfc70d.dll";
\r
909 const extern wchar_t mfc70ud_dll[] = L"mfc70ud.dll";
\r
910 const extern wchar_t msvcr71d_dll[] = L"msvcr71d.dll";
\r
911 const extern wchar_t mfc71d_dll[] = L"mfc71d.dll";
\r
912 const extern wchar_t mfc71ud_dll[] = L"mfc71ud.dll";
\r
913 const extern wchar_t msvcr80d_dll[] = L"msvcr80d.dll";
\r
914 const extern wchar_t mfc80d_dll[] = L"mfc80d.dll";
\r
915 const extern wchar_t mfc80ud_dll[] = L"mfc80ud.dll";
\r
916 const extern wchar_t msvcr90d_dll[] = L"msvcr90d.dll";
\r
917 const extern wchar_t mfc90d_dll[] = L"mfc90d.dll";
\r
918 const extern wchar_t mfc90ud_dll[] = L"mfc90ud.dll";
\r
919 const extern wchar_t msvcr100d_dll[] = L"msvcr100d.dll";
\r
920 const extern wchar_t mfc100d_dll[] = L"mfc100d.dll";
\r
921 const extern wchar_t mfc100ud_dll[] = L"mfc100ud.dll";
\r
923 // Visual Studio 6.0
\r
924 typedef CrtMfcPatch<msvcrtd_dll, mfc42d_dll, mfc42ud_dll,
\r
925 vector_new_name, vector_new_dbg_name,
\r
926 scalar_new_name, scalar_new_dbg_name,
\r
927 0, 0, 0, 711, 712, 714,
\r
928 0, 0, 0, 711, 712, 714>
\r
930 // Visual Studio .NET 2002
\r
931 typedef CrtMfcPatch<msvcr70d_dll, mfc70d_dll, mfc70ud_dll,
\r
932 vector_new_name, vector_new_dbg_name,
\r
933 scalar_new_name, scalar_new_dbg_name,
\r
934 257, 258, 259, 832, 833, 834,
\r
935 258, 259, 260, 833, 834, 835>
\r
937 // Visual Studio .NET 2003
\r
938 typedef CrtMfcPatch<msvcr71d_dll, mfc71d_dll, mfc71ud_dll,
\r
939 vector_new_name, vector_new_dbg_name,
\r
940 scalar_new_name, scalar_new_dbg_name,
\r
941 267, 268, 269, 893, 894, 895,
\r
942 267, 268, 269, 893, 894, 895>
\r
944 // Visual Studio 2005
\r
945 typedef CrtMfcPatch<msvcr80d_dll, mfc80d_dll, mfc80ud_dll,
\r
946 vector_new_name, vector_new_dbg_name,
\r
947 scalar_new_name, scalar_new_dbg_name,
\r
948 267, 268, 269, 893, 894, 895,
\r
949 267, 268, 269, 893, 894, 895>
\r
951 // Visual Studio 2008
\r
952 typedef CrtMfcPatch<msvcr90d_dll, mfc90d_dll, mfc90ud_dll,
\r
953 vector_new_name, vector_new_dbg_name,
\r
954 scalar_new_name, scalar_new_dbg_name,
\r
955 267, 268, 269, 931, 932, 933,
\r
956 267, 268, 269, 935, 936, 937>
\r
959 // Visual Studio 2010
\r
960 typedef CrtMfcPatch<msvcr100d_dll, mfc100d_dll, mfc100ud_dll,
\r
961 vector_new_name, vector_new_dbg_name,
\r
962 scalar_new_name, scalar_new_dbg_name,
\r
963 267, 268, 269, 1405, 1406, 1407,
\r
964 267, 268, 269, 1412, 1413, 1414>
\r