title: C++ custom calling convention
body: <p>While reverse engineering I came around a very odd program that uses a calling convention that passes one argument in eax ( very odd compiler ?? ). I want to call that function now and I don't know how to declare it, IDA defines it as</p>
  
  <pre><code>bool __usercall foo&lt;ax&gt;(int param1&lt;eax&gt;, int param2);
  </code></pre>
  
  <p>where param1 is passed in the eax register. I tried something like</p>
  
  <pre><code>bool MyFoo(int param1, int param2) 
  {
      __asm mov eax, param1;
      return  reinterpret_cast&lt;bool(__stdcall *)(int)&gt;(g_FooAddress)(param2);
  }
  </code></pre>
  
  <p>However, unfortunately my compiler makes use of the eax register when pushing param2 on the stack, is there any way how I can make this clean without writing the whole call with inline assembler? (I am using Visual Studio if that matters)</p>