1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| #include<stdio.h> #include<stdlib.h> #include<windows.h> char GDTaddr[6]={0}; char LDTtable[0x3ff] = {0}; __declspec(naked) void test() { __asm { pushad; pushfd; lea eax,[GDTaddr+2]; mov eax,[eax]; lea eax,[eax+0x90]; lea ecx,LDTtable; mov bx,cx; shl ebx,0x10; mov bx,0x03ff; mov dword ptr [eax],ebx; lea eax,[eax+4]; shr ecx,0x10; mov byte ptr [eax],cl; mov byte ptr [eax+1],0xe2; mov byte ptr [eax+4],ch; mov ax,0x93; lldt ax; popfd; popad; retf; } } int main() { char buf[6] = {0,0,0,0,0x48,0}; char ldt[]={0}; int b=0; *((int*)(LDTtable+0x8)) = 0x0000ffff; *((int*)(LDTtable+0xc)) = 0x00cff300; printf("%X\t,GDTaddr:%X\n",test,GDTaddr); system("pause"); __asm { sgdt GDTaddr; push fs; call fword ptr buf; sldt ldt; pop fs; mov ax,0xf; mov ds,ax; mov b,0x10; } printf("%X\n",b); system("pause"); return 0; }
|