diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..96f5dbb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tool/QDarkStyleSheet"] + path = tool/QDarkStyleSheet + url = https://github.com/gmh5225/QDarkStyleSheet diff --git a/DIYSystemMemoryDump.png b/DIYSystemMemoryDump.png new file mode 100644 index 0000000..2d97476 Binary files /dev/null and b/DIYSystemMemoryDump.png differ diff --git a/README.md b/README.md index 6dba2f6..64cdaf5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # Tool-DIYSystemMemoryDump +DIYSystemMemoryDump is a tool that forces a lock on the type of system memory dump. -DIYSystemMemoryDump is a tool that forces a lock on the type of system memory dump. \ No newline at end of file +![image](DIYSystemMemoryDump.png) + +# Documents +- https://docs.microsoft.com/en-us/troubleshoot/windows-server/performance/memory-dump-file-options diff --git a/tool/.gitignore b/tool/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/tool/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/tool/NewWorld.ico b/tool/NewWorld.ico new file mode 100644 index 0000000..d22e4d1 Binary files /dev/null and b/tool/NewWorld.ico differ diff --git a/tool/QDarkStyleSheet b/tool/QDarkStyleSheet new file mode 160000 index 0000000..6eca451 --- /dev/null +++ b/tool/QDarkStyleSheet @@ -0,0 +1 @@ +Subproject commit 6eca4512251843debc24029672d866ca36cb8057 diff --git a/tool/main.cpp b/tool/main.cpp new file mode 100644 index 0000000..da811e3 --- /dev/null +++ b/tool/main.cpp @@ -0,0 +1,26 @@ +#include "mainwindow.h" + +#include +#include +#include + +int main(int argc, char *argv[]) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif + QApplication a(argc, argv); + MainWindow w; + + QFile f(":/qdarkstyle/dark/style.qss"); + if (!f.exists()) { + printf("Unable to set stylesheet, file not found\n"); + } else { + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); + qApp->setStyleSheet(ts.readAll()); + } + + w.show(); + return a.exec(); +} diff --git a/tool/mainwindow.cpp b/tool/mainwindow.cpp new file mode 100644 index 0000000..2e64422 --- /dev/null +++ b/tool/mainwindow.cpp @@ -0,0 +1,63 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow), mDumpType(DUMPTYPE::KERNEL), mStop(false), + mRunning(false) +{ + ui->setupUi(this); + setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint); + setFixedSize(this->width(), this->height()); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_pushButton_start_clicked() +{ + if (mRunning) { + QMessageBox::information(this, "Tips", "You are running now!"); + return; + } + mRunning = true; + mStop = false; + + //https://docs.microsoft.com/en-us/troubleshoot/windows-server/performance/memory-dump-file-options + if (ui->radioButton_Auto->isChecked()) { + mDumpType = DUMPTYPE::AUTO; + } else if (ui->radioButton_Complete->isChecked()) { + mDumpType = DUMPTYPE::COMPLETE; + } else if (ui->radioButton_Kernel->isChecked()) { + mDumpType = DUMPTYPE::KERNEL; + } else if (ui->radioButton_Small->isChecked()) { + mDumpType = DUMPTYPE::SMALL; + } + + std::thread t1([&] { + while (!mStop) { + //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl + QSettings qRegQ("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\CrashControl", + QSettings::NativeFormat); + qRegQ.setValue("AlwaysKeepMemoryDump", (int) 0); + qRegQ.setValue("CrashDumpEnabled", (int) mDumpType); + //20ms + QThread::msleep(20); + } + mRunning = false; + }); + t1.detach(); + + QMessageBox::information(this, "Tips", "Start new running!"); +} + +void MainWindow::on_pushButton_stop_clicked() +{ + mStop = true; + QMessageBox::information(this, "Tips", "Stop running!"); +} diff --git a/tool/mainwindow.h b/tool/mainwindow.h new file mode 100644 index 0000000..3640947 --- /dev/null +++ b/tool/mainwindow.h @@ -0,0 +1,34 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void on_pushButton_start_clicked(); + + void on_pushButton_stop_clicked(); + +public: + enum DUMPTYPE { AUTO = 7, KERNEL = 2, SMALL = 3, COMPLETE = 1 }; + +public: + DUMPTYPE mDumpType; + bool mStop; + bool mRunning; + +private: + Ui::MainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/tool/mainwindow.ui b/tool/mainwindow.ui new file mode 100644 index 0000000..ed6f310 --- /dev/null +++ b/tool/mainwindow.ui @@ -0,0 +1,107 @@ + + + MainWindow + + + + 0 + 0 + 411 + 228 + + + + + 16777215 + 16777215 + + + + DIYSystemMemoryDump + + + + + + + + + Dump Type + + + + + + + + + + Complete memory dump + + + + + + + Kernel memory dump + + + + + + + + + + + Automatic memory dump + + + + + + + Small memory dump + + + + + + + + + + + + + + Start + + + + + + + Stop + + + + + + + + + + + 0 + 0 + 411 + 21 + + + + + + + + diff --git a/tool/tool.pro b/tool/tool.pro new file mode 100644 index 0000000..0cc31a3 --- /dev/null +++ b/tool/tool.pro @@ -0,0 +1,44 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +!contains(QMAKE_HOST.arch, x86_64) { + TARGET = DIYSystemMemoryDump32 +} else { + TARGET = DIYSystemMemoryDump64 +} + + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + + + +# ICO +RC_ICONS = NewWorld.ico + +# RESOURCES +RESOURCES += QDarkStyleSheet/qdarkstyle/dark/style.qrc +RESOURCES += QDarkStyleSheet/qdarkstyle/light/style.qrc +RESOURCES += QDarkStyleSheet/qdarkstyle/X64DBGDark/style.qrc + +#UAC +QMAKE_LFLAGS_WINDOWS += /MANIFESTUAC:"level='requireAdministrator'"