### Defining a NullablePtr Struct Field - C++ Example Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/ptr.pat.md This example demonstrates how to declare a `NullablePtr` as a field within a C++ struct. It shows `p_myInfo` as a nullable 64-bit pointer to `MyInfoTy`, illustrating the syntax for integrating `NullablePtr` into data structures. ```C++ struct MyStruct { std::ptr::NullablePtr p_myInfo; } ``` -------------------------------- ### Performing HTTP GET Request with hex::http in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/hex/http.pat.md This function performs an HTTP GET request to the specified URL. It takes a `url` string as input and returns the response body. This is a core function for retrieving data from web resources. ```rust fn get(str url); ``` -------------------------------- ### Using Parameter Packs for Variadic Functions - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This example illustrates the use of parameter packs to create variadic functions. The `print_sequence` function accepts an arbitrary number of arguments, printing the first and recursively calling itself with the rest of the pack until all values are processed. `std::sizeof_pack` is used to check the pack's size. ```Rust fn print_sequence(auto first, auto ... rest) { std::print("{}", first); if (std::sizeof_pack(rest) > 0) print_sequence(rest); }; print_sequence(1, 2, 3, 4, 5, 6); ``` -------------------------------- ### Defining Unions for Data Interpretation in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/data-types.md This example defines a `union` where multiple variables share the same starting memory address. This allows interpreting the same block of data as different types, such as an `u32` integer or a `float`. ```Rust union Converter { u32 integerData; float floatingPointData; }; ``` -------------------------------- ### Checking if String Starts With Substring in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/string.pat.md Determines if a string begins with a specified substring. It takes the main `string` and the `part` (substring) to check for, returning `true` if it matches, `false` otherwise. ```Rust fn starts_with(str string, str part); ``` -------------------------------- ### 3D Model Vertices and Indices Representation Example Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md Example of representing a 3D model's triangles using both `vertices` and `indices` arrays. The `indices` array contains groups of three indices, each pointing to vertices in the `vertices` array to define a triangle. This method allows for vertex reuse, reducing data redundancy. ```Conceptual vertices = [ { -1.0, -1.0, 0.0 }, // vertex (0) { 1.0, -1.0, 0.0 }, // vertex (1) { 0.0, 0.0, 0.0 }, // vertex (2) { 1.0, 1.0, 0.0 }, // vertex (3) { -1.0, 1.0, 0.0 }, // vertex (4) ] indices = [ // 1st triangle 0, 1, 2, // 2nd triangle 1, 2, 3, // 3rd triangle 2, 3, 4, // 4th triangle 4, 2, 0 ] ``` -------------------------------- ### 3D Model Vertices-Only Representation Example Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md Example of representing a 3D model's triangles using only a `vertices` array. Each group of three consecutive vertices defines a triangle. This method is used when no separate `indices` array is provided to the `3d` visualizer. ```Conceptual vertices = [ // 1st triangle { -1.0, -1.0, 0.0 }, // vertex (0) { 1.0, -1.0, 0.0 }, // vertex (1) { 0.0, 0.0, 0.0 }, // vertex (2) // 2nd triangle { 1.0, -1.0, 0.0 }, // vertex (1) { 0.0, 0.0, 0.0 }, // vertex (2) { 1.0, 1.0, 0.0 }, // vertex (3) // 3rd triangle { 1.0, 1.0, 0.0 }, // vertex (3) { 0.0, 0.0, 0.0 }, // vertex (2) { -1.0, 1.0, 0.0 }, // vertex (4) // 4th triangle { -1.0, 1.0, 0.0 }, // vertex (4) { 0.0, 0.0, 0.0 }, // vertex (2) { -1.0, -1.0, 0.0 }, // vertex (0) ] ``` -------------------------------- ### Importing Standard Library Headers in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This Rust snippet illustrates the use of the `import` statement for bringing standard library headers into scope. Standard library headers are designed to be imported this way, ensuring proper module resolution and preventing conflicts. It shows examples of importing `std.io`, `std.mem`, and `type.float16`. ```rust import std.io; import std.mem; import type.float16; ``` -------------------------------- ### Defining Multi-Line Comments in C++ Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/comments.md This snippet illustrates the syntax for multi-line comments in the Pattern Language, using C++ conventions. Multi-line comments start with `/*` and conclude with `*/`, allowing for comments that span across multiple lines, ideal for larger blocks of documentation or temporarily commenting out sections of code. ```cpp /* This is a multi line comment */ ``` -------------------------------- ### Instantiating Templated Types in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/data-types.md This example shows how to create a concrete type from a previously defined template. By specifying actual types like `u32` and `u64` within angle brackets, a specific instance of `MyTemplateStruct` is created at a given memory offset. ```Rust MyTemplateStruct myConcreteStruct @ 0x00; ``` -------------------------------- ### Implementing Struct Inheritance in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/data-types.md This example illustrates struct inheritance, where a child struct copies all members from a parent struct. The `Child : Parent` syntax makes `type` and `value` from `Parent` available in `Child`. ```Rust struct Parent { u32 type; float value; }; struct Child : Parent { char string[]; }; ``` -------------------------------- ### Getting String Length in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/string.pat.md Retrieves the length of a given string. The function takes a `string` parameter and returns its length. ```Rust fn length(str string); ``` -------------------------------- ### Aliasing GUID to UUID in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/type/guid.pat.md This snippet creates a type alias `UUID` for the `type::GUID` struct. This allows developers to use either `UUID` or `GUID` interchangeably, providing flexibility and adherence to common naming conventions for Universally Unique Identifiers. ```Rust using UUID = type::GUID; ``` -------------------------------- ### Using Reference Parameters with Custom Types - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This example illustrates the use of reference parameters to pass custom types efficiently. It defines a `MyString` struct and a `print_my_string` function that takes a `ref MyString` parameter. This avoids copying the entire `MyString` object, instead passing a reference to the original data, which is useful for large or custom-layout types. ```Rust struct MyString { char value[while(std::mem::read_unsigned($, 1) != 0xFF)]; }; fn print_my_string(ref MyString myString) { std::print(myString.value); }; ``` -------------------------------- ### Getting s64 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by a signed 64-bit integer (`s64`). It takes no parameters and provides a direct constant value. ```Rust fn s64_min(); ``` -------------------------------- ### Getting u64 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by an unsigned 64-bit integer (`u64`). It takes no parameters and provides a direct constant value. ```Rust fn u64_min(); ``` -------------------------------- ### Implementing While Loops for Iteration - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This snippet demonstrates a `while` loop, which continuously executes its body as long as the specified condition evaluates to true. The example shows a `check()` function as the loop condition, indicating that the loop will continue to run as long as `check()` returns a truthy value. ```Rust while (check()) { // Keeps on executing as long as the check() function returns true } ``` -------------------------------- ### Getting s32 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by a signed 32-bit integer (`s32`). It takes no parameters and provides a direct constant value. ```Rust fn s32_min(); ``` -------------------------------- ### Extracting Substring in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/string.pat.md Extracts a substring from a given string. Parameters include the `string` itself, `pos` for the starting index, and `count` for the number of characters to extract, returning the resulting substring. ```Rust fn substr(str string, u32 pos, u32 count); ``` -------------------------------- ### Getting s128 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by a signed 128-bit integer (`s128`). It takes no parameters and provides a direct constant value. ```Rust fn s128_min(); ``` -------------------------------- ### Getting u32 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by an unsigned 32-bit integer (`u32`). It takes no parameters and provides a direct constant value. ```Rust fn u32_min(); ``` -------------------------------- ### Getting s64 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by a signed 64-bit integer (`s64`). It takes no parameters and provides a direct constant value. ```Rust fn s64_max(); ``` -------------------------------- ### Getting s16 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by a signed 16-bit integer (`s16`). It takes no parameters and provides a direct constant value. ```Rust fn s16_min(); ``` -------------------------------- ### Getting u64 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by an unsigned 64-bit integer (`u64`). It takes no parameters and provides a direct constant value. ```Rust fn u64_max(); ``` -------------------------------- ### Getting s8 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by a signed 8-bit integer (`s8`). It takes no parameters and provides a direct constant value. ```Rust fn s8_min(); ``` -------------------------------- ### Calculating Base-2 Logarithm in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/math.pat.md This function calculates the base-2 logarithm of the input `value`. It is typically used for floating-point numbers. The return value is the power to which 2 must be raised to get `value`. ```Rust fn log2(auto value); ``` -------------------------------- ### Copying Bytes Between Custom Memory Sections (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/mem.pat.md Copies a specified range of bytes from one custom memory section to another. It requires source and destination section handles, their respective start addresses, and the number of bytes to copy for efficient data transfer. ```Rust fn copy_section_to_section(std::mem::Section from_section, u64 from_address, std::mem::Section to_section, u64 to_address, u64 size); ``` -------------------------------- ### Getting u16 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by an unsigned 16-bit integer (`u16`). It takes no parameters and provides a direct constant value. ```Rust fn u16_min(); ``` -------------------------------- ### Getting u8 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by an unsigned 8-bit integer (`u8`). It takes no parameters and provides a direct constant value. ```Rust fn u8_min(); ``` -------------------------------- ### Getting Default Bitfield Order in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/core.pat.md Retrieves the currently set default bitfield order. This function returns the `std::core::BitfieldOrder` value that is currently active. ```Rust fn get_bitfield_order(); ``` -------------------------------- ### Calculating Base-10 Logarithm in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/math.pat.md This function calculates the base-10 logarithm of the input `value`. It is typically used for floating-point numbers. The return value is the power to which 10 must be raised to get `value`. ```Rust fn log10(auto value); ``` -------------------------------- ### Using Casting Operator for Type Conversion - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/expressions.md Demonstrates the casting operator to convert an expression's type into another. In this example, a `float` input `x` is explicitly cast to `u32` before being added to an integer, resulting in an integer output. ```Rust fn test(float x) { return 1 + u32(x); } test(3.14159); // 4 ``` -------------------------------- ### Accessing Single Bytes with Dollar Operator - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/expressions.md Shows how the `$` operator can be used with array-like indexing to access individual bytes of the main data at the current offset. This example prints the value of the byte at address `0x00`. ```Rust std::print($[0]); // Prints the value of the byte at address 0x00 ``` -------------------------------- ### Returning a Value from a Function in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This snippet shows how to return a value from a function using the `return` keyword in Rust. The `get_value` function returns the integer `1234`, and the return type is automatically inferred. The example also demonstrates calling the function and printing its returned value. ```rust fn get_value() { return 1234; }; std::print("{}", get_value()); // 1234 ``` -------------------------------- ### Getting Custom Memory Section Size (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/mem.pat.md Retrieves the current size of a custom memory section. It takes the section handle as input and returns its size in bytes, allowing for inspection of allocated memory. ```Rust fn get_section_size(std::mem::Section section); ``` -------------------------------- ### Accumulating Values in Memory with std::math::accumulate (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/math.pat.md This function calculates the sum of all values within a specified memory range. It requires `start` and `end` addresses, and `valueSize` in bytes. Optional parameters include `section`, `operation` (defaulting to addition), and `endian` (defaulting to native) for flexible accumulation. ```rust fn accumulate(u128 start, u128 end, u128 valueSize, std::mem::Section section, std::math::AccumulateOperation operation, std::mem::Endian endian); ``` -------------------------------- ### Defining the GUID Structure in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/type/guid.pat.md This snippet defines the `GUID` struct, which represents a Globally Unique Identifier. The `[[sealed, format]]` attributes likely indicate specific compiler or formatting directives for this type. It serves as the fundamental type for handling UUIDs/GUIDs. ```Rust struct GUID { ... } [[sealed, format]]; ``` -------------------------------- ### Implementing Documentation Comments in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/comments.md This Rust snippet showcases various forms of documentation comments in the Pattern Language. It includes global doc comments (`/*! ... */`) for overall pattern documentation, local doc comments (`/** ... */`) for functions or types, and single-line local doc comments (`///`), demonstrating how to annotate code with detailed explanations, parameters, and return values for automated documentation generation. ```rust /*! This is a global doc comment. It documents the whole pattern and can contain various attributes that can be used by tools to extract information about the pattern. */ /** This is a local doc comment. It documents the function or type that immediately follows it. */ /** This is a doc comment documenting a function that adds two numbers together @param x The first parameter. @param y The second parameter. @return The sum of the two parameters. */ fn add(u32 x, u32 y) { return x + y; }; /// This is a single line local comment. It documents the function or type that immediately follows it. ``` -------------------------------- ### Importing Modules with `import as` (C++) - Original Namespace Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This C++ snippet shows a common scenario where library content is accessed using its full namespace, which can lead to verbose code. It sets the context for why the `import as` statement is useful by demonstrating the default, explicit namespace usage. ```C++ import std.ctype; char character @ 0x00; if (std::ctype::isdigit(character)) { // ... } ``` -------------------------------- ### Querying Provider Information - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/hex/provider.pat.md This function queries specific information from the currently loaded provider. The type of information available depends on the provider (e.g., file details for a File Provider, IP/port for a GDB Provider). It requires a `category` string to specify the type of information requested and an optional `argument` string for additional context, such as a region name for process memory. ```rust fn get_information(str category, str argument); ``` -------------------------------- ### Printing Formatted Output with std::print (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/io.pat.md Formats arguments using a format string and prints the result to the console. It supports C++20 `std::format` or libfmt's `fmt::format` syntax. The `fmt` parameter is the format string, and `args` are the values to be formatted. ```Rust fn print(auto fmt, auto ... args); ``` -------------------------------- ### Visualizing Sound with Hex Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This visualizer converts raw signed 16-bit PCM audio stream bytes into audible sound. It requires the audio data pattern, the number of channels, and the sample rate to correctly play the audio. ```Hex Visualizer Syntax [[hex::visualize("sound", pattern, num_channels, sample_rate)]] ``` -------------------------------- ### Forward Declaring Types for Recursive References in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/data-types.md This example shows how to forward declare a type using `using TypeName;` when two types recursively reference each other. This ensures the runtime knows about the type `B` before its full definition, allowing `A` to reference it. ```Rust // Tell the language that there will be a type named B in the future so if it encounters // a variable with this type, it has to postpone the parsing until the type has been declared using B; struct A { bool has_b; if (has_b) B b; }; struct B { bool has_a; if (has_a) A a; }; ``` -------------------------------- ### Formatting String with std::format (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/io.pat.md Formats arguments using a format string and returns the result as a string. Similar to `std::print`, it uses C++20 `std::format` or libfmt's `fmt::format` syntax. `fmt` is the format string, `args` are the values, and it returns the formatted string. ```Rust fn format(auto fmt, auto ... args); ``` -------------------------------- ### Calculating Natural Logarithm in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/math.pat.md This function calculates the natural logarithm (base `e`) of the input `value`. It is typically used for floating-point numbers. The return value is the power to which `e` must be raised to get `value`. ```Rust fn ln(auto value); ``` -------------------------------- ### Implementing ImHex Provider Base Class Functions (C++) Source: https://github.com/werwolv/documentation/blob/master/imhex/common/providers.md This C++ snippet defines the core virtual functions of the `Provider` base class in ImHex. These functions manage the lifecycle and data access operations for any data source, including opening/closing connections, reading/writing raw data at specified offsets, and determining the data source's actual size. They form the interface for custom data providers, allowing ImHex to interact with various data sources like files, processes, or web services. ```C++ // Called when a new provider is created. Opens a connection // to its data source bool open(); // Called when the provider is closed. Handles cleanup void close(); // Called whenever ImHex wants to read any data from this provider void readRaw(u64 offset, void *buffer, size_t size); // Called whenever Imhex wants to write any data to this provider void writeRaw(u64 offset, const void *buffer, size_t size); // Called when ImHex wants to know the size of this data size_t getActualSize(); ``` -------------------------------- ### Creating and Populating a Section in Rust-like Pattern Language Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/sections.md This snippet demonstrates how to create a new section named 'My Section', allocate a 0x100 byte buffer within it, populate specific bytes with data, and then define a pattern to decode data at the beginning of the section. It's useful for analyzing dynamically generated data such as compressed, encrypted, or otherwise transformed data. ```Rust-like Pattern Language #include std::mem::Section mySection = std::mem::create_section("My Section"); u8 sectionData[0x100] @ 0x00 in mySection; sectionData[0] = 0xAA; sectionData[1] = 0xBB; sectionData[2] = 0xCC; sectionData[3] = 0xDD; sectionData[0xFF] = 0x00; u32 value @ 0x00 in mySection; ``` -------------------------------- ### Getting Attribute Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/core.pat.md Retrieves the value of a specified `attribute` from a `pattern`. This function is used to obtain the primary value associated with an attribute. ```Rust fn get_attribute_value(auto pattern, str attribute); ``` -------------------------------- ### Getting s128 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by a signed 128-bit integer (`s128`). It takes no parameters and provides a direct constant value. ```Rust fn s128_max(); ``` -------------------------------- ### Opening a File in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/file.pat.md Opens a file at the specified `path` with the given `mode`. It returns a `Handle` to the newly opened file, which can then be used for subsequent file operations. This function is a prerequisite for reading from or writing to a file. ```rust fn open(str path, std::file::Mode mode); ``` -------------------------------- ### Creating Directories for a Path in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/file.pat.md Creates all necessary parent directories for the given `path` if they do not already exist. This function ensures that the directory structure is in place before attempting to create or write to a file within that path. ```rust fn create_directories(str path); ``` -------------------------------- ### Getting u128 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by an unsigned 128-bit integer (`u128`). It takes no parameters and provides a direct constant value. ```Rust fn u128_max(); ``` -------------------------------- ### Assigning to Dollar Operator to Change Cursor Position - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/expressions.md Illustrates how to modify the current cursor position by assigning a new value to the `$` operator. This example advances the cursor by `0x100` bytes, effectively seeking to a new offset. ```Rust $ += 0x100; ``` -------------------------------- ### Getting u128 Minimum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the smallest possible value that can be represented by an unsigned 128-bit integer (`u128`). It takes no parameters and provides a direct constant value. ```Rust fn u128_min(); ``` -------------------------------- ### Including Files with #include Directive (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This snippet demonstrates the use of the `#include` preprocessor directive in Rust-like syntax within the pattern language. The directive replaces itself with the lexical tokens of the specified file, including preprocessor defines. Paths can be enclosed in double quotes or pointy braces, and the file extension is optional, defaulting to `.pat` or `.hexpat`. ```Rust #include "std/io.pat" #include ``` -------------------------------- ### Importing Modules with import Statement (Pattern Language) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This snippet illustrates the `import` statement, which is processed during the parsing stage. It creates a separate parser for the imported file, inserting its Abstract Syntax Tree (AST) into the current file's AST. Unlike `#include`, preprocessor defines do not propagate. The path uses dot notation for folder separation, and the file extension is resolved automatically. ```Pattern Language import sys.mem; ``` -------------------------------- ### Defining a Basic Function with Explicit Parameters - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This snippet demonstrates a basic function definition in Rust-like syntax. It defines a `min` function that takes two `s32` parameters, `a` and `b`, and returns the smaller of the two. The return type is automatically deduced. It also shows how to call the function and print its result. ```Rust fn min(s32 a, s32 b) { if (a > b) return b; else return a; }; std::print(min(100, 200)); // 100 ``` -------------------------------- ### Retrieving Base Memory Address in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/mem.pat.md This Rust function `base_address` retrieves the starting address of the current data segment or memory region being operated on. It returns a `u128` representing the lowest address of the accessible memory, serving as a reference point for relative offsets. ```Rust fn base_address(); ``` -------------------------------- ### Getting s32 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by a signed 32-bit integer (`s32`). It takes no parameters and provides a direct constant value. ```Rust fn s32_max(); ``` -------------------------------- ### Importing Modules with `import as` (C++) - Renamed Namespace Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This C++ snippet demonstrates the `import as` statement, which allows renaming an imported namespace to a shorter alias. This reduces verbosity and prevents name collisions, making the code cleaner and easier to read when frequently referencing elements from that namespace. ```C++ import std.ctype as c; char character @ 0x00; if (c::isdigit(character)) { // ... } ``` -------------------------------- ### Implementing Manual Include Guards in C++ Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This C++ snippet demonstrates how to create manual include guards using `#ifndef` and `#define` preprocessor directives. This prevents a header file's contents from being included multiple times in a single compilation unit, avoiding redefinition errors. The guard typically wraps the entire content of the header file. ```c++ #ifndef FOO_HEXPAT #define FOO_HEXPAT // Pattern code #endif ``` -------------------------------- ### Including External Files with #include in Preprocessor Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/preprocessor.md This snippet illustrates the #include directive, which copies the content of the specified file (mylibrary.hexpat) directly into the current program. It is used for incorporating external code or definitions. ```cpp #include ``` -------------------------------- ### Getting u32 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by an unsigned 32-bit integer (`u32`). It takes no parameters and provides a direct constant value. ```Rust fn u32_max(); ``` -------------------------------- ### Getting s16 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by a signed 16-bit integer (`s16`). It takes no parameters and provides a direct constant value. ```Rust fn s16_max(); ``` -------------------------------- ### Advanced Match Statements with Multiple Values and Wildcards in Pattern Language Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/control-flow.md This snippet illustrates advanced usage of `match` statements, allowing matching against multiple values (e.g., `type` and `size`) simultaneously. It also introduces the `_` wildcard for creating default cases, enabling flexible parsing logic where specific combinations or any other case can be handled. ```Rust struct Packet { Type type; u8 size; match (type, size) { (Type::A, 0x200): PacketA packet; (Type::C, _): PacketC packet; (_, _): PacketB packet; } }; Packet packet[3] @ 0xF0; ``` -------------------------------- ### Querying File Size in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/file.pat.md Queries and returns the total size of the file, in bytes, identified by `handle`. This function is useful for determining the amount of data available in a file or for pre-allocating buffers for read operations. ```rust fn size(std::file::Handle handle); ``` -------------------------------- ### Getting u16 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by an unsigned 16-bit integer (`u16`). It takes no parameters and provides a direct constant value. ```Rust fn u16_max(); ``` -------------------------------- ### Resizing a File in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/file.pat.md Resizes the file identified by `handle` to the specified `size`. If the new size is smaller, the file is truncated; if larger, it may be padded with null bytes or extended, depending on the underlying file system. ```rust fn resize(std::file::Handle handle, u64 size); ``` -------------------------------- ### Getting s8 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by a signed 8-bit integer (`s8`). It takes no parameters and provides a direct constant value. ```Rust fn s8_max(); ``` -------------------------------- ### Visualizing Chunk Entropy with Hex Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This visualizer displays an entropy graph of bytes from a given pattern. The bytes are first split into chunks of a size specified by the `chunk_size` parameter, allowing for analysis of data randomness within segments. ```Hex Visualizer Syntax [[hex::visualize("chunk_entropy", pattern, chunk_size)]] ``` -------------------------------- ### Getting u8 Maximum Value in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/limits.pat.md This function returns the largest possible value that can be represented by an unsigned 8-bit integer (`u8`). It takes no parameters and provides a direct constant value. ```Rust fn u8_max(); ``` -------------------------------- ### Visualizing Hex Viewer with Hex Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This visualizer displays the raw bytes of the provided pattern in a traditional hexadecimal viewer format, allowing for byte-level inspection and analysis of data. ```Hex Visualizer Syntax [[hex::visualize("hex_viewer", pattern)]] ``` -------------------------------- ### Printing Warning Message with std::warning (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/io.pat.md Prints a warning message to the console without aborting execution. The `message` parameter is the string to be displayed as the warning. ```Rust fn warning(str message); ``` -------------------------------- ### Implementing If-Else-If Control Statements - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This snippet illustrates the structure of `if`, `else if`, and `else` control statements. It shows how different code blocks are executed based on the evaluation of conditions. Curly braces are used for multi-statement blocks, but are optional for single statements, following C-like language conventions. ```Rust if (x > 5) { // Execute when x is greater than 5 } else if (x == 2) { // Execute only when x is equals to 2 } else { // Execute otherwise } ``` -------------------------------- ### Getting Default Endianness in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/core.pat.md Retrieves the currently set default endianness. This function returns the `std::mem::Endian` value that is currently active for pattern creation. ```Rust fn get_endian(); ``` -------------------------------- ### Converting Any Type to String in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/string.pat.md Converts any given value to its string representation. It accepts an `auto x` parameter, allowing it to convert various data types, and returns the resulting string. ```Rust fn to_string(auto x); ``` -------------------------------- ### Applying a Visualizer to a Struct in ImHex Pattern Language (C++) Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This C++ snippet defines a `Coordinates` struct and applies the `[[hex::visualize]]` attribute. This ImHex-specific extension allows for advanced visualization of data beyond text and colors. The attribute takes the visualizer name ("coordinates") and the struct members (`latitude`, `longitude`) to be used by the visualizer as parameters. When applied, the `Value` column in the Pattern Data View will display a button to open the specified visualizer. ```cpp struct Coordinates { float latitude; float longitude; } [[hex::visualize("coordinates", latitude, longitude)]]; ``` -------------------------------- ### Executing Functions by Name in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/core.pat.md Executes a function identified by its `function_name` (namespace-prefixed), passing in all provided `args`. This allows for dynamic function invocation based on string names. ```Rust fn execute_function(str function_name, auto ... args); ``` -------------------------------- ### Visualizing 3D Models with Hex Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This visualizer renders 3D models from an array of structures, each containing three 4-Byte `float` values for X, Y, and Z coordinates. An optional `u32` array of indices can be provided to reference vertices, with `null` indicating no indices are used. Each group of three vertices or indices forms a triangle. ```Hex Visualizer Syntax [[hex::visualize("3d", vertices, indices)]] ``` -------------------------------- ### Getting Current Epoch Time in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/time.pat.md This function, `epoch`, returns the current time as the number of seconds that have elapsed since the Unix epoch. It takes no parameters and provides a `u32` (EpochTime) as its return value. ```Rust fn epoch(); ``` -------------------------------- ### Importing Auto Namespace with Renaming (C++) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This C++ snippet shows how to import an `auto` marked namespace from a library file and rename it. By using `import std.ctype as test;`, the `std::ctype` namespace (which was marked `auto`) is imported and aliased to `test`, allowing for concise access to its contents. ```C++ // Import the std::type namespace from the ctype.pat library file // and rename the std::ctype namespace to test import std.ctype as test; ``` -------------------------------- ### Defining Auto Namespace (C++) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This C++ snippet demonstrates how to mark a namespace within a library file as `auto`. This designation allows the `auto` namespace to be the default one imported and potentially renamed when using the `import` statement, simplifying the import process for libraries with multiple namespaces. ```C++ // std/ctype.pat namespace auto std::ctype { // ... } namespace impl { // ... } ``` -------------------------------- ### Decompressing Data with hex::dec::zlib_decompress (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/hex/dec.pat.md This function decompresses the bytes of a given `pattern` into a `section` using the zlib algorithm. It requires a `window_size` parameter for zlib configuration. The function returns the number of bytes decompressed or an error code from zlib. ```Rust fn zlib_decompress(auto pattern, std::mem::Section section, u64 window_size); ``` -------------------------------- ### Visualizing Bitmap with Hex Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This visualizer draws raw RGBA8 values (RR GG BB AA, one byte per channel) as an image. It requires the pattern containing the pixel data, along with the width and height of the resulting image in pixels. ```Hex Visualizer Syntax [[hex::visualize("bitmap", pattern, width, height)]] ``` -------------------------------- ### Accessing Data with Pattern Views in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This snippet demonstrates the use of "pattern views" in Rust, which allow accessing data at a specific memory address. The `u32 value @ address;` syntax creates a view of the `u32` value located at the given `address`, which can then be returned or used like a regular variable without generating an output pattern. ```rust fn read_u32(u32 address) { u32 value @ address; return value; }; std::print("{}", read_u32(0x1234)); // Prints the value at address 0x1234 formatted as a u32 ``` -------------------------------- ### Getting Current Array Index in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/core.pat.md Returns the current array index when used within a pattern being created as part of an array. If called outside an array context, it always yields 0. Useful for context-aware pattern generation. ```Rust fn array_index(); ``` -------------------------------- ### Importing External Patterns as New Types (Pattern Language) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/importing-modules.md This snippet shows how to import an entire pattern file as a new struct type using `import * from as `. This is useful for embedding other file formats or structures within a current pattern. When the new type is placed, the imported pattern's code is evaluated with adjusted offsets, effectively inlining its content. ```Pattern Language import * from pe as Executable; Executable executable @ 0x1234; ``` -------------------------------- ### Defining File Open Modes in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/file.pat.md Defines an enumeration `Mode` with `u8` underlying type, specifying how a file should be opened. It includes `Create` (for new or overwriting files), `Read` (for read-only access), and `Write` (for read and write access). ```rust enum Mode : u8 { Create, Read, Write }; ``` -------------------------------- ### Displaying RGBA Color Inline (Hex Visualizer Syntax) Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This inline visualizer renders a color directly within the value column. It takes four integer parameters: 'r' (red), 'g' (green), 'b' (blue), and 'a' (alpha), each expected to be between 0 and 255. This allows for direct visual representation of color data. ```Hex Visualizer Syntax [[hex::inline_visualize("color", r, g, b, a)]] ``` -------------------------------- ### Declaring Pattern Local Variables in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/data-types.md This example shows how to declare local variables within patterns using the `=` operator. These variables, like `localVariable`, store information for internal use within the pattern and do not become part of the final type definition. ```Rust struct MyType { u32 x, y, z; // Regular members float localVariable = 0.5; // Local variable }; ``` -------------------------------- ### Formatting Pattern Values in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/core.pat.md Formats a `pattern` into a string representation using its default formatter or a custom formatter function defined via `[[format]]` or `[[format_read]]` attributes. This provides a human-readable output for pattern values. ```Rust fn formatted_value(auto pattern); ``` -------------------------------- ### Calculating CRC64 Hash in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/hash.pat.md This function calculates the CRC64 hash for a given byte pattern. It requires parameters for initialization value (`init`), polynomial (`poly`), XOR-out value (`xorout`), and boolean flags for input (`reflect_in`) and output (`reflect_out`) reflection. It returns the calculated 64-bit CRC hash. ```Rust fn crc64(auto pattern, u64 init, u64 poly, u64 xorout, bool reflect_in, bool reflect_out); ``` -------------------------------- ### Implementing a Basic For Loop in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This snippet demonstrates a basic `for` loop structure in Rust. It initializes an iterating variable `i` of type `u8` to `0`, continues as long as `i` is less than `10`, and increments `i` by `1` after each iteration. The variable `i` is scoped only within the loop. ```rust // Declare a variable called i available only inside the for for (u8 i = 0, i < 10, i = i + 1) { // Keeps on executing as long as i is less than 10 // At the end, increment i by 1 } ``` -------------------------------- ### Getting Current Bit Offset in Bitfield (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/mem.pat.md Returns the current bit offset within a bitfield context. This is useful when working with bit-level operations and indicates the position (0-7) within the current byte, aiding in precise bit manipulation. ```Rust fn current_bit_offset(); ``` -------------------------------- ### Calculating Arc Hyperbolic Sine with std::math::asinh (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/math.pat.md This function computes the inverse hyperbolic sine (arc hyperbolic sine) of a given `value`. It takes a single `value` parameter and returns its arc hyperbolic sine. ```rust fn asinh(auto value); ``` -------------------------------- ### Getting Parameter Pack Size with std::sizeof_pack in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/sys.pat.md This function returns the number of parameters contained within a given parameter pack. It takes a `pack` (variadic argument list) and returns an integer representing the count of parameters. This is useful for compile-time introspection of variadic templates or functions. ```Rust fn sizeof_pack(auto ... pack, ); ``` -------------------------------- ### Setting Pattern Palette Colors in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/core.pat.md Sets the color palette for all future patterns created. The `colors` are provided as variable arguments, each being an RGBA8 32-bit integer (0xAABBGGRR). This allows for consistent color schemes. ```Rust fn set_pattern_palette_colors(auto ... colors, ); ``` -------------------------------- ### Defining relative_to_pointer Function - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/ptr.pat.md The `relative_to_pointer` function in Rust calculates a new pointer base using the provided `offset` as the starting address. This function is designed to interpret the `offset` parameter directly as the base address for subsequent pointer calculations, returning the computed base. ```Rust fn relative_to_pointer(u128 offset); ``` -------------------------------- ### Defining Single-Line Comments in C++ Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/comments.md This snippet demonstrates how to create a single-line comment in the Pattern Language using C++ syntax. Single-line comments begin with `//` and extend to the end of the current line, useful for brief inline notes or disabling a single line of code. ```cpp // This is a single line comment ``` -------------------------------- ### Comparing Values for Minimum in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/math.pat.md This function compares two input values, `a` and `b`, and returns the smaller of the two. It is a generic function, accepting any comparable types. The return value is `a` if `a` is less than `b`, otherwise `b`. ```Rust fn min(auto a, auto b); ``` -------------------------------- ### Visualizing Image with Hex Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This visualizer decodes and displays image data from any pattern containing image bytes, such as a struct or byte array. Supported formats include JPG, PNG, TGA, BMP, PSD, GIF, HDR, and PIC. ```Hex Visualizer Syntax [[hex::visualize("image", pattern)]] ``` -------------------------------- ### Setting Custom Memory Section Size (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/mem.pat.md Modifies the size of an existing custom memory section. This function requires the section handle and the new desired size in bytes, enabling dynamic resizing of memory regions. ```Rust fn set_section_size(std::mem::Section section, u128 size); ``` -------------------------------- ### Defining relative_to_end Function - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/ptr.pat.md The `relative_to_end` function in Rust computes a pointer base by starting from the end of the file and applying the given `offset` backwards. This function is useful for scenarios where pointers reference locations relative to the end of a data block or file, returning the derived pointer base. ```Rust fn relative_to_end(u128 offset); ``` -------------------------------- ### Writing Content to File in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/file.pat.md Writes the provided `data` (string or pattern) to the file identified by `handle` at the current cursor position. This operation modifies the file's content and requires the file to be opened in a writable mode. ```rust fn write(std::file::Handle handle, auto data); ``` -------------------------------- ### Converting String to Uppercase in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/string.pat.md Converts all characters in a string to their uppercase equivalents. It takes the `string` to convert and returns the new uppercase string. ```Rust fn to_upper(str string); ``` -------------------------------- ### Defining relative_to_parent Function - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/ptr.pat.md The `relative_to_parent` function in Rust determines a new pointer base by using the offset of the current pointer's parent as the starting address. It takes an `offset` (the pointer's value) and returns the calculated new pointer base, facilitating hierarchical pointer arithmetic. ```Rust fn relative_to_parent(u128 offset); ``` -------------------------------- ### Calculating Binomial Coefficient in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/math.pat.md This function calculates the binomial coefficient (combinations) of `n` items taken `k` at a time. Both `n` and `k` are unsigned 128-bit integers. ```Rust fn comb(u128 n, u128 k); ``` -------------------------------- ### Converting String to Lowercase in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/string.pat.md Converts all characters in a string to their lowercase equivalents. It takes the `string` to convert and returns the new lowercase string. ```Rust fn to_lower(str string); ``` -------------------------------- ### Using Custom Types (Unions) within Functions - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/functions.md This example shows how custom types, specifically a `union` named `FloatConverter`, can be used within functions. The `interpret_as_float` function takes a `u32` integer, assigns it to the union's `integer` member, and then returns the value interpreted as a `float` through the `floatingPoint` member, demonstrating type reinterpretation. ```Rust union FloatConverter { u32 integer; float floatingPoint; }; fn interpret_as_float(u32 integer) { FloatConverter converter; converter.integer = integer; return converter.floatingPoint; }; ``` -------------------------------- ### Displaying Progress Gauge Inline (Hex Visualizer Syntax) Source: https://github.com/werwolv/documentation/blob/master/imhex/views/pattern-data.md This inline visualizer displays a progress bar in the value column. It requires a single integer parameter 'progress', which should range from 0 to 100, representing the fill level of the bar. It's useful for visualizing completion or status. ```Hex Visualizer Syntax [[hex::inline_visualize("gauge", progress)]] ``` -------------------------------- ### Defining Endianness for Data Types in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/data-types.md This snippet demonstrates how to specify endianness for built-in data types in Rust. It shows examples of declaring a 32-bit unsigned integer as little-endian, a 64-bit double as big-endian, and an 8-bit signed integer using the native endianness. This allows overriding the default runtime endianness for specific variables. ```rust le u32 myUnsigned; // Little endian 32 bit unsigned integer be double myDouble; // Big endian 64 bit double precision floating point s8 myInteger; // Native endian 8 bit signed integer ``` -------------------------------- ### Calculating CRC16 Hash in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/hash.pat.md This function calculates the CRC16 hash for a given byte pattern. It requires parameters for initialization value (`init`), polynomial (`poly`), XOR-out value (`xorout`), and boolean flags for input (`reflect_in`) and output (`reflect_out`) reflection. It returns the calculated 16-bit CRC hash. ```Rust fn crc16(auto pattern, u16 init, u16 poly, u16 xorout, bool reflect_in, bool reflect_out); ``` -------------------------------- ### Defining an Enum with Explicit Values in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/data-types.md This Rust snippet illustrates the definition of an enum named `StorageType` with an underlying `u16` type. It demonstrates how enum members are assigned values, starting from `0x00` by default and incrementing, or explicitly set as shown with `Compressed = 0x10`, which then causes subsequent members like `Encrypted` to increment from that new base. ```rust enum StorageType : u16 { Plain, // 0x00 Compressed = 0x10, Encrypted // 0x11 }; ``` -------------------------------- ### Adding Virtual File to ImHex Filesystem (Rust) Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/hex/core.pat.md The `add_virtual_file` function allows adding a new file to ImHex's virtual file system. It requires a `path` (string) for the file's name and a `pattern` (auto-detected type) to associate with the file, enabling dynamic file management. ```Rust fn add_virtual_file(str path, auto pattern); ``` -------------------------------- ### Finding String in Memory Range in Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/libraries/std/mem.pat.md This Rust function `find_string_in_range` searches for a string within a specified memory region. It requires an `occurrence_index` (u128), `offsetFrom` (u128) to start, `offsetTo` (u128) to end the search, and the `string` (str) to find. It returns the `u128` address of the string if found within the given range. ```Rust fn find_string_in_range(u128 occurrence_index, u128 offsetFrom, u128 offsetTo, str string); ``` -------------------------------- ### Using Dollar Operator for Current Offset - Rust Source: https://github.com/werwolv/documentation/blob/master/pattern_language/core-language/expressions.md Demonstrates how the `$` operator expands to the current offset within the current pattern. It shows the offset before and after a 4-byte `u32` declaration, illustrating its automatic advancement. ```Rust #pragma base_address 0x00 std::print($); // 0 u32 x @ 0x00; std::print($); // 4 ```