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