13_平行进程
平行得2个程序之间
》通过cr3的切换,导致运行的代码是另外一个程序中的代码
上面代码的缺陷:
- 
不能动态获取cr3,得程序二先运行打印出来 
- 
不能很好平行的切换代码执行 
注意 这里实验的时候,需要多次调整地址;使得能平行过渡到另一个程序;可以使用Nop 这些填充来控制两者之间代码过度的位置照应。
程序1:
// 6_平行进程A.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
//0x403018
DWORD g_num;
//0x401000
void _declspec(naked) IdtEntry()
{
__asm
{
    int 3;
}
__asm {
    
    mov eax, cr3
    mov ds : [0x8003f3f0], eax
    mov eax, 0x099401a0
    nop
    nop
    mov cr3, eax
    //00401011
    mov ecx, 0x12345678
    mov ecx, 0x12345678
    mov ecx, 0x12345678
    mov ecx, 0x12345678
    //00401825
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    mov g_num, ecx
    push 0x3b
    pop fs
    iretd
}
}
void _declspec(naked)  go()
{
__asm {
    int 0x20;
    ret;
}
}
//eq 8003f500 0040ee00 00081000
void main()
{
if ((DWORD)IdtEntry != 0x401040)// code : there is not same as the past, there some crt func takes the place401000 ~401040
{
    printf("WRONG ADDR");
    //exit(0);
}
go();
}
程序2:
// 6_平行进程B.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
//0x403018
DWORD g_cr3;
DWORD g_num = 0;
//0x401000
void _declspec(naked) IdtEntry()
{
__asm{
    int 3;
}
__asm {
    mov eax, cr3
    mov g_cr3, eax
    push 0x3b
    pop fs;
    iretd
    //00401009
    mov eax, 0x12345678
    nop
    nop
    nop
    mov eax, 1
    mov g_num, eax
    mov ecx,0xaaaaaaaa
    mov eax, ds: [0x8003f3f0]
    mov cr3, eax
    //00401029
}
}
void _declspec(naked) go()
{
__asm{
    int 0x20
    ret;
}
}
void main()
{
if ((DWORD)IdtEntry != 0x401040)// code : there is not same as the past, there some crt func takes the place401000 ~401040
{
    printf("WRONG ADDR");
    //exit(0);
}
go();
int i = 0;
while (1)
{
    i++;
    if (i % 10 == 0)
    {
        i = 0;
        system("cls");
    }
    printf("cr3:%p\t num%d\n", g_cr3, g_num);
    Sleep(100);
}
}
结果: 几经修改终于平行;所以 还是得动态调整好一点。有时间再搞.
程序2 运行起来一开始得数据:
程序 1 运行起来之后(注意这里如果代码地址 对不齐 那么 就会 报错异常 ):
 
                     
                    
                 
                    
                
 



 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号