Log in

View Full Version : Why the program crashed


Limee AKA Lamer
September 8th, 2004, 13:37
I establish a SEH handle to deal with
int 1 exception,why the porgram crashed?

.586
.model flat,stdcall
option casemap:none

include kernel32.inc
include user32.inc
include windows.inc

includelib kernel32.lib
includelib user32.lib

.data
szCaption db "SEH",0
szTextSTEP db "The Program run on Step mode!",0
szText db "the program run normally!",0
SafeEsp dd 0

assume fs:nothing
.code
start:
push SEH
push fs:[0]
mov fs:[0],esp
mov [SafeEsp],esp
int 1
nop
invoke MessageBox,0,offset szText,offset szCaption,MB_OK
jmp Exit
SEH:
invoke MessageBox,0,offset szTextSTEP,offset szCaption,MB_OK
Exit:
mov esp,[SafeEsp]
pop fs:[0]
add esp,4
invoke ExitProcess,0
end start
end

nikolatesla20
September 8th, 2004, 13:46
try
Code:

push offset SEH


-nt20

Limee AKA Lamer
September 8th, 2004, 14:16
00401000 PUSH INT1.00401031 ; SE handler installation
00401005 PUSH DWORD PTR FS:[0]
0040100C MOV DWORD PTR FS:[0],ESP
00401013 MOV DWORD PTR DS:[40302A],ESP
00401019 INT 1
0040101B NOP
0040101C PUSH 0 ; /Style = MB_OK|MB_APPLMODAL
0040101E PUSH INT1.00403000
00401023 PUSH INT1.00403019
00401028 PUSH 0
0040102A CALL <JMP.&user32.MessageBoxA>
0040102F JMP SHORT INT1.00401044
00401031 PUSH 0
00401033 PUSH INT1.00403000
00401038 PUSH INT1.00403004
0040103D PUSH 0
0040103F CALL <JMP.&user32.MessageBoxA> ; \MessageBoxA
00401044 MOV ESP,DWORD PTR DS:[40302A]
0040104A POP DWORD PTR FS:[0]
00401051 ADD ESP,4
00401054 PUSH 0 ; /ExitCode = 0
00401056 CALL <JMP.&kernel32.ExitProcess> ; \ExitProcess
0040105B INT3
0040105C JMP DWORD PTR DS:[<&kernel32.ExitProcess>
00401062 JMP DWORD PTR DS:[<&user32.MessageBoxA>]


-nt20[/QUOTE]

nikolatesla20
September 8th, 2004, 14:29
Your code works fine for me, must be some other problem.

-nt20

Limee AKA Lamer
September 8th, 2004, 14:40
Tell me your Compiler version?
Maybe is the compiler question.
Which system is your program run,win9x or 2000/XP?

Quote:
[Originally Posted by nikolatesla20]Your code works fine for me, must be some other problem.

-nt20

nikolatesla20
September 8th, 2004, 14:52
Im using MASM7.1, on both windows 2000 and windows XP, and it works fine when I compile this. I get the message box "Program run on step mode!"

Limee AKA Lamer
September 8th, 2004, 15:04
int 1 has be compiled CD 01,
change it to F1,then the program work fine
please tell me which machine code is your int 1?

00401000 PUSH INT1.00401030 ; SE handler installation
00401005 PUSH DWORD PTR FS:[0]
0040100C MOV DWORD PTR FS:[0],ESP
00401013 MOV DWORD PTR DS:[40302A],ESP
00401019 INT1
~~~~
if the INT1 is CD 01 the program will crash,
if the INT1 is F1 the program wil work fine.
please tell me your machine code,thanks.




Quote:
[Originally Posted by nikolatesla20]Im using MASM7.1, on both windows 2000 and windows XP, and it works fine when I compile this. I get the message box "Program run on step mode!"

Limee AKA Lamer
September 8th, 2004, 15:07
Then the Program work fine.The Compiler is so bad!

include windows.inc
includelib kernel32.lib
includelib user32.lib

.data
szCaption db "SEH",0
szTextSTEP db "程序执行了单步操作!",0
szText db "程序正常运行了!",0
SafeEsp dd 0

assume fs:nothing
.code
start:
push SEH ;自己的结构化异常处理函数
push fs:[0]
mov fs:[0],esp ;加入到SEH链表中
mov [SafeEsp],esp
; int 1
db 0F1H
nop
invoke MessageBox,0,offset szText,offset szCaption,MB_OK
jmp Exit
SEH:
invoke MessageBox,0,offset szTextSTEP,offset szCaption,MB_OK
Exit:
mov esp,[SafeEsp]
pop fs:[0]
add esp,4
invoke ExitProcess,0
end start
end


Quote:
[Originally Posted by nikolatesla20]Im using MASM7.1, on both windows 2000 and windows XP, and it works fine when I compile this. I get the message box "Program run on step mode!"