¿ìËÙÒµÎñͨµÀ

Win32½á¹¹»¯Òì³£´¦Àí£¨SEH£©Ì½ÃØ(ÉÏ)

×÷Õß ØýÃû¼¼Êõ À´Ô´ ³ÌÐòÉè¼Æ ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-29
£¬»ØÏëһϽṹ»¯Òì³£´¦ÀíÊÇÒÔÏß³ÌΪ»ù´¡£¬²¢×÷ÓÃÔÚÿ¸öÏß³ÌÉÏ£¬Ã÷°×ÕâÒ»µãÊÇÓÐÖúÓÚÀí½âµÄ¡£Ò²¾ÍÊÇ˵£¬Ã¿¸öÏ߳̾߱¸Æä×Ô¼ºµÄÒì³£´¦Àí»Øµ÷º¯Êý¡£ÔÚÎÒ1996Äê5ÔµÄרÀ¸ÎÄÕÂÖУ¬ÎÒÃèÊöÁËÒ»¸ö¹Ø¼üµÄ Win32 Êý¾Ý½á¹¹——Ïß³ÌÐÅÏ¢¿é£¨¼´ TEB ºÍ TIB£©¡£¸ÃÊý¾Ý½á¹¹µÄijЩÓòÔÚ Windows NT¡¢Windows 95¡¢Win32s ºÍ OS/2 ƽ̨ÉÏÊÇÒ»ÑùµÄ¡£TIB ÖеĵÚÒ»¸ö DWORD ÊÇÖ¸ÏòÏß³Ì EXCEPTION_REGISTRATION ½á¹¹µÄÖ¸Õë¡£ÔÚ Intel Win32 ƽ̨ÉÏ£¬FS ¼Ä´æÆ÷×ÜÊÇÖ¸Ïòµ±Ç°µÄ TIB¡£Òò´Ë£¬ÔÚ FS:[0]λÖã¬ÄãÄÜÕÒµ½ EXCEPTION_REGISTRATION ½á¹¹µÄÖ¸Õë¡£

ÏÖÔÚÎÒÃÇÖªµÀÁË£¬µ±Òì³£·¢Éúʱ£¬ÏµÍ³¼ì²é³ö´íÏß³ÌµÄ TIB ²¢»ñÈ¡ EXCEPTION_REGISTRATION ½á¹¹µÄÖ¸Õë¡£Õâ¸ö½á¹¹ÖоÍÓÐÒ»¸ö _except_handler »Øµ÷º¯ÊýµÄÖ¸Õë¡£ÕâЩÐÅÏ¢×ãÒÔÈòÙ×÷ϵͳ֪µÀÔÚÄÄÀïÒÔ¼°ÈçºÎµ÷Óà _except_handler º¯Êý£¬Èçͼ¶þËùʾ£º

Win32½á¹¹»¯Òì³£´¦Àí£¨SEH£©Ì½ÃØ(ÉÏ)

ͼ¶þ _except_handler º¯Êý

ͨ¹ýÇ°ÃæµÄÃèÊö£¬ÎÒдÁËÒ»¸öС³ÌÐòÀ´¶Ô²Ù×÷ϵͳ²ãµÄ½á¹¹»¯Òì³£½øÐÐʾ·¶¡£³ÌÐò´úÂëÈçÏ£º

¡¡//==================================================
¡¡ //¡¡MYSEH¡¡-¡¡Matt¡¡Pietrek¡¡1997
¡¡ //¡¡Microsoft¡¡Systems¡¡Journal,¡¡January¡¡1997
¡¡ //¡¡FILE:¡¡MYSEH.CPp
¡¡ //¡¡To¡¡compile:¡¡CL¡¡MYSEH.CPp
¡¡ //==================================================
#define¡¡WIN32_LEAN_AND_MEAN
#include¡¡<windows.h>
#include¡¡<stdio.h>

DWORD¡¡scratch;

EXCEPTION_DISPOSITION
__cdecl
_except_handler(
¡¡¡¡ struct¡¡_EXCEPTION_RECORD¡¡*ExceptionRecord,
¡¡¡¡ void¡¡*¡¡EstablisherFrame,
¡¡¡¡ struct¡¡_CONTEXT¡¡*ContextRecord,
¡¡¡¡ void¡¡*¡¡DispatcherContext¡¡)
{
¡¡¡¡ unsigned¡¡i;

//¡¡Indicate¡¡that¡¡we¡¡made¡¡it¡¡to¡¡our¡¡exception¡¡handler
¡¡¡¡ printf(¡¡"Hello¡¡from¡¡an¡¡exception¡¡handler\n"¡¡);

//¡¡Change¡¡EAX¡¡in¡¡the¡¡context¡¡record¡¡so¡¡that¡¡it¡¡points¡¡to¡¡someplace
¡¡¡¡ //¡¡where¡¡we¡¡can¡¡successfully¡¡write
¡¡¡¡ ContextRecord->Eax¡¡=¡¡(DWORD)&scratch;

//¡¡Tell¡¡the¡¡OS¡¡to¡¡restart¡¡the¡¡faulting¡¡instruction
¡¡¡¡ return¡¡ExceptionContinueExecution;
}

int¡¡main()
{
¡¡¡¡ DWORD¡¡handler¡¡=¡¡(DWORD)_except_handler;
¡¡¡¡ __asm
¡¡¡¡ {
¡¡¡¡¡¡¡¡ //¡¡´´½¨¡¡EXCEPTION_REGISTRATION¡¡½á¹¹£º
¡¡¡¡¡¡¡¡ push¡¡handler
//¡¡handlerº¯ÊýµÄµØÖ·
¡¡¡¡¡¡¡¡ push¡¡FS:[0]¡¡
//¡¡Ç°Ò»¸öhandlerº¯ÊýµÄµØÖ·
¡¡¡¡¡¡¡¡ mov¡¡FS:[0],ESp
//¡¡×°ÈëеÄEXECEPTION_REGISTRATION½á¹¹
¡¡¡¡ }
¡¡¡¡ __asm
¡¡¡¡ {
¡¡¡¡¡¡¡¡ mov¡¡eax,0
//¡¡EAXÇåÁã
¡¡¡¡¡¡¡¡ mov¡¡[eax],¡¡1
//¡¡Ð´EAXÖ¸ÏòµÄÄÚ´æ´Ó¶ø¹ÊÒâÒý·¢Ò»¸ö´íÎó
¡¡¡¡ }
¡¡¡¡ printf(¡¡"After¡¡writing!\n"¡¡);
¡¡¡¡ __asm
¡¡¡¡ {
¡¡¡¡¡¡¡¡ //¡¡ÒÆÈ¥ÎÒÃǵġ¡EXECEPTION_REGISTRATION¡¡½á¹¹¼Ç¼
¡¡¡¡¡¡¡¡ mov¡¡eax,[ESP]¡¡¡¡
//¡¡»ñÈ¡Ç°Ò»¸ö½á¹¹
¡¡¡¡¡¡¡¡ mov¡¡FS:[0],¡¡EAX¡¡
//¡¡×°ÈëÇ°Ò»¸ö½á¹¹
¡¡¡¡¡¡¡¡ add¡¡esp,¡¡8
//¡¡½«¡¡EXECEPTION_REGISTRATION¡¡µ¯³ö¶ÑÕ»
¡¡¡¡ }
¡¡¡¡ return¡¡0;
}

´úÂëÖÐÖ»ÓÐÁ½¸öº¯Êý£¬main º¯ÊýʹÓÃÁËÈý²¿·ÖÄÚÁª»ã±à¿é ASM¡£µÚÒ»¸ö ASM ¿éͨ¹ýÁ½¸ö PUSH Ö¸Á¼´£º“PUSH handler”ºÍ“PUSH FS:[0]”£©ÔÚ¶ÑÕ»ÉϽ¨Á¢Ò»¸ö EXCEPTION_REGISTRATION ½á¹¹¡£PUSH FS:[0] ±£´æÒÔÇ° FS:[0] µÄÖµ£¬ËüÊǽṹµÄÒ»²¿·Ö£¬µ«Ä¿Ç°Õâ¸öÖµ¶ÔÎÒÃDz»ÖØÒª¡£ÖØÒªµÄÊÇÔÚ¶ÑÕ»ÉÏÓÐÒ»¸ö 8-byte µÄ EXCEPTION_REGISTRATION ½á¹¹¡£½ô½Ó×ŵÄÖ¸ÁMOV FS:[0],ESP£©ÊÇÈÃÏß³ÌÐÅÏ¢¿éÖеĵÚÒ»¸ö DWORD Ö¸µ½Ð嵀 EXCEPTION_REGISTRATION Ö¸Áî¡£

Èç¹ûÄãÏëÖªµÀΪ

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à
ú¹«Ë¾ÔÚÔËÓªÖеIJßÂÔ
  • iBATIS 3ÄÚµÄÐÂÌØÐÔ£º½«iBATISÓÃ×÷Ó¦ÓóÌÐòÄÚµÄÒ»Öֳ־ÿò¼Ü - ±à³ÌÈëÃÅÍø
  • Photoshop»æÖƸ߹âË®¾§ÖʸÐË®¾§Æ»¹û
  • Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

    µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

    µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

    ¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ