[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 |
|
---|
| 8 | void ObpPlus( int step )
|
---|
| 9 | {
|
---|
| 10 | extern int obp;
|
---|
| 11 | obp += step;
|
---|
| 12 |
|
---|
| 13 | // 例:epi=0x00401999
|
---|
[237] | 14 | if( BREAK_EIP(0x00433FD7) )
|
---|
[232] | 15 | {
|
---|
| 16 | int test=0;
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
[245] | 19 |
|
---|
[258] | 20 | void NativeCode::Put( const NativeCode &nativeCode, bool isOpBuffer )
|
---|
[257] | 21 | {
|
---|
| 22 | long baseOffset = size;
|
---|
| 23 |
|
---|
[263] | 24 | // コードバッファを追加
|
---|
[258] | 25 | Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer );
|
---|
[257] | 26 |
|
---|
[263] | 27 | // スケジュールを追加
|
---|
[257] | 28 | BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
|
---|
| 29 | {
|
---|
| 30 | this->schedules.push_back(
|
---|
| 31 | Schedule(
|
---|
| 32 | schedule.GetType(),
|
---|
[258] | 33 | baseOffset + schedule.GetOffset(),
|
---|
| 34 | schedule.GetLongPtrValue()
|
---|
[257] | 35 | )
|
---|
| 36 | );
|
---|
| 37 | }
|
---|
[263] | 38 |
|
---|
| 39 | // ソースコード行番号とネイティブコード位置の対応情報を追加
|
---|
| 40 | BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
|
---|
| 41 | {
|
---|
| 42 | this->sourceLines.push_back(
|
---|
| 43 | SourceLine(
|
---|
| 44 | sourceLine.GetLineNum(),
|
---|
| 45 | baseOffset + sourceLine.GetNativeCodePos(),
|
---|
| 46 | sourceLine.GetSourceCodePos(),
|
---|
| 47 | sourceLine.GetCodeType()
|
---|
| 48 | )
|
---|
| 49 | );
|
---|
| 50 | }
|
---|
[257] | 51 | }
|
---|
| 52 |
|
---|
[245] | 53 | void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
|
---|
| 54 | {
|
---|
| 55 | pUserProc->Using();
|
---|
| 56 |
|
---|
| 57 | Schedule schedule( pUserProc, size );
|
---|
| 58 | if( isCall == false )
|
---|
| 59 | {
|
---|
| 60 | schedule.SpecifyAddressOf();
|
---|
| 61 | }
|
---|
| 62 | schedules.push_back( schedule );
|
---|
| 63 |
|
---|
| 64 | *((long *)(codeBuffer+size))=0;
|
---|
| 65 | size += sizeof(long);
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | // 未完成
|
---|
| 70 | if( isCall )
|
---|
| 71 | {
|
---|
| 72 | pobj_SubAddrSchedule->add(pUserProc,1);
|
---|
| 73 | }
|
---|
| 74 | else
|
---|
| 75 | {
|
---|
| 76 | pobj_SubAddrSchedule->add(pUserProc,0);
|
---|
| 77 | }
|
---|
| 78 | extern char *OpBuffer;
|
---|
| 79 | extern int obp;
|
---|
| 80 | *((long *)(OpBuffer+obp))=0;
|
---|
| 81 | ObpPlus( sizeof(long) );
|
---|
| 82 | }
|
---|
[250] | 83 |
|
---|
| 84 | void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
|
---|
| 85 | {
|
---|
| 86 | pDllProc->Using();
|
---|
| 87 |
|
---|
| 88 | schedules.push_back( Schedule( pDllProc, size ) );
|
---|
| 89 |
|
---|
| 90 | *((long *)(codeBuffer+size))=0;
|
---|
| 91 | size += sizeof(long);
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | // 未完成
|
---|
| 96 | pobj_ImportAddrSchedule->add(pDllProc);
|
---|
| 97 | extern char *OpBuffer;
|
---|
| 98 | extern int obp;
|
---|
| 99 | *((long *)(OpBuffer+obp))=0;
|
---|
| 100 | ObpPlus( sizeof(long) );
|
---|
| 101 | }
|
---|
[263] | 102 |
|
---|
| 103 | void NativeCode::NextSourceLine()
|
---|
| 104 | {
|
---|
| 105 | if( sourceLines.size() )
|
---|
| 106 | {
|
---|
| 107 | if( sourceLines.back().GetNativeCodePos() == size )
|
---|
| 108 | {
|
---|
| 109 | sourceLines.back().SetSourceCodePos( cp );
|
---|
| 110 | return;
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | extern BOOL bDebugSupportProc;
|
---|
| 115 | extern BOOL bSystemProc;
|
---|
| 116 | DWORD sourceLineType = 0;
|
---|
| 117 | if( bDebugSupportProc )
|
---|
| 118 | {
|
---|
| 119 | sourceLineType |= CODETYPE_DEBUGPROC;
|
---|
| 120 | }
|
---|
| 121 | if( bSystemProc )
|
---|
| 122 | {
|
---|
| 123 | sourceLineType |= CODETYPE_SYSTEMPROC;
|
---|
| 124 | }
|
---|
| 125 | sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) );
|
---|
| 126 | }
|
---|