Daily Archives

3 Articles

Posted by Oleksandr Golovatyi on

Structured Exception Handling basics

OS provides SEH to deal directly with crashes.

SEH is language independent but is usually implemented in C/C++.

Pair __try/__except allows to set code inside __try and handle exception in __except (http://msdn.microsoft.com/de-de/library/s58ftw19.aspx). Pair __try/__finally ensures that section of code in __finally is always executed even if __try block terminates prematurely (http://msdn.microsoft.com/de-de/library/9xtt5hxz.aspx).

__except is an exception filter for one of 3 values:

Value Meaning
EXCEPTION_EXECUTE_HANDLER The system transfers control to the exception handler, and execution continues in the stack frame in which the handler is found.
EXCEPTION_CONTINUE_SEARCH The system continues to search for a handler.
EXCEPTION_CONTINUE_EXECUTION The system stops its search for a handler and returns control to the point at which the exception occurred. If the exception is noncontinuable, this results in an EXCEPTION_NONCONTINUABLE_EXCEPTION exception.
void f() { __try { __try { // some code } __except (EXCEPTION_EXECUTE_HANDLER) { // process the exception } } __finally { // executed regardless of whether function caused a crash } }

Exception handler can determine exception value with GetExceptionCode function (http://msdn.microsoft.com/en-us/library/ms679356(VS.85).aspx) which can be called only in exception filters.

__try { n = x / y; } __except (EXCEPTION_INT_DIVIDE_BY_ZERO == GetExceptionCode() ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { n = NaN; }

In __except user function can be called. GetExceptionInformation (http://msdn.microsoft.com/en-us/library/ms679357(VS.85).aspx) returns a pointer to structure with exception info.

To generate an exception RaiseException (http://msdn.microsoft.com/en-us/library/ms680552(VS.85).aspx) can be used.

SEH limitations:

  • error codes are limited to unsigned int.
  • doesn’t mix with C++ exceptions.
  • doesn’t call any of object destructors.

Additional reading:

Posted by Oleksandr Golovatyi on

Visual Studio: форматуючі символи для вікна Watch

Formatting Symbols for Watch Window

Symbol

Description

Sample

Displays

d, i

Signed decimal int

(int)0xF000F064,d

-268373915

u

Unsigned decimal int

0x0065,u

101

o

Unsigned octal decimal

0xF065,o

0170145

x, X

Hexidecimal integer

61541,x

0x0000F065

l, h

Long or short prefix for d, I, u, o, x, X

0x0042406042,hx

0x0c22

f

Signed float

3./2,f

1.500000

e

Signed float, scientific notation

3./2,e

1.500000e+00

g

Signed float or signed scientific, which one is shorter

3./2,g

1.5

c

char

0x0065,c

‘e’

s

string

szHiWorlds,z

“Hello world”

su

Unicode string

szWHiWorlds,su

“Hello world”

st

Unicode or ANSI string, dependint on settings in autoext.dat

   

hr

HRESULT or Win32 error code

0,hr

S_OK

wc

Window class flag

0x0040,wc

WC_DEFAULTCHAR

wm

Windows message

0x0010,wm

WM_CLOSE

Posted by Oleksandr Golovatyi on

Pay It Forward (2000)

 

Ідея дуже цікава і весь час чекаєш на розвиток. Але нажаль усе закінчується рожевими шмарклями…

 

І фільм начебто непоганий, і тим не менш після перегляду є якесь розчарування, наче надурили.

http://www.imdb.com/title/tt0223897/

 

 

[youtube=http://www.youtube.com/watch?v=_pCtXRP1edo&w=640&h=385&hd=1]