Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/create cmake build script #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
2 changes: 1 addition & 1 deletion Memscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

18 changes: 18 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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%
2 changes: 1 addition & 1 deletion utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down