My memory editor: Med

Introduction

There was a wonderful memory editor in Windows, that was Game Master. But it was not a freeware. And there is a freeware memory editor, it is ArtMoney. But it is also for Windows only. In Linux, there is only one memory editor, scanmem with GameConqueror as the GUI. However, there are some limitations from scanmem and GameConqueror. Thus, that is why I decided to create another one which can fit my needs. Therefore, I recently spent some time to develop this memory editor, namely Med.

This project was actually started because of Android hacking. I wanted to hack the Android game memory. I firstly wrote a program called “hed” (hex editor), which is purely in C language, to edit any binary file from ADB shell. The command-line works well. Then, I was thinking about to create “med” (memory editor) using C++, to edit any process from ADB shell. But it fails to work. However, during the development, it works well on the desktop computer, that is, x86 and x86-64 Linux.

Previously I was using GameConqueror. But I recently found that there are some limitations such as save/open file failed to work with the recent compiled version from the Git repository. Besides that, the memory editing does not work either. And, I also forked the project in the GitHub in order to add in a function, that is to “shift” all memory addresses. But at the end, it is not very useful either.

Med

Med is a result from my years of programming experience. It involves

  • C language as it deals with memory directly
  • C++ as I am using the C++ STL container, strings, and exceptional handling
    • I use strings heavily based on what I learnt from UNIX philosophy (as text is important), Tcl philosophy (“Everything is a string”), and OpenGL (as a state machine)
  • GTK+ (version 3) for the GUI
  • Multi-threading using GLib
  • Linux, as this memory editor only works on Linux and relies on procfs
  • JSON, save and open file as JSON file format. JSONPP library is used to work with C++

Though GTK+ is written in C, it is object-oriented. I do not choose Qt because of my fervent towards C language. And I admit that writing a program using C++ is faster and easier than C. The GUI design is actually using Glade.

Status

Med is still under development. If you want to use, just download and compile it. It is available here.

Memory editor editing memory in PCSX2
Memory editor editing memory in PCSX2

Gaming on Linux

Recently, I admit that Chromium is faster and smoother than Firefox. And now, for me, Firefox is my primary bookmark manager, reference manger with Zotero, and best ever download manager; yet Chromium is my primary web browser.

This is just like Windows is no more an Operating System for me, but a game console. I have no choice to admit this because playing games on Linux, is still far behind from Windows. The main reason is the developers usually target on Windows instead of Linux. However, it is truly worth for me to optimise the functionality of a computer by running Linux and sacrificing the gaming potentiality of Windows.

Native, Emulators, and Steam

There are several methods to play games on Linux. Steam is one of the methods, but it is not my favourite. Other than that, there are native games in Linux, one of my favourite is Cave Story. Another solution is using emulators, such as DOXBox, VBA-M, MAME, etc. However, not all emulators work perfectly, especially PS2 emulators.

WINE

WINE (WINE Is Not Emulator) is my another favourite. It allows to run Windows applications including some games. Yet, it does not work perfectly, not all games work. I have successfully used it to play KOEI Sangokushi (Romance of the Three Kingdoms) 12 and The Sims 4. WINE works fine with these games. However, some 3D games such as Assassin’s Creed II and Dead or Alive 5 Last Round do not work for me. Moreover, latest version of WINE does not guarantee better compatibility of all games. Some games work better with a certain version of WINE; some games requires certain patched version of WINE.

Virtualisation

So, the native Windows is still an attractive solution for playing games. Therefore, virtualisation is the possible solution. (LXC and Docker do not work, because they are containers.)

VirtualBox

VirtualBox is my favourite hypervisor because it is very easy to use. VirtualBox allows Direct3D yet it is under experimental. It has to be installed through the Guest Addition ISO image. However, I found that the Direct3D driver installed is wined3d.dll. As a result, the 3D rendering produces the same problem as in using WINE for certain games. As a conclusion, using VirtualBox to play 3D games does not work as expected.

QEMU/KVM

Since VirtualBox does not work with 3D games, I recently tried QEMU with KVM. Because I read some articles (this and this) regarding QEMU/KVM, it can virtualise the 3D graphics card. However, this requires 2 graphics cards: one for the host machine, another for guest machine. And this method uses VFIO, which is very troublesome.

Furthermore, there is a Virgil 3D project which targets to produce virtual 3D GPU. I studied a little, yet I didn’t try to compile it, because it seems like very troublesome. As a conclusion, QEMU/KVM does not work either.

VMware Player

So, the final solution I tried recently was VMware Player, which is free for non-commercial use. Installation of the VMware Player version 7 requires GCC 5.1.0 in Arch Linux. In this case, I have to install GCC 5.1.0 and compile the modules, then downgrade to GCC 4.9.2 again.

VMware Player is very similar to VirtualBox, but the VM management less useful than VirtualBox. Besides that, some VM configurations have to be done manually using text editor.

After some configurations and testing, I found that it works as the best among the virtualisation software. It is better than VirtualBox.

VMware Player 3D configuration

To enable VMware 3D graphics for Direct3D, firstly we have to make sure our host machine (Linux) allows “direct rendering” by entering the following command,

glxinfo | grep direct

Then, to make sure it works,

glxgears

Next, install WMware Player, then download and install VMware Tools for the guest OS. This can be done when running the Windows in the VM, by clicking “Virtual Machine” > “Install VMware Tools…”. Alternatively, we can download all VMware Tools for all the supported OSes from Player Preferences menu item. After finish downloading, we can run the setup in the Windows just like VirtualBox. The installation of VMware Tools allows seamless integration of the host and the guest like VirtualBox: such as resizing the window will resize the Windows resolution directly, and also the seamless mouse integration.

After installation, make sure 3D acceleration is enabled. This can be done from VMX file or from the Virtual Machine Settings,

mks.enable3d = "TRUE"
svga.graphicsMemoryKB = "1000000"

If 3D acceleration still does not work, then in the ~/.vmware/preferences, add

mks.gl.allowBlacklistedDrivers = "TRUE"

Next, in the ~/.vmware/preferences, add followings

pref.motionUngrab = "FALSE"
pref.motionGrab = "FALSE"

This disable auto grabbing or ungrabbing our mouse pointer when it moves into the VM window.

However, in my case, my 3D game is very sensitive to the mouse movement. Thus, I have to disable the drivers installed by the VMware Tools. This can be done through Device Manager in Windows. After disabling the drivers, my mouse cannot click anything in VM. I have to use keyboard to restart the Windows.

 

Finally, I think I can enjoy more games in Linux now, though playing the games virtually in Windows.