GdiLeakDetector

所属分类:弱点检测代码
开发工具:C++
文件大小:0KB
下载次数:0
上传日期:2018-09-22 10:12:13
上 传 者sh-1993
说明:  Gdi泄漏检测器,,
(GdiLeakDetector,,)

文件列表:
GdiLeakDetector.sln (2016, 2018-09-22)
GdiLeakDetector/ (0, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.cpp (1786, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.h (243, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.rc (5842, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.vcproj (5583, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.vcproj.CHENDEPING.chendeping.user (1352, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.vcproj.DEPING-DELL.chendeping.user (1354, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.vcproj.TONGHAO.闄堝痉骞.user (1344, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.vcxproj (7738, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.vcxproj.filters (2385, 2018-09-22)
GdiLeakDetector/GdiLeakDetector.vcxproj.user (162, 2018-09-22)
GdiLeakDetector/GdiLeakDetectorDlg.cpp (19038, 2018-09-22)
GdiLeakDetector/GdiLeakDetectorDlg.h (1199, 2018-09-22)
GdiLeakDetector/LineNumEdit.cpp (488, 2018-09-22)
GdiLeakDetector/LineNumEdit.h (240, 2018-09-22)
GdiLeakDetector/MyEdit.cpp (756, 2018-09-22)
GdiLeakDetector/MyEdit.h (303, 2018-09-22)
GdiLeakDetector/packages.config (140, 2018-09-22)
GdiLeakDetector/res/ (0, 2018-09-22)
GdiLeakDetector/res/GdiLeakDetector.ico (21630, 2018-09-22)
GdiLeakDetector/res/GdiLeakDetector.rc2 (286, 2018-09-22)
GdiLeakDetector/resource.h (1025, 2018-09-22)
GdiLeakDetector/stdafx.cpp (23, 2018-09-22)
GdiLeakDetector/stdafx.h (1530, 2018-09-22)
GdiSpy/ (0, 2018-09-22)
GdiSpy/GdiMonitor.cpp (23188, 2018-09-22)
GdiSpy/GdiMonitor.h (8397, 2018-09-22)
GdiSpy/GdiSpy.cpp (425, 2018-09-22)
GdiSpy/GdiSpy.vcproj (4729, 2018-09-22)
GdiSpy/GdiSpy.vcproj.CHENDEPING.chendeping.user (1326, 2018-09-22)
GdiSpy/GdiSpy.vcproj.DEPING-DELL.chendeping.user (1328, 2018-09-22)
GdiSpy/GdiSpy.vcproj.TONGHAO.闄堝痉骞.user (1318, 2018-09-22)
GdiSpy/GdiSpy.vcxproj (6206, 2018-09-22)
GdiSpy/GdiSpy.vcxproj.filters (1811, 2018-09-22)
GdiSpy/GdiSpy.vcxproj.user (162, 2018-09-22)
GdiSpy/StackWalker.cpp (18078, 2018-09-22)
... ...

# GdiLeakDetector ##Introduction This is an easy-to-use, powerful, and efficient tool to detect and locate GDI leaks. It can be a good tool for use with Visual Studio. ## Mechanism of the tool The tool has two parts: GdiLeakDetector.exe and GdiSpy.dll. GdiLeakDetector.exe is a special debugger. It will launch a process in debug mode and will inject GdiSpy.dll to the debuggee. GdiSpy.dll will intercept the GDI get/create call to log the call stack and intercept the release/delete call to remove the corresponding log. If there is any leak when the debuggee exits, there may be GDI leaks. I say 'may' because the spy DLL may not be the last DLL unloaded, and some DLLs may be unloaded after it and then release the GDI resources they hold. So in theory, the wrong leak report can occur. But I don't think it's a big problem because developers can easily ignore the wrong reports. ## Acknowledgement Thanks to StackWalker from CodeProject. I learned a lot from the code. ## class StackWalker API I have rewritten the class to meet my needs: ```cpp class CStackWalker { public: CStackWalker(LPCTSTR symPath); ~CStackWalker(); // skipFrameCount: don't get the last skipFrameCount callstack entries. // maxFrameCount: get maxFrameCount callstack entries at most. // if maxFrameCount == -1, // get as many callstack entries as possible. void GetCallStack(/*out*/vector& callStacker, int skipFrameCount, int maxFrameCount=10); private: ... } ``` Now you can reuse the class like this: ```cpp //some .cpp file CStackWalker g_StackWalker; void somefunc() { vector callStacks; g_StackWalker.GetCallstack(callStacks, 1); ShowCallstack(callStacks); } //other .cpp file extern CStackWalker g_StackWalker; void otherfunc() { vector callStacks; g_StackWalker.GetCallstack(callStacks, 1); ShowCallstack(callStacks); } ```

近期下载者

相关文件


收藏者