获取当前程序在内存中的起始位置
#include <iostream>
#include <Windows.h>
int a;
int main() {
a = 0x32;
HMODULE h=GetModuleHandle(NULL);
int* pa = &a;
std::cout << "程序起始位置:"<<h << std::endl;
std::cout << "a的位置:"<<pa << std::endl;
// 程序每次运行都会打印相同的偏移地址
std::cout << "相差:" << (int)pa-(int)h << std::endl;
}