[232] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[237] | 3 | #define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
|
---|
[232] | 4 |
|
---|
[465] | 5 | const ::DllProc &Schedule::GetDllProc() const
|
---|
| 6 | {
|
---|
[549] | 7 | _ASSERT( type == Schedule::DllProc );
|
---|
[465] | 8 | return *pDllProc;
|
---|
| 9 | }
|
---|
| 10 | const ::UserProc &Schedule::GetUserProc() const
|
---|
| 11 | {
|
---|
[549] | 12 | _ASSERT( type == Schedule::UserProc || type == Schedule::AddressOf || type == Schedule::CatchAddress );
|
---|
[465] | 13 | return *pUserProc;
|
---|
| 14 | }
|
---|
| 15 | const ::CClass &Schedule::GetClass() const
|
---|
| 16 | {
|
---|
[549] | 17 | _ASSERT( type == Schedule::ComVtbl || type == Schedule::Vtbl || type == Schedule::TypeInfo );
|
---|
[465] | 18 | return *pClass;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
[287] | 21 | void NativeCode::PutEx( const NativeCode &nativeCode )
|
---|
[232] | 22 | {
|
---|
[287] | 23 | long baseOffset = GetSize();
|
---|
[257] | 24 |
|
---|
[263] | 25 | // コードバッファを追加
|
---|
[287] | 26 | Put( nativeCode.GetBuffer(), nativeCode.GetSize() );
|
---|
[257] | 27 |
|
---|
[263] | 28 | // スケジュールを追加
|
---|
[257] | 29 | BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
|
---|
| 30 | {
|
---|
| 31 | this->schedules.push_back(
|
---|
| 32 | Schedule(
|
---|
| 33 | schedule.GetType(),
|
---|
[258] | 34 | baseOffset + schedule.GetOffset(),
|
---|
| 35 | schedule.GetLongPtrValue()
|
---|
[257] | 36 | )
|
---|
| 37 | );
|
---|
| 38 | }
|
---|
[263] | 39 |
|
---|
| 40 | // ソースコード行番号とネイティブコード位置の対応情報を追加
|
---|
| 41 | BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
|
---|
| 42 | {
|
---|
| 43 | this->sourceLines.push_back(
|
---|
| 44 | SourceLine(
|
---|
| 45 | baseOffset + sourceLine.GetNativeCodePos(),
|
---|
[637] | 46 | sourceLine.GetCodeType(),
|
---|
| 47 | sourceLine.GetSourceCodePosition()
|
---|
[263] | 48 | )
|
---|
| 49 | );
|
---|
| 50 | }
|
---|
[257] | 51 | }
|
---|
| 52 |
|
---|
[357] | 53 | void NativeCode::PutEx( long l, Schedule::Type scheduleType )
|
---|
| 54 | {
|
---|
[551] | 55 | if( scheduleType != Schedule::None )
|
---|
[357] | 56 | {
|
---|
[551] | 57 | schedules.push_back( Schedule( scheduleType, GetSize() ) );
|
---|
[357] | 58 | }
|
---|
| 59 |
|
---|
[551] | 60 | Put( l );
|
---|
[357] | 61 | }
|
---|
| 62 |
|
---|
[245] | 63 | void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
|
---|
| 64 | {
|
---|
| 65 | pUserProc->Using();
|
---|
| 66 |
|
---|
[550] | 67 | Schedule::Type type = isCall ? Schedule::UserProc : Schedule::AddressOf;
|
---|
[245] | 68 |
|
---|
[550] | 69 | schedules.push_back( Schedule( type, pUserProc, GetSize() ) );
|
---|
| 70 |
|
---|
[287] | 71 | Put( (long)0 );
|
---|
[245] | 72 | }
|
---|
[250] | 73 |
|
---|
[357] | 74 | void NativeCode::PutCatchAddressSchedule( const UserProc *pUserProc, long codePos )
|
---|
| 75 | {
|
---|
| 76 | pUserProc->Using();
|
---|
| 77 |
|
---|
[550] | 78 | schedules.push_back( Schedule( Schedule::CatchAddress, pUserProc, GetSize() ) );
|
---|
[357] | 79 |
|
---|
| 80 | Put( codePos );
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[250] | 83 | void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
|
---|
| 84 | {
|
---|
| 85 | pDllProc->Using();
|
---|
| 86 |
|
---|
[287] | 87 | schedules.push_back( Schedule( pDllProc, GetSize() ) );
|
---|
[250] | 88 |
|
---|
[287] | 89 | Put( (long)0 );
|
---|
[250] | 90 | }
|
---|
[263] | 91 |
|
---|
[370] | 92 | void NativeCode::PutComVtblSchedule( const CClass *pClass )
|
---|
| 93 | {
|
---|
| 94 | schedules.push_back( Schedule( Schedule::ComVtbl, pClass, GetSize() ) );
|
---|
| 95 |
|
---|
| 96 | Put( (long)0 );
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[282] | 99 | void NativeCode::PutVtblSchedule( const CClass *pClass )
|
---|
| 100 | {
|
---|
[370] | 101 | schedules.push_back( Schedule( Schedule::Vtbl, pClass, GetSize() ) );
|
---|
[282] | 102 |
|
---|
[287] | 103 | Put( (long)0 );
|
---|
[282] | 104 | }
|
---|
| 105 |
|
---|
[637] | 106 | void NativeCode::NextSourceLine( const SourceCodePosition &sourceCodePosition )
|
---|
[263] | 107 | {
|
---|
| 108 | if( sourceLines.size() )
|
---|
| 109 | {
|
---|
[287] | 110 | if( sourceLines.back().GetNativeCodePos() == GetSize() )
|
---|
[263] | 111 | {
|
---|
[637] | 112 | sourceLines.back().SetSourceCodePosition( sourceCodePosition );
|
---|
[263] | 113 | return;
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | extern BOOL bDebugSupportProc;
|
---|
| 118 | extern BOOL bSystemProc;
|
---|
| 119 | DWORD sourceLineType = 0;
|
---|
| 120 | if( bDebugSupportProc )
|
---|
| 121 | {
|
---|
| 122 | sourceLineType |= CODETYPE_DEBUGPROC;
|
---|
| 123 | }
|
---|
| 124 | if( bSystemProc )
|
---|
| 125 | {
|
---|
| 126 | sourceLineType |= CODETYPE_SYSTEMPROC;
|
---|
| 127 | }
|
---|
[280] | 128 | sourceLines.push_back(
|
---|
| 129 | SourceLine(
|
---|
[287] | 130 | GetSize(),
|
---|
[637] | 131 | sourceLineType,
|
---|
| 132 | sourceCodePosition
|
---|
[280] | 133 | )
|
---|
| 134 | );
|
---|
[263] | 135 | }
|
---|
[273] | 136 |
|
---|
| 137 | void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
|
---|
| 138 | {
|
---|
| 139 | BOOST_FOREACH( const Schedule &schedule, schedules )
|
---|
| 140 | {
|
---|
| 141 | if( schedule.GetType() == Schedule::DataTable )
|
---|
| 142 | {
|
---|
| 143 | Overwrite(
|
---|
| 144 | schedule.GetOffset(),
|
---|
| 145 | GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
|
---|
| 146 | );
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
[637] | 150 | void NativeCode::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
|
---|
[280] | 151 | {
|
---|
| 152 | BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
|
---|
| 153 | {
|
---|
[637] | 154 | sourceLine.GetSourceCodePosition().SetRelationalObjectModuleIndex(
|
---|
| 155 | relationTable[sourceLine.GetSourceCodePosition().GetRelationalObjectModuleIndex()]
|
---|
| 156 | );
|
---|
[280] | 157 | }
|
---|
| 158 | }
|
---|
[637] | 159 |
|
---|
| 160 | void NativeCode::Resolve()
|
---|
| 161 | {
|
---|
| 162 | // TODO: Resolve
|
---|
| 163 | }
|
---|