xiong's profile共享空间标题PhotosBlogLists Tools Help
    June 20

    How to debug UnhandleExceptionHandler!

    LONG WINAPI UnhandledExceptionFilter1(

      struct _EXCEPTION_POINTERS* ExceptionInfo

    )

      {

          MessageBox(0,"fdsa",0,0);

          return 0;

      }

     

    int main(int, char*)

    {

        SetUnhandledExceptionFilter(UnhandledExceptionFilter1);

        char *p=0;

        *p=0;

        return 0;

    }

     

    When running above code without debugger attached, the MessgeBox shows fine. However, when I attach windbg, the UnhandledExceptionFilter1 is not called any more. The behavior is by design and described in MSDN:

     

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/unhandledexceptionfilter.asp

     

    However, my customer uses self defined UnhandleExceptionHandler1 to do some jobs, and the function contains some bug. We need to debug the UnhandleExceptionHandler1 in windbg but as above test, the function is never called if windbg attached.

     

    I tried to change peb+2 to 0 to cheat the IsDebuggerPresent API. However it does not help.

     

    Is there any way to allow us to debug the UnhandleExceptionHandler1 function?

    ======

     

    Thanks Kwan Hyun Kim for providing the following superexcellent solution:

     

    1. put a bp on kernel32!UnhandledExceptionFilter

     

    0:000> bl

     0 e 00411410     0001 (0001)  0:**** uef!wmain

     1 e 004113be     0001 (0001)  0:**** uef!UnhandledExceptionFilter1+0x1e

     2 e 77e9951c     0001 (0001)  0:**** kernel32!UnhandledExceptionFilter

     

    2. debugger sees the first exception and run “g”

     

    0:000> g

    (a24.a08): Access violation - code c0000005 (first chance)

    First chance exceptions are reported before any exception handling.

    This exception may be expected and handled.

    eax=00000000 ebx=7ffde000 ecx=0012fe58 edx=7c82ed54 esi=0012fe90 edi=0012ff68

    eip=0041144c esp=0012fe90 ebp=0012ff68 iopl=0         nv up ei pl zr na pe nc

    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246

    uef!wmain+0x3c:

    0041144c c60000          mov     byte ptr [eax],0           ds:0023:00000000=??

     

    3. breakpoint 2 hit on kernel32!UnhandledExceptionFilter

     

    0:000> g

    Breakpoint 2 hit

    eax=0012fa9c ebx=00000000 ecx=10310980 edx=00000000 esi=00000000 edi=00000000

    eip=77e9951c esp=0012fa2c ebp=0012fa4c iopl=0         nv up ei pl zr na pe nc

    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246

    kernel32!UnhandledExceptionFilter:

    77e9951c 6830020000      push    230h

     

    4. run “g” to till you see a call to NtQueryInformationProcess (UnhandledExceptionFilter calls this function to see the process has a valid value in DebugPort field of EPROCESS)

     

    0:000> g 77e995cf

    eax=ffffffff ebx=00000004 ecx=77e98e31 edx=7c82ed54 esi=0012fa9c edi=00000000

    eip=77e995cf esp=0012f7c8 ebp=0012fa28 iopl=0         nv up ei ng nz na pe nc

    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000286

    kernel32!UnhandledExceptionFilter+0x84:

    77e995cf ff15b810e477    call    dword ptr [kernel32!_imp__NtQueryInformationProcess (77e410b8)] ds:0023:77e410b8={ntdll!ZwQueryInformationProcess (7c821998)}

     

    5. run “p” command to step over a call to NtQueryInformationProcess

     

    0:000> p

    eax=00000000 ebx=00000004 ecx=0012f7c0 edx=7c82ed54 esi=0012fa9c edi=00000000

    eip=77e995d5 esp=0012f7dc ebp=0012fa28 iopl=0         nv up ei ng nz na pe nc

    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000286

    kernel32!UnhandledExceptionFilter+0x8a:

    77e995d5 85c0            test    eax,eax

     

    6. eax has the return value, and change it into 0x80000000 <<< this is the trick

     

    0:000> r eax=80000000

     

    7. run “g” and your unhandledexceptionhandler will be called.

     

    0:000> g

    Breakpoint 1 hit

    eax=cccccccc ebx=00000004 ecx=00000000 edx=7c82ed54 esi=0012fa9c edi=0012f7d0

    eip=004113be esp=0012f704 ebp=0012f7d0 iopl=0         nv up ei pl nz na po nc

    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202

    uef!UnhandledExceptionFilter1+0x1e:

    004113be 8bf4            mov     esi,esp

     

    http://eparg.spaces.msn.com/blog/cns!59BFC22C0E7E1A76!1208.entry

     

    Comments (9)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    No namewrote:
    http://www.batteryfast.com/hp/nc6120.htm hp nc6120 battery
    http://www.batteryfast.com/dell/inspiron-1100-series.htm dell inspiron 1100 series battery
    http://www.batteryfast.com/dell/inspiron-1150.htm dell inspiron 1150 battery
    http://www.batteryfast.com/dell/inspiron-5150.htm dell inspiron 5150 battery
    http://www.batteryfast.com/dell/inspiron-5160.htm dell inspiron 5160 battery
    http://www.batteryfast.com/dell/inspiron-5100.htm dell inspiron 5100 battery
    http://www.batteryfast.com/dell/latitude-131l.htm dell latitude 131l battery
    http://www.batteryfast.com/dell/vostro-1000.htm dell vostro 1000 battery
    http://www.batteryfast.com/dell/gd761.htm dell gd761 battery
    http://www.batteryfast.com/dell/nt379.htm dell nt379 battery
    http://www.batteryfast.com/dell/latitude-d531.htm dell latitude d531 battery
    http://www.batteryfast.com/dell/precision-m65.htm dell precision m65 battery
    http://www.batteryfast.com/dell/vostro-1700.htm dell vostro 1700 battery
    http://www.batteryfast.com/gateway/8msb.htm gateway 8msb battery
    http://www.batteryfast.com/hp/pb992a.htm hp pb992a battery
    http://www.batteryfast.com/hp/dv2100.htm hp dv2100 battery
    http://www.batteryfast.com/hp/dv2200.htm hp dv2200 battery
    http://www.batteryfast.com/hp/hstnn-c29c.htm hp hstnn-c29c battery
    http://www.batteryfast.com/hp/nc8000.htm hp nc8000 battery
    http://www.batteryfast.com/dell/inspiron-b120.htm dell inspiron b120 battery
    http://www.batteryfast.com/dell/inspiron-b130.htm dell inspiron b130 battery
    http://www.batteryfast.com/gateway/12msbg.htm gateway 12msbg battery
    http://www.batteryfast.com/hp/7400.htm hp 7400 battery
    http://www.batteryfast.com/dell/inspiron-b120.htm dell inspiron b120 battery
    http://www.batteryfast.com/toshiba/pa3356u.htm toshiba pa3356u battery
    http://www.batteryfast.com/hp/2510p.htm hp 2510p battery
    http://www.batteryfast.com/hp/f3172a.htm hp f3172a battery
    http://www.batteryfast.com/dell/inspiron-2200.htm dell inspiron 2200 battery
    http://www.batteryfast.com/gateway/squ-414.htm gateway squ-414 battery
    http://www.batteryfast.com/hp/hstnn-lb33.htm hp hstnn-lb33 battery
    http://www.batteryfast.com/mitac/bp-8089.htm mitac bp-8089 battery
    http://www.batteryfast.com/toshiba/satellite-m55.htm toshiba satellite m55 battery
    http://www.batteryfast.com/toshiba/satellite-m115.htm toshiba satellite m115 battery
    http://www.batteryfast.com/toshiba/qosmio-f25.htm toshiba qosmio f25 battery
    http://www.batteryfast.com/toshiba/satellite-m60.htm toshiba satellite m60 battery
    http://www.batteryfast.com/toshiba/satellite-p200.htm toshiba satellite p200 battery
    http://www.batteryfast.com/toshiba/pa3536u-1brs.htm toshiba pa3536u-1brs battery
    http://www.batteryfast.com/hp/hstnn-db17.htm hp hstnn-db17 battery
    http://www.akkuliste.com/hp/411462-421.htm hp 411462-421 akku
    http://www.akkuliste.com/hp/ev088aa.htm hp ev088aa akku
    http://www.akkuliste.com/hp/ex941aa.htm hp ex941aa akku
    http://www.akkuliste.com/laptop akku
    http://www.akkuliste.com/laptop batteries
    http://www.akkuliste.com/dell laptop batteries/
    http://www.akkuliste.com/dell/wr050.htm dell wr050 akku
    Nov. 10
    No namewrote:
    http://www.adapterlist.com/acer/as07b31.htm acer as07b31 battery
    http://www.adapterlist.com/laptop-ac-adapter/toshiba/toshiba-15V-5A-75w-6.3mm-3.0mm.php
    http://www.adapterlist.com/laptop-ac-adapter/toshiba/toshiba-15V-6A-90w-6.3mm-3.0mm.php
    http://www.adapterlist.com/laptop-ac-adapter/toshiba/toshiba-19V-3.42A-65w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/toshiba/toshiba-19V-4.74A-90w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/samsung/samsung-19V-3.16A-60w-5.5mm-3.4mm-pin-inside.php
    http://www.adapterlist.com/laptop-ac-adapter/liteon/liteon-19V-3.95A-75w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/liteon/liteon-19V-4.74A-90w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/liteon/liteon-19V-6.3A-120w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/liteon/liteon-19V-6.3A-120w-4pin-round.php
    http://www.adapterlist.com/laptop-ac-adapter/liteon/liteon-19V-3.42A-65w-5.5mm-2.5mm-white.php
    http://www.adapterlist.com/laptop-ac-adapter/toshiba/toshiba-15V-8A-120w-special-4-hole.php
    http://www.adapterlist.com/laptop-ac-adapter/liteon/liteon-19V-4.74A-90w-5.5mm-1.7mm.php
    http://www.adapterlist.com/laptop-ac-adapter/hp/hp-19V-4.74A-90w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/hp/hp-18.5V-3.5A-65w-4.8mm-1.7mm.php
    http://www.adapterlist.com/laptop-ac-adapter/hp/hp-19V-4.74A-90w-4.8mm-1.7mm.php
    http://www.adapterlist.com/laptop-ac-adapter/acer/acer-19V-3.42A-65w-5.5mm-2.5mm-big-head.php
    http://www.adapterlist.com/laptop-ac-adapter/acer/acer-19V-3.42A-65w-5.5mm-1.5mm-small-head.php
    http://www.adapterlist.com/laptop-ac-adapter/fujitsu/fujitsu-19V-4.74A-90w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/dell/dell-19V-3.16A-60w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/dell/dell-20V-3.5A-70w-horseshoe-style-special-for-dell-pa-6.php
    http://www.adapterlist.com/laptop-ac-adapter/compaq/compaq-19V-4.74A-90w-5.5mm-2.5mm.php
    http://www.adapterlist.com/laptop-ac-adapter/dell/dell-19.5V-3.34A-65w-7.4mm-5.0mm-with-pin-pa-12.php
    http://www.adapterlist.com/laptop-ac-adapter/asus/asus-19v-3.42A-65w-5.5mm-2.5mm.php
    http://www.adapterlist.com/dell/latitude-d620.htm dell latitude d620 battery
    http://www.adapterlist.com/acer/as07b41.htm acer as07b41 battery
    http://www.adapterlist.com/dell/xps-1330.htm dell xps 1330 battery
    http://www.adapterlist.com/dell/xps-m1330.htm dell xps m1330 battery
    http://www.adapterlist.com/acer/as07b42.htm acer as07b42 battery
    http://www.adapterlist.com/acer/as07b72.htm acer as07b72 battery
    http://www.adapterlist.com/acer/as07b52.htm acer as07b52 battery
    http://www.adapterlist.com/acer/travelmate-4200.htm acer travelmate 4200 battery
    http://www.adapterlist.com/acer/aspire-5100.htm acer aspire 5100 battery
    Oct. 27
    Oct. 26
    http://www.adapterlist.com/toshiba/pa3331u-1brs.htm toshiba pa3331u-1brs battery
    http://www.adapterlist.com/compaq/nx9005.htm compaq nx9005 battery
    http://www.adapterlist.com/asus/w1.htm asus w1 battery
    http://www.adapterlist.com/asus/w3a.htm asus w3a battery
    http://www.adapterlist.com/asus/w3n.htm asus w3n battery
    http://www.adapterlist.com/asus/w3000a.htm asus w3000a battery
    http://www.adapterlist.com/asus/m6000-silver.htm asus m6000 silver battery
    http://www.adapterlist.com/compaq/presario-1200.htm compaq presario 1200 battery
    http://www.adapterlist.com/compaq/presario-1600.htm compaq presario 1600 battery
    http://www.adapterlist.com/compaq/presario-1800.htm compaq presario 1800 battery
    http://www.adapterlist.com/compaq/nc8000.htm compaq nc8000 battery
    http://www.adapterlist.com/compaq/nx5000.htm compaq nx5000 battery
    http://www.adapterlist.com/compaq/n600.htm compaq n600 battery
    http://www.adapterlist.com/compaq/n610c.htm compaq n610c battery
    http://www.adapterlist.com/dell/1691p.htm dell 1691p battery
    http://www.adapterlist.com/dell/inspiron-9100.htm dell inspiron 9100 battery
    http://www.adapterlist.com/gateway/squ-413.htm gateway squ-413 battery
    http://www.adapterlist.com/dell/latitude-d531.htm dell latitude d531 battery
    http://www.adapterlist.com/acer/travelmate-4200.htm acer travelmate 4200 battery
    http://www.adapterlist.com/ibm/02k7072.htm ibm 02k7072 battery
    http://www.adapterlist.com/mitac/bp-8089x.htm mitac bp-8089x battery
    http://www.adapterlist.com/mitac/bp-8389.htm mitac bp-8389 battery
    http://www.adapterlist.com/mitac/bp-8089p.htm mitac bp-8089p battery
    http://www.adapterlist.com/toshiba/pa3128u.htm toshiba pa3128u battery
    http://www.adapterlist.com/toshiba/pa3191u.htm toshiba pa3191u battery
    http://www.adapterlist.com/toshiba/portege-m200.htm toshiba portege m200 battery
    http://www.adapterlist.com/toshiba/pa3128u-grey.htm toshiba pa3128u grey battery
    http://www.adapterlist.com/toshiba/pa3191u-grey.htm toshiba pa3191u grey battery
    http://www.adapterlist.com/toshiba/a70.htm toshiba a70 battery
    http://www.adapterlist.com/acer/btp-amj1.htm acer btp-amj1 battery
    http://www.adapterlist.com/asus/al23-901.htm asus al23-901 battery
    http://www.adapterlist.com/hp/nx7000.htm hp nx7000 battery
    http://www.adapterlist.com/hp/presario-x1000.htm hp presario x1000 battery
    http://www.adapterlist.com/gateway/m1200.htm gateway m1200 battery
    http://www.adapterlist.com/gateway/m1300.htm gateway m1300 battery
    http://www.adapterlist.com/acer/aspire-3690.htm acer aspire 3690 battery
    http://www.adapterlist.com/dell/312-039.htm dell 312-039 battery
    http://www.adapterlist.com/hp/hstnn-fb44.htm hp hstnn-fb44 battery
    http://www.adapterlist.com/toshiba/satellite-x200.htm toshiba satellite x200 battery
    http://www.adapterlist.com/hp/hstnn-db02.htm hp hstnn-db02 battery
    http://www.adapterlist.com/acer/btp-63d1.htm acer btp-63d1 battery
    http://www.adapterlist.com/acer/aspire-3020.htm acer aspire 3020 battery
    http://www.adapterlist.com/acer/aspire-3610.htm acer aspire 3610 battery
    http://www.adapterlist.com/hp/nx5000.htm hp nx5000 battery
    http://www.adapterlist.com/hp/nw8000.htm hp nw8000 battery
    Oct. 23
    http://www.toplaptopbatteries.com/gateway/bat0016.php Gateway bat0016 m1200 m1300 battery
    http://www.toplaptopbatteries.com/gateway/btp-68b3.php Gateway m500 m505 medion md2900 md6179 battery
    http://www.toplaptopbatteries.com/hp/320912-001.php HP nc8200 nc8230 7400 battery
    http://www.toplaptopbatteries.com/hp/336962-001-002-battery.php HP zt3000 zt3010us 337607-001 battery
    http://www.toplaptopbatteries.com/hp/364602-001.php HP nx6120 nc6100 nc6120 nx6100 nc6200 battery
    http://www.toplaptopbatteries.com/hp/dv6000.php HP hstnn-db42 dv2000 dv6000 v6000 battery
    http://www.toplaptopbatteries.com/hp/dv9000.php HP hstnn-lb33 dv9000 dv9700 dv9600 battery
    http://www.toplaptopbatteries.com/hp/hp510.php HP 510 530 hstnn-fb40 battery
    http://www.toplaptopbatteries.com/hp/hp520.php HP 500 hstnn-fb39 434045-661 battery

    http://www.toplaptopbatteries.com/hp/hstnn-c16c.php HP dv8000 dv8100 dv8200 battery
    http://www.toplaptopbatteries.com/hp/hstnn-db02.php HP hstnn-ib04 346970-001 hstnn-db02 battery
    http://www.toplaptopbatteries.com/hp/hstnn-db17.php HP m2000 dv1000 dv4000 battery
    http://www.toplaptopbatteries.com/hp/nc2400-battery.php HP 2510p nc2400 eh768aa battery
    http://www.toplaptopbatteries.com/hp/nc4000.php HP nc4010 dd880a nc4000 battery
    http://www.toplaptopbatteries.com/hp/nc6000.php HP nx5000 nc6000 nc8000 dg105a battery
    http://www.toplaptopbatteries.com/hp/zt1000.php HP zt1000 f2299a f3172b f3172a battery
    http://www.toplaptopbatteries.com/ibm/02k7055.php IBM 02k6928 02k7055 thinkpad r32 r40 battery
    http://www.toplaptopbatteries.com/ibm/02k7072.php IBM 02k7072 02k7034 thinkpad t30 battery

    http://www.toplaptopbatteries.com/ibm/41n5666.php IBM thinkpad t60 92p1141 battery
    http://www.toplaptopbatteries.com/ibm/92p1000.php IBM thinkpad x40 x41 92p1002 battery
    http://www.toplaptopbatteries.com/mitac/8050-battery.php Mitac bp-8050(p) MIM2120 battery
    http://www.toplaptopbatteries.com/mitac/8375.php Mitac 8375 8575 8575a black battery
    http://www.toplaptopbatteries.com/mitac/2364978.php Mitac 8375 8575 8575a white battery
    http://www.toplaptopbatteries.com/mitac/advent8089.php Mitac bp-8089 bp-8089x bp-8389 battery
    http://www.toplaptopbatteries.com/mitac/bp-8599.php Mitac bp-8x99,bp-8599 battery
    http://www.toplaptopbatteries.com/nec/op-570-75901.php Nec pc-vp-wp44 op-570-75901 battery
    http://www.toplaptopbatteries.com/sony/pcga-bp2sa-battery.php Sony pcga-bp2s pcga-bp2sa battery
    Oct. 21
    No namewrote:

    Hi,Do you have used LCDs, second hand LCDs, used flat screens and used LCD monitors? Please go here:www.sstar-hk.com(Southern Stars).We are constantly buying re-usable LCD panels and working for LCD recycling.The re-usable panels go through strictly designed process of categorizing, checking, testing, repairing and refurbishing before they are re-used to make remanufactured LCD displays and TV sets.Due to our recent breakthrough in testing and repairing technology of LCD, we can improve the value for your LCD panels. website:www.sstar-hk.com[begijhefbjefga]

    Oct. 18
    Jan. 17
    Oct. 9
    Bonnie W.wrote:
    O...
     
    MY...
     
    GOD...
    June 20

    Trackbacks

    The trackback URL for this entry is:
    http://eparg.spaces.live.com/blog/cns!59BFC22C0E7E1A76!1208.trak
    Weblogs that reference this entry
    • None