Skip to content

Cyberpunk 2077 plugin to help reverse engineer data types.

License

Notifications You must be signed in to change notification settings

rayshader/cp2077-red-memorydump

Repository files navigation

Red Memory Dump

Cyberpunk 2077 GitHub License Donate

This tool allows to dump memory to help in analyzing unknown data types. It provides an interface with CET.

Getting started

Compatibility

Installation

  1. Install requirements:
  1. Extract the latest archive into the Cyberpunk 2077 directory.

Demo

screenshot of tool

Setup

You'll need to configure CET to use a monospace font. You can import one of your choice or pick from existing fonts. For example with NotoSansMono-Regular.ttf.

In bin/x64/plugins/cyber_engine_tweaks/, change config.json with:

{
  // ...
  "fonts": {
    // ...
    "path": "C:/Program Files (x86)/Steam/steamapps/common/Cyberpunk 2077/bin/x64/plugins/cyber_engine_tweaks/fonts/NotoSansMono-Regular.ttf"
    // ...
  }
  // ...
}

Note

fonts.path must be an absolute path to be loaded by CET.

Usage

This tool introduce MemoryDump with three core functions:

TrackScriptable(object: ref<IScriptable>) -> ref<MemoryTarget>;
TrackSerializable(object: ref<ISerializable>) -> ref<MemoryTarget>;
TrackAddress(name: String, type: CName, address: Uint64, opt size: Uint32) -> ref<MemoryTarget>;

It will return a MemoryTarget which allows to dump memory in a "frame".

Important

It only keeps the internal pointer of the object. If reference to the object is lost, it will result in unexpected behaviors.

This tool requires a MemoryTarget to print it in CET's overlay. You have two possibilities to provide a target:

CET's console

You can use CET's console to write commands and manually add a target. You will need to import the tool's API using:

RedMemoryModApi = GetMod("RedMemoryMod").api

You can then use MemoryDump to track and add a target:

player = Game.GetPlayer()
target = MemoryDump.TrackScriptable(player)
RedMemoryModApi.AddTarget(target)
-- It should be visible in section TARGETS

AddCustomTarget

You can define your custom behavior in RedMemoryDump/AddCustomTarget.lua where the plugin is installed. You can react to common CET events and return a target you want to track.

You must define AddCustomTarget which will be triggered when you click on the button Add custom target in CET overlay, for example:

-- See file itself for more.

-- ...
AddCustomTarget = function(context)
  local player = Game.GetPlayer()

  return MemoryDump.TrackScriptable(player)
end
-- ...

Tip

This is the recommended solution, DRY.

Development

Contributions are welcome, feel free to fill an issue or a PR.

Usage

  1. Install requirements:
  • CMake v3.27+
  • Visual Studio Community 2022+
  • Node JS v20.11+
    • run npm install --save-dev archiver
  1. Configure project with:
cmake -G "Visual Studio 17 2022" -A x64 -S . -B build
  1. Build in debug mode:
cmake --build build --target RedMemoryDump --config Debug

Tests

  1. Install in your game directory:
node install.mjs
  1. Run game.
  2. Open CET, show Game Log popup.
  3. Output should show tests result.

Release

  1. Build in release mode:
cmake --build build --target RedMemoryDump --config Release
  1. Bundle release:
node bundle.mjs