vmware 같은 가상머신을 어떻게 만드는지에 대한 내용입니다.
재 작년인가에 세미나할때 만든 거 같은데 :-)
동영상도 있습니다. 음하하하
[slide share]
; 15 2 1 0 ; +----------------------------+-------------------+--+--+--+ ; | index |TI| RPL | ; +----------------------------+-------------------+--+--+--+ ; ; index ; GDT 의 인덱스 값 ( GDT = index * sizeof(GDT Descriptor) ) ; ; TI (Table Indicator) ; 0 이면 GDT (Global Descriptor Table) ; 1 이면 LDT (Local Descriptor Table) ; ; RPL (Requestor Privilege Level)
cs=0010 ss=0018 ds=002b es=002b fs=0053 gs=002b efl=00000202
0: kd> dg 0 80
P Si Gr Pr Lo
Sel Base Limit Type l ze an es ng Flags
---- ----------------- ----------------- ---------- - -- -- -- -- --------
0000 00000000`00000000 00000000`00000000 <reserved> 0 Nb By Np Nl 00000000
0008 00000000`00000000 00000000`00000000 <reserved> 0 Nb By Np Nl 00000000
0010 00000000`00000000 00000000`00000000 Code RE Ac 0 Nb By P Lo 0000029b
0018 00000000`00000000 00000000`ffffffff Data RW Ac 0 Bg Pg P Nl 00000c93
0020 00000000`00000000 00000000`ffffffff Code RE 3 Bg Pg P Nl 00000cfa
0028 00000000`00000000 00000000`ffffffff Data RW Ac 3 Bg Pg P Nl 00000cf3
0030 00000000`00000000 00000000`00000000 Code RE Ac 3 Nb By P Lo 000002fb
0038 00000000`00000000 00000000`00000000 <reserved> 0 Nb By Np Nl 00000000
0040 00000000`00b96080 00000000`00000067 TSS32 Busy 0 Nb By P Nl 0000008b
0048 00000000`0000ffff 00000000`0000f800 <reserved> 0 Nb By Np Nl 00000000
0050 ffffffff`fffe0000 00000000`00003c00 Data RW Ac 3 Bg By P Nl 000004f3
0058 00000000`00000000 00000000`00000000 <reserved> 0 Nb By Np Nl 00000000
0060 00000000`00000000 00000000`ffffffff Code RE 0 Bg Pg P Nl 00000c9a
0068 00000000`00000000 00000000`00000000 <reserved> 0 Nb By Np Nl 00000000
0070 00000000`00000000 00000000`00000000 <reserved> 0 Nb By Np Nl 00000000
0078 00000000`00000000 00000000`00000000 <reserved> 0 Nb By Np Nl 00000000
0080 Unable to get descriptor
cs = 0x0010 : 00010 0 00 -> r0, gdt, Sel = 0010 0 00 -> 0x10 ss = 0x0018 : 00011 0 00 -> r0, gdt, Sel = 0011 0 00 -> 0x18 fs = 0x0053 : 01010 0 11 -> r3, gdt, Sel = 1010 0 00 -> 0x50 ds,es,gs = 0x002b : 00101 0 11 -> r3, gdt, Sel = 0101 0 00 -> 0x28
/**
* @brief
**/
class ConstPositionTest
{
public:
//> (const char*) msg : char* 가 const, 즉 msg 가 가리키는 데이터 변경 불가
char* Function1(const char* msg)
{
msg[0] = 't'; // error
return m_msg;
}
//> char* (const msg) : msg 변수가 const, 즉 msg 포인터 변수 변경 불가
char* Function2(char* const msg)
{
msg = m_msg; //error
return m_msg;
}
//> 메소드 상수화, 이 메소드는 클래스 멤버를 읽을 수는 있으나 변경 할 수는 없음
char* Function3(char* msg) const
{
m_msg = msg; //error
return m_msg;
}
//> (const char*) : 리턴 값이 const char* 이므로 리턴 받는 변수도 const char* 이어야 함
//> 따라서 리턴되는 포인터가 가리키는 데이터 변경 불가
const char* Function4(char* msg)
{
m_msg = msg;
return m_msg; //반환 받는 타입이 const가 아닐 경우 error
}
private:
char* m_msg;
};
/**
* @brief
* @param
* @see
* @remarks
* @code
* @endcode
* @return
**/
bool test_const_position()
{
ConstPositionTest test;
char msg[] = "hello, const!";
test.Function1(msg);
test.Function2(msg);
test.Function3(msg);
const char* pMessage = test.Function4(msg);
pMessage[0] = 0; // error
}
1000 : Visual C++ 4.x (4.0)
1100 : Visual C++ 5 (5.0)
1200 : Visual C++ 6 (6.0)
1300 : Visual C++ .NET (7.0)
1310 : Visual C++ .NET 2003 (7.1)
1400 : Visual C++ .NET 2005 (8.0)
1500 : Visual C++ .NET 2008 (9.0)
1600 : Visual C++ 2010 (10.0)1700 : Visual C++ 2012 (11.0)
#includestatic void __stdcall Test1() { // CR4 레지스터에 접근해 볼까요? unsigned long _cr4=0x00000000; __asm { mov eax, cr4 mov _cr4, eax } CFIX_LOG(L"cr4 = 0x%08x", _cr4); } CFIX_BEGIN_FIXTURE( MyFixture ) CFIX_FIXTURE_ENTRY( Test1 ) CFIX_END_FIXTURE()
static void __stdcall Test1()
{
// CR4 레지스터에 접근해 볼까요?
unsigned long _cr4=0x00000000;
__asm
{
_emit 0x0f ; mov eax, cr4
_emit 0x20
_emit 0xe0
mov _cr4, eax
}
CFIX_LOG(L"cr4 = 0x%08x", _cr4);
}
1>c:\visualassert\examples\kernelmode\cl : warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release 1>c:\visualassert\examples\kernelmode\suite.c : warning C4819: The file contains a character that cannot be represented in the current code page (949). Save the file in Unicode format to prevent data loss
# MSC_WARNING_LEVEL=/W4 /WX /Wp64 MSC_WARNING_LEVEL=/W4
.686 .model flat, StdCall option casemap:none .code ; int __stdcall test_sum(int _param1, int _param2) test_sum PROC StdCall _param1, _param2 mov eax, _param1 add eax, _param2 ret test_sum ENDP ; int __stdcall test_sum2(int _param1, int _param2) test_sum2 PROC StdCall _param1, _param2 mov eax, _param1 add eax, _param2 ret 08h test_sum ENDP end
push ebp mov esp, ebp mov eax, dword ptr [ebp+08h] add eax, dword ptr [ebp+0ch] leave ret 08h
.686 .model flat, StdCall option casemap:none .code ; int __stdcall test_sum(int _param1, int _param2) test_sum PROC StdCall _param1, _param2 mov eax, _param1 add eax, _param2 ret test_sum ENDP ; int __stdcall test_sum2(int _param1, int _param2) test_sum PROC StdCall _param1, _param2 mov eax, _param1 add eax, _param2 ret 08h test_sum ENDP option prologue:none option epilogue:none ; int __stdcall test_sum3(int _param1, int _param2) test_sum3 PROC Stdcall _param1, _param2 ; build stack frame push ebp mov ebp, esp mov eax, dword ptr [ebp+08h] add eax, dwrod ptr [ebp+0ch] ; restore stack frame mov esp, ebp pop ebp ret 08h test_sum3 ENDP option prologue:PrologueDef option prologue:EpilogueDef end