my_windows_core_reading_note(1)process_base_address

   
   
#include <stdio.h>
#include <tchar.h>
#include <windows.h>


#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x0501 
#endif


extern "C" const IMAGE_DOS_HEADER __ImageBase;


void DumpModule() {
   // Get the base address of the running application.
   // Can be different from the running module if this code is in a DLL.
   HMODULE hModule = GetModuleHandle(NULL);
   _tprintf(TEXT("with GetModuleHandle(NULL) = 0x%x\r\n"), hModule);


   // Use the pseudo-variable __ImageBase to get
   // the address of the current module hModule/hInstance.
   _tprintf(TEXT("with __ImageBase = 0x%x\r\n"), (HINSTANCE)&__ImageBase);


   // Pass the address of the current method DumpModule
   // as parameter to GetModuleHandleEx to get the address
   // of the current module hModule/hInstance.
   hModule = NULL;
   GetModuleHandleEx(
      GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
      (PCTSTR)DumpModule,
      &hModule);
   _tprintf(TEXT("with GetModuleHandleEx = 0x%x\r\n"), hModule);
}


int _tmain(int argc, TCHAR* argv[]) {
   DumpModule();
   return(0);
}




发现在本机的vs2005环境编译时老是报错
error C2065: 'GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS' : undeclared identifier
加入
d:\vc\console\tmp>cl *.cpp -I "e:\program files\microsoft sdks\windows\v7.1\incl
ude"
后,才通过,
看来
网上说的
#define _WIN32_WINNT 0x0501 
及更新SDK都是浮云


不过把代码放到我的VM中去,直接运行vs2008的命令行都是可以直接编译过去的..不解....
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值