CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

请教高手,SymInitialize()和SymLoadModule()这两个函数怎么用?

楼主swbreath(雪白呼嘘())2004-09-03 21:39:20 在 VC/MFC / 基础类 提问

请问这两个函数是干什么用的,大体是什么功能,那里有具体一点的介绍,在msdn上看了半天还是没有明白是什么意思,在此小弟先谢了,  
   
  我重新写了一个小个程序,就出现下列情况,  
  testsym.obj   :   error   LNK2001:   unresolved   external   symbol   __imp__SymInitialize@12  
  Debug/testsym.exe   :   fatal   error   LNK1120:   1   unresolved   externals  
  是怎么回事呀!谢谢!  
  问题点数:200、回复次数:13Top

1 楼flyelf(空谷清音)回复于 2004-09-03 21:59:40 得分 0

#pragma   comment(lib,   "   Dbghelp.lib")Top

2 楼kpld8888(kpld)回复于 2004-09-04 01:17:21 得分 0

UpTop

3 楼laiyiling(陌生人[MVP])回复于 2004-09-04 08:19:30 得分 0

Header:   Declared   in   Dbghelp.h.  
  Library:   Use   Dbghelp.lib.  
   
   
  #   include   <Dbghelp.h>  
  #pragma   comment(lib,   "Dbghelp.lib")Top

4 楼Henu(守护进程)回复于 2004-09-04 08:29:29 得分 0

关注中Top

5 楼holyeagle(一杯清茶)回复于 2004-09-04 08:32:06 得分 0

http://www.microsoft.com/china/MSDN/library/windev/COMponentdev/ACOMSymbolEngineAidsDebugging.mspx  
  MS的中文介绍,还有相关例子Top

6 楼holyeagle(一杯清茶)回复于 2004-09-04 08:37:29 得分 0

对了例子编译的时候会有  
  Error   Message:   C2668:   InlineIsEqualGUID:   Ambiguous   Call   to   Overloaded   Function  
  这个编译错误,把每个InlineIsEqualGUID改为::ATL::InlineIsEqualGUID()   ,这是因为SDK和alt空间的名字空间问题。Top

7 楼swbreath(雪白呼嘘())回复于 2004-09-04 13:13:30 得分 0

谢谢上面的高人,但是问题还没有完全解决。能在指点指点吗?  
  我写了一个简单的程序,  
  main(int   argc,char   *argv[]   )  
  {  
  int   err;  
  HANDLE   dhandle;  
   
  printf("this   is   test\n");  
  printf("argv[0]:%s,argv[1]:%s\n",argv[0],argv[1]);  
   
  //dhandle   =   GetCurrentProcess();  
  //SymInitialize(dhandle,"",FALSE);  
   
  if(!SymInitialize(GetCurrentProcess(),"",FALSE))  
  {  
  err=GetLastError();  
  printf("Failed   Initailize   Process   Symbol   table,WIN32   Errcd:%d",err);  
  return   0;  
  }  
  if(!SymLoadModule(GetCurrentProcess(),NULL,argv[0],NULL,0,0))  
  {  
  err=GetLastError();  
  printf("Failed   load   symbol   filename:%s,WIN32   Errcd:%d",argv[0],err);  
  return   0;  
  }    
  }  
   
  dbghelp.lib是在vc的开发环境中设置的,现在问题出现了,我在vc的开发环境下运行没有问题,但是我直接在console下,键入命令就出现问题了  
  C:\vctest\testmain\Debug>testmain  
  this   is   test  
  argv[0]:testmain,argv[1]:(null)  
  Failed   load   symbol   filename:testmain,WIN32   Errcd:0  
  或者  
  C:\vctest\testmain\Debug>C:\vctest\testmain\Debug\testmain  
  this   is   test  
  argv[0]:C:\vctest\testmain\Debug\testmain,argv[1]:(null)  
  Failed   load   symbol   filename:C:\vctest\testmain\Debug\testmain,WIN32   Errcd:0  
  再次感谢Top

8 楼swbreath(雪白呼嘘())回复于 2004-09-04 13:17:56 得分 0

而且不能加#   include   <Dbghelp.h>  
  如果加了dbghelp.h的话,将会出现大量的错误!  
  我用的是#include   <Imagehlp.h>  
  请问#include   <Imagehlp.h>和dbghelp.h有区别吗?我是指就运行SymInitialize()和SymLoadModule()这两个函数而言,谢谢Top

9 楼pigo()回复于 2004-09-06 11:17:33 得分 0

 
  up   :)  
  Top

10 楼DentistryDoctor(不在无聊中无奈,就在沉默中变态)回复于 2004-09-06 11:52:36 得分 200

这两个函数的使用,MSDN0209期的buglayers中有详细的从事贸易子。Top

11 楼DentistryDoctor(不在无聊中无奈,就在沉默中变态)回复于 2004-09-06 11:55:35 得分 0

#pragma   comment   (lib,"imagehlp.lib"),Top

12 楼tianyuhan(╰☆思忆季节)回复于 2004-09-06 11:56:58 得分 0

SymInitialize  
  The   SymInitialize   function   initializes   the   symbol   handler   for   a   process.  
   
  BOOL   SymInitialize(  
      IN   HANDLE   hProcess,            
      IN   LPSTR   UserSearchPath,      
      IN   BOOL   fInvadeProcess      
  );  
     
  Parameters  
  hProcess    
  Handle   to   the   process   for   which   symbols   are   to   be   maintained.   If   the   application   is   a   debugger,   use   the   process   handle   for   the   object   being   debugged,   otherwise   use   the   GetCurrentProcess   function   to   obtain   the   process   handle.    
  UserSearchPath    
  Pointer   to   a   null-terminated   string   that   specifies   a   path,   or   series   of   paths   separated   by   a   semicolon   (;),   that   is   used   to   search   for   symbol   files.   If   a   value   of   NULL   is   used,   then   ImageHlp   attempts   to   form   a   symbol   path   from   the   following   sources:    
  Current   directory    
  Environment   variable   _NT_SYMBOL_PATH    
  Environment   variable   _NT_ALTERNATE_SYMBOL_PATH    
  Environment   variable   SYSTEMROOT    
  fInvadeProcess    
  If   this   value   is   TRUE,   ImageHlp   enumerates   the   loaded   modules   for   the   process   and   effectively   calls   the   SymLoadModule   function   for   each   module.    
  Return   Values  
  If   the   function   succeeds,   the   return   value   is   TRUE.  
   
  If   the   function   fails,   the   return   value   is   FALSE.   To   retrieve   extended   error   information,   call   GetLastError.  
   
  Remarks  
  The   SymInitialize   function   is   used   to   initialize   the   symbol   handler   for   a   process.   In   the   context   of   the   symbol   handler,   a   process   is   a   convenient   object   to   use   when   collecting   symbol   information.   Usually,   symbol   handlers   are   used   by   debuggers   and   other   tools   that   need   to   load   symbols   for   a   process   being   debugged.    
   
  ///////////////////////////////////////////////  
   
   
  SymLoadModule  
  The   SymLoadModule   function   loads   the   symbol   table.    
   
  BOOL   SymLoadModule(  
      IN   HANDLE   hProcess,      
      IN   HANDLE   hFile,            
      IN   LPSTR   ImageName,      
      IN   LPSTR   ModuleName,    
      IN   DWORD   BaseOfDll,      
      IN   DWORD   SizeOfDll        
  );  
     
  Parameters  
  hProcess    
  Handle   to   the   process   that   was   originally   passed   to   the   SymInitialize   function.    
  hFile    
  Handle   to   the   file   for   the   executable   image.   This   argument   is   used   mostly   by   debuggers,   where   the   debugger   passes   the   file   handle   obtained   from   a   debug   event.   A   value   of   NULL   indicates   that   hFile   is   not   used.    
  ImageName    
  Pointer   to   a   null-terminated   string   that   specifies   the   name   of   the   executable   image.   This   name   can   contain   a   partial   path,   a   full   path,   or   no   path   at   all.   If   the   file   cannot   be   located   by   the   name   provided,   the   symbol   search   path   is   used.    
  ModuleName    
  Pointer   to   a   null-terminated   string   that   specifies   a   shortcut   name   for   the   module.   If   the   pointer   value   is   NULL,   ImageHlp   creates   a   name   using   the   base   name   of   the   symbol   file.    
  BaseOfDll    
  Specifies   the   load   address   of   the   module.   If   the   value   is   zero,   ImageHlp   obtains   the   load   address   from   the   symbol   file.   The   load   address   contained   in   the   symbol   file   is   not   necessarily   the   actual   load   address.   Debuggers   and   other   applications   having   an   actual   load   address   should   use   the   real   load   address   when   calling   this   function.    
  SizeOfDll    
  Specifies   the   size   of   the   module.   If   the   value   is   zero,   ImageHlp   obtains   the   size   from   the   symbol   file.   The   size   contained   in   the   symbol   file   is   not   necessarily   the   actual   size.   Debuggers   and   other   applications   having   an   actual   size   should   use   the   real   size   when   calling   this   function.    
  Return   Values  
  If   the   function   succeeds,   the   return   value   is   TRUE.  
   
  If   the   function   fails,   the   return   value   is   FALSE.   To   retrieve   extended   error   information,   call   GetLastError.  
   
  Remarks  
  The   symbol   handler   creates   an   entry   for   the   module   and   if   the   deferred   symbol   loading   option   is   turned   off,   an   attempt   is   made   to   load   the   symbols.   If   deferred   symbol   loading   is   enabled,   the   module   is   marked   as   deferred   and   the   symbols   are   not   loaded   until   a   reference   is   made   to   a   symbol   in   the   module.  
   
  To   unload   the   symbol   table,   use   the   SymUnloadModule   function.    
   
   
   
  Top

13 楼swbreath(雪白呼嘘())回复于 2004-09-06 12:34:37 得分 0

DentistryDoctor,牙科医生兄你说的MSDN0209期的buglayers中有详细的从事贸易子,在那里能找到相关的资料,小弟先谢了!Top

相关问题

  • enumwindows函数怎么用?
  • 怎么用Shell_NotifyIcon函数
  • 函数指针怎么用?
  • 取整函数怎么写?
  • val函数怎么用啊!!
  • 怎么加时间函数?
  • decade函数怎么使用?
  • SETWINDOWPOS API函数怎么用
  • 怎么使用CopyFile()函数?
  • Seek函数怎么用?

关键词

  • win32
  • 函数
  • debug
  • syminitialize
  • symbol
  • symloadmodule
  • testmain
  • dbghelp
  • imagehlp
  • vctest

得分解答快速导航

  • 帖主:swbreath
  • DentistryDoctor

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo