title: What does "using VirtualFn1_t = void(__thiscall*)(void* thisptr);" means in c++?
body: <p>I am trying to understand hooking while reading source code For virtual function method table hooking from wikipedia I came accross this line.</p>
  
  <pre><code>using VirtualFn1_t = void(__thiscall*)(void* thisptr);
  </code></pre>
  
  <p>I don't know what its mean . Is it casting void pointer to calling convention and recasting it into void pointer and using it as VirtualFn1_t alias. I also wanna understand what <code>void (__thiscall*)(void* thisptr)</code> and <code>(__thiscall*)(void* thisptr)</code> means .</p>
  
  <p>Here is the full source from wikipedia.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "windows.h"
  
  using namespace std;
  
  class VirtualClass
  {
  public:
  
      int number;
  
      virtual void VirtualFn1() //This is the virtual function that will be hooked.
      {
          cout &lt;&lt; "VirtualFn1 called " &lt;&lt; number++ &lt;&lt; "\n\n";
      }
  };
  
  
  
  
  using VirtualFn1_t = void(__thiscall*)(void* thisptr); 
  VirtualFn1_t orig_VirtualFn1;
  
  
  void __fastcall hkVirtualFn1(void* thisptr, int edx) //This is our hook function which we will cause the program to call instead of the original VirtualFn1 function after hooking is done.
  {
      cout &lt;&lt; "Hook function called" &lt;&lt; "\n";
  
      orig_VirtualFn1(thisptr); //Call the original function.
  }
  
  
  
  
  int main()
  {
      VirtualClass* myClass = new VirtualClass(); //Create a pointer to a dynamically allocated instance of VirtualClass.
  
      void** vTablePtr = *reinterpret_cast&lt;void***&gt;(myClass); //Find the address that points to the base of VirtualClass' VMT (which then points to VirtualFn1) and store it in vTablePtr.
  
      DWORD oldProtection;
      VirtualProtect(vTablePtr, 4, PAGE_EXECUTE_READWRITE, &amp;oldProtection); //Removes page protection at the start of the VMT so we can overwrite its first pointer.
  
      orig_VirtualFn1 = reinterpret_cast&lt;VirtualFn1_t&gt;(*vTablePtr); //Stores the pointer to VirtualFn1 from the VMT in a global variable so that it can be accessed again later after its entry in the VMT has been 
                                                                    //overwritten with our hook function.
  
      *vTablePtr = &amp;hkVirtualFn1; //Overwrite the pointer to VirtualFn1 within the virtual table to a pointer to our hook function (hkVirtualFn1).
  
      VirtualProtect(vTablePtr, 4, oldProtection, 0); //Restore old page protection.
  
      myClass-&gt;VirtualFn1(); //Call the virtual function from our class instance. Because it is now hooked, this will actually call our hook function (hkVirtualFn1).
      myClass-&gt;VirtualFn1();
      myClass-&gt;VirtualFn1();
  
      delete myClass;
  
      return 0;
  }
  </code></pre>