Ignore:
Timestamp:
Nov 5, 2007, 3:25:55 AM (17 years ago)
Author:
dai
Message:

例外処理機構実装中...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/system/exception.ab

    r249 r372  
    33Class TryLayer
    44Public
    5     Const AddressOfCatch As VoidPtr
    6     Const StackPtr As LONG_PTR
     5    Const addressOfCatch As VoidPtr
     6    Const basePtr As LONG_PTR
     7    Const stackPtr As LONG_PTR
    78    context As CONTEXT
    89    Const debugProcNum As DWord
    910   
    10     Sub TryLayer( AddressOfCatch As VoidPtr, StackPtr As LONG_PTR )
    11         This.AddressOfCatch = AddressOfCatch
    12         This.StackPtr = StackPtr
     11    Sub TryLayer( addressOfCatch As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR )
     12        This.addressOfCatch = addressOfCatch
     13        This.basePtr = basePtr
     14        This.stackPtr = stackPtr
    1315
    14         context.ContextFlags=CONTEXT_ALL
    15         If Thread.CurrentThread().__GetContext(context) = 0 Then
     16        Dim tempContext As CONTEXT
     17
     18        tempContext.ContextFlags = CONTEXT_CONTROL or CONTEXT_INTEGER
     19        If Thread.CurrentThread().__GetContext(tempContext) = 0 Then
    1620            ' TODO: エラー処理
    1721            debug
    1822        End If
     23        context = tempContext
    1924
    2025#ifdef _DEBUG
     
    5358
    5459    'Try
    55     Function BeginTryScope( AddressOfCatch As VoidPtr, StackPtr As LONG_PTR ) As TryLayer
     60    Function BeginTryScope( addressOfCatch As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer
    5661        ppTryLayers = _System_realloc( ppTryLayers, ( nTryLayers + 1 ) * SizeOf( *TryLayer ) )
    57         ppTryLayers[nTryLayers] = New TryLayer( AddressOfCatch, StackPtr )
     62        ppTryLayers[nTryLayers] = New TryLayer( addressOfCatch, basePtr, stackPtr )
    5863        nTryLayers++
    5964
     
    8792        '--------------------------------------------------
    8893
     94        'レジスタ情報を取得
     95        Dim context = ppTryLayers[nTryLayers - 1]->context
     96
    8997        'カレント スレッドを取得
    9098        Dim thread = Thread.CurrentThread
    9199
    92         'レジスタ情報を取得
    93         Dim context = ppTryLayers[nTryLayers - 1]->context
    94 debug
    95100        '新しいip, spをセット
    96101#ifdef _WIN64
    97         context.Rip = ppTryLayers[nTryLayers - 1]->AddressOfCatch As QWord
    98         'context.Rsp = ppTryLayers[nTryLayers - 1]->StackPtr
     102        context.Rip = ppTryLayers[nTryLayers - 1]->addressOfCatch As QWord
     103        context.Rbp = ppTryLayers[nTryLayers - 1]->basePtr
     104        context.Rsp = ppTryLayers[nTryLayers - 1]->stackPtr
    99105#else
    100         context.Eip = ppTryLayers[nTryLayers - 1]->AddressOfCatch As DWord
    101         context.Esp = ppTryLayers[nTryLayers - 1]->StackPtr
     106        context.Eip = ppTryLayers[nTryLayers - 1]->addressOfCatch As DWord
     107        context.Ebp = ppTryLayers[nTryLayers - 1]->basePtr
     108        context.Esp = ppTryLayers[nTryLayers - 1]->stackPtr
    102109#endif
    103110
     
    109116        End If
    110117#endif
    111 
     118debug
    112119        If thread.__SetContext( context ) = 0 Then
    113120            OutputDebugString(Ex"レジスタ情報の設定に失敗しました。\r\n")
    114121            Return
    115122        End If
     123        debug
    116124    End Sub
    117125
Note: See TracChangeset for help on using the changeset viewer.