source: dev/trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp@ 258

Last change on this file since 258 was 258, checked in by dai_9181, 17 years ago

Linkerの骨格を作成した

File size: 1.6 KB
Line 
1#include "stdafx.h"
2
3#include <NativeCode.h>
4#include <Procedure.h>
5
6#define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
7
8void ObpPlus( int step )
9{
10 extern int obp;
11 obp += step;
12
13 // 例:epi=0x00401999
14 if( BREAK_EIP(0x00433FD7) )
15 {
16 int test=0;
17 }
18}
19
20void NativeCode::Put( const NativeCode &nativeCode, bool isOpBuffer )
21{
22 long baseOffset = size;
23
24 Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer );
25
26 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
27 {
28 this->schedules.push_back(
29 Schedule(
30 schedule.GetType(),
31 baseOffset + schedule.GetOffset(),
32 schedule.GetLongPtrValue()
33 )
34 );
35 }
36}
37
38void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
39{
40 pUserProc->Using();
41
42 Schedule schedule( pUserProc, size );
43 if( isCall == false )
44 {
45 schedule.SpecifyAddressOf();
46 }
47 schedules.push_back( schedule );
48
49 *((long *)(codeBuffer+size))=0;
50 size += sizeof(long);
51
52
53
54 // 未完成
55 if( isCall )
56 {
57 pobj_SubAddrSchedule->add(pUserProc,1);
58 }
59 else
60 {
61 pobj_SubAddrSchedule->add(pUserProc,0);
62 }
63 extern char *OpBuffer;
64 extern int obp;
65 *((long *)(OpBuffer+obp))=0;
66 ObpPlus( sizeof(long) );
67}
68
69void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
70{
71 pDllProc->Using();
72
73 schedules.push_back( Schedule( pDllProc, size ) );
74
75 *((long *)(codeBuffer+size))=0;
76 size += sizeof(long);
77
78
79
80 // 未完成
81 pobj_ImportAddrSchedule->add(pDllProc);
82 extern char *OpBuffer;
83 extern int obp;
84 *((long *)(OpBuffer+obp))=0;
85 ObpPlus( sizeof(long) );
86}
Note: See TracBrowser for help on using the repository browser.