Quantcast
Channel: Visual Leak Detector for Visual C++ 2008-2015
Viewing all articles
Browse latest Browse all 704

Commented Unassigned: LoadLibrary bug... [10555]

$
0
0
My English is not very good.
So instead sample code.

```
#include "vld.h"
#include <Windows.h>
#include <tchar.h>
#include <process.h>

UINT WINAPI ThreadProc1(LPVOID pParam)
{
while(1)
{
HMODULE hModule = ::LoadLibrary(_T("wtsapi32.dll"));

if(NULL != hModule)
{
::FreeLibrary(hModule);
hModule = NULL;
}
}

return 0;
}

UINT WINAPI ThreadProc2(LPVOID pParam)
{
while(1)
{
HMODULE hModule = ::LoadLibrary(_T("psapi.dll"));

if(NULL != hModule)
{
::FreeLibrary(hModule);
hModule = NULL;
}
}

return 0;
}

int main(int argc, char *argv[])
{
UINT nThreadID;
HANDLE hThread[2];

hThread[0] = (HANDLE)_beginthreadex(NULL, 0, ThreadProc1, NULL, 0, &nThreadID);
hThread[1] = (HANDLE)_beginthreadex(NULL, 0, ThreadProc2, NULL, 0, &nThreadID);

::WaitForMultipleObjects(2, hThread, TRUE, INFINITE);

return 0;
}

```



=> Crash Utility.cpp

```
IMAGE_IMPORT_DESCRIPTOR* FindOriginalImportDescriptor (HMODULE importmodule, LPCSTR exportmodulename)
{
IMAGE_IMPORT_DESCRIPTOR* idte = NULL;
IMAGE_SECTION_HEADER* section = NULL;
ULONG size = 0;

// Locate the importing module's Import Directory Table (IDT) entry for the
// exporting module. The importing module actually can have several IATs --
// one for each export module that it imports something from. The IDT entry
// gives us the offset of the IAT for the module we are interested in.
g_imageLock.Enter();
__try
{
___idte = (IMAGE_IMPORT_DESCRIPTOR*)ImageDirectoryEntryToDataEx((PVOID)importmodule, TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT, &size, &section);___
}
__except(FilterFunction(GetExceptionCode()))
{
idte = NULL;
}
...
}
```
Comments: Reproducible test case better than words

Viewing all articles
Browse latest Browse all 704

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>