蜜蜂. 发表于 2023-5-3 08:52

发点好玩的东西!

### MSVC编译器下的玩意!

```cpp
#define OFFSET(n, t, o) \
__forceinline t& propGet##n() \
{\
return *(t*)((uintptr_t)this + o);\
}\
__forceinline t& propSet##n(const t& value) \
{\
return *(t*)((uintptr_t)this + o) = value;\
}\
\
__declspec(property(get = propGet##n, put = propSet##n)) t& n;\


class EPROCESS
{
public:
OFFSET(Length, uint32_t, 0x10);

};

int main()
{
EPROCESS* Process = (EPROCESS*)malloc(100);
Process->Length = 10;
printf("%X\n", Process->Length);
free(Process);
}
```

sjtkxy 发表于 2023-5-4 04:57

老飞飞 发表于 2023-5-4 11:46

很不错,谢谢分享。。。
页: [1]
查看完整版本: 发点好玩的东西!