title: Arbitrary pointer to unknown class function - invalid type conversion
body: <p>I have a hack program; it injects some functions into a target process to control it. The program is written in C++ with inline assembly.</p>
  
  <pre><code>class GameProcMain {
   // this just a class
  };
  
  GameProcMain* mainproc; // there is no problem I can do =(GameProcMain*)0xC1EA90
  </code></pre>
  
  <p>Now I want to define a class function (which set ecx to class pointer) instead of writing assembly.</p>
  
  <pre><code>PPLYDATA GetNearblyMob(__Vector3* cordinate) {
      __asm {
      mov ecx, 0xC1EA90
      enter code here
      push cordinate
      mov edi, 0x4A8010
      call edi
      }
  }
  </code></pre>
  
  <p>I want to define it and call it like.</p>
  
  <pre><code>PPLYDATA (DLPL::*GetNearblyMob)(__Vector3* cordinate);
  
  mainproc-&gt;GetNearblyMob(ADDR_CHRB-&gt;kordinat)
  </code></pre>
  
  <p>When I try <code>GetNearblyMob=(PPLYDATA (DLPL::*)(__Vector3*)) 0x4A8010;</code></p>
  
  <p>It says something like <code>error: invalid type conversion: "int" to "PPLYDATA (DLPL::*)(int, int)"</code></p>
  
  <p>but I can do this to set the pointer:</p>
  
  <pre><code>void initializeHack() {
  __asm {
  LEA edi, GetNearblyMob
  MOV eax, 0x4A8010
  MOV [edi], eax
  }
  }
  </code></pre>
  
  <p>Now I want to learn "how I can set GetNearblyMob without using assembly and legitimately in C++".</p>