深入淺出 First chance, second chance和ExceptionPort

來源:互聯網
上載者:User

ExceptionPort的作用,是在使用者態異常的第2輪分發過程中,如果第二輪還無人處理,那麼就會發到ExceptionPort 。關於異常的分發,部分可以參考 理解UnhandledExceptionFilter

對於ExceptionPort,每個普通進程都會設定,CSRSS進程負責監聽。CSRSS收到異常訊息後一般是立刻終止進程,Win7開始,略有變化。

可以使用windbg做個實驗,加深對上述概念的理解。來段簡單的代碼,

int main(int argc, char* argv[])
{
 *(int*)0=1;
 return 0;
}

進入windbg

0:000> g
Thu Feb 24 09:53:34.370 2011 (UTC + 8:00): (c7c.12c0): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000027 ebx=7ffda000 ecx=00424a60 edx=00424a60 esi=00000000 edi=0012ff48
eip=00401035 esp=0012fefc ebp=0012ff48 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206
*** WARNING: Unable to verify checksum for UEF.exe
UEF!main+0x25:
00401035 c7050000000001000000 mov dword ptr ds:[0],1  ds:0023:00000000=????????

全文見 深入淺出 First chance, second chance和ExceptionPort

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.