Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MemoryDumpTo/CreateTableText.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include <MemoryDumpTo.h>
#include "MemoryDumpTo.h"

#define szHeaderDELPHI "const Table: array[0..%u] of %s = (\r\n"
#define szHeaderCPP "const %s Table[%u] = {\r\n"
Expand Down
13 changes: 4 additions & 9 deletions MemoryDumpTo/MemoryDumpTo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include <MemoryDumpTo.h>
#include "MemoryDumpTo.h"

// GLOBAL Plugin SDK variables
int pluginHandle;
Expand All @@ -10,19 +10,16 @@ int hMenuDisasm;
int hMenuDump;
int hMenuStack;

extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInstDLL = hinstDLL;
return TRUE;
}

BOOL AboutDlg()
{
MSGBOXPARAMS mbp;
TCHAR Buffer[MAX_PATH / 2];

__stosb((PBYTE)&mbp, 0, sizeof(mbp));
__stosb((PBYTE)&Buffer, 0, sizeof(Buffer));
MSGBOXPARAMS mbp{};
TCHAR Buffer[MAX_PATH / 2]{};

mbp.cbSize = sizeof(mbp);
mbp.hwndOwner = hwndDlg;
Expand All @@ -32,11 +29,9 @@ BOOL AboutDlg()
mbp.dwStyle = MB_OK | MB_USERICON;
mbp.lpszIcon = MAKEINTRESOURCE(IDI_ICON);


wsprintf(Buffer, szMemoryDumpToAbout, sz_plugin_version);
MessageBoxIndirect(&mbp);

//MessageBox(hwndDlg, Buffer, TEXT("About"), MB_ICONINFORMATION);
return TRUE;
}

Expand Down
2 changes: 1 addition & 1 deletion MemoryDumpTo/MemoryDumpTo.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern int hMenuStack;
#define szMemoryDumpToAbout (szMemoryDumpTo TEXT(" \n") szCopyright)
#define plugin_name "MemoryDumpTo"
#define plugin_version 1
#define sz_plugin_version TEXT("0.2")
#define sz_plugin_version TEXT("0.3")

#define lengthof(s) { sizeof(s) / sizeof((s)[0]) }

Expand Down
8 changes: 4 additions & 4 deletions MemoryDumpTo/MemoryDumpTo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<ErrorReporting>None</ErrorReporting>
<IntrinsicFunctions>true</IntrinsicFunctions>
<ExceptionHandling>false</ExceptionHandling>
<ExceptionHandling>Sync</ExceptionHandling>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<GuardEHContMetadata>false</GuardEHContMetadata>
Expand Down Expand Up @@ -136,7 +136,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<OmitFramePointers>false</OmitFramePointers>
<IntrinsicFunctions>true</IntrinsicFunctions>
<ExceptionHandling>false</ExceptionHandling>
<ExceptionHandling>Sync</ExceptionHandling>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<GuardEHContMetadata>false</GuardEHContMetadata>
Expand Down Expand Up @@ -170,7 +170,7 @@
<ErrorReporting>None</ErrorReporting>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<ExceptionHandling>false</ExceptionHandling>
<ExceptionHandling>Sync</ExceptionHandling>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<GuardEHContMetadata>false</GuardEHContMetadata>
Expand Down Expand Up @@ -206,7 +206,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<ExceptionHandling>false</ExceptionHandling>
<ExceptionHandling>Sync</ExceptionHandling>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<GuardEHContMetadata>false</GuardEHContMetadata>
Expand Down
47 changes: 23 additions & 24 deletions MemoryDumpTo/plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include <MemoryDumpTo.h>
#include "MemoryDumpTo.h"

SIZE_T ReadMemoryDump(PVOID* MemoryDump)
{
Expand All @@ -9,20 +9,22 @@ SIZE_T ReadMemoryDump(PVOID* MemoryDump)

if (DbgIsDebugging())
{
GuiSelectionGet(GUI_DUMP, &sel);
SizeDump = sel.end - sel.start;
SizeDump++;
MemDump = VirtualAlloc(0, SizeDump, MEM_COMMIT, PAGE_READWRITE);
if (MemDump)
if (GuiSelectionGet(GUI_DUMP, &sel))
{
if (DbgMemRead(sel.start, MemDump, SizeDump))
{
*MemoryDump = MemDump;
}
else
SizeDump = sel.end - sel.start;
SizeDump++;
MemDump = VirtualAlloc(0, SizeDump, MEM_COMMIT, PAGE_READWRITE);
if (MemDump)
{
VirtualFree(MemDump, 0, MEM_RELEASE);
SizeDump = 0;
if (DbgMemRead(sel.start, MemDump, SizeDump))
{
*MemoryDump = MemDump;
}
else
{
VirtualFree(MemDump, 0, MEM_RELEASE);
SizeDump = 0;
}
}
}
}
Expand All @@ -34,13 +36,12 @@ BOOL SaveToFile()
SIZE_T SizeDump = 0;
PVOID StartDump;
SELECTIONDATA SelectionData;
OPENFILENAME ofn;
TCHAR FilePath[MAX_PATH];
OPENFILENAME ofn{};
TCHAR FilePath[MAX_PATH]{};

__stosb((PBYTE)&ofn, 0, sizeof(ofn));
__stosb((PBYTE)&FilePath, 0, sizeof(FilePath));
if (!GuiSelectionGet(GUI_DUMP, &SelectionData))
return FALSE;

GuiSelectionGet(GUI_DUMP, &SelectionData);
SizeDump = SelectionData.end - SelectionData.start;
if (SizeDump)
{
Expand All @@ -63,29 +64,29 @@ BOOL SaveToFile()
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_EXTENSIONDIFFERENT | OFN_OVERWRITEPROMPT;
if (GetSaveFileName(&ofn))
{
#ifdef _UNICODE
#ifdef _UNICODE
DumpMemoryW(DbgGetProcessHandle(), StartDump, SizeDump, FilePath);
#else
DumpMemory(DbgGetProcessHandle(), StartDump, SizeDump, FilePath);
#endif
return TRUE;
}
}
return TRUE;
return FALSE;
}

static INIT_PARAM InitParam;
static PVOID TableText;

INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
TCHAR FormatBuffer[MAX_PATH / 2];
TCHAR FormatBuffer[MAX_PATH / 2]{};

switch (uMsg)
{
case WM_INITDIALOG:
{
SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInstDLL, MAKEINTRESOURCE(IDI_ICON)));
__stosb((PBYTE)&FormatBuffer, 0, sizeof(FormatBuffer));
wsprintf(FormatBuffer, szMemoryDumpTo, sz_plugin_version);
SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)FormatBuffer);
lstrcpy(FormatBuffer, szCopyright);
Expand All @@ -109,14 +110,12 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
case BYTE_RBN:
{

TableText = CreateTableText(InitParam.DataPtr, InitParam.DataSize, InitParam.ProgLang, MD_Byte);
if (TableText)
{
SendMessage(GetDlgItem(hWnd, EXPORT_EDT), WM_CLEAR, 0, 0);
SendMessageA(GetDlgItem(hWnd, EXPORT_EDT), WM_SETTEXT, 0, (LPARAM)TableText);
VirtualFree(TableText, 0, MEM_RELEASE);

}
}
return (INT_PTR)TRUE;
Expand Down