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

Handle __declspec(novtable) #276

Open
sei-eschwartz opened this issue Dec 2, 2024 · 3 comments
Open

Handle __declspec(novtable) #276

sei-eschwartz opened this issue Dec 2, 2024 · 3 comments
Assignees

Comments

@sei-eschwartz
Copy link
Collaborator

In #275, we learned that certain ATL interface classes use __declspec(novtable) which stops the compiler from installing vftables. This causes problems with reasonNOTConstructor_G, and probably other rules as well.

This can be observed in https://github.com/edmcman/MFCApplication/blob/master/Release/MFCApplication.exe at CView::CView which does not install a vftable.

How should we fix this? One option might be to hard-code a list of classes to block for reasonNOTConstructor_G. For example, in #275, that would be CScrollView. CScrollView does have a vftable, but its parent, CView, does not. We can use RTTI to identify the installation of CScrollView's vftable, and from there block it.

But this only works because CScrollView does not have __declspec(novtable). It definitely could though, as it is an abstract class. So this technique might not work universally.

@sei-eschwartz
Copy link
Collaborator Author

Another option could be using hashes like for new and delete. I doubt these functions change much.

@sei-eschwartz
Copy link
Collaborator Author

Cory suggested adding a noVFTableClassConstructor/1 fact that can introduce synthetic vftable writes and initial memory, such as:

possibleVFTableWrite(0x4f7de6, 0x4f7de3, sv_18361059439791859340, 0, 0xeeeeee)
initialMemory(0xeeeeee, 0x53af32) 

@sei-eschwartz
Copy link
Collaborator Author

Some code thrown around chat:

factVFTableWrite(Addr, Addr, ThisPtr, VFTable) :-
    noVFTableClassConstructor(Addr),
    thisPtrDefinition(ThisPtr, _, _, 0, Addr),
    VFTable = vftable-hack-thing(Addr).
initalMemory(VFTable, PureAddr):
    noVFTableClassConstructor(Addr),
    thisPtrDefinition(ThisPtr, _, _, 0, Addr),
    factVFTableWrite(Addr, Addr, ThisPtr, VFTable)
    purecall(PureAddr).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants