Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] hex::core::add_virtual_file does not accept char[] #2032

Open
1 task
rsp4jack opened this issue Dec 27, 2024 · 1 comment
Open
1 task

[Bug] hex::core::add_virtual_file does not accept char[] #2032

rsp4jack opened this issue Dec 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@rsp4jack
Copy link

Operating System

Linux

What's the issue you encountered?

import hex.core;
import std.mem;

char array[while(!std::mem::eof())] @ 0x0;

hex::core::add_virtual_file("/", array);
E: [ Stack Trace ]
E: /usr/share/imhex/includes/hex/core.pat:47:59
E: 47 | dd_virtual_file(path, pattern);
E:                                    ^
E: <Source Code>:6:39
E: 6 | hex::core::add_virtual_file("/", array);
E:                                           ^


E: runtime error: Cannot cast value to type 'pattern'

How can the issue be reproduced?

Pass a char[] into it

ImHex Version

1.36.0

ImHex Build Type

  • Nightly or built from sources

Installation type

AUR imhex-bin

Additional context?

Is char[] not a pattern? A u8[] works.

@rsp4jack rsp4jack added the bug Something isn't working label Dec 27, 2024
@WerWolv
Copy link
Owner

WerWolv commented Dec 27, 2024

Hey
You're right, this is a bit confusing. The thing is, char arrays create a string pattern when they're created so they can show up as strings in the pattern data view. When passing those strings to functions, they automatically decay to actual string values and lose their pattern information such as the location where they were in your data. I believe this is sadly pretty hard to fix without breaking many other patterns in the process. I can however document this a bit better in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants