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