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

Create MOD_CODE #52

Open
7 of 8 tasks
Vipon opened this issue Feb 20, 2024 · 1 comment
Open
7 of 8 tasks

Create MOD_CODE #52

Vipon opened this issue Feb 20, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Vipon
Copy link
Owner

Vipon commented Feb 20, 2024

  • Macro MOD_CODE
  • Save information about modification point in code art compile time
  • Save information about hidden code at compile time
  • Init global mod_code pointer to a separate section with all information
  • MSVC workaround
  • Add MOD_CODE types: with_nops, without
  • Add modification with_nops
  • Add modification without.
@Vipon Vipon self-assigned this Feb 20, 2024
@Vipon Vipon added the enhancement New feature or request label Feb 20, 2024
@Vipon Vipon added this to binDynMod Feb 20, 2024
Vipon added a commit that referenced this issue Feb 20, 2024
* Create initial macro MOD_CODE and init/fini functions.
* Add mach-o fixups parsing.

issue: #52
Vipon added a commit that referenced this issue Feb 23, 2024
Init mod_code module and update mach-o parser.
* Create initial macro MOD_CODE and init/fini functions.
* Add mach-o fixups parsing.

issue: #52
@Vipon
Copy link
Owner Author

Vipon commented Feb 24, 2024

clang-cl or MSVC compatible clang compiles MOD_CODE absolutely wrong, so need to create special workaround.

Corner of problem is how inline assembler directive ".section" procced. It breaks function and all code after MOD_CODE point are placed at the start of section ".text".

So need to force compiler to tie it up. Possible solution

volatile static int a = 1;
if (__buildin_expect(a == 0, 0)) {
    MOD_CODE(code);
}

MOD_CODE will be placed in unlikely executable path. Lost part of initial function will be at likely path. There is only only one problem - it produces extra instructions for if clause. Maybe need to save MSVC type for pointer and replace useless code with NOPs.

Vipon added a commit that referenced this issue Feb 24, 2024
Vipon added a commit that referenced this issue Feb 24, 2024
Create MSVC workaround for MOD_CODE.

issue: #52
Vipon added a commit that referenced this issue Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant