[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 | sourceLine.GetLineNum(),
|
---|
| 46 | baseOffset + sourceLine.GetNativeCodePos(),
|
---|
[280] | 47 | sourceLine.GetSourceIndex(),
|
---|
[263] | 48 | sourceLine.GetSourceCodePos(),
|
---|
| 49 | sourceLine.GetCodeType()
|
---|
| 50 | )
|
---|
| 51 | );
|
---|
| 52 | }
|
---|
[257] | 53 | }
|
---|
| 54 |
|
---|
[357] | 55 | void NativeCode::PutEx( long l, Schedule::Type scheduleType )
|
---|
| 56 | {
|
---|
[551] | 57 | if( scheduleType != Schedule::None )
|
---|
[357] | 58 | {
|
---|
[551] | 59 | schedules.push_back( Schedule( scheduleType, GetSize() ) );
|
---|
[357] | 60 | }
|
---|
| 61 |
|
---|
[551] | 62 | Put( l );
|
---|
[357] | 63 | }
|
---|
| 64 |
|
---|
[245] | 65 | void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
|
---|
| 66 | {
|
---|
| 67 | pUserProc->Using();
|
---|
| 68 |
|
---|
[550] | 69 | Schedule::Type type = isCall ? Schedule::UserProc : Schedule::AddressOf;
|
---|
[245] | 70 |
|
---|
[550] | 71 | schedules.push_back( Schedule( type, pUserProc, GetSize() ) );
|
---|
| 72 |
|
---|
[287] | 73 | Put( (long)0 );
|
---|
[245] | 74 | }
|
---|
[250] | 75 |
|
---|
[357] | 76 | void NativeCode::PutCatchAddressSchedule( const UserProc *pUserProc, long codePos )
|
---|
| 77 | {
|
---|
| 78 | pUserProc->Using();
|
---|
| 79 |
|
---|
[550] | 80 | schedules.push_back( Schedule( Schedule::CatchAddress, pUserProc, GetSize() ) );
|
---|
[357] | 81 |
|
---|
| 82 | Put( codePos );
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[250] | 85 | void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
|
---|
| 86 | {
|
---|
| 87 | pDllProc->Using();
|
---|
| 88 |
|
---|
[287] | 89 | schedules.push_back( Schedule( pDllProc, GetSize() ) );
|
---|
[250] | 90 |
|
---|
[287] | 91 | Put( (long)0 );
|
---|
[250] | 92 | }
|
---|
[263] | 93 |
|
---|
[370] | 94 | void NativeCode::PutComVtblSchedule( const CClass *pClass )
|
---|
| 95 | {
|
---|
| 96 | schedules.push_back( Schedule( Schedule::ComVtbl, pClass, GetSize() ) );
|
---|
| 97 |
|
---|
| 98 | Put( (long)0 );
|
---|
| 99 | }
|
---|
| 100 |
|
---|
[282] | 101 | void NativeCode::PutVtblSchedule( const CClass *pClass )
|
---|
| 102 | {
|
---|
[370] | 103 | schedules.push_back( Schedule( Schedule::Vtbl, pClass, GetSize() ) );
|
---|
[282] | 104 |
|
---|
[287] | 105 | Put( (long)0 );
|
---|
[282] | 106 | }
|
---|
| 107 |
|
---|
[597] | 108 | void NativeCode::NextSourceLine( int currentSourceIndex, int nowLine )
|
---|
[263] | 109 | {
|
---|
| 110 | if( sourceLines.size() )
|
---|
| 111 | {
|
---|
[287] | 112 | if( sourceLines.back().GetNativeCodePos() == GetSize() )
|
---|
[263] | 113 | {
|
---|
[597] | 114 | sourceLines.back().SetSourceCodePos( nowLine );
|
---|
[263] | 115 | return;
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | extern BOOL bDebugSupportProc;
|
---|
| 120 | extern BOOL bSystemProc;
|
---|
| 121 | DWORD sourceLineType = 0;
|
---|
| 122 | if( bDebugSupportProc )
|
---|
| 123 | {
|
---|
| 124 | sourceLineType |= CODETYPE_DEBUGPROC;
|
---|
| 125 | }
|
---|
| 126 | if( bSystemProc )
|
---|
| 127 | {
|
---|
| 128 | sourceLineType |= CODETYPE_SYSTEMPROC;
|
---|
| 129 | }
|
---|
[280] | 130 | sourceLines.push_back(
|
---|
| 131 | SourceLine(
|
---|
| 132 | (long)sourceLines.size(),
|
---|
[287] | 133 | GetSize(),
|
---|
[551] | 134 | currentSourceIndex,
|
---|
[597] | 135 | nowLine,
|
---|
[280] | 136 | sourceLineType
|
---|
| 137 | )
|
---|
| 138 | );
|
---|
[263] | 139 | }
|
---|
[273] | 140 |
|
---|
| 141 | void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
|
---|
| 142 | {
|
---|
| 143 | BOOST_FOREACH( const Schedule &schedule, schedules )
|
---|
| 144 | {
|
---|
| 145 | if( schedule.GetType() == Schedule::DataTable )
|
---|
| 146 | {
|
---|
| 147 | Overwrite(
|
---|
| 148 | schedule.GetOffset(),
|
---|
| 149 | GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
|
---|
| 150 | );
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
[280] | 154 | void NativeCode::ResetSourceIndexes( long sourceIndexBase )
|
---|
| 155 | {
|
---|
| 156 | BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
|
---|
| 157 | {
|
---|
| 158 | sourceLine.SetSourceIndex( sourceLine.GetSourceIndex() + sourceIndexBase );
|
---|
| 159 | }
|
---|
| 160 | }
|
---|