һƪ½²¶ÔÆë±È½ÏºÃµÄÎÄÕ£¬×ªÌùÈçÏÂ:
´óÖ±ê×¢Ò»¶þ:
1.ÄÚ´æ¶ÔÆë:¼ÆËã»úϵͳ¶Ô»ù±¾ÀàÐÍÊý¾ÝÔÚÄÚ´æÖдæ·ÅµÄλÖÃÓÐÏÞÖÆ£¬ËüÃÇ»áÒªÇóÕâЩÊý¾ÝµÄÊ×µØÖ·µÄÖµÊÇij¸öÊýk(ͨ³£ËüΪ4»ò8)µÄ±¶ÊýkÔò±»³ÆΪ¸ÃÊý¾ÝÀàÐ͵ĶÔÆëÄ£Êý(alignment modulus)
2.²»Í¬±àÒëÆ÷ĬÈϵÄ×î´ó¶ÔÆë×Ö½ÚÊýÊDz»Ò»ÑùµÄ,±ÈÈçvc==8,gcc==4,¿ÉÒÔͨ¹ý#progma pack (n)À´ÐÞ¸Ä,·ÖÎö³ÌÐòµÄʱºòҪעÒâ±àÒëÆ÷µÄÇø±ð
3.Ò»¸ö½á¹¹ÌåÀïÃæ,°´ÕÕalignment modulus×î´óµÄÊý¾Ý³ÉÔ±À´½øÐжÔÆë,³¬¹ý±àÒëÆ÷¹æ¶¨×î´óµÄ¶ÔÆë×Ö½Ú¸öÊý,°´±àÒëÆ÷×î´ó¶ÔÆë×Ö½Ú¸öÀ´
4.doubleÀàÐÍÔÚvcÀïÃæalignment modulus == 8,¶øÔÚgccÀïÃæÓÉÓÚĬÈÏ×î´ó¶ÔÆë¸öÊýÊÇ4,²»ÉèÖõĻ°,alignment modulus == 4
5.ÒòΪÊý×é¸÷ÔªËØÖ®¼ä²»ÄÜÓпÕ϶,ËùÒÔ{int a;char b;}
ÕâÖÖÇé¿ö,ĬÈÏÔÚVCÀïÃæÒ²ÐèÒªÕ¼8¸ö×Ö½Ú.
ÕýÎÄÈçÏ£º
µ±ÔÚCÖж¨ÒåÁËÒ»¸ö½á¹¹ÀàÐÍʱ£¬ËüµÄ´óСÊÇ·ñµÈÓÚ¸÷×Ö¶Î(field)´óС֮ºÍ£¿±àÒëÆ÷½«ÈçºÎÔÚÄÚ´æÖзÅÖÃÕâЩ×ֶΣ¿ANSI C¶Ô½á¹¹ÌåµÄÄÚ´æ²¼¾ÖÓÐʲôҪÇ󣿶øÎÒÃǵijÌÐòÓÖÄÜ·ñÒÀÀµÕâÖÖ²¼¾Ö£¿ÕâЩÎÊÌâ»òÐí¶Ô²»ÉÙÅóÓÑÀ´Ëµ»¹ÓеãÄ£ºý£¬ÄÇô±¾ÎľÍÊÔ×Å̽¾¿ËüÃDZ³ºóµÄÃØÃÜ¡£
Ê×ÏÈ£¬ÖÁÉÙÓÐÒ» ......
һƪ½²¶ÔÆë±È½ÏºÃµÄÎÄÕ£¬×ªÌùÈçÏÂ:
´óÖ±ê×¢Ò»¶þ:
1.ÄÚ´æ¶ÔÆë:¼ÆËã»úϵͳ¶Ô»ù±¾ÀàÐÍÊý¾ÝÔÚÄÚ´æÖдæ·ÅµÄλÖÃÓÐÏÞÖÆ£¬ËüÃÇ»áÒªÇóÕâЩÊý¾ÝµÄÊ×µØÖ·µÄÖµÊÇij¸öÊýk(ͨ³£ËüΪ4»ò8)µÄ±¶ÊýkÔò±»³ÆΪ¸ÃÊý¾ÝÀàÐ͵ĶÔÆëÄ£Êý(alignment modulus)
2.²»Í¬±àÒëÆ÷ĬÈϵÄ×î´ó¶ÔÆë×Ö½ÚÊýÊDz»Ò»ÑùµÄ,±ÈÈçvc==8,gcc==4,¿ÉÒÔͨ¹ý#progma pack (n)À´ÐÞ¸Ä,·ÖÎö³ÌÐòµÄʱºòҪעÒâ±àÒëÆ÷µÄÇø±ð
3.Ò»¸ö½á¹¹ÌåÀïÃæ,°´ÕÕalignment modulus×î´óµÄÊý¾Ý³ÉÔ±À´½øÐжÔÆë,³¬¹ý±àÒëÆ÷¹æ¶¨×î´óµÄ¶ÔÆë×Ö½Ú¸öÊý,°´±àÒëÆ÷×î´ó¶ÔÆë×Ö½Ú¸öÀ´
4.doubleÀàÐÍÔÚvcÀïÃæalignment modulus == 8,¶øÔÚgccÀïÃæÓÉÓÚĬÈÏ×î´ó¶ÔÆë¸öÊýÊÇ4,²»ÉèÖõĻ°,alignment modulus == 4
5.ÒòΪÊý×é¸÷ÔªËØÖ®¼ä²»ÄÜÓпÕ϶,ËùÒÔ{int a;char b;}
ÕâÖÖÇé¿ö,ĬÈÏÔÚVCÀïÃæÒ²ÐèÒªÕ¼8¸ö×Ö½Ú.
ÕýÎÄÈçÏ£º
µ±ÔÚCÖж¨ÒåÁËÒ»¸ö½á¹¹ÀàÐÍʱ£¬ËüµÄ´óСÊÇ·ñµÈÓÚ¸÷×Ö¶Î(field)´óС֮ºÍ£¿±àÒëÆ÷½«ÈçºÎÔÚÄÚ´æÖзÅÖÃÕâЩ×ֶΣ¿ANSI C¶Ô½á¹¹ÌåµÄÄÚ´æ²¼¾ÖÓÐʲôҪÇ󣿶øÎÒÃǵijÌÐòÓÖÄÜ·ñÒÀÀµÕâÖÖ²¼¾Ö£¿ÕâЩÎÊÌâ»òÐí¶Ô²»ÉÙÅóÓÑÀ´Ëµ»¹ÓеãÄ£ºý£¬ÄÇô±¾ÎľÍÊÔ×Å̽¾¿ËüÃDZ³ºóµÄÃØÃÜ¡£
Ê×ÏÈ£¬ÖÁÉÙÓÐÒ» ......
Ê×ÏÈ¿´ÏÂÏÂÃæÕâ¶Î£º
int main()
{
char *name = "fengkewei";
char name1[] = "fengkewei";
char *name2 = "fengkewei";
char *name3 = "woaifengkewei";
int i = 10;
int j = 10;
int k = 11;
return 0;
}
ÈôÄú¾õµÃËüÃÇÓ¦¸Ã¶¼±£´æÔÚÄÚ´æÖеÄÒ»¿éµØ·½£¬ÄÇÇëÍùÏ¿´¡£¡£¡£¡£
ÏÂÃæÊDZàÒëÆ÷Ϊ¸÷¸ö±äÁ¿·ÖÅäµÄÄÚ´æµØÖ·£¬ÓÉÓÚ·ÖÅäÔÚÕ»ÉÏ ËùÒÔµØÖ·ÊǵݼõµÄ
---------------------Õ»Çø------------------------------------
+ &name 0x0013ff5c unsigned char * *
+ &name1 0x0013ff48 unsigned char [10]*
+ &name2 0x0013ff3c unsigned char * *
+ &name3 0x0013ff30 unsigned char * *
+ &i 0x0013ff24 int *
+ &j 0x0013ff18 int *
+ &k 0x0013ff0c int *
---------------------------------------------------------------
&name ºÍ&name1[] Ïà²î20¸ö×Ö½Ú µ«"fengkewei"Ö»ÓÐ10¸ö×Ö½Ú£¨´ø¿Õ×Ö·û£©
&name1[]ºÍ&name2 Ïà²î12¸ö×Ö½Ú
ºóÃ涼Õý³£ÁË ¶¼²î12
ΪʲôÊÇ12£¿
——————&mda ......
Ê×ÏÈ¿´ÏÂÏÂÃæÕâ¶Î£º
int main()
{
char *name = "fengkewei";
char name1[] = "fengkewei";
char *name2 = "fengkewei";
char *name3 = "woaifengkewei";
int i = 10;
int j = 10;
int k = 11;
return 0;
}
ÈôÄú¾õµÃËüÃÇÓ¦¸Ã¶¼±£´æÔÚÄÚ´æÖеÄÒ»¿éµØ·½£¬ÄÇÇëÍùÏ¿´¡£¡£¡£¡£
ÏÂÃæÊDZàÒëÆ÷Ϊ¸÷¸ö±äÁ¿·ÖÅäµÄÄÚ´æµØÖ·£¬ÓÉÓÚ·ÖÅäÔÚÕ»ÉÏ ËùÒÔµØÖ·ÊǵݼõµÄ
---------------------Õ»Çø------------------------------------
+ &name 0x0013ff5c unsigned char * *
+ &name1 0x0013ff48 unsigned char [10]*
+ &name2 0x0013ff3c unsigned char * *
+ &name3 0x0013ff30 unsigned char * *
+ &i 0x0013ff24 int *
+ &j 0x0013ff18 int *
+ &k 0x0013ff0c int *
---------------------------------------------------------------
&name ºÍ&name1[] Ïà²î20¸ö×Ö½Ú µ«"fengkewei"Ö»ÓÐ10¸ö×Ö½Ú£¨´ø¿Õ×Ö·û£©
&name1[]ºÍ&name2 Ïà²î12¸ö×Ö½Ú
ºóÃ涼Õý³£ÁË ¶¼²î12
ΪʲôÊÇ12£¿
——————&mda ......
ºÍÔÚIDEÖбàÒëÏà±È£¬ÃüÁîÐÐģʽ±àÒëËٶȸü¿ì£¬²¢¿ÉÒÔ±ÜÃâ±»IDE²úÉúµÄһЩ¸½¼ÓÐÅÏ¢Ëù¸ÉÈÅ¡£±¾ÎĽ«½éÉÜ΢ÈíC/C++±àÒëÆ÷ÃüÁîÐÐģʽÉ趨ºÍÓ÷¨¡£ 1¡¢ÉèÖû·¾³±äÁ¿£º PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\include LIB=C:\Program Files\Microsoft Visual Studio 8\VC\lib Èç¹ûÌáʾÕÒ²»µ½mspdb80.dllÎļþ£¬Ôò´ÓC:\Program Files\Microsoft Visual Studio 8\Common7\IDEÏ¿½±´¡°msobj80.dll,mspdb80.dll,mspdbcore.dll,mspdbsrv.exe¡±ÕâËĸöÎļþµ½C:\Program Files\Microsoft Visual Studio 8\VC\binϼ´¿É¡£ 2¡¢ÃüÁîÑ¡Ï 1) /C:ÔÚÔ¤´¦ÀíÊä³öÖб£Áô×¢ÊÍÓï¾ä 2) /c:Ö»±àÒ룬²»Á¬½Ó£¬Ï൱ÓÚÔÚ"Build"²Ëµ¥ÏÂÑ¡ÔñÁË"Compile" 3) /D:¶¨Òå³£Á¿ºÍºê£¬ÓëÔ´³ÌÐòÀïµÄ#define ÓÐÏàͬЧ¹û 4) /E:Ô¤´¦ÀíC¡¢C£«£«Ô´Îļþ£¬½«Ô´ÎļþÖÐËùÓеÄÔ¤±àÒëÖ¸Áî¼°ºêÕ¹¿ª£¬½«×¢ÊÍÈ¥µô£¬È»ºó½«Ô¤´¦ÀíÆ÷µÄÊä³ö¿½±´ÖÁ±ê×¼Êä³öÉ豸Êä³ö£¬²¢ÇÒÔÚÿ¸öÎļþµÄ¿ªÍ·ºÍĩβ¼ÓÈ ......
ºÍÔÚIDEÖбàÒëÏà±È£¬ÃüÁîÐÐģʽ±àÒëËٶȸü¿ì£¬²¢¿ÉÒÔ±ÜÃâ±»IDE²úÉúµÄһЩ¸½¼ÓÐÅÏ¢Ëù¸ÉÈÅ¡£±¾ÎĽ«½éÉÜ΢ÈíC/C++±àÒëÆ÷ÃüÁîÐÐģʽÉ趨ºÍÓ÷¨¡£ 1¡¢ÉèÖû·¾³±äÁ¿£º PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\include LIB=C:\Program Files\Microsoft Visual Studio 8\VC\lib Èç¹ûÌáʾÕÒ²»µ½mspdb80.dllÎļþ£¬Ôò´ÓC:\Program Files\Microsoft Visual Studio 8\Common7\IDEÏ¿½±´¡°msobj80.dll,mspdb80.dll,mspdbcore.dll,mspdbsrv.exe¡±ÕâËĸöÎļþµ½C:\Program Files\Microsoft Visual Studio 8\VC\binϼ´¿É¡£ 2¡¢ÃüÁîÑ¡Ï 1) /C:ÔÚÔ¤´¦ÀíÊä³öÖб£Áô×¢ÊÍÓï¾ä 2) /c:Ö»±àÒ룬²»Á¬½Ó£¬Ï൱ÓÚÔÚ"Build"²Ëµ¥ÏÂÑ¡ÔñÁË"Compile" 3) /D:¶¨Òå³£Á¿ºÍºê£¬ÓëÔ´³ÌÐòÀïµÄ#define ÓÐÏàͬЧ¹û 4) /E:Ô¤´¦ÀíC¡¢C£«£«Ô´Îļþ£¬½«Ô´ÎļþÖÐËùÓеÄÔ¤±àÒëÖ¸Áî¼°ºêÕ¹¿ª£¬½«×¢ÊÍÈ¥µô£¬È»ºó½«Ô¤´¦ÀíÆ÷µÄÊä³ö¿½±´ÖÁ±ê×¼Êä³öÉ豸Êä³ö£¬²¢ÇÒÔÚÿ¸öÎļþµÄ¿ªÍ·ºÍĩβ¼ÓÈ ......
Óô˷¨Ç°È·±£ÄãµÄCÔ´´úÂëÊÇÎÞ´íµÄ~~
½â¾ö°ì·¨£º
C:
ÔÚÖ÷º¯Êýºó¼Ógetch()»òch=getch(); (ÈóÌÐòµÈ´ýÄã°´ÏÂÈÎÒâ¼ü£¬ÔÙ¼ÌÐøÖ´ÐÐÏÂÃæµÄÓï¾ä)
C++:
1.°üº¬Í·Îļþʱ£º #include <stdlib.h>/*header file£¬ÒòΪÔÚstdlib.hÍ·ÎļþÖж¨ÒåÁËsystem()º¯Êý*/
2.ÔÚ×îºóÒ»¾ä¼ÓÉÏ£ºsystem("PAUSE");//systemº¯Êý£¬PauseÊôÓÚDOSÃüÁî
ʵ¼ÊÉÏsystemº¯ÊýÊÇ¿ÉÒÔµ÷ÓÃһЩDOSÃüÁî
ÒÔÏÂΪDOSÃüÁ
ASSOC ÏÔʾ»òÐÞ¸ÄÎļþÀ©Õ¹Ãû¹ØÁª¡£
AT ¼Æ»®ÔÚ¼ÆËã»úÉÏÔËÐеÄÃüÁîºÍ³ÌÐò¡£
ATTRIB ÏÔʾ»ò¸ü¸ÄÎļþÊôÐÔ¡£
BREAK ÉèÖûòÇå³ýÀ©Õ¹Ê½ CTRL+C ¼ì²é¡£
CACLS ÏÔʾ»òÐÞ¸ÄÎļþµÄ·ÃÎÊ¿ØÖÆÁбí(ACLs)¡£
CALL ´ÓÁíÒ»¸öÅú´¦Àí³ÌÐòµ÷ÓÃÕâÒ»¸ö¡£
CD ÏÔʾµ±Ç°Ä¿Â¼µÄÃû³Æ»ò½«Æä¸ü¸Ä¡£
CHCP ÏÔʾ»òÉèÖû´úÂëÒ³Êý¡£
CHDIR ÏÔʾµ±Ç°Ä¿Â¼µÄÃû³Æ»ò½«Æä¸ü¸Ä¡£
CHKDSK ¼ì²é´ÅÅ̲¢ÏÔʾ״̬±¨¸æ¡£
CHKNTFS ÏÔʾ»òÐÞ¸ÄÆô¶¯Ê±¼ä´ÅÅ̼ì²é¡£
CLS Çå³ýÆÁÄ»¡£
CMD ´ò¿ªÁíÒ»¸ö Windows ÃüÁî½âÊͳÌÐò´°¿Ú¡£
COLOR ÉèÖÃĬÈÏ¿ØÖÆ̨ǰ¾°ºÍ±³¾°ÑÕÉ«¡£
COMP ±È½ÏÁ½¸ö»òÁ½Ì×ÎļþµÄÄÚÈÝ¡£
COMPACT ÏÔʾ»ò¸ü¸Ä NTFS ·ÖÇøÉÏÎļþµÄѹËõ¡£
CONVERT ½« FAT ¾íת»»³É N ......
Óô˷¨Ç°È·±£ÄãµÄCÔ´´úÂëÊÇÎÞ´íµÄ~~
½â¾ö°ì·¨£º
C:
ÔÚÖ÷º¯Êýºó¼Ógetch()»òch=getch(); (ÈóÌÐòµÈ´ýÄã°´ÏÂÈÎÒâ¼ü£¬ÔÙ¼ÌÐøÖ´ÐÐÏÂÃæµÄÓï¾ä)
C++:
1.°üº¬Í·Îļþʱ£º #include <stdlib.h>/*header file£¬ÒòΪÔÚstdlib.hÍ·ÎļþÖж¨ÒåÁËsystem()º¯Êý*/
2.ÔÚ×îºóÒ»¾ä¼ÓÉÏ£ºsystem("PAUSE");//systemº¯Êý£¬PauseÊôÓÚDOSÃüÁî
ʵ¼ÊÉÏsystemº¯ÊýÊÇ¿ÉÒÔµ÷ÓÃһЩDOSÃüÁî
ÒÔÏÂΪDOSÃüÁ
ASSOC ÏÔʾ»òÐÞ¸ÄÎļþÀ©Õ¹Ãû¹ØÁª¡£
AT ¼Æ»®ÔÚ¼ÆËã»úÉÏÔËÐеÄÃüÁîºÍ³ÌÐò¡£
ATTRIB ÏÔʾ»ò¸ü¸ÄÎļþÊôÐÔ¡£
BREAK ÉèÖûòÇå³ýÀ©Õ¹Ê½ CTRL+C ¼ì²é¡£
CACLS ÏÔʾ»òÐÞ¸ÄÎļþµÄ·ÃÎÊ¿ØÖÆÁбí(ACLs)¡£
CALL ´ÓÁíÒ»¸öÅú´¦Àí³ÌÐòµ÷ÓÃÕâÒ»¸ö¡£
CD ÏÔʾµ±Ç°Ä¿Â¼µÄÃû³Æ»ò½«Æä¸ü¸Ä¡£
CHCP ÏÔʾ»òÉèÖû´úÂëÒ³Êý¡£
CHDIR ÏÔʾµ±Ç°Ä¿Â¼µÄÃû³Æ»ò½«Æä¸ü¸Ä¡£
CHKDSK ¼ì²é´ÅÅ̲¢ÏÔʾ״̬±¨¸æ¡£
CHKNTFS ÏÔʾ»òÐÞ¸ÄÆô¶¯Ê±¼ä´ÅÅ̼ì²é¡£
CLS Çå³ýÆÁÄ»¡£
CMD ´ò¿ªÁíÒ»¸ö Windows ÃüÁî½âÊͳÌÐò´°¿Ú¡£
COLOR ÉèÖÃĬÈÏ¿ØÖÆ̨ǰ¾°ºÍ±³¾°ÑÕÉ«¡£
COMP ±È½ÏÁ½¸ö»òÁ½Ì×ÎļþµÄÄÚÈÝ¡£
COMPACT ÏÔʾ»ò¸ü¸Ä NTFS ·ÖÇøÉÏÎļþµÄѹËõ¡£
CONVERT ½« FAT ¾íת»»³É N ......
BoundsChecker²ÉÓÃÒ»ÖÖ±»³ÆΪ Code InjectionµÄ¼¼Êõ£¬À´½Ø»ñ¶Ô·ÖÅäÄÚ´æºÍÊÍ·ÅÄÚ´æµÄº¯ÊýµÄµ÷Ó᣼òµ¥µØ˵£¬µ±ÄãµÄ³ÌÐò¿ªÊ¼ÔËÐÐʱ£¬BoundsCheckerµÄDLL±»×Ô¶¯ÔØÈë½ø³ÌµÄµØÖ·¿Õ¼ä£¨Õâ¿ÉÒÔͨ¹ýsystem-levelµÄHookʵÏÖ£©£¬È»ºóËü»áÐ޸Ľø³ÌÖжÔÄÚ´æ·ÖÅäºÍÊͷŵĺ¯Êýµ÷Óã¬ÈÃÕâЩµ÷ÓÃÊ×ÏÈתÈëËüµÄ´úÂ룬ȻºóÔÙÖ´ÐÐÔÀ´µÄ´úÂë¡£BoundsCheckerÔÚ×öÕâЩ¶¯×÷µÄʱ£¬ÎÞÐëÐ޸ı»µ÷ÊÔ³ÌÐòµÄÔ´´úÂë»ò¹¤³ÌÅäÖÃÎļþ£¬ÕâʹµÃʹÓÃËü·Ç³£µÄ¼ò±ã¡¢Ö±½Ó¡£
¡¡¡¡ÕâÀïÎÒÃÇÒÔmallocº¯ÊýΪÀý£¬½Ø»ñÆäËûµÄº¯Êý·½·¨Óë´ËÀàËÆ¡£
¡¡¡¡ÐèÒª±»½Ø»ñµÄº¯Êý¿ÉÄÜÔÚDLLÖУ¬Ò²¿ÉÄÜÔÚ³ÌÐòµÄ´úÂëÀï¡£±ÈÈ磬Èç¹û¾²Ì¬Á¬½áC-Runtime Library£¬ÄÇômallocº¯ÊýµÄ´úÂë»á±»Á¬½áµ½³ÌÐòÀΪÁ˽ػñס¶ÔÕâÀຯÊýµÄµ÷Óã¬BoundsChecker»á¶¯Ì¬ÐÞ¸ÄÕâЩº¯ÊýµÄÖ¸Áî¡£
¡¡¡¡ÒÔÏÂÁ½¶Î»ã±à´úÂ룬һ¶ÎûÓÐBoundsChecker½éÈ룬ÁíÒ»¶ÎÔòÓÐBoundsCheckerµÄ½éÈ룺
126: _CRTIMP void * __cdecl malloc (
127: size_t nSize
128: )
129: {
00403C10 push ebp
00403C11 mov ebp,esp
130: return _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
00403C13 push 0
00403C15 push 0
00403C17 push 1
00403C19 mov eax,[__n ......
BoundsChecker²ÉÓÃÒ»ÖÖ±»³ÆΪ Code InjectionµÄ¼¼Êõ£¬À´½Ø»ñ¶Ô·ÖÅäÄÚ´æºÍÊÍ·ÅÄÚ´æµÄº¯ÊýµÄµ÷Ó᣼òµ¥µØ˵£¬µ±ÄãµÄ³ÌÐò¿ªÊ¼ÔËÐÐʱ£¬BoundsCheckerµÄDLL±»×Ô¶¯ÔØÈë½ø³ÌµÄµØÖ·¿Õ¼ä£¨Õâ¿ÉÒÔͨ¹ýsystem-levelµÄHookʵÏÖ£©£¬È»ºóËü»áÐ޸Ľø³ÌÖжÔÄÚ´æ·ÖÅäºÍÊͷŵĺ¯Êýµ÷Óã¬ÈÃÕâЩµ÷ÓÃÊ×ÏÈתÈëËüµÄ´úÂ룬ȻºóÔÙÖ´ÐÐÔÀ´µÄ´úÂë¡£BoundsCheckerÔÚ×öÕâЩ¶¯×÷µÄʱ£¬ÎÞÐëÐ޸ı»µ÷ÊÔ³ÌÐòµÄÔ´´úÂë»ò¹¤³ÌÅäÖÃÎļþ£¬ÕâʹµÃʹÓÃËü·Ç³£µÄ¼ò±ã¡¢Ö±½Ó¡£
¡¡¡¡ÕâÀïÎÒÃÇÒÔmallocº¯ÊýΪÀý£¬½Ø»ñÆäËûµÄº¯Êý·½·¨Óë´ËÀàËÆ¡£
¡¡¡¡ÐèÒª±»½Ø»ñµÄº¯Êý¿ÉÄÜÔÚDLLÖУ¬Ò²¿ÉÄÜÔÚ³ÌÐòµÄ´úÂëÀï¡£±ÈÈ磬Èç¹û¾²Ì¬Á¬½áC-Runtime Library£¬ÄÇômallocº¯ÊýµÄ´úÂë»á±»Á¬½áµ½³ÌÐòÀΪÁ˽ػñס¶ÔÕâÀຯÊýµÄµ÷Óã¬BoundsChecker»á¶¯Ì¬ÐÞ¸ÄÕâЩº¯ÊýµÄÖ¸Áî¡£
¡¡¡¡ÒÔÏÂÁ½¶Î»ã±à´úÂ룬һ¶ÎûÓÐBoundsChecker½éÈ룬ÁíÒ»¶ÎÔòÓÐBoundsCheckerµÄ½éÈ룺
126: _CRTIMP void * __cdecl malloc (
127: size_t nSize
128: )
129: {
00403C10 push ebp
00403C11 mov ebp,esp
130: return _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
00403C13 push 0
00403C15 push 0
00403C17 push 1
00403C19 mov eax,[__n ......
freadº¯ÊýºÍfwriteº¯Êý
1.º¯Êý¹¦ÄÜ
ÓÃÀ´¶Áдһ¸öÊý¾Ý¿é¡£
2.Ò»°ãµ÷ÓÃÐÎʽ
fread(buffer,size,count,fp);
fwrite(buffer,size,count,fp);
3.˵Ã÷
£¨1£©buffer£ºÊÇÒ»¸öÖ¸Õ룬¶ÔfreadÀ´Ëµ£¬ËüÊǶÁÈëÊý¾ÝµÄ´æ·ÅµØÖ·¡£¶ÔfwriteÀ´Ëµ£¬ÊÇÒªÊä³öÊý¾ÝµÄµØÖ·¡£
£¨2£©size£ºÒª¶ÁдµÄ×Ö½ÚÊý£»
£¨3£©count:Òª½øÐжÁд¶àÉÙ¸ösize×Ö½ÚµÄÊý¾ÝÏ
£¨4£©fp:ÎļþÐÍÖ¸Õë¡£
×¢Ò⣺1 Íê³É´Îд²Ù(fwrite())×÷ºó±ØÐë¹Ø±ÕÁ÷(fclose());
2 Íê³ÉÒ»´Î¶Á²Ù×÷(fread())ºó£¬Èç¹ûûÓйرÕÁ÷(fclose()),ÔòÖ¸Õë(FILE * fp)×Ô¶¯ÏòºóÒƶ¯Ç°Ò»´Î¶ÁдµÄ³¤¶È£¬²»¹Ø±ÕÁ÷¼ÌÐøÏÂÒ»´Î¶Á²Ù×÷Ôò½Ó×ÅÉϴεÄÊä³ö¼ÌÐøÊä³ö;
3 fprintf() £º °´¸ñʽÊäÈëµ½Á÷£¬ÆäÔÐÍÊÇint fprintf(FILE *stream, const char *format[, argument, ...]);ÆäÓ÷¨ºÍprintf()Ïàͬ£¬²»¹ý²»ÊÇдµ½¿ØÖÆ̨£¬¶øÊÇдµ½Á÷°ÕÁË¡£×¢ÒâµÄÊÇ·µ»ØֵΪ´Ë´Î²Ù×÷дÈëµ½ÎļþµÄ×Ö½ÚÊý¡£Èçint c = fprintf(fp, "%s %s %d %f", str1,str2, a, b) ;str1£º10×Ö½Ú£» ......
freadº¯ÊýºÍfwriteº¯Êý
1.º¯Êý¹¦ÄÜ
ÓÃÀ´¶Áдһ¸öÊý¾Ý¿é¡£
2.Ò»°ãµ÷ÓÃÐÎʽ
fread(buffer,size,count,fp);
fwrite(buffer,size,count,fp);
3.˵Ã÷
£¨1£©buffer£ºÊÇÒ»¸öÖ¸Õ룬¶ÔfreadÀ´Ëµ£¬ËüÊǶÁÈëÊý¾ÝµÄ´æ·ÅµØÖ·¡£¶ÔfwriteÀ´Ëµ£¬ÊÇÒªÊä³öÊý¾ÝµÄµØÖ·¡£
£¨2£©size£ºÒª¶ÁдµÄ×Ö½ÚÊý£»
£¨3£©count:Òª½øÐжÁд¶àÉÙ¸ösize×Ö½ÚµÄÊý¾ÝÏ
£¨4£©fp:ÎļþÐÍÖ¸Õë¡£
×¢Ò⣺1 Íê³É´Îд²Ù(fwrite())×÷ºó±ØÐë¹Ø±ÕÁ÷(fclose());
2 Íê³ÉÒ»´Î¶Á²Ù×÷(fread())ºó£¬Èç¹ûûÓйرÕÁ÷(fclose()),ÔòÖ¸Õë(FILE * fp)×Ô¶¯ÏòºóÒƶ¯Ç°Ò»´Î¶ÁдµÄ³¤¶È£¬²»¹Ø±ÕÁ÷¼ÌÐøÏÂÒ»´Î¶Á²Ù×÷Ôò½Ó×ÅÉϴεÄÊä³ö¼ÌÐøÊä³ö;
3 fprintf() £º °´¸ñʽÊäÈëµ½Á÷£¬ÆäÔÐÍÊÇint fprintf(FILE *stream, const char *format[, argument, ...]);ÆäÓ÷¨ºÍprintf()Ïàͬ£¬²»¹ý²»ÊÇдµ½¿ØÖÆ̨£¬¶øÊÇдµ½Á÷°ÕÁË¡£×¢ÒâµÄÊÇ·µ»ØֵΪ´Ë´Î²Ù×÷дÈëµ½ÎļþµÄ×Ö½ÚÊý¡£Èçint c = fprintf(fp, "%s %s %d %f", str1,str2, a, b) ;str1£º10×Ö½Ú£» ......