Skip to content

[Memhack] ItBString

DasKeifer edited this page Sep 30, 2026 · 7 revisions

Memhack ItBString

The Memhack ItBString struct represents Into the Breach's internal string type in game memory.

It has the standard memhack base struct functions/fields.

Overview

ItBString is a union type that can store strings in two ways:

  • LOCAL - Short strings (up to 15 characters) stored directly in the struct
  • REMOTE - Longer strings stored as a pointer to heap-allocated memory

Strings typically use a dictionary key that is looked up to support localization. This works for ItBString most of the time but in some menus it seems to not use any modded added values to the dictionary. A notable one is the post mission, level up skill description UI. As such ItBString will, by default, auto dereference any dictionary values when the ItBString string value is set. This can be disabled globally via the AutoUndictionary field in ItBString

Table of Contents

Data

Field Type Offset Description
strLocal char[16] 0x0 Local storage for short strings
strRemotePtr pointer (C String) 0x0 Pointer to remote string data
strLen int 0x10 Length of the string
unionType int 0x14 Type of storage: LOCAL (0x0F) or REMOTE (0x1F)

Data Functions

These are functions that draw from the data in the struct or set the data in the struct

Constants and Globals

Static Utility Functions

These functions are used to generate the getXxxxStr functions and setXxxx Functions for structs that use ItBString. This are not directly used by ItBString.

Other Functions

There are a number of private and internal functions. These should generally be avoided outside of memhack

get

  • string ItBString:get()

Returns the string value, handling both LOCAL and REMOTE storage automatically.

Example:

local pilot = pawn:GetPilot()
local name = pilot:getName()  -- Returns ItBString struct
local nameStr = name:get()    -- Returns actual string
LOG("Pilot name: " .. nameStr)

set

  • void ItBString:set(value, skipUndictionary)
Argument name Type Description
value string or ItBString The string value to set
skipUndictionary boolean If true, will NOT deference dictionary key to a string but will store the dictionary key. Defaults to false/nil and automatically handles dictionary keys or strings

Sets the string value, automatically choosing LOCAL or REMOTE storage based on length. Accepts either a string or another ItBString struct.

Example:

local name = pilot:getName()
name:set("New Name")
-- Or using another ItBString
name:set(otherPilot:getName())

getStrLen

  • int ItBString:getStrLen()

Returns the length of the string in characters.

Example:

local name = pilot:getName()
LOG("Name length: " .. name:getStrLen())

getUnionType

  • int ItBString:getUnionType()

Returns the storage type: ItBString.LOCAL (0x0F) for local storage or ItBString.REMOTE (0x1F) for remote storage.

Example:

local name = pilot:getName()
if name:getUnionType() == memhack.structs.ItBString.LOCAL then
    LOG("Short string stored locally")
else
    LOG("Long string stored remotely")
end

LOCAL

  • int = 0x0F (15)

Constant representing local (inline) string storage for strings up to 15 characters.

REMOTE

  • int = 0x1F (31)

Constant representing remote (pointer-based) string storage for strings longer than 15 characters.

AutoUndictionary

  • boolean = true

Global used to control the default auto undictionary behavior for setting string values of all ItBStrings. If set to false, it will NOT deference the strings (i.e. store the dictionary keys). Defaults to true.

Changing this will have no effect on existing strings

makeItBStringGetterName

  • function ItBString.makeItBStringGetterName(fieldName)
Argument name Type Description
fieldName string Name of the ItBString field

Static function that generates the getter function name for an ItBString field. Used internally during struct creation.

Returns the name that will be used for the string getter wrapper. I.e. "getStr"

Example:

-- Used internally like:
local strGetterName = memhack.structs.ItBString.makeItBStringGetterName("name")
LOG("Getter for field 'name' is ".. strGetterName)

makeItBStringSetterName

  • function ItBString.makeItBStringSetterName(fieldName)
Argument name Type Description
fieldName string Name of the ItBString field

Static function that generates the setter function name for an ItBString field. Used internally during struct creation.

Returns the name that will be used for the string setter wrapper. I.e. "set"

Example:

-- Used internally like:
local strSetterName = memhack.structs.ItBString.makeItBStringSetterName("name")
LOG("Setter for field 'name' is ".. strSetterName)

makeItBStringGetSetWrappers

  • void ItBString.makeItBStringGetSetWrappers(structType, fieldName)
Argument name Type Description
structType table The struct type to add wrappers to
fieldName string Name of the ItBString field

Static function that creates convenience getter/setter wrappers on a struct for an ItBString field using the getter/setter wrapper names. This allows direct string access without manually calling get()/set().

For example, for a field named "name", this creates:

  • getNameStr() - Returns the string directly
  • setName(str) - Sets the string directly

Example:

-- Used internally during struct creation:
memhack.structs.ItBString.makeItBStringGetSetWrappers(Pilot, "name")

-- This allows you to use:
local nameStr = pilot:getNameStr()  -- Instead of pilot:getName():get()
pilot:setName("New Name")           -- Instead of pilot:getName():set("New Name")

Private and Internal Functions

These functions are for internal use or advanced manipulation. Most users should use get() and set() instead. These are expected to primarily be used when making changes in memhack itself.

_setUnionType

  • void ItBString:_setUnionType(type)
Argument name Type Description
type int Union type (LOCAL or REMOTE)

Sets the union type directly. For internal use only. Use set() instead which handles this automatically.

_setStrLen

  • void ItBString:_setStrLen(len)
Argument name Type Description
len int String length

Sets the string length field directly. For internal use only. Use set() instead which handles this automatically.

_getStrLocal

  • string ItBString:_getStrLocal()

Reads the string from local storage. For internal use only. Use get() instead which handles both storage types automatically.

_setStrLocal

  • void ItBString:_setStrLocal(str)
Argument name Type Description
str string String to write to local storage

Writes the string to local storage. For internal use only. Use set() instead which handles storage selection automatically.

_getStrRemotePtr

  • int ItBString:_getStrRemotePtr()

Returns the pointer to remote string data. For internal use only. Use get() instead which handles both storage types automatically.

_setStrRemotePtr

  • void ItBString:_setStrRemotePtr(ptr)
Argument name Type Description
ptr int Pointer to remote string data

Sets the remote string pointer. For internal use only. Use set() instead which handles storage allocation automatically.

_getStrRemote

  • string ItBString:_getStrRemote()

Reads the string from remote storage via the pointer. For internal use only. Use get() instead which handles both storage types automatically.

Clone this wiki locally