Hi, I know the processing of CPU load the mechine code is different between the ring0 and ring3. so same mechine code array means the different code in the ring0 and ring3. So we need write a jmp far code in the ring0 mode. Would you please reference i386p asm book. I guess vc++ compiler have solve the problem. but c++builder still do not know it, you need do it by yourself. I can not assure whether my solution will help you. Would you please let me know the result, whatever it can solve it or not.Regards Jansen Zhu void __declspec( naked ) Ring0Proc(void) // 中 断 例 程, 运 行 在Ring0 { _asm{ mov _eax,eax // mov _ecx,ecx // mov eax, CR0 // 测 试Ring3 中 不 能 执 行 的 特 权 指 令 mov _cr0,eax // jmp far next: next: iretd // 中断返回,与在实模式编程无 本 质 区 别 } }
像 jmp far next: next: 这样的的操作一般有两种用途: 1清除cpu中的指令预取队列,这一般是用在一些加/解密软件或病毒中,由于程序动态修改代码,所以要清除cpu中的指令预取队列. 2由实模式进入保护模式时,通过该操作来装入cs. 在该程序中既不修改自身代码,也无需再装入(调用中断时,已经装入cs了),所以不用jmp far. "I know the processing of CPU load the mechine code is different between the ring0 and ring3. so same mechine code array means the different code in the ring0 and ring3." 这里的不同应该是在实模式与保护模式之间,而不是保护模式下的ring0和ring3之间. win9x下的主控台程序仍是保护模式下的32位程序. 出现蓝屏现象应该是另有原因.
I know the processing of CPU load the mechine code
is different between the ring0 and ring3. so same mechine
code array means the different code in the ring0 and ring3.
So we need write a jmp far code in the ring0 mode. Would you
please reference i386p asm book.
I guess vc++ compiler have solve the problem. but c++builder
still do not know it, you need do it by yourself.
I can not assure whether my solution will help you.
Would you please let me know the result, whatever
it can solve it or not.Regards
Jansen Zhu
void __declspec( naked ) Ring0Proc(void) // 中 断 例 程, 运 行 在Ring0
{
_asm{
mov _eax,eax //
mov _ecx,ecx //
mov eax, CR0 // 测 试Ring3 中 不 能 执 行 的 特 权 指 令
mov _cr0,eax //
jmp far next:
next:
iretd // 中断返回,与在实模式编程无 本 质 区 别
}
}
next:
这样的的操作一般有两种用途:
1清除cpu中的指令预取队列,这一般是用在一些加/解密软件或病毒中,由于程序动态修改代码,所以要清除cpu中的指令预取队列.
2由实模式进入保护模式时,通过该操作来装入cs.
在该程序中既不修改自身代码,也无需再装入(调用中断时,已经装入cs了),所以不用jmp far.
"I know the processing of CPU load the mechine code
is different between the ring0 and ring3. so same mechine
code array means the different code in the ring0 and ring3."
这里的不同应该是在实模式与保护模式之间,而不是保护模式下的ring0和ring3之间.
win9x下的主控台程序仍是保护模式下的32位程序.
出现蓝屏现象应该是另有原因.
http://lu0.126.com
CR0=80000013 EAX=6200 EBX=0
void Ring0Proc() // 在Ring0中执行你自已的子程序
{
asm mov eax,CR0; // 测验Ring3不能执行的特权指令
}
// =====================================================
void __declspec(naked) NewInt() //新中断
{
Ring0Proc();
asm iretd;
}
#define IntNo 3void GotoRing0()
{
static DWORDLONG Buf; //静态或全局变量
asm
{
mov edi,offset Buf;
sidt [edi]; // 取IDT->Buf
mov ebx,[edi+2]; // 求中断门基址
add ebx,IntNo*8;
mov esi,ebx;
push edi;
push esi;
movsd; //保存原中断门->Buf
movsd; cli;
mov eax,offset NewInt;
mov [ebx],ax;
shr eax,16;
mov [ebx+6],ax; // 修改新中断门
mov ax,0ee00h;
mov [ebx+4],ax; // 设置门属性 int IntNo; pop edi;
pop esi;
movsd; // 恢复原中断门
movsd;
sti;
}
}
// ===================================================