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

Question around memory permissions #102

Open
re-fox opened this issue Nov 25, 2020 · 0 comments
Open

Question around memory permissions #102

re-fox opened this issue Nov 25, 2020 · 0 comments

Comments

@re-fox
Copy link
Contributor

re-fox commented Nov 25, 2020

I was building support for Kernel32.dll, IsBadStringPtr and seeking guidance.

This is largely a copy of IsBadReadPtr with adjustments made for string width.

    @apihook('IsBadStringPtr', argc=2)
    def IsBadStringPtr(self, emu, argv, ctx={}):
        '''
        BOOL IsBadStringPtrW(
            LPCWSTR  lpsz,
            UINT_PTR ucchMax
        );
        '''
        lp, ucchMax = argv
        cw = self.get_char_width(ctx)
        rv = True
        if lp and ucchMax:
            v1 = emu.is_address_valid(lp)
            v2 = emu.is_address_valid(lp + (cw*ucchMax - cw))
            if v1 and v2:
                rv = False
        return rv

The question I have: If I wanted to explicitly check for R permissions of the memory section. What's the best way to do that? I'm assuming that I would get_address_map and then READ_PERMISSION & mm.get_prot()?

mm = emu.get_address_map(lp)
if READ_PERM & mm.get_prot():
   <do something>
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