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

Defining a Charset through Enums. #2714

Closed
frozenLake opened this issue Feb 1, 2021 · 3 comments
Closed

Defining a Charset through Enums. #2714

frozenLake opened this issue Feb 1, 2021 · 3 comments
Assignees
Labels
Reason: Out of scope This is outside the scope of the Ghidra project Type: Enhancement New feature or request

Comments

@frozenLake
Copy link

Is your feature request related to a problem? Please describe.
Currently, without modifying Java code, it is impossible to create a custom charset. While Java does have a number of existing Charsets, I am presently dealing with a program that uses a custom charset. Right now, I am using arrays of a custom "Text" enum, but this is rather clunky, and fails at visualization.

Describe the solution you'd like
I would like to be able to import an enum as a charset, or set the display of enums into a string like format.

Describe alternatives you've considered
Maybe formatting for charset_info.xml could be expanded to actually define a custom charset? Admittingly, this might be possible, but given the code, it does not appear to be the case.

Additional context
I have already searched through existing issues, but one only seems to lead to importing java's StandardCharsets, while the other blindly leads to charset_info.xml, without any context as to how this is useful for the current issue.

@dev747368 dev747368 added the Type: Enhancement New feature or request label Feb 2, 2021
@GMMan
Copy link

GMMan commented Jun 21, 2022

From the looks of it, maybe you can implement a new Charset and CharsetProvider and add it to charset_info.xml. Not sure if editing the XML is even necessary because it seems to add charsets discovered from the JVM, unless the char size is multi-byte. I'll be trying this out later.

@GMMan
Copy link

GMMan commented Jun 21, 2022

For the basic case of single-byte character sets, it is pretty simple. All you have to do is build a .jar with your CharsetProvider and Charset and drop it into Ghidra's Ghidra/patch directory. Here's a sample project demonstrating custom CharsetProvider and Charset. There are surely better implementations, but this should do in a pinch. After you drop the .jar into Ghidra, you can right click on a string, select Data -> Settings... or Data -> Default Settings..., and pick your new encoding from the Charset list.

image

@ryanmkurtz ryanmkurtz added the Status: Triage Information is being gathered label Jun 22, 2022
@dev747368
Copy link
Collaborator

In general, the example/custom charset that @GMMan linked seems like the right direction to take. I'm going to mark the original request as out of scope and close.

@dev747368 dev747368 added Reason: Out of scope This is outside the scope of the Ghidra project and removed Status: Triage Information is being gathered labels Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reason: Out of scope This is outside the scope of the Ghidra project Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants