Skip to content

[Bug] "relative_to_parent" is not working as expected #2507

@Valeour

Description

@Valeour

Operating System

Windows

What's the issue you encountered?

When using "relative_to_parent" in conjunction with pointer_base, the offset is exactly the same as relative_to_base.

How can the issue be reproduced?

Data example:

00 00 08 00 00 00 00 00 01 00 03 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Pattern:

import std.ptr;

struct SecretData
{
    u16 value;
};

struct DataFinder
{
    u16 id;
    SecretData *offset : u16 [[pointer_base("std::ptr::relative_to_pointer")]];
};

struct DataFinderParent
{
    u16 id;
    SecretData *offset : u16 [[pointer_base("std::ptr::relative_to_parent")]];
};

DataFinder FirstBase @ 0x0;
DataFinderParent FirstParent @ 0x0;

DataFinder SecondBase @ 0x10;
DataFinderParent SecondParent @ 0x10;

Both outputs are the same, where as DataFinderParent First and Second I would expect to point to 0x8 and 0x28 respectively.

ImHex Version

1.37.4

ImHex Build Type

  • Nightly or built from sources

Installation type

MSI/Installer

Additional context?

Creating a custom pointer_base method that uses addressof(parent.parent) produces expected results.

fn relative_to_parent(u128 offset) {
    return addressof(parent.parent);
};

My assumption is that the parent is returning the variable itself, not the parent structure.
Is this intentional and I've misunderstood the use of relative_to_parent?
I'm uncertain as it produces the same results as relative_to_pointer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions