From 89d2ea49c2f53f5f23ad097d01f96eab1c1eca4d Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 13 Aug 2025 22:09:01 +0300 Subject: [PATCH] Minor updates; make 0 warnings --- MemoryDumpTo/CreateTableText.cpp | 2 +- MemoryDumpTo/MemoryDumpTo.cpp | 13 +++------ MemoryDumpTo/MemoryDumpTo.h | 2 +- MemoryDumpTo/MemoryDumpTo.vcxproj | 8 +++--- MemoryDumpTo/plugin.cpp | 47 +++++++++++++++---------------- 5 files changed, 33 insertions(+), 39 deletions(-) diff --git a/MemoryDumpTo/CreateTableText.cpp b/MemoryDumpTo/CreateTableText.cpp index 17ecc08..d98bb55 100644 --- a/MemoryDumpTo/CreateTableText.cpp +++ b/MemoryDumpTo/CreateTableText.cpp @@ -1,5 +1,5 @@ -#include +#include "MemoryDumpTo.h" #define szHeaderDELPHI "const Table: array[0..%u] of %s = (\r\n" #define szHeaderCPP "const %s Table[%u] = {\r\n" diff --git a/MemoryDumpTo/MemoryDumpTo.cpp b/MemoryDumpTo/MemoryDumpTo.cpp index 559dcf6..70b6c0f 100644 --- a/MemoryDumpTo/MemoryDumpTo.cpp +++ b/MemoryDumpTo/MemoryDumpTo.cpp @@ -1,5 +1,5 @@ -#include +#include "MemoryDumpTo.h" // GLOBAL Plugin SDK variables int pluginHandle; @@ -10,7 +10,7 @@ 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; @@ -18,11 +18,8 @@ extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, 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; @@ -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; } diff --git a/MemoryDumpTo/MemoryDumpTo.h b/MemoryDumpTo/MemoryDumpTo.h index 25956b0..e872b68 100644 --- a/MemoryDumpTo/MemoryDumpTo.h +++ b/MemoryDumpTo/MemoryDumpTo.h @@ -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]) } diff --git a/MemoryDumpTo/MemoryDumpTo.vcxproj b/MemoryDumpTo/MemoryDumpTo.vcxproj index f10b452..e7343e2 100644 --- a/MemoryDumpTo/MemoryDumpTo.vcxproj +++ b/MemoryDumpTo/MemoryDumpTo.vcxproj @@ -103,7 +103,7 @@ MultiThreadedDebugDLL None true - false + Sync true false false @@ -136,7 +136,7 @@ ProgramDatabase false true - false + Sync true false false @@ -170,7 +170,7 @@ None Size Default - false + Sync true false false @@ -206,7 +206,7 @@ ProgramDatabase Size Default - false + Sync true false false diff --git a/MemoryDumpTo/plugin.cpp b/MemoryDumpTo/plugin.cpp index b3842ac..8cecf5a 100644 --- a/MemoryDumpTo/plugin.cpp +++ b/MemoryDumpTo/plugin.cpp @@ -1,5 +1,5 @@ -#include +#include "MemoryDumpTo.h" SIZE_T ReadMemoryDump(PVOID* MemoryDump) { @@ -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; + } } } } @@ -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) { @@ -63,14 +64,15 @@ 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; @@ -78,14 +80,13 @@ 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); @@ -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;