diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2010-07-16 10:04:42 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2010-07-16 10:04:42 +0400 |
commit | 22cd497d1334273d22e954653113a08a1dbb1131 (patch) | |
tree | 799b361c20bec896f5fc59f5b6ab5652992c7eb1 /src/apps/mplayerc/mplayerc.cpp | |
parent | 3f86f99aa4c6956c98bbc4b41d1e367b25445385 (diff) |
Add : Heap Corruption Detection(http://msdn.microsoft.com/en-us/library/bb430720.aspx)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2123 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc/mplayerc.cpp')
-rw-r--r-- | src/apps/mplayerc/mplayerc.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/apps/mplayerc/mplayerc.cpp b/src/apps/mplayerc/mplayerc.cpp index 1796b9a61..65c1ac11a 100644 --- a/src/apps/mplayerc/mplayerc.cpp +++ b/src/apps/mplayerc/mplayerc.cpp @@ -775,6 +775,30 @@ public: }
};
+BOOL SetHeapOptions() {
+ HMODULE hLib = LoadLibrary(L"kernel32.dll");
+ if (hLib == NULL) return FALSE;
+
+ typedef BOOL (WINAPI *HSI)
+ (HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
+ HSI pHsi = (HSI)GetProcAddress(hLib,"HeapSetInformation");
+ if (!pHsi) {
+ FreeLibrary(hLib);
+ return FALSE;
+ }
+
+#ifndef HeapEnableTerminationOnCorruption
+# define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
+#endif
+
+ BOOL fRet = (pHsi)(NULL,HeapEnableTerminationOnCorruption,NULL,0)
+ ? TRUE
+ : FALSE;
+ if (hLib) FreeLibrary(hLib);
+
+ return fRet;
+}
+
BOOL CMPlayerCApp::InitInstance()
{
@@ -794,6 +818,17 @@ BOOL CMPlayerCApp::InitInstance() AfxMessageBox(_T("Could not create console"));
#endif
+ if(SetHeapOptions())
+ {
+ TRACE(_T("Terminate on corruption enabled\n"));
+ }
+ else
+ {
+ CString heap_err;
+ heap_err.Format(_T("Terminate on corruption error = %d\n"), GetLastError());
+ TRACE(heap_err);
+ }
+
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
|