[232] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[245] | 3 | #include <NativeCode.h>
|
---|
| 4 | #include <Procedure.h>
|
---|
| 5 |
|
---|
[237] | 6 | #define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
|
---|
[232] | 7 |
|
---|
[276] | 8 | void NativeCode::Put( const NativeCode &nativeCode )
|
---|
[232] | 9 | {
|
---|
[257] | 10 | long baseOffset = size;
|
---|
| 11 |
|
---|
[263] | 12 | // コードバッファを追加
|
---|
[276] | 13 | Put( nativeCode.codeBuffer, nativeCode.size );
|
---|
[257] | 14 |
|
---|
[263] | 15 | // スケジュールを追加
|
---|
[257] | 16 | BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
|
---|
| 17 | {
|
---|
| 18 | this->schedules.push_back(
|
---|
| 19 | Schedule(
|
---|
| 20 | schedule.GetType(),
|
---|
[258] | 21 | baseOffset + schedule.GetOffset(),
|
---|
| 22 | schedule.GetLongPtrValue()
|
---|
[257] | 23 | )
|
---|
| 24 | );
|
---|
| 25 | }
|
---|
[263] | 26 |
|
---|
| 27 | // ソースコード行番号とネイティブコード位置の対応情報を追加
|
---|
| 28 | BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
|
---|
| 29 | {
|
---|
| 30 | this->sourceLines.push_back(
|
---|
| 31 | SourceLine(
|
---|
| 32 | sourceLine.GetLineNum(),
|
---|
| 33 | baseOffset + sourceLine.GetNativeCodePos(),
|
---|
| 34 | sourceLine.GetSourceCodePos(),
|
---|
| 35 | sourceLine.GetCodeType()
|
---|
| 36 | )
|
---|
| 37 | );
|
---|
| 38 | }
|
---|
[257] | 39 | }
|
---|
| 40 |
|
---|
[245] | 41 | void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
|
---|
| 42 | {
|
---|
| 43 | pUserProc->Using();
|
---|
| 44 |
|
---|
| 45 | Schedule schedule( pUserProc, size );
|
---|
| 46 | if( isCall == false )
|
---|
| 47 | {
|
---|
| 48 | schedule.SpecifyAddressOf();
|
---|
| 49 | }
|
---|
| 50 | schedules.push_back( schedule );
|
---|
| 51 |
|
---|
| 52 | *((long *)(codeBuffer+size))=0;
|
---|
| 53 | size += sizeof(long);
|
---|
| 54 | }
|
---|
[250] | 55 |
|
---|
| 56 | void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
|
---|
| 57 | {
|
---|
| 58 | pDllProc->Using();
|
---|
| 59 |
|
---|
| 60 | schedules.push_back( Schedule( pDllProc, size ) );
|
---|
| 61 |
|
---|
| 62 | *((long *)(codeBuffer+size))=0;
|
---|
| 63 | size += sizeof(long);
|
---|
| 64 | }
|
---|
[263] | 65 |
|
---|
| 66 | void NativeCode::NextSourceLine()
|
---|
| 67 | {
|
---|
| 68 | if( sourceLines.size() )
|
---|
| 69 | {
|
---|
| 70 | if( sourceLines.back().GetNativeCodePos() == size )
|
---|
| 71 | {
|
---|
| 72 | sourceLines.back().SetSourceCodePos( cp );
|
---|
| 73 | return;
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | extern BOOL bDebugSupportProc;
|
---|
| 78 | extern BOOL bSystemProc;
|
---|
| 79 | DWORD sourceLineType = 0;
|
---|
| 80 | if( bDebugSupportProc )
|
---|
| 81 | {
|
---|
| 82 | sourceLineType |= CODETYPE_DEBUGPROC;
|
---|
| 83 | }
|
---|
| 84 | if( bSystemProc )
|
---|
| 85 | {
|
---|
| 86 | sourceLineType |= CODETYPE_SYSTEMPROC;
|
---|
| 87 | }
|
---|
| 88 | sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) );
|
---|
| 89 | }
|
---|
[273] | 90 |
|
---|
| 91 | void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
|
---|
| 92 | {
|
---|
| 93 | BOOST_FOREACH( const Schedule &schedule, schedules )
|
---|
| 94 | {
|
---|
| 95 | if( schedule.GetType() == Schedule::DataTable )
|
---|
| 96 | {
|
---|
| 97 | Overwrite(
|
---|
| 98 | schedule.GetOffset(),
|
---|
| 99 | GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
|
---|
| 100 | );
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|