[224] | 1 | #pragma once
|
---|
| 2 |
|
---|
[244] | 3 | class UserProc;
|
---|
| 4 |
|
---|
[224] | 5 | class Schedule
|
---|
| 6 | {
|
---|
| 7 | public:
|
---|
| 8 | enum Type
|
---|
| 9 | {
|
---|
[237] | 10 | None = 10000,
|
---|
[225] | 11 | GlobalVar, // グローバル変数スケジュール
|
---|
[237] | 12 | DataTable, // データテーブル スケジュール
|
---|
[357] | 13 | CatchAddress, // Catchアドレス スケジュール
|
---|
[225] | 14 | Relocation, // リロケーション情報スケジュール
|
---|
[244] | 15 | UserProc, // ユーザ定義関数呼び出し側スケジュール
|
---|
| 16 | AddressOf, // ユーザ定義関数位置スケジュール
|
---|
[257] | 17 | DllProc, // DLL関数位置スケジュール
|
---|
[370] | 18 | ComVtbl, // com_vtblスケジュール
|
---|
[282] | 19 | Vtbl, // vtblスケジュール
|
---|
[355] | 20 | TypeInfo, // TypeInfoスケジュール
|
---|
[224] | 21 | };
|
---|
| 22 |
|
---|
| 23 | private:
|
---|
| 24 | Type type;
|
---|
[244] | 25 | long offset;
|
---|
[224] | 26 |
|
---|
[244] | 27 | union{
|
---|
| 28 | LONG_PTR lpValue;
|
---|
| 29 | const ::UserProc *pUserProc;
|
---|
[250] | 30 | const ::DllProc *pDllProc;
|
---|
[282] | 31 | const ::CClass *pClass;
|
---|
[244] | 32 | };
|
---|
| 33 |
|
---|
[224] | 34 | // XMLシリアライズ用
|
---|
| 35 | private:
|
---|
| 36 | friend class boost::serialization::access;
|
---|
| 37 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
| 38 | {
|
---|
[256] | 39 | trace_for_serialize( "serializing - Schedule" );
|
---|
| 40 |
|
---|
[224] | 41 | ar & BOOST_SERIALIZATION_NVP( type );
|
---|
| 42 | ar & BOOST_SERIALIZATION_NVP( offset );
|
---|
[272] | 43 |
|
---|
| 44 | switch( type )
|
---|
| 45 | {
|
---|
| 46 | case UserProc:
|
---|
| 47 | case AddressOf:
|
---|
[357] | 48 | case CatchAddress:
|
---|
[278] | 49 | ar & boost::serialization::make_nvp("pUserProc", const_cast<::UserProc *&>(pUserProc));
|
---|
[272] | 50 | break;
|
---|
| 51 | case DllProc:
|
---|
[278] | 52 | ar & boost::serialization::make_nvp("pDllProc", const_cast<::DllProc *&>(pDllProc));
|
---|
[272] | 53 | break;
|
---|
[370] | 54 | case ComVtbl:
|
---|
[282] | 55 | case Vtbl:
|
---|
[355] | 56 | case TypeInfo:
|
---|
[282] | 57 | ar & boost::serialization::make_nvp("pClass", const_cast<::CClass *&>(pClass));
|
---|
| 58 | break;
|
---|
[272] | 59 | default:
|
---|
| 60 | ar & BOOST_SERIALIZATION_NVP( lpValue );
|
---|
| 61 | break;
|
---|
| 62 | }
|
---|
[224] | 63 | }
|
---|
| 64 |
|
---|
| 65 | public:
|
---|
| 66 | Schedule()
|
---|
| 67 | {
|
---|
| 68 | }
|
---|
[258] | 69 | Schedule( Type type, long offset, LONG_PTR lpValue = 0 )
|
---|
[224] | 70 | : type( type )
|
---|
| 71 | , offset( offset )
|
---|
[258] | 72 | , lpValue( lpValue )
|
---|
[224] | 73 | {
|
---|
| 74 | }
|
---|
[258] | 75 | Schedule( const ::UserProc *pUserProc, long offset )
|
---|
[244] | 76 | : type( Schedule::UserProc )
|
---|
| 77 | , offset( offset )
|
---|
| 78 | , pUserProc( pUserProc )
|
---|
| 79 | {
|
---|
| 80 | }
|
---|
[258] | 81 | Schedule( const ::DllProc *pDllProc, long offset )
|
---|
[257] | 82 | : type( Schedule::DllProc )
|
---|
[250] | 83 | , offset( offset )
|
---|
| 84 | , pDllProc( pDllProc )
|
---|
| 85 | {
|
---|
| 86 | }
|
---|
[355] | 87 | Schedule( Type type, const ::CClass *pClass, long offset )
|
---|
| 88 | : type( type )
|
---|
| 89 | , pClass( pClass )
|
---|
| 90 | , offset( offset )
|
---|
| 91 | {
|
---|
[370] | 92 | if( !( type == Schedule::ComVtbl || type == Schedule::Vtbl || type == Schedule::TypeInfo ) )
|
---|
| 93 | {
|
---|
| 94 | DebugBreak();
|
---|
| 95 | }
|
---|
[355] | 96 | }
|
---|
[224] | 97 | ~Schedule()
|
---|
| 98 | {
|
---|
| 99 | }
|
---|
[244] | 100 |
|
---|
[257] | 101 | Type GetType() const
|
---|
| 102 | {
|
---|
| 103 | return type;
|
---|
| 104 | }
|
---|
| 105 | long GetOffset() const
|
---|
| 106 | {
|
---|
| 107 | return offset;
|
---|
| 108 | }
|
---|
[258] | 109 | LONG_PTR GetLongPtrValue() const
|
---|
| 110 | {
|
---|
| 111 | return lpValue;
|
---|
| 112 | }
|
---|
[465] | 113 | const ::DllProc &GetDllProc() const;
|
---|
| 114 | const ::UserProc &GetUserProc() const;
|
---|
| 115 | const ::CClass &GetClass() const;
|
---|
[257] | 116 |
|
---|
[465] | 117 | void SpecifyAddressOf();
|
---|
| 118 | void SpecifyCatchAddress();
|
---|
[224] | 119 | };
|
---|
| 120 | typedef std::vector<Schedule> Schedules;
|
---|
| 121 |
|
---|
[263] | 122 | #define CODETYPE_SYSTEMPROC 0x0001
|
---|
| 123 | #define CODETYPE_DEBUGPROC 0x0002
|
---|
| 124 | class SourceLine
|
---|
| 125 | {
|
---|
| 126 | int lineNum;
|
---|
| 127 | long nativeCodePos;
|
---|
[280] | 128 | int sourceIndex;
|
---|
[263] | 129 | long sourceCodePos;
|
---|
| 130 | DWORD codeType;
|
---|
| 131 |
|
---|
| 132 | // XMLシリアライズ用
|
---|
| 133 | private:
|
---|
| 134 | friend class boost::serialization::access;
|
---|
| 135 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
| 136 | {
|
---|
| 137 | trace_for_serialize( "serializing - SourceLine" );
|
---|
| 138 |
|
---|
| 139 | ar & BOOST_SERIALIZATION_NVP( lineNum );
|
---|
| 140 | ar & BOOST_SERIALIZATION_NVP( nativeCodePos );
|
---|
[280] | 141 | ar & BOOST_SERIALIZATION_NVP( sourceIndex );
|
---|
[263] | 142 | ar & BOOST_SERIALIZATION_NVP( sourceCodePos );
|
---|
| 143 | ar & BOOST_SERIALIZATION_NVP( codeType );
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | public:
|
---|
[280] | 147 | SourceLine( int lineNum, int nativeCodePos, int sourceIndex, int sourceCodePos, DWORD codeType )
|
---|
[263] | 148 | : lineNum( lineNum )
|
---|
| 149 | , nativeCodePos( nativeCodePos )
|
---|
[280] | 150 | , sourceIndex( sourceIndex )
|
---|
[263] | 151 | , sourceCodePos( sourceCodePos )
|
---|
| 152 | , codeType( codeType )
|
---|
| 153 | {
|
---|
| 154 | }
|
---|
| 155 | SourceLine()
|
---|
| 156 | {
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | int GetLineNum() const
|
---|
| 160 | {
|
---|
| 161 | return lineNum;
|
---|
| 162 | }
|
---|
| 163 | long GetNativeCodePos() const
|
---|
| 164 | {
|
---|
| 165 | return nativeCodePos;
|
---|
| 166 | }
|
---|
[280] | 167 | int GetSourceIndex() const
|
---|
| 168 | {
|
---|
| 169 | return sourceIndex;
|
---|
| 170 | }
|
---|
| 171 | void SetSourceIndex( int sourceIndex )
|
---|
| 172 | {
|
---|
| 173 | this->sourceIndex = sourceIndex;
|
---|
| 174 | }
|
---|
[263] | 175 | long GetSourceCodePos() const
|
---|
| 176 | {
|
---|
| 177 | return sourceCodePos;
|
---|
| 178 | }
|
---|
| 179 | void SetSourceCodePos( int sourceCodePos )
|
---|
| 180 | {
|
---|
| 181 | this->sourceCodePos = sourceCodePos;
|
---|
| 182 | }
|
---|
| 183 | DWORD GetCodeType() const
|
---|
| 184 | {
|
---|
| 185 | return codeType;
|
---|
| 186 | }
|
---|
| 187 | bool IsInSystemProc() const
|
---|
| 188 | {
|
---|
| 189 | return ( (codeType&CODETYPE_SYSTEMPROC) != 0 );
|
---|
| 190 | }
|
---|
| 191 | bool IsInDebugProc() const
|
---|
| 192 | {
|
---|
| 193 | return ( (codeType&CODETYPE_DEBUGPROC) != 0 );
|
---|
| 194 | }
|
---|
| 195 | };
|
---|
| 196 | typedef std::vector<SourceLine> SourceLines;
|
---|
| 197 |
|
---|
[529] | 198 | class NativeCode : public Jenga::Common::Binary
|
---|
[224] | 199 | {
|
---|
[263] | 200 | // リンカで解決しなければならないスケジュール
|
---|
[224] | 201 | Schedules schedules;
|
---|
| 202 |
|
---|
[263] | 203 | // ソースコード行番号とネイティブコード位置の対応情報
|
---|
| 204 | SourceLines sourceLines;
|
---|
| 205 |
|
---|
[224] | 206 | // XMLシリアライズ用
|
---|
| 207 | private:
|
---|
| 208 | friend class boost::serialization::access;
|
---|
[287] | 209 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
[224] | 210 | {
|
---|
[256] | 211 | trace_for_serialize( "serializing(load) - NativeCode" );
|
---|
| 212 |
|
---|
[529] | 213 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Jenga::Common::Binary );
|
---|
[224] | 214 | ar & BOOST_SERIALIZATION_NVP( schedules );
|
---|
[263] | 215 | ar & BOOST_SERIALIZATION_NVP( sourceLines );
|
---|
[224] | 216 | }
|
---|
[256] | 217 |
|
---|
[224] | 218 | public:
|
---|
| 219 | NativeCode()
|
---|
[529] | 220 | : Jenga::Common::Binary()
|
---|
[224] | 221 | {
|
---|
| 222 | }
|
---|
[276] | 223 | NativeCode( const NativeCode &nativeCode )
|
---|
[529] | 224 | : Jenga::Common::Binary()
|
---|
[256] | 225 | {
|
---|
[287] | 226 | PutEx( nativeCode );
|
---|
[256] | 227 | }
|
---|
[276] | 228 | NativeCode( const char *codeBuffer, int size )
|
---|
[529] | 229 | : Jenga::Common::Binary( codeBuffer, size )
|
---|
[252] | 230 | {
|
---|
| 231 | }
|
---|
[224] | 232 | ~NativeCode()
|
---|
| 233 | {
|
---|
| 234 | }
|
---|
| 235 |
|
---|
[256] | 236 | void operator =( const NativeCode &nativeCode )
|
---|
| 237 | {
|
---|
| 238 | Clear();
|
---|
[287] | 239 | PutEx( nativeCode );
|
---|
[256] | 240 | }
|
---|
| 241 |
|
---|
[257] | 242 | const Schedules &GetSchedules() const
|
---|
| 243 | {
|
---|
| 244 | return schedules;
|
---|
| 245 | }
|
---|
[237] | 246 |
|
---|
[287] | 247 | void PutEx( const NativeCode &nativeCode );
|
---|
[357] | 248 | void PutEx( long l, Schedule::Type scheduleType );
|
---|
[245] | 249 | void PutUserProcSchedule( const UserProc *pUserProc, bool isCall );
|
---|
[357] | 250 | void PutCatchAddressSchedule( const UserProc *pUserProc, long codePos );
|
---|
[250] | 251 | void PutDllProcSchedule( const DllProc *pDllProc );
|
---|
[370] | 252 | void PutComVtblSchedule( const CClass *pClass );
|
---|
[282] | 253 | void PutVtblSchedule( const CClass *pClass );
|
---|
[263] | 254 |
|
---|
[265] | 255 | const SourceLines &GetSourceLines() const
|
---|
| 256 | {
|
---|
| 257 | return sourceLines;
|
---|
| 258 | }
|
---|
[263] | 259 | void NextSourceLine();
|
---|
[273] | 260 |
|
---|
| 261 | void ResetDataSectionBaseOffset( long dataSectionBaseOffset );
|
---|
[280] | 262 | void ResetSourceIndexes( long sourceIndexBase );
|
---|
[224] | 263 | };
|
---|