Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this a new method to get address of any function member?
    primarykey
    data
    text
    <p><strong>"Member function"</strong> is the most stubborn thing. Simply I cannot convert them into <code>*void</code> values. I've done some methods which can solve this; however, the only thing I annoyed: I have to create a new definition for every set of argument types. So the fastest method to achieve the goal :</p> <pre><code>struct FOO{ void ONE_PARAM(int){} void TWO_PARAM(int, int){} void THREE_PARAM(int, int, int){} void FOUR_PARAM(int, int, int, int){} }; </code></pre> <p>Firstly, calling a structure function member by assembly :</p> <pre><code>__asm mov ecx, ADDRESS_OF_STRUCTURE __asm push //parameters __asm call ADDRESS_OF_MEMBER_FUNCTION </code></pre> <p><strong>Longest : Template...</strong></p> <pre><code>template &lt;class F,void (F::*Function)(int)&gt; //Note : Only for FOO::ONE_PARAM void * GetFunctionAddress() { union ADDRESS { void (F::*func)(int); void * function_address; }address_data; address_data.func = Function; return address_data.function_address; } </code></pre> <p><strong>Shorter method : Define a function pointer to member function</strong></p> <pre><code>void *function_address; /////////////////////////////////////////////// void(FOO::*address_ONE_PARAM)(int) = FOO::ONE_PARAM; void(FOO::*address_TWO_PARAM)(int, int) = FOO::TWO_PARAM; void(FOO::*address_THREE_PARAM)(int, int, int) = FOO::THREE_PARAM; void(FOO::*address_FOUR_PARAM)(int, int, int, int) = FOO::FOUR_PARAM; __asm mov eax, address_ONE_PARAM //OK __asm mov function_address, eax __asm mov eax, address_TWO_PARAM //OK __asm mov function_address, eax __asm mov eax, address_THREE_PARAM //OK __asm mov function_address, eax __asm mov eax, address_FOUR_PARAM //OK __asm mov function_address, eax </code></pre> <p>But it's still too long.</p> <p><strong>The most convenient method</strong> : Using directly standard function : <strong>sprintf</strong></p> <p>I discovered <strong>__thiscall</strong> functions also can be pushed as <strong>"..." parameters</strong> and I have checked it carefully by function <strong>printf</strong>. It is simple, and you don't need to define again its whole set of argument types to accept the pointer. And the code :</p> <pre><code>unsigned int address; char buffer[12]; /////////////////////////////////////////////// sprintf(buffer, "0x%X", FOO::ONE_PARAM); address = strtol(buffer,NULL,16); sprintf(buffer, "0x%X", FOO::TWO_PARAM); address = strtol(buffer,NULL,16); sprintf(buffer, "0x%X", FOO::THREE_PARAM); address = strtol(buffer,NULL,16); sprintf(buffer, "0x%X", FOO::FOUR_PARAM); address = strtol(buffer,NULL,16); </code></pre> <p>As you can see this method is much shorter and also it's very convenient. I don't need to insert assembly code, the code looks better but on the other hand, I am worrying about speed. Can the code be compressed more? Suppose two commands now it only requires a single command to work, is this possible?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload