Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

请问 LPCVOID怎么进行运算?

LPCVOID Base = (void *) 0x210811989F0;

LPCVOID Num = (void *) 0x2387C88;

LPCVOID Result = reinterpret_cast<LPCVOID>(0x210811989F0 + 0x2387C88);
// 0x21083520678

怎么才能通过 BaseNum 得到 Result 的值?
半路出家啃c++,基础还没学完,麻烦赐教


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

我没理解错的话你是想通过某个地址+偏移 获取内存中的某个值?

struct Foo
{
    int bar;
    char str[20];
    int baz;
};
Foo foo;
foo.baz = 100;

const void* lpBase = (const void*)&foo;
const int offset = sizeof(int) + 20;
printf("%d", *(int*)((char*)lpBase + offset));   // 100

奇怪的需求,正常的业务代码很少遇到,倒是一些逆向的场景里经常有


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...