How to hack the virtual table?

前端 未结 9 869
谎友^
谎友^ 2021-01-31 21:41

I would like to know how to change the address of Test which is in the virtual table with that of HackedVTable.

void HackedVtable()
{
           


        
9条回答
  •  失恋的感觉
    2021-01-31 21:57

    I don't think the vTable is in read only area because is it dynamically populated. The only way it can fail is when the compiler is absolutely sure which implementation will be called in compile time and skip the vTable lookup with direct function call(de-virtualization).

    EDIT: As @groovyspaceman pointed out, I see that I used wrong wording. The vTable class member pointer is mutable, the vTable itself is compiler generated and it depends on the system and the compiler if it can, or cannot be modified.

提交回复
热议问题