Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

qwe

  • Loading branch information...
commit 0275f56b65b59419c4cb7f8d589a4dc367bd309f 1 parent c4b8294
@Logioniz authored
Showing with 21 additions and 6 deletions.
  1. +8 −6 7/1.c
  2. +13 −0 7/2.asm
View
14 7/1.c
@@ -16,6 +16,7 @@ void add_idt_entry(_uint,_uint);
void clear_screen();
int PrintToScreen(int, char*);
void PrintToScreenHex(int, _uint);
+void idt_13();
_uint random();
//void srand (_uint);
//int rand (void);
@@ -48,7 +49,7 @@ void nameless_func()
for(int i=0;i<256;++i)
if(i!=13)
add_idt_entry(i,(_uint)idt_sub_0);
- add_idt_entry(13,(_uint) idt_sub_13);
+ add_idt_entry(13,(_uint) idt_sub_13); //Правильнее здесь указать функцию idt_13, которая в файле 2.asm, там pusha, popa есть. Да и ещё там в той функции нельзя pop %eax заменять на add esp,4 - сам в ахуе...И нужно ассемблерные вставки убрать в idt_sub_13
idt_ptr.limit = (8*256)<<16;
idt_ptr.baseaddress = (_uint)idt_table;
@@ -66,10 +67,12 @@ void nameless_func()
PrintToScreen(160," \0");
short qwe = *((short *)(random() % 0x400000));
- for(int i=0;i<399999999;++i);
+ for(int i=0;i<29999999;++i);
}
- *((short*) 0xb8000) = 0x0731;
+// short qwe = *((short *) 0x7fffffff);
+// *((short*) 0xb8002) = 0x0732;
+// __asm__("hlt");
// short qwe = *((short *) 0x7fffffff);
}
@@ -86,7 +89,6 @@ void add_idt_entry(_uint n, _uint func)
idt_table[n].zero = 0;
idt_table[n].type_attr = 0x8F;
idt_table[n].offset_2 = (_ushort) (( func) >> 16);
-
}
void idt_sub_0()
@@ -98,14 +100,14 @@ void idt_sub_0()
void idt_sub_13(_uint eip, _uint cs, _uint eflags)
{
- __asm__("pusha");
+// __asm__("pusha");
int i =PrintToScreen(0,"General Protection\0");
i = PrintToScreen(80,"CS: \0");
PrintToScreenHex(i,cs);
i = PrintToScreen(160,"EIP: \0");
PrintToScreenHex(i,eip);
- __asm__("popa");
+// __asm__("popa");
__asm__("leave");
__asm__("pop %eax"); //osdev - "For some exceptions, an error code is also pushed on the stack, which must be POPped before doing IRET. "
View
13 7/2.asm
@@ -2,6 +2,9 @@ cpu 386
bits 32
global load_idt_table
+extern idt_sub_13
+global idt_13
+
section .text
load_idt_table:
push ebp
@@ -12,3 +15,13 @@ load_idt_table:
pop ebx
pop ebp
ret
+
+idt_13:
+ pusha
+ call idt_sub_13
+ popa
+ ;mov word [0xb8000], 0x0731
+ pop eax
+ ;add esp, 4
+ iret
+
Please sign in to comment.
Something went wrong with that request. Please try again.