Skip to content

Commit

Permalink
Merge pull request #105 from cristian64/application_arguments
Browse files Browse the repository at this point in the history
Add the `--dolphin-process-name` command-line option.
  • Loading branch information
dreamsyntax authored Mar 7, 2024
2 parents b2b2074 + 90f70dd commit 0dea3f5
Show file tree
Hide file tree
Showing 10 changed files with 467 additions and 396 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
cmake Source -B .\Source\bin -A x64 "-DCMAKE_PREFIX_PATH=..\Externals\Qt\Qt6.5.1\x64"
cmake --build .\Source\bin --config ${{ matrix.configuration }} --parallel
shell: powershell

- name: Copy LICENSE, README
run: |
copy .\LICENSE .\Source\bin\${{ matrix.configuration }}
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
cmake Source -B Source/build -DCMAKE_BUILD_TYPE=Release
cmake --build Source/build --parallel
shell: bash

- name: Copy LICENSE, README, Prepare Artifacts
run: |
mkdir Source/build/artifacts
Expand All @@ -90,7 +90,7 @@ jobs:
run: |
.github/assets/appimage.sh
shell: bash

- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -110,12 +110,12 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Dependencies
run: |
brew install cmake
shell: bash

- name: Initialize submodules
run: git submodule update --init

Expand Down
21 changes: 0 additions & 21 deletions .vscode/settings.json

This file was deleted.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ If the program unhooks itself from Dolphin, a read/write operation has failed. T

Finally, the program includes a memory viewer which shows a hexadecimal view and an ASCII view of the memory. Click on the corresponding button or right click on a watch to browse the memory using the memory viewer.

### Command-line Arguments

A number of options can be provided as command-line arguments:

```
Usage: dolphin-memory-engine [options]
A RAM search made specifically to search, monitor and edit the Dolphin Emulator's emulated memory.
Options:
-h, --help Displays help on
commandline options.
--help-all Displays help including Qt
specific options.
-v, --version Displays version
information.
-d, --dolphin-process-name <dolphin_process_name> Specify custom name for
the Dolphin Emulator
process. By default,
platform-specific names are
used (e.g. "Dolphin.exe" on
Windows, or "dolphin-emu"
on Linux or macOS).
```

## Troubleshouting

On Linux, the program may require additional kernel permissions to be able to read and write memory to external processes (which is required to read and write the memory of Dolphin). If nothing happens to Dolphin, but the program frequently unhooks itself, the program is missing the required permissions. Grant these permissions by running the following command as root:
Expand Down
232 changes: 116 additions & 116 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,117 +1,117 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(GCC_min_version 10)
project(dolphin-memory-engine)

if(WIN32)
set(DolphinProcessSrc DolphinProcess/Windows/WindowsDolphinProcess.cpp)
set(ExeIconSrc Resources/exeicon.rc)
endif(WIN32)

if(UNIX AND NOT APPLE)
set(DolphinProcessSrc DolphinProcess/Linux/LinuxDolphinProcess.cpp)
endif(UNIX AND NOT APPLE)

if(APPLE)
set(DolphinProcessSrc DolphinProcess/Mac/MacDolphinProcess.cpp)
endif(APPLE)

set(SRCS ${DolphinProcessSrc}
DolphinProcess/DolphinAccessor.cpp
Common/MemoryCommon.cpp
MemoryWatch/MemWatchEntry.cpp
MemoryWatch/MemWatchTreeNode.cpp
CheatEngineParser/CheatEngineParser.cpp
MemoryScanner/MemoryScanner.cpp
GUI/GUICommon.cpp
GUI/Settings/SConfig.cpp
GUI/Settings/DlgSettings.cpp
GUI/MemCopy/DlgCopy.cpp
GUI/MemWatcher/MemWatchDelegate.cpp
GUI/MemWatcher/MemWatchModel.cpp
GUI/MemWatcher/Dialogs/DlgChangeType.cpp
GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp
GUI/MemWatcher/MemWatchWidget.cpp
GUI/MemWatcher/Dialogs/DlgImportCTFile.cpp
GUI/MemScanner/ResultsListModel.cpp
GUI/MemScanner/MemScanWidget.cpp
GUI/MemViewer/MemViewer.cpp
GUI/MemViewer/MemViewerWidget.cpp
GUI/MainWindow.cpp
Resources/resource.qrc
${ExeIconSrc}
main.cpp)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt6Widgets REQUIRED)
find_package(Qt6Core REQUIRED)
find_package(Qt6Gui REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

IF(WIN32)
SET(GUI_TYPE WIN32)
ENDIF(WIN32)

add_executable(dolphin-memory-engine ${GUI_TYPE} ${SRCS})

target_link_libraries(dolphin-memory-engine Qt6::Widgets)
target_link_libraries(dolphin-memory-engine Qt6::Gui)
target_link_libraries(dolphin-memory-engine Qt6::Core)

if(WIN32)
set_target_properties(dolphin-memory-engine PROPERTIES OUTPUT_NAME DolphinMemoryEngine)
if($<CONFIG:Debug>)
get_target_property(WIDGETDLL Qt6::Widgets IMPORTED_LOCATION_DEBUG)
get_target_property(COREDLL Qt6::Widgets IMPORTED_LOCATION_DEBUG)
get_target_property(GUIDLL Qt6::Widgets IMPORTED_LOCATION_DEBUG)
else($<CONFIG:Debug>)
get_target_property(WIDGETDLL Qt6::Widgets IMPORTED_LOCATION_RELEASE)
get_target_property(COREDLL Qt6::Widgets IMPORTED_LOCATION_RELEASE)
get_target_property(GUIDLL Qt6::Widgets IMPORTED_LOCATION_RELEASE)
endif($<CONFIG:Debug>)
add_custom_command(
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::Widgets>
$<TARGET_FILE_DIR:dolphin-memory-engine>
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::Core>
$<TARGET_FILE_DIR:dolphin-memory-engine>
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::Gui>
$<TARGET_FILE_DIR:dolphin-memory-engine>
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
$<TARGET_FILE_DIR:dolphin-memory-engine>/platforms
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::QWindowsIntegrationPlugin>
$<TARGET_FILE_DIR:dolphin-memory-engine>/platforms
COMMAND ${CMAKE_COMMAND} -E make_directory
$<TARGET_FILE_DIR:dolphin-memory-engine>/styles
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::QWindowsVistaStylePlugin>
$<TARGET_FILE_DIR:dolphin-memory-engine>/styles
)
endif(WIN32)

if(APPLE)
set_target_properties(dolphin-memory-engine PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME "Dolphin Memory Engine"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.aldelaro5.dolphin-memory-engine"
)

set(MACOSX_BUNDLE_ICON_FILE "logo.icns")
set(app_icon_macos "Resources/logo.icns")
set_source_files_properties(${app_icon_macos} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
configure_file(${app_icon_macos} ${CMAKE_BINARY_DIR}/dolphin-memory-engine.app/Contents/Resources/${MACOSX_BUNDLE_ICON_FILE} COPYONLY)
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(GCC_min_version 10)
project(dolphin-memory-engine)

if(WIN32)
set(DolphinProcessSrc DolphinProcess/Windows/WindowsDolphinProcess.cpp)
set(ExeIconSrc Resources/exeicon.rc)
endif(WIN32)

if(UNIX AND NOT APPLE)
set(DolphinProcessSrc DolphinProcess/Linux/LinuxDolphinProcess.cpp)
endif(UNIX AND NOT APPLE)

if(APPLE)
set(DolphinProcessSrc DolphinProcess/Mac/MacDolphinProcess.cpp)
endif(APPLE)

set(SRCS ${DolphinProcessSrc}
DolphinProcess/DolphinAccessor.cpp
Common/MemoryCommon.cpp
MemoryWatch/MemWatchEntry.cpp
MemoryWatch/MemWatchTreeNode.cpp
CheatEngineParser/CheatEngineParser.cpp
MemoryScanner/MemoryScanner.cpp
GUI/GUICommon.cpp
GUI/Settings/SConfig.cpp
GUI/Settings/DlgSettings.cpp
GUI/MemCopy/DlgCopy.cpp
GUI/MemWatcher/MemWatchDelegate.cpp
GUI/MemWatcher/MemWatchModel.cpp
GUI/MemWatcher/Dialogs/DlgChangeType.cpp
GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp
GUI/MemWatcher/MemWatchWidget.cpp
GUI/MemWatcher/Dialogs/DlgImportCTFile.cpp
GUI/MemScanner/ResultsListModel.cpp
GUI/MemScanner/MemScanWidget.cpp
GUI/MemViewer/MemViewer.cpp
GUI/MemViewer/MemViewerWidget.cpp
GUI/MainWindow.cpp
Resources/resource.qrc
${ExeIconSrc}
main.cpp)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt6Widgets REQUIRED)
find_package(Qt6Core REQUIRED)
find_package(Qt6Gui REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

IF(WIN32)
SET(GUI_TYPE WIN32)
ENDIF(WIN32)

add_executable(dolphin-memory-engine ${GUI_TYPE} ${SRCS})

target_link_libraries(dolphin-memory-engine Qt6::Widgets)
target_link_libraries(dolphin-memory-engine Qt6::Gui)
target_link_libraries(dolphin-memory-engine Qt6::Core)

if(WIN32)
set_target_properties(dolphin-memory-engine PROPERTIES OUTPUT_NAME DolphinMemoryEngine)
if($<CONFIG:Debug>)
get_target_property(WIDGETDLL Qt6::Widgets IMPORTED_LOCATION_DEBUG)
get_target_property(COREDLL Qt6::Widgets IMPORTED_LOCATION_DEBUG)
get_target_property(GUIDLL Qt6::Widgets IMPORTED_LOCATION_DEBUG)
else($<CONFIG:Debug>)
get_target_property(WIDGETDLL Qt6::Widgets IMPORTED_LOCATION_RELEASE)
get_target_property(COREDLL Qt6::Widgets IMPORTED_LOCATION_RELEASE)
get_target_property(GUIDLL Qt6::Widgets IMPORTED_LOCATION_RELEASE)
endif($<CONFIG:Debug>)
add_custom_command(
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::Widgets>
$<TARGET_FILE_DIR:dolphin-memory-engine>
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::Core>
$<TARGET_FILE_DIR:dolphin-memory-engine>
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::Gui>
$<TARGET_FILE_DIR:dolphin-memory-engine>
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
$<TARGET_FILE_DIR:dolphin-memory-engine>/platforms
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::QWindowsIntegrationPlugin>
$<TARGET_FILE_DIR:dolphin-memory-engine>/platforms
COMMAND ${CMAKE_COMMAND} -E make_directory
$<TARGET_FILE_DIR:dolphin-memory-engine>/styles
TARGET dolphin-memory-engine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt6::QWindowsVistaStylePlugin>
$<TARGET_FILE_DIR:dolphin-memory-engine>/styles
)
endif(WIN32)

if(APPLE)
set_target_properties(dolphin-memory-engine PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME "Dolphin Memory Engine"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.aldelaro5.dolphin-memory-engine"
)

set(MACOSX_BUNDLE_ICON_FILE "logo.icns")
set(app_icon_macos "Resources/logo.icns")
set_source_files_properties(${app_icon_macos} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
configure_file(${app_icon_macos} ${CMAKE_BINARY_DIR}/dolphin-memory-engine.app/Contents/Resources/${MACOSX_BUNDLE_ICON_FILE} COPYONLY)
endif(APPLE)
9 changes: 8 additions & 1 deletion Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../../Common/CommonUtils.h"
#include "../../Common/MemoryCommon.h"

#include <cstdlib>
#include <cstring>
#include <dirent.h>
#include <fstream>
Expand Down Expand Up @@ -106,6 +107,8 @@ bool LinuxDolphinProcess::findPID()
if (directoryPointer == nullptr)
return false;

static const char* const s_dolphinProcessName{std::getenv("DME_DOLPHIN_PROCESS_NAME")};

m_PID = -1;
struct dirent* directoryEntry = nullptr;
while (m_PID == -1 && (directoryEntry = readdir(directoryPointer)))
Expand All @@ -118,7 +121,11 @@ bool LinuxDolphinProcess::findPID()
std::string line;
aCmdLineFile.open("/proc/" + std::string(directoryEntry->d_name) + "/comm");
getline(aCmdLineFile, line);
if (line == "dolphin-emu" || line == "dolphin-emu-qt2" || line == "dolphin-emu-wx")

const bool match{s_dolphinProcessName ? line == s_dolphinProcessName :
(line == "dolphin-emu" || line == "dolphin-emu-qt2" ||
line == "dolphin-emu-wx")};
if (match)
m_PID = aPID;

aCmdLineFile.close();
Expand Down
10 changes: 8 additions & 2 deletions Source/DolphinProcess/Mac/MacDolphinProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include "../../Common/CommonUtils.h"
#include "../../Common/MemoryCommon.h"

#include <cstdlib>
#include <memory>
#include <string_view>
#include <sys/sysctl.h>
#include <mach/mach_vm.h>

Expand All @@ -22,11 +24,15 @@ bool MacDolphinProcess::findPID()
if(sysctl((int*) mib, 4, procs.get(), &procSize, NULL, 0) == -1)
return false;

static const char* const s_dolphinProcessName{std::getenv("DME_DOLPHIN_PROCESS_NAME")};

m_PID = -1;
for(int i = 0; i < procSize / sizeof(kinfo_proc); i++)
{
if(std::strcmp(procs[i].kp_proc.p_comm, "Dolphin") == 0 ||
std::strcmp(procs[i].kp_proc.p_comm, "dolphin-emu") == 0)
const std::string_view name{procs[i].kp_proc.p_comm};
const bool match{s_dolphinProcessName ? name == s_dolphinProcessName :
(name == "Dolphin" || name == "dolphin-emu")};
if (match)
{
m_PID = procs[i].kp_proc.p_pid;
}
Expand Down
Loading

0 comments on commit 0dea3f5

Please sign in to comment.