[Type1]
typedef void (CClientSocket::*TSendPacket)(const CprintPacket&);
TSendPacket lpSendPacket = (TSendPacket)&CClientSocket::SendPacket;
PDWORD pSendPacket = (PDWORD)&lpSendPacket;
pSendPacket = (PDWORD)*pSendPacket;
[Type2]
template <class T1, class T2>
T1 union_cast(T2 v)
{
static_assert(sizeof(T1) >= sizeof(T2), "Bad union_cast!");
union UT {T1 t1; T2 t2;} u;
u.t2 = v;
return u.t1;
}
class MyClass
{
public:
void foo(int);
};
auto p = union_cast<void *>(&MyClass::foo);
[Type3]
void *DisMember(size_t size, ...)
{
if (size != sizeof(void *)) return NULL;
va_list args;
va_start(args, size);
void *res = va_arg(args, void *);
va_end(args);
return res;
}
// snip
void Base::MyMethod() { /* ... */ }
// snip
void *anything = DisMember(sizeof(void (Base::*)()), &Base::MyMethod);
[Type4]
LPVOID pVoid;
__asm
{
push eax
mov eax, CPatternSearch::BytePatternSearch
mov pVoid, eax
pop eax
}