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

Introduce sanitize_va() & has_prefix() for VA formatting #61

Merged
merged 6 commits into from
Feb 23, 2025

Conversation

yourpwnguy
Copy link
Contributor

@yourpwnguy yourpwnguy commented Feb 19, 2025

Summary

This PR introduces two new utility functions, sanitize_va() and has_prefix(), to handle and properly format virtual addresses (VA), particularly when copied from WinDbg.

Changes

  • Added has_prefix()

    • Checks if a virtual address string starts with "0x" or "0X".
    • Also, prevents redundant prefixing in sanitization logic.
  • Added sanitize_va()

    • Removes backticks ('`') from VA strings (WinDbg formatting) ( Ex: 00007ff7`89da0000 )
    • Ensures "0x" prefix is added if missing.
  • Optimised get_file_size()

    • Optimized to avoid unnecessary checks and modifications.

Introduced sanitize_va()

Introduced has_prefix() which now ensures "0x" prefix only when needed.

Reduced unnecessary code repetition.
Improved readability & efficiency.
@0vercl0k
Copy link
Owner

@yourpwnguy please try this out; if this works for you I'll get this merged.

Cheers

@yourpwnguy
Copy link
Contributor Author

@0vercl0k It seems fine and works correctly! You can merge it after checking my comment on the va_to_integer function regarding erase(). Not a necessary change, just an observation.

Cheers!

@0vercl0k
Copy link
Owner

Where is this comment @yourpwnguy I can't seem to find it 😅

@yourpwnguy
Copy link
Contributor Author

@0vercl0k Oh, I actually meant for you to check the text under review, my bad! 😅 I'll make sure to be clearer next time.

@0vercl0k
Copy link
Owner

I don't seem to see anything on my side; unless I'm missing something 🤔

0vercl0k
0vercl0k previously approved these changes Feb 23, 2025
@0vercl0k
Copy link
Owner

Do you mind pasting it here so that I can have a look before merging please?

@yourpwnguy
Copy link
Contributor Author

I see, maybe it's on my side. I will just comment the text here.

I noticed that when using *it = '\0';, calling va.size() just after it still returns the original size, which might be misleading for debugging or if va was used elsewhere.

Using va.erase(it, va.end()); correctly updates the size. That said, since va is only used within this function and passed directly to strtoull(), it doesn’t actually matter in this case, just mentioning it in case it’s relevant.

@0vercl0k 0vercl0k merged commit b32eef1 into 0vercl0k:master Feb 23, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants