flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Teehee
Code: try { } catch (Exception) { } _________________ Sorry if bad english. |
|||
![]() |
|
Teehee
wow, thats so big.. but i can't understand macros yet.
![]() |
|||
![]() |
|
revolution
It is probably easier just to make your code correct and never generate exceptions.
Try/catch is the only way I know of to use into in a Windows proggy. But who ever used it anyway even in the DOS days when you could? |
|||
![]() |
|
revolution
BTW: did you know that the WM_TIMER callback is run under the API try/catch block? This means you can't use int3 to trigger a debugger, it gets swallowed by the handler and your proggy continues to run.
![]() |
|||
![]() |
|
vid
Most often I have seen try/catch implemented in C using setjmp() / longjmp() mechanism.
Basically you just save stack pointer and address where to jump on every "try", stack up these structures, and on exception go back over them until you find appropriate catch for the type of exception that was thrown. This becomes useful when you have ability to automatically call "destructors" of objects that needs some extra code upon release (like open file handles, allocated memory, etc.). This is not very much possible to do (in sane way) in ASM or C, and so try/catch isn't used so often either. |
|||
![]() |
|
revolution
vid wrote: Most often I have seen try/catch implemented in C using setjmp() / longjmp() mechanism. |
|||
![]() |
|
vid
Depends on implementation
![]() Supposing we are speaking of Windows, I never checked. However, I saw it used somewhere in HAL.DLL, and I am not really so sure SEH can be used there. In userland, my guess would be SEH is used. |
|||
![]() |
|
b1528932
in userland, exceptions will NEVER occur. And if they do there is nbothing u can do about them, just kill the app.
In kernel mode however, its diffrent story. Windows provide SEH. structure at address 0 holds NT_TIB, and NT_TIB holds exception records. each one is called by exception handler (well not exactly, exception handler return control to userland first, then userland function calls them). If they return something - next is invoked, if theyt return something else - execution is halted. you have to change ip/registers manually to fix the exception issue. |
|||
![]() |
|
revolution
b1528932 wrote: in userland, exceptions will NEVER occur. b1528932 wrote: And if they do there is nbothing u can do about them, just kill the app. |
|||
![]() |
|
baldr
Teehee,
There are try/catch and __try/__catch. They are different. Matt Pietrek described them in MSJ June 1997 "Under the hood" column; OpenRCE contains fine article about MSVC implementation details. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.