0

In windows I used

__try {
    __int64(__fastcall * calladdress)(__int64, __int64);
    calladdress = (__int64*)par1;
    returnvalue = calladdress(par2, par3);
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
    returnvalue = 0;
    }

In linux,

ptr64 functionaddr = data[0];
ptr64 par1 = data[1];
ptr64 par2 = data[2];
void * returnAddr = (void*) data[3];

ptr64(__fastcall* calladdress(ptr64,ptr64);
calladdress = (ptr64*)functionaddr;
*(ptr64*)returnAddr = calladdress(par1,par2);
Error: expected ')' befor '*' token

ptr64(__fastcall* calladdress(ptr64,ptr64);
                ^ here

Sorry for newbie question, but I don't know much about gcc.

It worked well in Windows, but I don't know how to compile this code on Linux.

If you know how to solve this problem, please reply.

Mat
  • 202,337
  • 40
  • 393
  • 406
medq
  • 21
  • 2

1 Answers1

0

First of all, I don't know much about Linux, so I can't guarantee that my answer is exactly right.

Just a quick search showed that the Linux kernel seems to be using fastcall like this.

#define FASTCALL(x) x __attribute__((regparm(3)))
#define fastcall __attribute__((regparm(3)))

More references: x86 gcc compiled assembly code: fastcall behavior

Sprite
  • 3,222
  • 1
  • 12
  • 29