diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a2eb44 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Build folder +**/build + +# Temporary user files +**/CMakeLists.txt.user diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..97eca6a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +project(memscan VERSION 0.1.0 LANGUAGES CXX) + +## build conditions: + +if(NOT MSVC) + message(FATAL_ERROR "Error: memscan only supports Windows right now!") +endif() + +## build settings: + +set(CMAKE_CXX_STANDARD 11) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the build type" FORCE) +endif() + +set(CMAKE_CXX_FLAGS_RELEASE -O2) + +## files: + +set(source_files + Memscan.cpp + main.cpp + utils.cpp) + +set(header_files + Memscan.h + utils.h) + +## executable: + +add_executable(${PROJECT_NAME} + ${source_files} + ${header_files}) diff --git a/Memscan.cpp b/Memscan.cpp index d024015..069e5fd 100644 --- a/Memscan.cpp +++ b/Memscan.cpp @@ -56,7 +56,7 @@ Memscan::Memscan(string pin, PROCESS_MODE process_mode) { wchar_t* temp_process_name = new wchar_t[temp_size]; // loop gets process name from process handle while (true) { - if (0 == GetProcessImageFileName(process_handle, temp_process_name, temp_size)) { + if (0 == GetProcessImageFileNameW(process_handle, temp_process_name, temp_size)) { cerr << "Error: GetProcessImageFileName() failed in " << basename(__FILE__) << ":" << __LINE__ << ". Last error: " << GetLastError() << "." << endl; exit(1); } else if (wcslen(temp_process_name) == (temp_size-1)) { diff --git a/README.md b/README.md index 4659c65..fa5f264 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,17 @@ You can also specify the combination of memory units you want to scan for (e.g., Would scan the process for dwords and quadwords. +### Building + +Being [Cmake](https://cmake.org/)-based, configure the project (preferably *out-of-source*) and run the build. Here is an example: + +```shh +memscan$ mkdir build +memscan$ cd build +memscan/build$ cmake .. +memscan/build$ cmake --build . +``` + ### License memscan is distributed under the GNU General Public License v3.0 (GPLv3). diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..080943f --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,18 @@ +os: Visual Studio 2015 + +platform: + - x64 + +configuration: + - Debug + - Release + +init: + - cmd: cmake --version + - cmd: msbuild /version + +build_script: + - cmd: md build + - cmd: cd build + - cmd: cmake -G "Visual Studio 14 2015 Win64" .. + - cmd: cmake --build . --config %configuration% diff --git a/utils.cpp b/utils.cpp index 2e8abda..663ccc8 100644 --- a/utils.cpp +++ b/utils.cpp @@ -200,7 +200,7 @@ HMODULE get_base_address(HANDLE process_handle, wstring path) { wchar_t* module_path = new wchar_t[path.length()+1]; // find module of specified path for (int i = 0; i < (needed/sizeof(HMODULE)); i++) { - GetModuleFileNameEx(process_handle, hmarr[i], module_path, (DWORD) path.length()); + GetModuleFileNameExW(process_handle, hmarr[i], module_path, (DWORD) path.length()); if (to_upper(basename(path)) == to_upper(basename(module_path))) { rtn = hmarr[i]; break;