Hello,ALL

here is an Error Handle code written by Comrade. i modified a little to find my code error. but the code can't show more information.
I need to show follow:

1. Exception style
2. ALL registers

(ContextFlags? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? ?0h
? iDr0? ? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? ?4h
? iDr1? ? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? ?8h
? iDr2? ? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 0Ch
? iDr3? ? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 10h
? iDr6? ? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 14h
? iDr7? ? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 18h
? FloatSave? ? ?FLOATING_SAVE_AREA <>? ? ? ?;offset? ? 1Ch
? ? ? ?;(sizeof FLOATING_SAVE_AREA = 70h)
? regGs? ? ? ? ?DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 8Ch (1Ch + 70h)
? regFs? ? ? ? ?DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 90h
? regEs? ? ? ? ?DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 94h
? regDs? ? ? ? ?DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 98h
? regEdi? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ? 9Ch
? regEsi? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0A0h
? regEbx? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0A4h
? regEdx? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0A8h
? regEcx? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0ACh
? regEax? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0B0h
? regEbp? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0B4h
? regEip? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0B8h
? regCs? ? ? ? ?DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0BCh
? regFlag? ? ? ?DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0D0h
? regEsp? ? ? ? DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0D4h
? regSs? ? ? ? ?DWORD? ? ? ?? ? ? ? ? ? ? ? ;offset? ?0D8h
)

3. All Segment registers
4. Stack.
;=========================================
;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat, stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

include \masm32\macros\macros.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
m2m MACRO M1, M2
push M2
pop M1
ENDM
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ErrorHandler PROTO C :DWORD,:DWORD,:DWORD,:DWORD
ExceptionFilter PROTO :DWORD
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.const
szErrorThread db 13, 10, "Error at %08Xh", 13, 10, "Registers:", 13, 10, "eax = %08Xh ebx = %08Xh ecx = %08Xh", 13, 10, "edx = %08Xh esp = %08Xh ebp = %08Xh", 13, 10, "esi = %08Xh edi = %08Xh", 13, 10, 13, 10, "Recovering...", 13, 10,0
szErrorFinal db 13, 10, "Error at %08Xh", 13, 10, "Quitting...", 13, 10, 0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
szMessage db 256 dup (?)
seh dd 6 dup (?)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
start:
invoke GetModuleHandle,NULL
invoke SetUnhandledExceptionFilter, ADDR ExceptionFilter
; install the SEH-frame
assume fs:nothing
push OFFSET ErrorHandler
push FS:[0]
mov , esp
mov , ebp
mov , ebx
mov , esi
mov , edi
mov , OFFSET @@safe
mov FS:[0], esp
; critical code
; zero uninitialized data
;==============================================================================
; here is your code
int 3
;mov eax,0
;mov ecx,2
;div ecx
;==============================================================================
push edi
push esi
push ebx
@@exit:
pop ebx
pop esi
pop edi
@@safe:
pop FS:[0]
jmp ExitProcess
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ErrorHandler proc C lpExcept:DWORD, lpFrame:DWORD, lpContext:DWORD, lpDispatch:DWORD
mov eax, lpExcept
mov ecx, lpContext
invoke wsprintf, ADDR szMessage, ADDR szErrorThread, ,\
, , , ,\
, , ,
invoke MessageBox,NULL, ADDR szMessage, SADD("1_Error Occured"),MB_ICONEXCLAMATION

mov eax, lpContext
m2m ,
m2m ,
m2m ,
m2m ,
m2m ,
m2m ,

xor eax, eax ; continue execution
ret
ErrorHandler endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ExceptionFilter proc lpExcept:DWORD
mov eax, lpExcept
invoke wsprintf, ADDR szMessage, ADDR szErrorFinal,
invoke MessageBox,NULL, ADDR szMessage, SADD("2_Error Occured"),MB_ICONEXCLAMATION
invoke ExitProcess, 0
xor eax, eax
inc eax ; EXCEPTION_EXECUTE_HANDLER
ret
ExceptionFilter endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

end start

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=ErrorHandle_1

? ? \masm32\bin\ml /c /coff %name%.bat
? ? \masm32\bin\Link /subsystem:windows %name%.obj
? ?
? ? if exist *.bak del *.bak
? ? if exist *.obj del *.obj
echo.
;=========================================
regards
Posted on 2005-08-18 09:40:07 by dcskm4200
I don't understand. What error did you encounter? the int3 is placed in the code to generate an exception btw.
Posted on 2005-08-18 10:47:51 by roticv
Hello, roticv

Thanks you for response.
of course, the code didn't exist in Error. my means is to help me for boosting up the function.

regards.
Posted on 2005-08-18 19:41:31 by dcskm4200
Hello,

Okay I see that I misread your post.

1. You just need to extract the registers values in the context structure passed by the value in ecx and modifying the below code so that the register values would be displayed in your MessageBox.


  invoke  wsprintf, ADDR szMessage, ADDR szErrorThread, ,\
      , , , ,\
      , , ,


2. You can extract the exception code from lpexcept. Take a look at http://www.jorgon.freeserve.co.uk/TestbugHelp/Exceptions.htm
Posted on 2005-08-19 06:41:12 by roticv
Hello, roticv

Thanks you for help.

it is helpful to improve the code. I need more times to read the article carefully.

regards.
Posted on 2005-08-19 08:10:47 by dcskm4200