PAGINGINIT32: ;must be called in 32-bits protected mode push eax push edx push ecx push ebx push edi push es mov ax,SLCT_FLAT_RW mov es,ax xor edx,edx mov eax,dword [ds:DISPMEMTOTAL_32] mov ebx,400000h div ebx mov ecx,eax cmp edx,0 je .end inc ecx .end: push ecx ;init all PDEs mov eax, PTEBASE | PG_P | PG_USU | PG_RWW mov edi, PDEBASE .loop1: mov dword [es:edi],eax add edi,4 dec ecx add eax,4096 cmp ecx,0 jne .loop1 ;init all PTEs pop eax mov ebx,1024 mul ebx mov ecx,eax mov eax, PG_P | PG_USU | PG_RWW xor edi,edi mov edi, PTEBASE .loop2: mov dword [es:edi],eax add edi,4 add eax,4096 dec ecx cmp ecx,0 jne .loop2 mov eax, PDEBASE mov cr3, eax mov eax, cr0 or eax, 80000000h mov cr0, eax jmp short .end2 .end2: nop pop es pop edi pop ebx pop ecx pop edx pop eax ret ;void* MEMCPY32(void* Source;void* Destination;ULONG32 Size) MEMCPY32: push ebp mov ebp,esp push esi push edi push ecx push eax mov ax,SLCT_FLAT_RW mov es,ax mov esi,dword [ss:ebp+8] mov edi,dword [ss:ebp+12] mov ecx,dword [ss:ebp+16] .loop: mov al,byte [es:esi] mov byte [ds:edi],al inc esi inc edi dec ecx cmp ecx,0 je .end jmp .loop .end: pop eax pop ecx pop edi pop esi pop ebp ret