title: Delphi pointer casting
body: <p>I want to use this simple C function in delphi, but cant cast the values to pointer perfectly.</p>
  
  <p>C function :</p>
  
  <pre><code>PVOID GetInterfaceMethod(PVOID intf, DWORD methodIndex)
  {
    return *(PVOID*)(*(DWORD_PTR*)intf + methodIndex);
  }
  </code></pre>
  
  <p>Delphi function :</p>
  
  <pre><code>function GetInterfaceMethod(const intf; methodIndex: DWORD): Pointer;
  begin
    // return *(PVOID*)(*(DWORD_PTR*)intf + methodIndex);    x64
    // return *(PVOID*)(*(DWORD*)intf + methodIndex * 4);    x86
    Result := Pointer(Pointer(DWORD_PTR(Pointer(intf)^) + methodIndex)^);  //x64
  end;
  </code></pre>
  
  <p>Excuse me for my bad English.</p>