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

Features

  • track an ISerializable or a raw address as a target.
  • dump memory of target with the Capture button (aka a frame).
  • navigate between frames.
  • view memory of a frame as bytes in hexadecimal form.
  • hide known bytes in view memory, when already bound by RTTI properties.
  • select an offset in memory and a data type to check the content (support common types of RED4engine).
  • list known RTTI properties, hover/select a property to scroll to it in view memory.
  • player to navigate through frames every 200 ms.
  • record frames at custom rate, with start/stop button or hot key.

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 two core functions:

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".

Note

Internally, only a weak reference is hold. When reference is disposed, a message will tell. You won't be able to dump new frames.

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:

RedMemoryDump = GetMod("RedMemoryDump")

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

player = Game.GetPlayer()
target = MemoryDump.TrackSerializable(player)
RedMemoryDump.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 AddTarget which will be triggered when you click on the button Add target in CET overlay, for example:

-- See file itself for more.

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

  return MemoryDump.TrackSerializable(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+
  • red-cli v0.3.0+
  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:
red-cli install
  1. Run game.
  2. Open CET, you should see a "RedMemoryDump" window.

Release

  1. Build in release mode:
cmake --build build --target RedMemoryDump --config Release
  1. Bundle release:
red-cli pack