| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> C++: shui dong le wo de zhi zhen

C++: shui dong le wo de zhi zhen

2008-06-01 02:05:05 编辑來源:互联网 评论
 
 
 
本文为【C++:谁动了我的指针】的拼音翻译版
  yi zhe xu : ben wen jie shao le yi zhong zai tiao shi guo cheng zhong xun zhao xuan gua zhi zhen ( ye zhi zhen ) de fang fa , zhe zhong fang fa shi tong guo dui new he delete yun suan fu de chong zai lai shi xian de 。
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  zhe zhong fang fa bu shi wan mei de , ta shi yi tiao shi qi de nei cun xie lu wei dai jia lai shi xian de , yin wei wen zhong chu xian de dai ma shi jue bu neng chu xian zai yi ge zui zhong fa bu de ruan jian chan pin zhong de , zhi neng zai tiao shi shi shi yong 。 zai VC zhong , zai tiao shi huan jing xia , ke yi jian dan de tong guo ba new ti huan cheng DEBUG_NEW lai shi xian gong neng geng qiang geng fang bian de zhi zhen jian ce , xiang qing ke shen kao MSDN。DEBUG_NEW de shi xian si lu yu ben wen you xiang tong de di fang , yin ci wen zhang zhong jie shao de fang fa sui ran bu shi zui jia de , dan huan suan shi yong , geng chong yao de shi , ta ti gong gei wo men yi zhong xin de si lu 。
  jian jie : qian ji tian fa sheng le zhe yang yi jian shi , wo zheng zai tiao shi yi ge cheng xu , zhe ge cheng xu yong le yi da dui luan qi ba zao de zhi zhen lai chu li yi ge lian biao , zui zhong zai yi ge zhi xiang lian biao jie dian de zhi zhen shang chu le wen ti 。 wo men yu ji ta ying dang zhi xiang de shi yi ge xu ji lei de dui xiang 。 wo xiang dao di yi ge wen ti shi : zhi zhen suo zhi de di fang zhen de you yi ge dui xiang ma ? chu wen ti de zhi zhen zhi ke yi bei 4 zheng chu , bing qie bu shi NULL de , suo yi ke yi duan ding ta zeng jing shi yi ge you xiao de zhi zhen 。 tong guo shi yong Visual Studio de nei cun cha kan chuang kou (View->Debug Windows->Memory) wo men fa xian zhe ge zhi zhen suo zhi de shu ju shi FE EE FE EE FE EE ... zhe tong chang yi wei zhe nei cun shi zeng jing shi bei fen pei le de , dan xian zai que chu yu yi zhong wei fen pei de zhuang tai 。 bu zhi shi shui 、 zai shen me di fang ba wo de zhi zhen suo zhi de nei cun qu yu gei shi fang diao le 。 wo xiang yao zhao chu yi zhong fang an lai cha chu wo de shu ju dao di shi zen me hui bei shi fang de 。
  bei jing :
  wo zui zhong tong guo chong zai le new he delete yun suan fu zhao dao le wo diu shi de shu ju 。 dang yi ge han shu bei tiao yong shi , shen shu hui shou xian bei ya dao zhan shang hou , ran hou fan hui di zhi ye hui bei ya dao zhan shang 。 wo men ke yi zai new he delete yun suan fu de han shu zhong ba zhe xie xin xi cong zhan shang ti qu chu lai , bang zhu wo men tiao shi cheng xu 。
  dai ma :
  zai jing li le ji ci cuo wu de cai ce hou , wo jue ding qiu zhu yu chong zai new he delete yun suan fu lai bang wo zhao dao wo de zhi zhen suo zhi xiang de shu ju 。 xia mian de new yun suan fu de shi xian ba fan hui di zhi cong zhan shang ti le chu lai 。 zhe ge fan hui di zhi wei yu chuan di guo lai de shen shu he di yi ge ju bu bian liang de di zhi zhi jian 。 bian yi qi de she zhi 、 tiao yong han shu de fang fa 、 ji suan ji de ti xi jie gou dou hui yin xiang dao zhe ge fan hui di zhi de shi ji wei zhi , suo yi nin zai shi yong xia mian dai ma de shi hou , yao gen ju nin de shi ji qing kuang zuo yi xie tiao zheng 。 yi dan new yun suan fu huo de le fan hui di zhi , ta jiu zai jiang yao shi ji fen pei de nei cun qian mian fen pei e wai de 16 ge zi jie de kong jian lai cun fang zhe ge fan hui di zhi he shi ji de fen pei de nei cun da xiao , bing qie ba shi ji yao fen pei de nei cun kuai shou di zhi fan hui 。 dui yu delete yun suan fu , ni ke yi kan dao , ta bu zai shi fang kong jian 。 ta yong yu new tong yang de fang fa ba fan hui di zhi ti qu chu lai , xie dao shi ji fen pei kong jian da xiao de hou mian ( yi zhe zhu : jiu shi shang mian fen pei de 16 ge zi jie de di 9 dao di 12 ge zi jie ), zai zui hou si ge zi jie zhong tian shang DE AD BE EF( yi zhe zhu : si ge shi liu jin zhi shu , dang cheng dan ci lai kan zheng hao shi dead beef, yong lai biao shi nei cun yi shi fang zhen shi hen xing xiang !), bing qie ba sheng yu de kong jian ( yi zhe zhu : jiu shi yuan ben shi ji ying gai fen pei er xian zai ying gai yao shi fang diao de kong jian ) dou tian shang yi ge chong fu de zhi 。 xian zai , jia ru cheng xu you yu yi ge cuo wu de zhi zhen er chu cuo , wo zhi xu da kai nei cun cha kan chuang kou , zhao dao chu cuo de zhi zhen suo zhi de di fang , zai wang qian zhao 16 ge zi jie 。 zhe li de zhi jiu shi tiao yong new yun suan fu de di zhi , jie xia lai si ge zi jie jiu shi shi ji fen pei de nei cun da xiao , di san ge si ge zi jie shi tiao yong delete yun suan fu de di zhi , zui hou si ge zi jie ying gai shi DE AD BE EF。 jie xia de shi ji fen pei guo de nei cun nei rong ying gai shi 77 77 77 77。 yao tong guo zhe liang ge fan hui di zhi zai yuan cheng xu zhong fen bie zhao dao dui ying de new he delete, ke yi zhe yang zuo : shou xian ba biao shi di zhi de si ge zi jie de nei rong dao xu pai yi xia , zhe yang cai neng de dao zhen zheng de di zhi , zhe li yin wei zai Intel ping tai shang zi jie xu shi di wei zai qian de 。 xia yi bu , zai yuan dai ma shang you ji dian ji , xuan “Go To Diassembly”。 zai fan hui bian de chuang kou shang de zuo bian yi lan jiu shi ji qi dai ma dui ying de nei cun di zhi 。 an Ctrl + G huo xuan ze Edit->Go To... bing shu ru ni zhao dao de di zhi zhi yi 。 fan hui bian de chuang kou jiu jiang gun dong dao dui ying de new huo delete de han shu tiao yong wei zhi 。 yao hui dao yuan cheng xu zhi xu zai ci you jian dan ji , xuan ze “Go To Source”。 nin jiu ke yi kan dao xiang ying de new huo delete de tiao yong le 。
C++:谁动了我的指针
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
  xian zai nin jiu ke yi hen fang bian de zhao chu nin de shu ju shi he shi diu shi de le 。 zhi yu yao zhao chu wei shen me delete hui bei tiao yong , jiu yao kao nin zi ji le 。
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  #include <MALLOC.H>
  void * :perator new(size_t size)
  
   {
  int stackVar;
  unsigned long stackVarAddr = (unsigned long)&stackVar;
  unsigned long argAddr = (unsigned long)&size;
  void ** retAddrAddr = (void **)(stackVarAddr/2 + argAddr/2 + 2);
  void * retAddr = * retAddrAddr;
  unsigned char *retBuffer = (unsigned char*)malloc(size + 16);
  memset(retBuffer, 0, 16);
  memcpy(retBuffer, &retAddr, sizeof(retAddr));
  memcpy(retBuffer + 4, &size, sizeof(size));
  return retBuffer + 16;
  }
  void :perator delete(void *buf)
  {
  int stackVar;
  if(!buf)
  return;
  unsigned long stackVarAddr = (unsigned long)&stackVar;
  unsigned long argAddr = (unsigned long)&buf;
  void ** retAddrAddr = (void **)(stackVarAddr/2 + argAddr/2 + 2);
  void * retAddr = * retAddrAddr;
  unsigned char* buf2 = (unsigned char*)buf;
  buf2 -= 8;
  memcpy(buf2, &retAddr, sizeof(retAddr));
  size_t size;
  buf2 -= 4;
  memcpy(&size, buf2, sizeof(buf2));
  buf2 += 8;
  buf2[0] = 0xde;
  buf2[1] = 0xad;
  buf2[2] = 0xbe;
  buf2[3] = 0xef;
  buf2 += 4;
  memset(buf2, 0x7777, size);
  // deallocating destroys saved addresses, so dont
  // buf -= 16;
  // free(buf);
  }
  qi ta zhi de guan zhu de di fang : zhe duan dai ma tong yang ke yi yong yu nei cun xie lu de jian ce 。 zhi xu xiu gai delete yun suan fu shi ta zhen zheng de qu shi fang nei cun , bing qie zai cheng xu tui chu qian , yong __heapwalk bian li suo you yi fen pei de nei cun kuai bing ba tiao yong new de di zhi ti qu chu lai , zhe jiu jiang de dao yi fen mei you bei delete pi pei de new tiao yong lie biao 。 huan yao zhu chong de shi : zhe li lie chu de dai ma zhi neng zai tiao shi de shi hou qu shi yong , jia ru ni ba ta duan dai ma fang dao zui zhong de chan pin zhong , hui dao zhi cheng xu yun xing shi nei cun bei da liang de xiao hao 。
C++:谁动了我的指针
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
yi zhe xu :   ben wen jie shao le yi zhong zai tiao shi guo cheng zhong xun zhao xuan gua zhi zhen ( ye zhi zhen ) de fang fa , zhe zhong fang fa shi tong guo dui new he delete yun suan fu de chong zai lai shi xian de 。    zhe zhong fang fa bu shi wan mei de , ta shi yi tiao shi qi de nei cun xie lu wei dai jia lai shi xian de , yin wei wen zhong chu xian de dai ma shi jue bu neng chu xian zai yi ge zui zhong fa bu de ruan jian chan pin zhong de , zhi neng zai tiao shi shi shi yong 。   zai VC zhong , zai tiao shi huan jing xia , ke yi jian dan de tong guo ba new ti huan cheng DEBUG_NEW lai shi xian gong neng geng qiang geng fang bian de zhi zhen jian ce , xiang qing ke shen kao MSDN。DEBUG_NEW de shi xian si lu yu ben wen you xiang tong de di fang , yin ci wen zhang zhong jie shao de fang fa sui ran bu shi zui jia de , dan huan suan shi yong , geng chong yao de shi , ta ti gong gei wo men yi zhong xin de si lu 。 jian jie :   qian ji tian fa sheng le zhe yang yi jian shi , wo zheng zai tiao shi yi ge cheng xu , zhe ge cheng xu yong le yi da dui luan qi ba zao de zhi zhen lai chu li yi ge lian biao , zui zhong zai yi ge zhi xiang lian biao jie dian de zhi zhen shang chu le wen ti 。 wo men yu ji ta ying dang zhi xiang de shi yi ge xu ji lei de dui xiang 。 wo xiang dao di yi ge wen ti shi : zhi zhen suo zhi de di fang zhen de you yi ge dui xiang ma ? chu wen ti de zhi zhen zhi ke yi bei 4 zheng chu , bing qie bu shi NULL de , suo yi ke yi duan ding ta zeng jing shi yi ge you xiao de zhi zhen 。 tong guo shi yong Visual Studio de nei cun cha kan chuang kou (View->Debug Windows->Memory) wo men fa xian zhe ge zhi zhen suo zhi de shu ju shi FE EE FE EE FE EE ... zhe tong chang yi wei zhe nei cun shi zeng jing shi bei fen pei le de , dan xian zai que chu yu yi zhong wei fen pei de zhuang tai 。 bu zhi shi shui 、 zai shen me di fang ba wo de zhi zhen suo zhi de nei cun qu yu gei shi fang diao le 。 wo xiang yao zhao chu yi zhong fang an lai cha chu wo de shu ju dao di shi zen me hui bei shi fang de 。 bei jing :    wo zui zhong tong guo chong zai le new he delete yun suan fu zhao dao le wo diu shi de shu ju 。 dang yi ge han shu bei tiao yong shi , shen shu hui shou xian bei ya dao zhan shang hou , ran hou fan hui di zhi ye hui bei ya dao zhan shang 。 wo men ke yi zai new he delete yun suan fu de han shu zhong ba zhe xie xin xi cong zhan shang ti qu chu lai , bang zhu wo men tiao shi cheng xu 。 dai ma :    zai jing li le ji ci cuo wu de cai ce hou , wo jue ding qiu zhu yu chong zai new he delete yun suan fu lai bang wo zhao dao wo de zhi zhen suo zhi xiang de shu ju 。 xia mian de new yun suan fu de shi xian ba fan hui di zhi cong zhan shang ti le chu lai 。 zhe ge fan hui di zhi wei yu chuan di guo lai de shen shu he di yi ge ju bu bian liang de di zhi zhi jian 。 bian yi qi de she zhi 、 tiao yong han shu de fang fa 、 ji suan ji de ti xi jie gou dou hui yin xiang dao zhe ge fan hui di zhi de shi ji wei zhi , suo yi nin zai shi yong xia mian dai ma de shi hou , yao gen ju nin de shi ji qing kuang zuo yi xie tiao zheng 。 yi dan new yun suan fu huo de le fan hui di zhi , ta jiu zai jiang yao shi ji fen pei de nei cun qian mian fen pei e wai de 16 ge zi jie de kong jian lai cun fang zhe ge fan hui di zhi he shi ji de fen pei de nei cun da xiao , bing qie ba shi ji yao fen pei de nei cun kuai shou di zhi fan hui 。   dui yu delete yun suan fu , ni ke yi kan dao , ta bu zai shi fang kong jian 。 ta yong yu new tong yang de fang fa ba fan hui di zhi ti qu chu lai , xie dao shi ji fen pei kong jian da xiao de hou mian ( yi zhe zhu : jiu shi shang mian fen pei de 16 ge zi jie de di 9 dao di 12 ge zi jie ), zai zui hou si ge zi jie zhong tian shang DE AD BE EF( yi zhe zhu : si ge shi liu jin zhi shu , dang cheng dan ci lai kan zheng hao shi dead beef, yong lai biao shi nei cun yi shi fang zhen shi hen xing xiang !), bing qie ba sheng yu de kong jian ( yi zhe zhu : jiu shi yuan ben shi ji ying gai fen pei er xian zai ying gai yao shi fang diao de kong jian ) dou tian shang yi ge chong fu de zhi 。   xian zai , jia ru cheng xu you yu yi ge cuo wu de zhi zhen er chu cuo , wo zhi xu da kai nei cun cha kan chuang kou , zhao dao chu cuo de zhi zhen suo zhi de di fang , zai wang qian zhao 16 ge zi jie 。 zhe li de zhi jiu shi tiao yong new yun suan fu de di zhi , jie xia lai si ge zi jie jiu shi shi ji fen pei de nei cun da xiao , di san ge si ge zi jie shi tiao yong delete yun suan fu de di zhi , zui hou si ge zi jie ying gai shi DE AD BE EF。 jie xia de shi ji fen pei guo de nei cun nei rong ying gai shi 77 77 77 77。   yao tong guo zhe liang ge fan hui di zhi zai yuan cheng xu zhong fen bie zhao dao dui ying de new he delete, ke yi zhe yang zuo : shou xian ba biao shi di zhi de si ge zi jie de nei rong dao xu pai yi xia , zhe yang cai neng de dao zhen zheng de di zhi , zhe li yin wei zai Intel ping tai shang zi jie xu shi di wei zai qian de 。 xia yi bu , zai yuan dai ma shang you ji dian ji , xuan “Go To Diassembly”。 zai fan hui bian de chuang kou shang de zuo bian yi lan jiu shi ji qi dai ma dui ying de nei cun di zhi 。 an Ctrl + G huo xuan ze Edit->Go To... bing shu ru ni zhao dao de di zhi zhi yi 。 fan hui bian de chuang kou jiu jiang gun dong dao dui ying de new huo delete de han shu tiao yong wei zhi 。 yao hui dao yuan cheng xu zhi xu zai ci you jian dan ji , xuan ze “Go To Source”。 nin jiu ke yi kan dao xiang ying de new huo delete de tiao yong le 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785336.html][img]http://image.wangchao.net.cn/it/1323423844185.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo    xian zai nin jiu ke yi hen fang bian de zhao chu nin de shu ju shi he shi diu shi de le 。 zhi yu yao zhao chu wei shen me delete hui bei tiao yong , jiu yao kao nin zi ji le 。   #include <MALLOC.H>   void * :perator new(size_t size)   {     int stackVar;     unsigned long stackVarAddr = (unsigned long)&stackVar;     unsigned long argAddr = (unsigned long)&size;     void ** retAddrAddr = (void **)(stackVarAddr/2 + argAddr/2 + 2);     void * retAddr = * retAddrAddr;     unsigned char *retBuffer = (unsigned char*)malloc(size + 16);     memset(retBuffer, 0, 16);     memcpy(retBuffer, &retAddr, sizeof(retAddr));     memcpy(retBuffer + 4, &size, sizeof(size));     return retBuffer + 16;   }   void :perator delete(void *buf)   {     int stackVar;     if(!buf)       return;     unsigned long stackVarAddr = (unsigned long)&stackVar;     unsigned long argAddr = (unsigned long)&buf;     void ** retAddrAddr = (void **)(stackVarAddr/2 + argAddr/2 + 2);     void * retAddr = * retAddrAddr;     unsigned char* buf2 = (unsigned char*)buf;     buf2 -= 8;     memcpy(buf2, &retAddr, sizeof(retAddr));     size_t size;     buf2 -= 4;     memcpy(&size, buf2, sizeof(buf2));     buf2 += 8;     buf2[0] = 0xde;     buf2[1] = 0xad;     buf2[2] = 0xbe;     buf2[3] = 0xef;          buf2 += 4;     memset(buf2, 0x7777, size);     // deallocating destroys saved addresses, so dont     // buf -= 16;     // free(buf);   } qi ta zhi de guan zhu de di fang :   zhe duan dai ma tong yang ke yi yong yu nei cun xie lu de jian ce 。 zhi xu xiu gai delete yun suan fu shi ta zhen zheng de qu shi fang nei cun , bing qie zai cheng xu tui chu qian , yong __heapwalk bian li suo you yi fen pei de nei cun kuai bing ba tiao yong new de di zhi ti qu chu lai , zhe jiu jiang de dao yi fen mei you bei delete pi pei de new tiao yong lie biao 。   huan yao zhu chong de shi : zhe li lie chu de dai ma zhi neng zai tiao shi de shi hou qu shi yong , jia ru ni ba ta duan dai ma fang dao zui zhong de chan pin zhong , hui dao zhi cheng xu yun xing shi nei cun bei da liang de xiao hao 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785336.html][img]http://image.wangchao.net.cn/it/1323423844219.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
情人节的清纯女生(9)
情人节的清纯女生(8)
情人节的清纯女生(7)
情人节的清纯女生(6)
山东蓬莱海边组照
一探哲蚌 II
一探哲蚌 III
古长城的一角
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有