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

Figure out a way to allow more assembler/disassembler modes #225

Closed
rdbo opened this issue May 28, 2024 · 3 comments
Closed

Figure out a way to allow more assembler/disassembler modes #225

rdbo opened this issue May 28, 2024 · 3 comments

Comments

@rdbo
Copy link
Owner

rdbo commented May 28, 2024

Some architectures have lots of modes, e.g ARM.
ARM has thumb mode, v8 mode, etc
What I'm thinking is to interpret those as different architectures:

enum {
        LM_ARCH_ARM,
        LM_ARCH_ARMV8,
        LM_ARCH_ARM_THUMB,
        LM_ARCH_X86_16,
        LM_ARCH_X86,
        LM_ARCH_X64,
        // ...
}

In addition to this, I could also deprecate the bits parameter from the LM_AssembleEx and LM_DisassembleEx functions

@rdbo
Copy link
Owner Author

rdbo commented May 28, 2024

Another point in favor of this is that some architectures don't have multiple bit size support.
For example, the ARM architecture can only be 32 bits. It is never 64 bits. 64 bit ARM is a completely different arch, ARM64/AARCH64

@rdbo
Copy link
Owner Author

rdbo commented May 29, 2024

One difficulty found because of this transition (branch: arch-breaking) is that you can no longer assemble/disassemble for remote processes using LM_GetArchitecture() as the architecture, and process.bits as the bits.
To counter that, I added a field arch to lm_process_t which contains the detailed architecture of that process.

Another problem that arrived from that is: how should libmem guess its architecture?
But now I realize, libmem has always assumed the architectures. For example, if you are running a x86/x64 machine, and the process is 32 bits, libmem has always been assuming that the process is x86_32.
Which means this behavior has always been there, just not explicitly. Now it has become explicit:

static inline lm_arch_t
get_architecture_from_bits(lm_size_t bits)
{
        // ...
}

This function has been added to guess the architecture of a process based on its bits.

Now you can use process.arch to assemble/disassemble for remote processes without doing the guessing yourself and leaving that up to libmem.

@rdbo
Copy link
Owner Author

rdbo commented May 30, 2024

arch-breaking branch was merged, let's hope this doesn't come back to haunt me in the future.

@rdbo rdbo closed this as completed May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant