Fix memory leaks and module instrumentation in frida_gdiplus (#841)
* Fix memory leaks and module instrumentation in frida_gdiplus * Run clang-format
This commit is contained in:
parent
dee3bc4492
commit
d6d4fa506b
@ -6,4 +6,4 @@ Then compile the harness `cl.exe /LD harness.cc /link /dll gdiplus.lib ole32.lib
|
|||||||
|
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
To run the example `target\release\frida_gdiplus.exe -H harness.dll -i corpus -o output`
|
To run the example `target\release\frida_gdiplus.exe -H harness.dll -i corpus -o output --libs-to-instrument gdi32.dll --libs-to-instrument gdi32full.dll --libs-to-instrument gdiplus.dll --libs-to-instrument WindowsCodecs.dll`
|
||||||
|
@ -15,6 +15,19 @@ using namespace Gdiplus;
|
|||||||
GdiplusStartupInput gdiplusStartupInput;
|
GdiplusStartupInput gdiplusStartupInput;
|
||||||
ULONG_PTR gdiplusToken;
|
ULONG_PTR gdiplusToken;
|
||||||
|
|
||||||
|
// Some DLLs are lazily loaded during image loading
|
||||||
|
// FridaInstrumentationHelper doesn't instrument DLLs that are loaded after
|
||||||
|
// init, so they're manually loaded here
|
||||||
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||||
|
switch (fdwReason) {
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
LoadLibraryA("gdi32full.dll");
|
||||||
|
LoadLibraryA("WindowsCodecs.dll");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) int LLVMFuzzerTestOneInput(const uint8_t *data,
|
extern "C" __declspec(dllexport) int LLVMFuzzerTestOneInput(const uint8_t *data,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
static DWORD init = 0;
|
static DWORD init = 0;
|
||||||
@ -34,8 +47,6 @@ extern "C" __declspec(dllexport) int LLVMFuzzerTestOneInput(const uint8_t *data,
|
|||||||
Gdiplus::Bitmap *m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
|
Gdiplus::Bitmap *m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
|
||||||
pStream->Release();
|
pStream->Release();
|
||||||
if (m_pBitmap) {
|
if (m_pBitmap) {
|
||||||
if (m_pBitmap->GetLastStatus() == Gdiplus::Ok) return true;
|
|
||||||
|
|
||||||
delete m_pBitmap;
|
delete m_pBitmap;
|
||||||
m_pBitmap = NULL;
|
m_pBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user