asmブロックを介してC++メンバー関数を呼び出したい。コンパイラはMSVC++(VS2008)であり、移植性は問題ではありません。組み込みシステム用のリモーティング/RMIタイプのメカニズムを構築する必要があります。クライアントはオブジェクト名、メソッド名、arguments(serialized)を送信し、適切なオブジェクトに対してメソッドを呼び出す必要があります。PDBファイルから取得できるタイプ情報。一般的なInvoke関数を作成する必要があります。オブジェクトを引数として取るメンバー関数を呼び出す方法に固執しています。具体的には。ctorをコピーするためのポインターを取得できません。何か案が。
PS:以下のコードは、C::funcRefに対して正しくコンパイルおよび実行されます。
#include <stdio.h>
struct Point
{
int x;
int y;
Point()
{
x = 10;
y =10;
}
Point(const Point& p)
{
x = p.x;
y = p.y;
}
virtual ~Point()
{
}
};
class C
{
public:
void funcRef(Point& p)
{
printf("C::funcRef\n x= %d, y =%d\n", p.x, p.y);
}
void funcObj(Point p)
{
printf("C::funcObj\nx = %d y = %d\n", p.x, p.y);
}
};
void main()
{
C* c = new C;
Point p;
//c->funcRef(p);
// this works
__asm
{
lea eax, p;
push eax;
mov ecx, c;
call [C::funcRef];
}
// c->funcObj(p);
__asm
{
sub esp, 12; // make room for sizeof(Point)
mov ecx, esp;
lea eax, p;
push eax;
// how to call copy ctor here
mov ecx, c;
call [C::funcObj];
}
}