From 2a222c4446717101504fd3a44fd978d8df7daa2b Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Wed, 22 Aug 2018 12:24:55 -0400 Subject: [PATCH] start cleaning up headers --- CMakeLists.txt | 2 ++ GUI/extensions.cpp | 1 - GUI/extensions.h | 6 +----- GUI/main.cpp | 18 +++++++++++++----- GUI/mainwindow.h | 5 +---- GUI/misc.h | 4 +--- GUI/qtcommon.h | 6 ++++++ extensions/extensions.h | 2 ++ host/host.cc | 4 ---- host/host.h | 8 +++----- host/pipe.cc | 1 - host/pipe.h | 2 +- host/textthread.cc | 2 -- host/textthread.h | 7 +------ host/winmutex.h | 7 ++----- include/common.h | 11 +++++++++++ 16 files changed, 44 insertions(+), 42 deletions(-) create mode 100644 GUI/qtcommon.h create mode 100644 include/common.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d5aad7a..2b647da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,8 @@ add_definitions( /DITH_HAS_CRT ) +include_directories(include) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Build) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Build) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Build) diff --git a/GUI/extensions.cpp b/GUI/extensions.cpp index 2cb2464..4a5d66f 100644 --- a/GUI/extensions.cpp +++ b/GUI/extensions.cpp @@ -1,6 +1,5 @@ #include "extensions.h" #include -#include #include std::shared_mutex extenMutex; diff --git a/GUI/extensions.h b/GUI/extensions.h index bf5283a..ee06e33 100644 --- a/GUI/extensions.h +++ b/GUI/extensions.h @@ -1,12 +1,8 @@ #ifndef EXTENSIONS_H #define EXTENSIONS_H -#include -#include +#include "qtcommon.h" #include -#include -#include -#include std::map LoadExtensions(); std::wstring DispatchSentenceToExtensions(std::wstring sentence, std::unordered_map miscInfo); diff --git a/GUI/main.cpp b/GUI/main.cpp index 2984ab4..d3b6902 100644 --- a/GUI/main.cpp +++ b/GUI/main.cpp @@ -1,12 +1,20 @@ #include "mainwindow.h" -#include "../host/host.h" #include int main(int argc, char *argv[]) { - QApplication a(argc, argv); - MainWindow w; - w.show(); + _CrtMemState memStates[100] = {}; + _CrtMemCheckpoint(memStates); + { + QApplication a(argc, argv); + MainWindow w; + w.show(); - return a.exec(); + + a.exec(); + } + _CrtMemCheckpoint(memStates + 1); + if (_CrtMemDifference(memStates + 2, memStates + 0, memStates + 1)) + _CrtMemDumpStatistics(memStates + 2); + return 0; } diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index 8cad8c3..dcfdac7 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -1,13 +1,10 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include "qtcommon.h" #include -#include -#include #include #include -#include -#include #include "../host/host.h" namespace Ui diff --git a/GUI/misc.h b/GUI/misc.h index 556b62f..de2a13b 100644 --- a/GUI/misc.h +++ b/GUI/misc.h @@ -1,9 +1,7 @@ #ifndef MISC_H #define MISC_H -#include -#include -#include +#include "qtcommon.h" #include "../host/host.h" QString GetFullModuleName(DWORD processId, HMODULE module = NULL); diff --git a/GUI/qtcommon.h b/GUI/qtcommon.h new file mode 100644 index 0000000..52be976 --- /dev/null +++ b/GUI/qtcommon.h @@ -0,0 +1,6 @@ +#pragma once + +#include "common.h" +#include +#include +#include \ No newline at end of file diff --git a/extensions/extensions.h b/extensions/extensions.h index 13194cd..49868c9 100644 --- a/extensions/extensions.h +++ b/extensions/extensions.h @@ -1,3 +1,5 @@ +#pragma once + #define WIN32_LEAN_AND_MEAN #include #include diff --git a/host/host.cc b/host/host.cc index 417a6c2..8a408bb 100644 --- a/host/host.cc +++ b/host/host.cc @@ -5,13 +5,9 @@ #include "host.h" #include "pipe.h" #include "winmutex.h" -#include -#include -#include #include "../vnrhook/include/const.h" #include "../vnrhook/include/defs.h" #include "../vnrhook/include/types.h" -#include std::unordered_map textThreadsByParams; std::unordered_map processRecordsByIds; diff --git a/host/host.h b/host/host.h index 41f534a..a3da0fb 100644 --- a/host/host.h +++ b/host/host.h @@ -4,14 +4,12 @@ // 8/23/2013 jichi // Branch: ITH/IHF.h, rev 105 -#define DLLEXPORT __declspec(dllexport) - -#include +#include "common.h" #include "textthread.h" -#include -#include #include "../vnrhook/include/types.h" +#define DLLEXPORT __declspec(dllexport) + struct ProcessRecord { HANDLE process_handle; diff --git a/host/pipe.cc b/host/pipe.cc index c13cea5..8223058 100644 --- a/host/pipe.cc +++ b/host/pipe.cc @@ -6,7 +6,6 @@ #include "host.h" #include "../vnrhook/include/defs.h" #include "../vnrhook/include/const.h" -#include void CreateNewPipe() { diff --git a/host/pipe.h b/host/pipe.h index 961c06f..cb0dee5 100644 --- a/host/pipe.h +++ b/host/pipe.h @@ -3,7 +3,7 @@ // pipe.h // 7/19/2018 Artikash -#include +#include "common.h" void CreateNewPipe(); diff --git a/host/textthread.cc b/host/textthread.cc index 0744b54..9499c79 100644 --- a/host/textthread.cc +++ b/host/textthread.cc @@ -6,9 +6,7 @@ #endif // _MSC_VER #include "textthread.h" -#include #include "../vnrhook/include/const.h" -#include "winmutex.h" #define TT_LOCK std::lock_guard ttLocker(ttMutex) // Synchronized scope for accessing private data diff --git a/host/textthread.h b/host/textthread.h index 059bc0e..a6d4a78 100644 --- a/host/textthread.h +++ b/host/textthread.h @@ -4,12 +4,7 @@ // 8/23/2013 jichi // Branch: ITH/TextThread.h, rev 120 -#include -#include -#include -#include -#include -#include +#include "common.h" struct ThreadParameter { diff --git a/host/winmutex.h b/host/winmutex.h index b924a2c..1cb43d9 100644 --- a/host/winmutex.h +++ b/host/winmutex.h @@ -3,10 +3,7 @@ // 12/11/2011 jichi #include - -#ifdef _MSC_VER -# pragma warning(disable:4800) // C4800: forcing value to bool -#endif // _MSC_VER +#include "common.h" // Artikash 7/20/2018: similar to std::lock guard but use Winapi objects for cross process comms @@ -14,7 +11,7 @@ class MutexLocker { HANDLE mutex; public: - explicit MutexLocker(HANDLE mutex) : mutex(mutex) { WaitForSingleObject(mutex, 0); } + MutexLocker(HANDLE mutex) : mutex(mutex) { WaitForSingleObject(mutex, 0); } ~MutexLocker() { if (mutex != INVALID_HANDLE_VALUE && mutex != nullptr) ReleaseMutex(mutex); } }; diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000..655a44a --- /dev/null +++ b/include/common.h @@ -0,0 +1,11 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN +#include +#include // A2W +#include +#include +#include +#include +#include +#include \ No newline at end of file