title: How to hack the virtual table?
body: <p>I would like to know how to change the address of <code>Test</code> which is in the virtual table with that of <code>HackedVTable</code>.</p>
  <pre><code>void HackedVtable()
  {
      cout &lt;&lt; &quot;Hacked V-Table&quot; &lt;&lt; endl;
  }
  
  class Base
  {    
  public:
      virtual Test()  { cout &lt;&lt;&quot;base&quot;;    }
      virtual Test1() { cout &lt;&lt; &quot;Test 1&quot;; }
      void *prt;
      Base(){}
  };
  
  class Derived : public Base
  {
  public: 
      Test()
      {
          cout &lt;&lt;&quot;derived&quot;;
      }
  };
  
  int main()
  {    
      Base b1;
  
      b1.Test(); // how to change this so that `HackedVtable` should be called instead of `Test`?
  
      return 0;
  }
  </code></pre>