thank u ! appreciete tht, nd sorry for taking a time to respo ^^In this case where you are in trouble to understand some macro, you can instruct GCC to expand macros and show the output, to do this in our case:
Bash:x86_64-w64-mingw32-gcc main.c -E
Taking this part of source:
C:FCALL(fptrs, WriteProcessMemoryPtr, proc_handle, remote_mem, payload_data, payload_size, &written );
GCC will output:
C:( _Generic(fptrs.WriteProcessMemoryPtr, OpenProcessPtr_t: (OpenProcessPtr_t)((unsigned long long)fptrs.WriteProcessMemoryPtr ^ fptrs.rval ), Virtua lAllocExPtr_t: (VirtualAllocExPtr_t)((unsigned long long)fptrs.WriteProcessMemoryPtr ^ fptrs.rval ), WriteProcessMemoryPtr_t: (WriteProcessMemoryPtr _t)((unsigned long long)fptrs.WriteProcessMemoryPtr ^ fptrs.rval ), CreateRemoteThreadPtr_t: (CreateRemoteThreadPtr_t)((unsigned long long)fptrs.Wri teProcessMemoryPtr ^ fptrs.rval ) ) (proc_handle, remote_mem, payload_data, payload_size, &written) )
From here you can see it expand to a function call, the macro was used so the address of function can be auto decoded with this expression "
(unsigned long long)fptrs.WriteProcessMemoryPtr ^ fptrs.rval )" and then casted to the correct type. The "tricky" things about this macro can be just two things, the usage do _Generic to select the correct cast and the usage of __VA_ARGS__, so the macro the handle different number of arguments, this allow to expand for different function calls. For both subjects I think the references is more useful than a new explanation from me.
References:
_Generic Selection
Variadic Macros