mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 02:32:57 +00:00
Added PE loader to LOADROS. Updated symbol search in Loader
svn path=/trunk/; revision=533
This commit is contained in:
parent
c4ba9a330d
commit
9083091f7b
8 changed files with 720 additions and 223 deletions
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include <winddi.h>
|
#include <winddi.h>
|
||||||
|
|
||||||
|
#include "vgaddi.h"
|
||||||
|
|
||||||
VOID VGADDIAssertMode(IN DHPDEV DPev,
|
VOID VGADDIAssertMode(IN DHPDEV DPev,
|
||||||
IN BOOL Enable);
|
IN BOOL Enable);
|
||||||
VOID VGADDICompletePDEV(IN DHPDEV PDev,
|
VOID VGADDICompletePDEV(IN DHPDEV PDev,
|
||||||
|
@ -90,7 +92,9 @@ DrvEnableDriver(IN ULONG EngineVersion,
|
||||||
{
|
{
|
||||||
DriveEnableData->pdrvfn = FuncList;
|
DriveEnableData->pdrvfn = FuncList;
|
||||||
DriveEnableData->c = sizeof FuncList / sizeof &FuncList[0];
|
DriveEnableData->c = sizeof FuncList / sizeof &FuncList[0];
|
||||||
|
DriveEnableData->iDriverVersion = DDI_DRIVER_VERSION;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DrvDisableDriver
|
// DrvDisableDriver
|
||||||
|
@ -103,16 +107,32 @@ DrvEnableDriver(IN ULONG EngineVersion,
|
||||||
|
|
||||||
VOID DrvDisableDriver(VOID)
|
VOID DrvDisableDriver(VOID)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------- Driver Implementation
|
// ----------------------------------------------- Driver Implementation
|
||||||
|
|
||||||
VOID VGADDIAssertMode(IN DHPDEV DPev,
|
|
||||||
IN BOOL Enable);
|
// DrvEnablePDEV
|
||||||
VOID VGADDICompletePDEV(IN DHPDEV PDev,
|
// DESCRIPTION:
|
||||||
IN HDEV Dev);
|
// This function is called after DrvEnableDriver to get information
|
||||||
VOID VGADDIDisablePDEV(IN DHPDEV PDev);
|
// about the mode that is to be used. This function just returns
|
||||||
VOID VGADDIDisableSurface(IN DHPDEV PDev);
|
// information, and should not yet initialize the mode.
|
||||||
|
// ARGUMENTS:
|
||||||
|
// IN DEVMODEW * DM Describes the mode requested
|
||||||
|
// IN LPWSTR LogAddress
|
||||||
|
// IN ULONG PatternCount number of patterns expected
|
||||||
|
// OUT HSURF * SurfPatterns array to contain pattern handles
|
||||||
|
// IN ULONG CapsSize the size of the DevCaps object passed in
|
||||||
|
// OUT ULONG * DevCaps Device Capabilities object
|
||||||
|
// IN ULONG DevInfoSize the size of the DevInfo object passed in
|
||||||
|
// OUT DEVINFO * DI Device Info object
|
||||||
|
// IN LPWSTR DevDataFile ignore
|
||||||
|
// IN LPWSTR DeviceName Device name
|
||||||
|
// IN HANDLE Driver handle to KM driver
|
||||||
|
// RETURNS:
|
||||||
|
// DHPDEV a handle to a DPev object
|
||||||
|
|
||||||
DHPDEV VGADDIEnablePDEV(IN DEVMODEW *DM,
|
DHPDEV VGADDIEnablePDEV(IN DEVMODEW *DM,
|
||||||
IN LPWSTR LogAddress,
|
IN LPWSTR LogAddress,
|
||||||
IN ULONG PatternCount,
|
IN ULONG PatternCount,
|
||||||
|
@ -123,9 +143,45 @@ DHPDEV VGADDIEnablePDEV(IN DEVMODEW *DM,
|
||||||
OUT DEVINFO *DI,
|
OUT DEVINFO *DI,
|
||||||
IN LPWSTR DevDataFile,
|
IN LPWSTR DevDataFile,
|
||||||
IN LPWSTR DeviceName,
|
IN LPWSTR DeviceName,
|
||||||
IN HANDLE Driver);
|
IN HANDLE Driver)
|
||||||
|
{
|
||||||
|
PPDEV PDev;
|
||||||
|
|
||||||
|
PDev = EngAllocMem(FL_ZERO_MEMORY, sizeof(PDEV), ALLOC_TAG);
|
||||||
|
if (PDev == NULL)
|
||||||
|
{
|
||||||
|
EngDebugPrint(1, "EngAllocMem failed for PDEV\n");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PDev->KMDriver = Driver;
|
||||||
|
|
||||||
|
/* FIXME: fill out DevCaps */
|
||||||
|
/* FIXME: full out DevInfo */
|
||||||
|
|
||||||
|
return PDev;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DrvEnablePDEV
|
||||||
|
// DESCRIPTION
|
||||||
|
// Called after initialization of PDEV is complete. Supplies
|
||||||
|
// a reference to the GDI handle for the PDEV.
|
||||||
|
|
||||||
|
VOID VGADDICompletePDEV(IN DHPDEV PDev,
|
||||||
|
IN HDEV Dev)
|
||||||
|
{
|
||||||
|
((PPDEV) PDev)->GDIDevHandle = Dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID VGADDIAssertMode(IN DHPDEV DPev,
|
||||||
|
IN BOOL Enable);
|
||||||
|
VOID VGADDIDisablePDEV(IN DHPDEV PDev);
|
||||||
|
VOID VGADDIDisableSurface(IN DHPDEV PDev);
|
||||||
HSURF VGADDIEnableSurface(IN DHPDEV PDev);
|
HSURF VGADDIEnableSurface(IN DHPDEV PDev);
|
||||||
ULONG VGADDIGetModes(IN HANDLE Driver,
|
ULONG VGADDIGetModes(IN HANDLE Driver,
|
||||||
IN ULONG DataSize,
|
IN ULONG DataSize,
|
||||||
OUT PDEVMODEW DM);
|
OUT PDEVMODEW DM);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
;
|
;
|
||||||
; Base address of the kernel
|
; Base address of the kernel
|
||||||
;
|
;
|
||||||
KERNEL_BASE equ 0c0000000h
|
KERNEL_BASE equ 0c0000000h
|
||||||
|
|
||||||
;
|
;
|
||||||
; Segment selectors
|
; Segment selectors
|
||||||
;
|
;
|
||||||
USER_CS equ 08h
|
USER_CS equ 08h
|
||||||
USER_DS equ 010h
|
USER_DS equ 010h
|
||||||
KERNEL_CS equ 020h
|
KERNEL_CS equ 020h
|
||||||
KERNEL_DS equ 028h
|
KERNEL_DS equ 028h
|
||||||
|
|
||||||
;
|
;
|
||||||
; Space reserved in the gdt for tss descriptors
|
; Space reserved in the gdt for tss descriptors
|
||||||
|
@ -31,6 +31,26 @@ org 100h
|
||||||
;
|
;
|
||||||
BITS 16
|
BITS 16
|
||||||
|
|
||||||
|
%define NDEBUG 1
|
||||||
|
|
||||||
|
%macro DPRINT 1+
|
||||||
|
%ifndef NDEBUG
|
||||||
|
jmp %%end_str
|
||||||
|
|
||||||
|
%%str: db %1
|
||||||
|
|
||||||
|
%%end_str:
|
||||||
|
push di
|
||||||
|
push ds
|
||||||
|
push es
|
||||||
|
pop ds
|
||||||
|
mov di, %%str
|
||||||
|
call print_string
|
||||||
|
pop ds
|
||||||
|
pop di
|
||||||
|
%endif
|
||||||
|
%endmacro
|
||||||
|
|
||||||
entry:
|
entry:
|
||||||
;
|
;
|
||||||
; Load stack
|
; Load stack
|
||||||
|
@ -38,6 +58,8 @@ entry:
|
||||||
cli
|
cli
|
||||||
push ds
|
push ds
|
||||||
pop ss
|
pop ss
|
||||||
|
push ds
|
||||||
|
pop es
|
||||||
mov sp,real_stack_end
|
mov sp,real_stack_end
|
||||||
sti
|
sti
|
||||||
|
|
||||||
|
@ -126,9 +148,9 @@ l14:
|
||||||
; Process the arguments
|
; Process the arguments
|
||||||
;
|
;
|
||||||
mov di,loading_msg
|
mov di,loading_msg
|
||||||
call _print_string
|
call print_string
|
||||||
mov di,dx
|
mov di,dx
|
||||||
call _print_string
|
call print_string
|
||||||
mov ah,02h
|
mov ah,02h
|
||||||
mov dl,0dh
|
mov dl,0dh
|
||||||
int 021h
|
int 021h
|
||||||
|
@ -141,7 +163,8 @@ l14:
|
||||||
;
|
;
|
||||||
push di
|
push di
|
||||||
mov dx,di
|
mov dx,di
|
||||||
call _load_file
|
; call _load_file
|
||||||
|
call pe_load_module
|
||||||
pop di
|
pop di
|
||||||
|
|
||||||
;
|
;
|
||||||
|
@ -180,147 +203,11 @@ exit:
|
||||||
;
|
;
|
||||||
_error:
|
_error:
|
||||||
mov di,err_msg
|
mov di,err_msg
|
||||||
call _print_string
|
call print_string
|
||||||
jmp exit
|
jmp exit
|
||||||
|
|
||||||
end_cmd_line dw 0
|
end_cmd_line dw 0
|
||||||
|
|
||||||
|
|
||||||
;
|
|
||||||
; Read in a file to kernel_base, set kernel base to the end of the file in
|
|
||||||
; memory rounded up to the nearest page
|
|
||||||
;
|
|
||||||
; In:
|
|
||||||
; DI = filename
|
|
||||||
;
|
|
||||||
_load_file:
|
|
||||||
inc dword [_nr_files]
|
|
||||||
|
|
||||||
;
|
|
||||||
; Open the file
|
|
||||||
;
|
|
||||||
mov ah,03dh
|
|
||||||
mov al,0
|
|
||||||
mov dx,di
|
|
||||||
int 021h
|
|
||||||
jc _error
|
|
||||||
mov [file_handle],ax
|
|
||||||
|
|
||||||
;
|
|
||||||
; Find filelength
|
|
||||||
;
|
|
||||||
mov ah,042h
|
|
||||||
mov al,2
|
|
||||||
mov bx,[file_handle]
|
|
||||||
mov cx,0
|
|
||||||
mov dx,0
|
|
||||||
int 021h
|
|
||||||
|
|
||||||
;
|
|
||||||
; Convert the filelength in DX:AX to a dword in EBX
|
|
||||||
;
|
|
||||||
movzx ebx,dx
|
|
||||||
shl ebx,16
|
|
||||||
mov bx,ax
|
|
||||||
|
|
||||||
;
|
|
||||||
; Record the length of the module in boot parameter table
|
|
||||||
;
|
|
||||||
mov esi,[_nr_files]
|
|
||||||
dec esi
|
|
||||||
mov [_module_lengths+esi*4],ebx
|
|
||||||
|
|
||||||
;
|
|
||||||
; Convert the length into
|
|
||||||
;
|
|
||||||
mov [size_mod_4k],bx
|
|
||||||
and word [size_mod_4k],0fffh
|
|
||||||
|
|
||||||
shr ebx,12
|
|
||||||
mov [size_div_4k],ebx
|
|
||||||
|
|
||||||
|
|
||||||
;
|
|
||||||
; Seek to beginning of file
|
|
||||||
;
|
|
||||||
mov ah,042h
|
|
||||||
mov al,0
|
|
||||||
mov bx,[file_handle]
|
|
||||||
mov cx,0
|
|
||||||
mov dx,0
|
|
||||||
int 021h
|
|
||||||
jc _error
|
|
||||||
|
|
||||||
;
|
|
||||||
; Read in the module
|
|
||||||
;
|
|
||||||
push ds
|
|
||||||
|
|
||||||
;
|
|
||||||
; Convert the linear point to the load address into a seg:off
|
|
||||||
;
|
|
||||||
mov edi,[next_load_base]
|
|
||||||
call convert_to_seg
|
|
||||||
mov dx,di
|
|
||||||
|
|
||||||
;
|
|
||||||
; Move onto the next position in prepartion for a future read
|
|
||||||
;
|
|
||||||
mov eax,[size_div_4k]
|
|
||||||
mov bx,[size_mod_4k]
|
|
||||||
cmp bx,0
|
|
||||||
je l20
|
|
||||||
inc eax
|
|
||||||
l20:
|
|
||||||
shl eax,0ch
|
|
||||||
add [next_load_base],eax
|
|
||||||
|
|
||||||
push fs
|
|
||||||
pop ds
|
|
||||||
|
|
||||||
;
|
|
||||||
; We read the kernel in 4k chunks (because)
|
|
||||||
;
|
|
||||||
l6:
|
|
||||||
;
|
|
||||||
; Check if we have read it all
|
|
||||||
;
|
|
||||||
mov ax,[es:size_div_4k]
|
|
||||||
cmp ax,0
|
|
||||||
je l5
|
|
||||||
|
|
||||||
;
|
|
||||||
; Make the call (dx was loaded above)
|
|
||||||
;
|
|
||||||
mov ah,3fh
|
|
||||||
mov bx,[es:file_handle]
|
|
||||||
mov cx,01000h
|
|
||||||
int 21h
|
|
||||||
|
|
||||||
;
|
|
||||||
; We move onto the next pointer by altering ds
|
|
||||||
;
|
|
||||||
mov ax,ds
|
|
||||||
add ax,0100h
|
|
||||||
mov ds,ax
|
|
||||||
dec word [es:size_div_4k]
|
|
||||||
jmp l6
|
|
||||||
|
|
||||||
l5:
|
|
||||||
;
|
|
||||||
; Read the last section
|
|
||||||
;
|
|
||||||
mov ah,3fh
|
|
||||||
mov bx,[es:file_handle]
|
|
||||||
mov cx,[es:size_mod_4k]
|
|
||||||
int 21h
|
|
||||||
pop ds
|
|
||||||
jnc _no_error
|
|
||||||
jmp _error
|
|
||||||
|
|
||||||
_no_error:
|
|
||||||
ret
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; In: EDI = address
|
; In: EDI = address
|
||||||
; Out: FS = segment
|
; Out: FS = segment
|
||||||
|
@ -330,11 +217,14 @@ convert_to_seg:
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
mov eax,edi
|
mov eax,edi
|
||||||
shr eax,16
|
; shr eax,16
|
||||||
shl eax,12
|
; shl eax,12
|
||||||
mov fs,ax
|
; mov fs,ax
|
||||||
|
shr eax, 4
|
||||||
|
mov fs, ax
|
||||||
|
and edi, 0xf
|
||||||
|
|
||||||
and edi,0ffffh
|
; and edi,0ffffh
|
||||||
|
|
||||||
pop eax
|
pop eax
|
||||||
ret
|
ret
|
||||||
|
@ -342,24 +232,541 @@ convert_to_seg:
|
||||||
;
|
;
|
||||||
; Print string in DS:DI
|
; Print string in DS:DI
|
||||||
;
|
;
|
||||||
_print_string:
|
print_string:
|
||||||
push ax
|
push ebp
|
||||||
push dx
|
mov bp, sp
|
||||||
push di
|
push eax
|
||||||
mov ah,02h
|
push edx
|
||||||
l3:
|
push edi
|
||||||
mov dl,[di]
|
|
||||||
cmp dl,0
|
mov ax, 0x0200
|
||||||
je l4
|
.loop:
|
||||||
int 021h
|
mov dl, [di]
|
||||||
|
cmp dl, 0
|
||||||
|
je .end_loop
|
||||||
|
cmp dl, '%'
|
||||||
|
jne .print_char
|
||||||
|
inc di
|
||||||
|
mov dl, [di]
|
||||||
|
cmp dl, 'a'
|
||||||
|
jne .not_ax
|
||||||
|
push eax
|
||||||
|
mov eax, [ss:bp - 4]
|
||||||
|
call print_ax
|
||||||
|
pop eax
|
||||||
|
jmp .next_char
|
||||||
|
|
||||||
|
.not_ax:
|
||||||
|
cmp dl, 'A'
|
||||||
|
jne .not_eax
|
||||||
|
push eax
|
||||||
|
mov eax, [ss:bp - 4]
|
||||||
|
call print_eax
|
||||||
|
pop eax
|
||||||
|
jmp .next_char
|
||||||
|
|
||||||
|
.not_eax:
|
||||||
|
cmp dl, 'c'
|
||||||
|
jne .not_cx
|
||||||
|
push ax
|
||||||
|
mov ax, cx
|
||||||
|
call print_ax
|
||||||
|
pop ax
|
||||||
|
jmp .next_char
|
||||||
|
|
||||||
|
.not_cx:
|
||||||
|
|
||||||
|
.print_char:
|
||||||
|
int 0x21
|
||||||
|
|
||||||
|
.next_char:
|
||||||
inc di
|
inc di
|
||||||
jmp l3
|
jmp .loop
|
||||||
l4:
|
|
||||||
pop di
|
.end_loop:
|
||||||
pop dx
|
pop edi
|
||||||
pop ax
|
pop edx
|
||||||
|
pop eax
|
||||||
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
;
|
||||||
|
; print_ax - print the number in the ax register
|
||||||
|
;
|
||||||
|
|
||||||
|
print_ax:
|
||||||
|
push ax
|
||||||
|
push bx
|
||||||
|
push cx
|
||||||
|
push dx
|
||||||
|
|
||||||
|
mov bx, ax
|
||||||
|
mov ax, 0x0200
|
||||||
|
mov cx, 4
|
||||||
|
.loop:
|
||||||
|
mov dx, bx
|
||||||
|
shr dx, 12
|
||||||
|
and dl, 0x0f
|
||||||
|
cmp dl, 0x0a
|
||||||
|
jge .hex_val
|
||||||
|
add dl, '0'
|
||||||
|
jmp .not_hex
|
||||||
|
|
||||||
|
.hex_val:
|
||||||
|
add dl, 'a' - 10
|
||||||
|
|
||||||
|
.not_hex:
|
||||||
|
int 0x21
|
||||||
|
shl bx, 4
|
||||||
|
dec cx
|
||||||
|
jnz .loop
|
||||||
|
|
||||||
|
pop dx
|
||||||
|
pop cx
|
||||||
|
pop bx
|
||||||
|
pop ax
|
||||||
|
ret
|
||||||
|
|
||||||
|
print_eax:
|
||||||
|
push eax
|
||||||
|
push ebx
|
||||||
|
push ecx
|
||||||
|
push edx
|
||||||
|
|
||||||
|
mov ebx, eax
|
||||||
|
mov ax, 0x0200
|
||||||
|
mov cx, 8
|
||||||
|
.loop:
|
||||||
|
mov edx, ebx
|
||||||
|
shr edx, 28
|
||||||
|
and dl, 0x0f
|
||||||
|
cmp dl, 0x0a
|
||||||
|
jge .hex_val
|
||||||
|
add dl, '0'
|
||||||
|
jmp .not_hex
|
||||||
|
|
||||||
|
.hex_val:
|
||||||
|
add dl, 'a' - 10
|
||||||
|
|
||||||
|
.not_hex:
|
||||||
|
int 0x21
|
||||||
|
shl ebx, 4
|
||||||
|
dec cx
|
||||||
|
jnz .loop
|
||||||
|
|
||||||
|
pop edx
|
||||||
|
pop ecx
|
||||||
|
pop ebx
|
||||||
|
pop eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
STRUC DOS_HDR
|
||||||
|
e_magic: resw 1
|
||||||
|
e_cblp: resw 1
|
||||||
|
e_cp: resw 1
|
||||||
|
e_crlc: resw 1
|
||||||
|
e_cparhdr: resw 1
|
||||||
|
e_minalloc: resw 1
|
||||||
|
e_maxalloc: resw 1
|
||||||
|
e_ss: resw 1
|
||||||
|
e_sp: resw 1
|
||||||
|
e_csum: resw 1
|
||||||
|
e_ip: resw 1
|
||||||
|
e_cs: resw 1
|
||||||
|
e_lfarlc: resw 1
|
||||||
|
e_ovno: resw 1
|
||||||
|
e_res: resw 4
|
||||||
|
e_oemid: resw 1
|
||||||
|
e_oeminfo: resw 1
|
||||||
|
e_res2: resw 10
|
||||||
|
e_lfanew: resd 1
|
||||||
|
ENDSTRUC
|
||||||
|
|
||||||
|
STRUC NT_HDRS
|
||||||
|
nth_sig: resd 1
|
||||||
|
ntf_mach: resw 1
|
||||||
|
ntf_num_secs: resw 1
|
||||||
|
ntf_timestamp: resd 1
|
||||||
|
ntf_symtab_ptr: resd 1
|
||||||
|
ntf_num_syms: resd 1
|
||||||
|
ntf_opt_hdr_sz: resw 1
|
||||||
|
ntf_chars: resw 1
|
||||||
|
|
||||||
|
nto_magic: resw 1
|
||||||
|
nto_mjr_lnk_vr: resb 1
|
||||||
|
nto_mnr_lnk_vr: resb 1
|
||||||
|
nto_code_sz: resd 1
|
||||||
|
nto_data_sz: resd 1
|
||||||
|
nto_bss_sz: resd 1
|
||||||
|
nto_entry_offs: resd 1
|
||||||
|
nto_code_offs: resd 1
|
||||||
|
nto_data_offs: resd 1
|
||||||
|
nto_image_base: resd 1
|
||||||
|
nto_sec_align: resd 1
|
||||||
|
nto_file_align: resd 1
|
||||||
|
nto_mjr_os_ver: resw 1
|
||||||
|
nto_Mnr_os_ver: resw 1
|
||||||
|
nto_mjr_img_vr: resw 1
|
||||||
|
nto_Mnr_img_vr: resw 1
|
||||||
|
nto_mjr_subsys: resw 1
|
||||||
|
nto_mnr_subsys: resw 1
|
||||||
|
nto_w32_ver: resd 1
|
||||||
|
nto_image_sz: resd 1
|
||||||
|
nto_hdr_sz: resd 1
|
||||||
|
nto_chksum: resd 1
|
||||||
|
nto_subsys: resw 1
|
||||||
|
nto_dll_chars: resw 1
|
||||||
|
nto_stk_res_sz: resd 1
|
||||||
|
nto_stk_cmt_sz: resd 1
|
||||||
|
nto_hp_res_sz: resd 1
|
||||||
|
nto_hp_cmt_sz: resd 1
|
||||||
|
nto_ldr_flags: resd 1
|
||||||
|
nto_dir_cnt: resd 1
|
||||||
|
nto_dir_ent: resq 16
|
||||||
|
ENDSTRUC
|
||||||
|
|
||||||
|
STRUC DATA_DIR
|
||||||
|
dd_rva: resd 1
|
||||||
|
dd_sz: resd 1
|
||||||
|
ENDSTRUC
|
||||||
|
|
||||||
|
STRUC SCN_HDR
|
||||||
|
se_name: resb 8
|
||||||
|
se_vsz: resd 1
|
||||||
|
se_vaddr: resd 1
|
||||||
|
se_rawsz: resd 1
|
||||||
|
se_raw_ofs: resd 1
|
||||||
|
se_reloc_ofs: resd 1
|
||||||
|
se_lnum_ofs: resd 1
|
||||||
|
se_num_relocs: resw 1
|
||||||
|
se_num_lnums: resw 1
|
||||||
|
se_chars: resd 1
|
||||||
|
ENDSTRUC
|
||||||
|
|
||||||
|
;
|
||||||
|
; pe_load_module - load a PE module into memory
|
||||||
|
;
|
||||||
|
; DI - Filename
|
||||||
|
;
|
||||||
|
; [_nr_files] - total files loaded (incremented)
|
||||||
|
; [next_load_base] - load base for file (updated to next loc)
|
||||||
|
; [_module_lengths] - correct slot is set.
|
||||||
|
;
|
||||||
|
|
||||||
|
pe_load_module:
|
||||||
|
push dx
|
||||||
|
push ds
|
||||||
|
|
||||||
|
push ds
|
||||||
|
pop es
|
||||||
|
|
||||||
|
mov eax, [next_load_base]
|
||||||
|
mov [load_base], eax
|
||||||
|
DPRINT 'next_load_base %A', 13, 10, 0
|
||||||
|
|
||||||
|
;
|
||||||
|
; Open the file
|
||||||
|
;
|
||||||
|
mov ax, 0x3d00
|
||||||
|
mov dx, di
|
||||||
|
int 0x21
|
||||||
|
jnc .open_good
|
||||||
|
jmp .error
|
||||||
|
.open_good:
|
||||||
|
mov [file_handle],ax
|
||||||
|
|
||||||
|
;
|
||||||
|
; Seek to beginning of file
|
||||||
|
;
|
||||||
|
mov ax,0x4200
|
||||||
|
mov bx, [file_handle]
|
||||||
|
mov cx, 0
|
||||||
|
mov dx, 0
|
||||||
|
int 0x21
|
||||||
|
jnc .rewind_good
|
||||||
|
jmp .error
|
||||||
|
.rewind_good:
|
||||||
|
|
||||||
|
;
|
||||||
|
; Compute load address for PE headers
|
||||||
|
;
|
||||||
|
mov edi,[load_base]
|
||||||
|
call convert_to_seg
|
||||||
|
mov dx,di
|
||||||
|
push fs
|
||||||
|
pop ds
|
||||||
|
|
||||||
|
;
|
||||||
|
; Load the headers
|
||||||
|
;
|
||||||
|
mov ax, 0x3f00
|
||||||
|
mov bx, [es:file_handle]
|
||||||
|
mov cx, 0x1000
|
||||||
|
int 0x21
|
||||||
|
|
||||||
|
;
|
||||||
|
; Check DOS MZ Header
|
||||||
|
;
|
||||||
|
mov bx, dx
|
||||||
|
mov ax, word [bx + e_magic]
|
||||||
|
cmp ax, 'MZ'
|
||||||
|
je .mz_hdr_good
|
||||||
|
push es
|
||||||
|
pop ds
|
||||||
|
mov dx, bad_mz_msg
|
||||||
|
mov di, dx
|
||||||
|
call print_string
|
||||||
|
jmp .error
|
||||||
|
|
||||||
|
.mz_hdr_good:
|
||||||
|
;
|
||||||
|
; Check PE Header
|
||||||
|
;
|
||||||
|
mov eax, dword [bx + e_lfanew]
|
||||||
|
DPRINT 'lfanew %A ', 0
|
||||||
|
add bx, ax
|
||||||
|
mov eax, dword [bx + nth_sig]
|
||||||
|
cmp eax, 0x00004550
|
||||||
|
je .pe_hdr_good
|
||||||
|
push es
|
||||||
|
pop ds
|
||||||
|
mov dx, bad_pe_msg
|
||||||
|
mov di, dx
|
||||||
|
call print_string
|
||||||
|
jmp .error
|
||||||
|
|
||||||
|
.pe_hdr_good:
|
||||||
|
;
|
||||||
|
; Get header size and bump next_load_base
|
||||||
|
;
|
||||||
|
mov eax, [bx + nto_hdr_sz]
|
||||||
|
DPRINT 'header size %A ', 0
|
||||||
|
add dword [es:next_load_base], eax
|
||||||
|
|
||||||
|
;
|
||||||
|
; Setup section pointer
|
||||||
|
;
|
||||||
|
mov ax, [bx + ntf_num_secs]
|
||||||
|
DPRINT 'num sections %a', 13, 10, 0
|
||||||
|
mov [es:num_sections], ax
|
||||||
|
add bx, NT_HDRS_size
|
||||||
|
mov [es:cur_section], bx
|
||||||
|
mov [es:cur_section + 2], ds
|
||||||
|
;
|
||||||
|
; Load each section or fill with zeroes
|
||||||
|
;
|
||||||
|
.scn_loop:
|
||||||
|
;
|
||||||
|
; Compute size of data to load from file
|
||||||
|
;
|
||||||
|
mov eax, [bx + se_rawsz]
|
||||||
|
DPRINT 'raw size %A ', 0
|
||||||
|
cmp eax, 0
|
||||||
|
jne .got_data
|
||||||
|
jmp .no_data
|
||||||
|
.got_data:
|
||||||
|
mov [es:size_mod_4k], ax
|
||||||
|
and word [es:size_mod_4k], 0x0fff
|
||||||
|
shr eax, 12
|
||||||
|
mov dword [es:size_div_4k], eax
|
||||||
|
|
||||||
|
;
|
||||||
|
; Seek to section offset
|
||||||
|
;
|
||||||
|
mov eax, [bx + se_raw_ofs]
|
||||||
|
DPRINT 'raw offset %A ', 0
|
||||||
|
mov dx, ax
|
||||||
|
shr eax, 16
|
||||||
|
mov cx, ax
|
||||||
|
mov ax,0x4200
|
||||||
|
mov bx, [es:file_handle]
|
||||||
|
int 0x21
|
||||||
|
jnc .seek_good
|
||||||
|
jmp .error
|
||||||
|
.seek_good:
|
||||||
|
|
||||||
|
;
|
||||||
|
; Load the base pointer
|
||||||
|
;
|
||||||
|
mov edi,[es:next_load_base]
|
||||||
|
call convert_to_seg
|
||||||
|
mov dx, di
|
||||||
|
push fs
|
||||||
|
pop ds
|
||||||
|
|
||||||
|
;
|
||||||
|
; Read data in 4k chunks
|
||||||
|
;
|
||||||
|
.do_chunk:
|
||||||
|
;
|
||||||
|
; Check if we have read it all
|
||||||
|
;
|
||||||
|
mov eax, [es:size_div_4k]
|
||||||
|
cmp eax, 0
|
||||||
|
je .chunk_done
|
||||||
|
|
||||||
|
;
|
||||||
|
; Make the call (dx was loaded above)
|
||||||
|
;
|
||||||
|
mov ax, 0x3f00
|
||||||
|
mov bx, [es:file_handle]
|
||||||
|
mov cx, 0x1000
|
||||||
|
int 0x21
|
||||||
|
; FIXME: should check return status and count
|
||||||
|
|
||||||
|
;
|
||||||
|
; We move onto the next pointer by altering ds
|
||||||
|
;
|
||||||
|
mov ax, ds
|
||||||
|
add ax, 0x0100
|
||||||
|
mov ds, ax
|
||||||
|
dec word [es:size_div_4k]
|
||||||
|
jmp .do_chunk
|
||||||
|
|
||||||
|
.chunk_done:
|
||||||
|
;
|
||||||
|
; Read the last section
|
||||||
|
;
|
||||||
|
mov ax, 0x3f00
|
||||||
|
mov bx, [es:file_handle]
|
||||||
|
mov cx, [es:size_mod_4k]
|
||||||
|
int 0x21
|
||||||
|
jnc .last_read_good
|
||||||
|
jmp .error
|
||||||
|
.last_read_good:
|
||||||
|
|
||||||
|
.no_data:
|
||||||
|
;
|
||||||
|
; Zero out uninitialized data sections
|
||||||
|
;
|
||||||
|
lds bx, [es:cur_section]
|
||||||
|
mov eax, dword [bx + se_chars]
|
||||||
|
DPRINT 'section chars %A', 13, 10, 0
|
||||||
|
test dword [bx + se_chars], 0x80
|
||||||
|
jz .no_fill
|
||||||
|
|
||||||
|
;
|
||||||
|
; Compute size of section to zero fill
|
||||||
|
;
|
||||||
|
mov eax, [bx + se_vsz]
|
||||||
|
cmp eax, 0
|
||||||
|
je .no_fill
|
||||||
|
mov [es:size_mod_4k], ax
|
||||||
|
and word [es:size_mod_4k], 0x0fff
|
||||||
|
shr eax, 12
|
||||||
|
mov [size_div_4k], eax
|
||||||
|
|
||||||
|
;
|
||||||
|
; Load the base pointer
|
||||||
|
;
|
||||||
|
mov edi,[es:next_load_base]
|
||||||
|
call convert_to_seg
|
||||||
|
mov dx, di
|
||||||
|
push fs
|
||||||
|
pop ds
|
||||||
|
|
||||||
|
.do_fill:
|
||||||
|
;
|
||||||
|
; Check if we have read it all
|
||||||
|
;
|
||||||
|
mov eax, [es:size_div_4k]
|
||||||
|
cmp eax, 0
|
||||||
|
je .fill_done
|
||||||
|
|
||||||
|
;
|
||||||
|
; Zero out a chunk
|
||||||
|
;
|
||||||
|
mov ax, 0x0000
|
||||||
|
mov cx, 0x1000
|
||||||
|
push di
|
||||||
|
push es
|
||||||
|
push ds
|
||||||
|
pop es
|
||||||
|
rep stosb
|
||||||
|
pop es
|
||||||
|
pop di
|
||||||
|
|
||||||
|
;
|
||||||
|
; We move onto the next pointer by altering ds
|
||||||
|
;
|
||||||
|
mov ax, ds
|
||||||
|
add ax, 0x0100
|
||||||
|
mov ds, ax
|
||||||
|
dec word [es:size_div_4k]
|
||||||
|
jmp .do_fill
|
||||||
|
|
||||||
|
.fill_done:
|
||||||
|
;
|
||||||
|
; Read the last section
|
||||||
|
;
|
||||||
|
mov ax, 0x0000
|
||||||
|
mov cx, [es:size_mod_4k]
|
||||||
|
push di
|
||||||
|
push es
|
||||||
|
push ds
|
||||||
|
pop es
|
||||||
|
rep stosb
|
||||||
|
pop es
|
||||||
|
pop di
|
||||||
|
|
||||||
|
.no_fill:
|
||||||
|
|
||||||
|
;
|
||||||
|
; Update raw data offset in section header
|
||||||
|
;
|
||||||
|
lds bx, [es:cur_section]
|
||||||
|
mov eax, [es:next_load_base]
|
||||||
|
sub eax, [es:load_base]
|
||||||
|
DPRINT 'new raw offset %A ', 0
|
||||||
|
mov [bx + se_raw_ofs], eax
|
||||||
|
|
||||||
|
;
|
||||||
|
; Update next_load_base
|
||||||
|
;
|
||||||
|
mov eax, [bx + se_vsz]
|
||||||
|
DPRINT 'scn virtual sz %A ', 0
|
||||||
|
and eax, 0xfffff000
|
||||||
|
add dword [es:next_load_base], eax
|
||||||
|
test dword [bx + se_vsz], 0xfff
|
||||||
|
jz .even_scn
|
||||||
|
add dword [es:next_load_base], 0x1000
|
||||||
|
|
||||||
|
.even_scn:
|
||||||
|
mov eax, [es:next_load_base]
|
||||||
|
DPRINT 'next load base %A', 13, 10, 0
|
||||||
|
|
||||||
|
;
|
||||||
|
; Setup for next section or exit loop
|
||||||
|
;
|
||||||
|
dec word [es:num_sections]
|
||||||
|
jz .scn_done
|
||||||
|
add bx, SCN_HDR_size
|
||||||
|
mov [es:cur_section], bx
|
||||||
|
jmp .scn_loop
|
||||||
|
|
||||||
|
.scn_done:
|
||||||
|
;
|
||||||
|
; Update module_length
|
||||||
|
;
|
||||||
|
mov eax, [es:next_load_base]
|
||||||
|
sub eax, [es:load_base]
|
||||||
|
mov esi, [es:_nr_files]
|
||||||
|
mov [es:_module_lengths + esi * 4], eax
|
||||||
|
|
||||||
|
inc dword [es:_nr_files]
|
||||||
|
|
||||||
|
pop ds
|
||||||
|
pop dx
|
||||||
|
ret
|
||||||
|
|
||||||
|
.error:
|
||||||
|
push es
|
||||||
|
pop ds
|
||||||
|
mov di, err_msg
|
||||||
|
call print_string
|
||||||
|
jmp exit
|
||||||
|
|
||||||
;
|
;
|
||||||
; Handle of the currently open file
|
; Handle of the currently open file
|
||||||
;
|
;
|
||||||
|
@ -375,6 +782,10 @@ size_mod_4k dw 0
|
||||||
;
|
;
|
||||||
size_div_4k dd 0
|
size_div_4k dd 0
|
||||||
|
|
||||||
|
load_base dd 0
|
||||||
|
num_sections dw 0
|
||||||
|
cur_section dd 0
|
||||||
|
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
|
@ -383,17 +794,15 @@ last_addr dw 0
|
||||||
;
|
;
|
||||||
; Generic error message
|
; Generic error message
|
||||||
;
|
;
|
||||||
err_msg db 'Error during operation',0
|
err_msg db 'Error during operation',10, 13, 0
|
||||||
rostitle db '',0
|
bad_mz_msg db 'Module has bad MZ header', 10, 13, 0
|
||||||
|
bad_pe_msg db 'Module has bad PE header', 10, 13, 0
|
||||||
|
rostitle db '',0
|
||||||
|
loading_msg db 'Loading: ',0
|
||||||
|
death_msg db 'death', 0
|
||||||
|
|
||||||
;
|
filelength_lo dw 0
|
||||||
;
|
filelength_hi dw 0
|
||||||
;
|
|
||||||
loading_msg db 'Loading: ',0
|
|
||||||
death_msg: db 'death', 0
|
|
||||||
|
|
||||||
filelength_lo dw 0
|
|
||||||
filelength_hi dw 0
|
|
||||||
|
|
||||||
kernel_page_directory_base dd 0
|
kernel_page_directory_base dd 0
|
||||||
system_page_table_base dd 0
|
system_page_table_base dd 0
|
||||||
|
|
|
@ -35,8 +35,8 @@ LOADERS = dos
|
||||||
#
|
#
|
||||||
DEVICE_DRIVERS = blue ide keyboard mouse null parallel serial vidport
|
DEVICE_DRIVERS = blue ide keyboard mouse null parallel serial vidport
|
||||||
# DEVICE_DRIVERS = beep event floppy ide_test sound test test1
|
# DEVICE_DRIVERS = beep event floppy ide_test sound test test1
|
||||||
FS_DRIVERS = minix vfat ext2
|
FS_DRIVERS = vfat
|
||||||
# FS_DRIVERS = template
|
# FS_DRIVERS = minix ext2 template
|
||||||
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(FS_DRIVERS)
|
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(FS_DRIVERS)
|
||||||
|
|
||||||
APPS = args hello shell test cat bench
|
APPS = args hello shell test cat bench
|
||||||
|
|
|
@ -264,6 +264,7 @@ MmUnlockPages
|
||||||
MmUnlockPagableImageSection
|
MmUnlockPagableImageSection
|
||||||
MmUnmapIoSpace
|
MmUnmapIoSpace
|
||||||
MmUnmapLockedPages
|
MmUnmapLockedPages
|
||||||
|
NtCreateToken
|
||||||
ObDereferenceObject
|
ObDereferenceObject
|
||||||
ObReferenceObjectByHandle
|
ObReferenceObjectByHandle
|
||||||
ObReferenceObjectByPointer
|
ObReferenceObjectByPointer
|
||||||
|
@ -356,6 +357,7 @@ ZwClose
|
||||||
ZwCreateDirectoryObject
|
ZwCreateDirectoryObject
|
||||||
ZwCreateFile
|
ZwCreateFile
|
||||||
ZwCreateKey
|
ZwCreateKey
|
||||||
|
ZwCreateToken
|
||||||
ZwDeleteKey
|
ZwDeleteKey
|
||||||
ZwEnumerateKey
|
ZwEnumerateKey
|
||||||
ZwEnumerateValueKey
|
ZwEnumerateValueKey
|
||||||
|
|
|
@ -121,7 +121,7 @@ asmlinkage void _main(boot_param* _bp)
|
||||||
boot_param bp;
|
boot_param bp;
|
||||||
unsigned int last_kernel_address;
|
unsigned int last_kernel_address;
|
||||||
|
|
||||||
memset((void *)&edata,0,((int)&end)-((int)&edata));
|
// memset((void *)&edata,0,((int)&end)-((int)&edata));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy the parameters to a local buffer because lowmem will go away
|
* Copy the parameters to a local buffer because lowmem will go away
|
||||||
|
@ -169,12 +169,14 @@ asmlinkage void _main(boot_param* _bp)
|
||||||
DPRINT("%d files loaded\n",bp.nr_files);
|
DPRINT("%d files loaded\n",bp.nr_files);
|
||||||
|
|
||||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
||||||
start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
|
// start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
|
||||||
|
start1 = start + bp.module_length[1];
|
||||||
for (i=1;i<bp.nr_files;i++)
|
for (i=1;i<bp.nr_files;i++)
|
||||||
{
|
{
|
||||||
DPRINT("process module at %08lx\n", start);
|
DPRINT("process module at %08lx\n", start);
|
||||||
LdrProcessDriver((PVOID)start);
|
LdrProcessDriver((PVOID)start);
|
||||||
start=start+PAGE_ROUND_UP(bp.module_length[i]);
|
// start=start+PAGE_ROUND_UP(bp.module_length[i]);
|
||||||
|
start = start + bp.module_length[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -53,6 +53,7 @@ NTSTATUS LdrProcessDriver(PVOID ModuleLoadBase);
|
||||||
PMODULE_OBJECT LdrLoadModule(PUNICODE_STRING Filename);
|
PMODULE_OBJECT LdrLoadModule(PUNICODE_STRING Filename);
|
||||||
PMODULE_OBJECT LdrProcessModule(PVOID ModuleLoadBase);
|
PMODULE_OBJECT LdrProcessModule(PVOID ModuleLoadBase);
|
||||||
PVOID LdrGetExportAddress(PMODULE_OBJECT ModuleObject, char *Name, unsigned short Hint);
|
PVOID LdrGetExportAddress(PMODULE_OBJECT ModuleObject, char *Name, unsigned short Hint);
|
||||||
|
static PMODULE_OBJECT LdrOpenModule(PUNICODE_STRING Filename);
|
||||||
static PIMAGE_SECTION_HEADER LdrPEGetEnclosingSectionHeader(DWORD RVA,
|
static PIMAGE_SECTION_HEADER LdrPEGetEnclosingSectionHeader(DWORD RVA,
|
||||||
PMODULE_OBJECT ModuleObject);
|
PMODULE_OBJECT ModuleObject);
|
||||||
static NTSTATUS LdrCreateModule(PVOID ObjectBody,
|
static NTSTATUS LdrCreateModule(PVOID ObjectBody,
|
||||||
|
@ -252,39 +253,14 @@ LdrLoadModule(PUNICODE_STRING Filename)
|
||||||
PWSTR RemainingPath;
|
PWSTR RemainingPath;
|
||||||
UNICODE_STRING ModuleName;
|
UNICODE_STRING ModuleName;
|
||||||
|
|
||||||
DPRINT("Loading Module %W...\n", Filename);
|
|
||||||
|
|
||||||
/* Check for module already loaded */
|
/* Check for module already loaded */
|
||||||
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
if ((ModuleObject = LdrOpenModule(Filename)) != NULL)
|
||||||
if (wcsrchr(Filename->Buffer, '\\') != 0)
|
|
||||||
{
|
{
|
||||||
wcscat(NameBuffer, wcsrchr(Filename->Buffer, '\\') + 1);
|
return ModuleObject;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wcscat(NameBuffer, Filename->Buffer);
|
|
||||||
}
|
|
||||||
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
|
||||||
ModuleName.Buffer = NameBuffer;
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&ModuleName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
Status = ObFindObject(&ObjectAttributes,
|
|
||||||
(PVOID *) &ModuleObject,
|
|
||||||
&RemainingPath);
|
|
||||||
CHECKPOINT;
|
|
||||||
if (NT_SUCCESS(Status) && *RemainingPath == 0)
|
|
||||||
{
|
|
||||||
return ModuleObject;
|
|
||||||
}
|
|
||||||
CHECKPOINT;
|
|
||||||
if (!wcsncmp(Filename->Buffer, MODULE_ROOT_NAME, wcslen(MODULE_ROOT_NAME)))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPRINT("Loading Module %W...\n", Filename);
|
||||||
|
|
||||||
/* Open the Module */
|
/* Open the Module */
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
Filename,
|
Filename,
|
||||||
|
@ -393,6 +369,46 @@ LdrProcessModule(PVOID ModuleLoadBase)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PMODULE_OBJECT
|
||||||
|
LdrOpenModule(PUNICODE_STRING Filename)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
WCHAR NameBuffer[60];
|
||||||
|
UNICODE_STRING ModuleName;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
PMODULE_OBJECT ModuleObject;
|
||||||
|
PWSTR RemainingPath;
|
||||||
|
|
||||||
|
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
||||||
|
if (wcsrchr(Filename->Buffer, '\\') != 0)
|
||||||
|
{
|
||||||
|
wcscat(NameBuffer, wcsrchr(Filename->Buffer, '\\') + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcscat(NameBuffer, Filename->Buffer);
|
||||||
|
}
|
||||||
|
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
||||||
|
ModuleName.Buffer = NameBuffer;
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&ModuleName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = ObFindObject(&ObjectAttributes,
|
||||||
|
(PVOID *) &ModuleObject,
|
||||||
|
&RemainingPath);
|
||||||
|
CHECKPOINT;
|
||||||
|
if (NT_SUCCESS(Status) && (RemainingPath == NULL || *RemainingPath == 0))
|
||||||
|
{
|
||||||
|
DPRINT("Module %W at %p\n", Filename, ModuleObject);
|
||||||
|
|
||||||
|
return ModuleObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
LdrGetExportAddress(PMODULE_OBJECT ModuleObject,
|
LdrGetExportAddress(PMODULE_OBJECT ModuleObject,
|
||||||
char *Name,
|
char *Name,
|
||||||
|
@ -617,12 +633,14 @@ LdrPEProcessModule(PVOID ModuleLoadBase)
|
||||||
/* Check to make sure that import lib is kernel */
|
/* Check to make sure that import lib is kernel */
|
||||||
pName = (PCHAR) DriverBase +
|
pName = (PCHAR) DriverBase +
|
||||||
ImportModuleDirectory->dwRVAModuleName;
|
ImportModuleDirectory->dwRVAModuleName;
|
||||||
|
#if 0
|
||||||
if (!strcmp(pName, "ntoskrnl.exe") || !strcmp(pName, "HAL.dll"))
|
if (!strcmp(pName, "ntoskrnl.exe") || !strcmp(pName, "HAL.dll"))
|
||||||
{
|
{
|
||||||
LibraryModuleObject = NULL;
|
LibraryModuleObject = NULL;
|
||||||
DPRINT("Kernel imports\n");
|
DPRINT("Kernel imports\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
||||||
for (Idx = 0; NameBuffer[Idx] != 0; Idx++)
|
for (Idx = 0; NameBuffer[Idx] != 0; Idx++)
|
||||||
|
@ -799,19 +817,21 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
|
||||||
OrdinalList = (PWORD)((DWORD)ExportDirectory->AddressOfNameOrdinals -
|
OrdinalList = (PWORD)((DWORD)ExportDirectory->AddressOfNameOrdinals -
|
||||||
Delta + ModuleObject->Base);
|
Delta + ModuleObject->Base);
|
||||||
DPRINT("Delta:%08x\n", Delta);
|
DPRINT("Delta:%08x\n", Delta);
|
||||||
DPRINT("Func:%08x RVA:%08x Name:%08x RVA:%08x Ord:%08x RVA:%08x\n", FunctionList,
|
DPRINT("Func:%08x RVA:%08x Name:%08x RVA:%08x\nOrd:%08x RVA:%08x ",
|
||||||
ExportDirectory->AddressOfFunctions, NameList,
|
FunctionList, ExportDirectory->AddressOfFunctions,
|
||||||
ExportDirectory->AddressOfNames, OrdinalList,
|
NameList, ExportDirectory->AddressOfNames,
|
||||||
ExportDirectory->AddressOfNameOrdinals);
|
OrdinalList, ExportDirectory->AddressOfNameOrdinals);
|
||||||
DPRINT("NumNames:%d NumFuncs:%d\n", ExportDirectory->NumberOfNames,
|
DPRINT("NumNames:%d NumFuncs:%d\n", ExportDirectory->NumberOfNames,
|
||||||
ExportDirectory->NumberOfFunctions);
|
ExportDirectory->NumberOfFunctions);
|
||||||
for(;;);
|
|
||||||
ExportAddress = 0;
|
ExportAddress = 0;
|
||||||
if (Name != NULL)
|
if (Name != NULL)
|
||||||
{
|
{
|
||||||
for (Idx = 0; Idx < ExportDirectory->NumberOfNames; Idx++)
|
for (Idx = 0; Idx < ExportDirectory->NumberOfNames; Idx++)
|
||||||
{
|
{
|
||||||
DPRINT(" Name:%s NameList[%d]:%s\n", Name, Idx, NameList[Idx]);
|
DPRINT(" Name:%s NameList[%d]:%s\n",
|
||||||
|
Name,
|
||||||
|
Idx,
|
||||||
|
(DWORD) ModuleObject->Base + NameList[Idx]);
|
||||||
if (!strcmp(Name, (PCHAR) ((DWORD)ModuleObject->Base + NameList[Idx])))
|
if (!strcmp(Name, (PCHAR) ((DWORD)ModuleObject->Base + NameList[Idx])))
|
||||||
{
|
{
|
||||||
ExportAddress = (PVOID) ((DWORD)ModuleObject->Base +
|
ExportAddress = (PVOID) ((DWORD)ModuleObject->Base +
|
||||||
|
|
|
@ -69,6 +69,7 @@ HalGetInterruptVector
|
||||||
KeBugCheck
|
KeBugCheck
|
||||||
KeBugCheckEx
|
KeBugCheckEx
|
||||||
KeFlushIoBuffers
|
KeFlushIoBuffers
|
||||||
|
KeGetCurrentIrql
|
||||||
KeInitializeDpc
|
KeInitializeDpc
|
||||||
KeInitializeEvent
|
KeInitializeEvent
|
||||||
KeInitializeSpinLock
|
KeInitializeSpinLock
|
||||||
|
@ -78,6 +79,8 @@ KeStallExecutionProcessor
|
||||||
KeSynchronizeExecution
|
KeSynchronizeExecution
|
||||||
KeRaiseIrql
|
KeRaiseIrql
|
||||||
KeWaitForSingleObject
|
KeWaitForSingleObject
|
||||||
|
HalGetBusDataByOffset
|
||||||
|
HalSetBusDataByOffset
|
||||||
InitializeObjectAttributes
|
InitializeObjectAttributes
|
||||||
IoAllocateController
|
IoAllocateController
|
||||||
IoAttachDeviceToDeviceStack
|
IoAttachDeviceToDeviceStack
|
||||||
|
@ -90,6 +93,7 @@ IoCreateDevice
|
||||||
IoCreateStreamFileObject
|
IoCreateStreamFileObject
|
||||||
IoCreateSymbolicLink
|
IoCreateSymbolicLink
|
||||||
IoDeleteController
|
IoDeleteController
|
||||||
|
IoDeleteDevice
|
||||||
IoDisconnectInterrupt
|
IoDisconnectInterrupt
|
||||||
IoFreeController
|
IoFreeController
|
||||||
IoGetCurrentIrpStackLocation
|
IoGetCurrentIrpStackLocation
|
||||||
|
@ -102,8 +106,11 @@ IoStartPacket
|
||||||
IoStartNextPacket
|
IoStartNextPacket
|
||||||
IoStartNextPacketByKey
|
IoStartNextPacketByKey
|
||||||
IoStartTimer
|
IoStartTimer
|
||||||
|
IoStopTimer
|
||||||
MmGetSystemAddressForMdl
|
MmGetSystemAddressForMdl
|
||||||
|
MmMapIoSpace
|
||||||
RtlAnsiStringToUnicodeString
|
RtlAnsiStringToUnicodeString
|
||||||
|
RtlCompareMemory
|
||||||
RtlConvertLongToLargeInteger
|
RtlConvertLongToLargeInteger
|
||||||
RtlConvertUlongToLargeInteger
|
RtlConvertUlongToLargeInteger
|
||||||
RtlCopyMemory
|
RtlCopyMemory
|
||||||
|
@ -115,6 +122,7 @@ RtlInitUnicodeString
|
||||||
RtlLargeIntegerAdd
|
RtlLargeIntegerAdd
|
||||||
RtlLargeIntegerGreaterThan
|
RtlLargeIntegerGreaterThan
|
||||||
RtlLargeIntegerShiftRight
|
RtlLargeIntegerShiftRight
|
||||||
|
RtlMoveMemory
|
||||||
RtlTimeFieldsToTime
|
RtlTimeFieldsToTime
|
||||||
RtlTimeToTimeFields
|
RtlTimeToTimeFields
|
||||||
RtlZeroMemory
|
RtlZeroMemory
|
||||||
|
|
|
@ -260,7 +260,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
|
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
|
||||||
&PiNextThreadUniqueId);
|
&PiNextThreadUniqueId);
|
||||||
Thread->Cid.UniqueProcess = (HANDLE)Thread->ThreadsProcess->UniqueProcessId;
|
Thread->Cid.UniqueProcess = (HANDLE)Thread->ThreadsProcess->UniqueProcessId;
|
||||||
DbgPrint("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread);
|
DPRINT("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread);
|
||||||
ObReferenceObjectByPointer(Thread,
|
ObReferenceObjectByPointer(Thread,
|
||||||
THREAD_ALL_ACCESS,
|
THREAD_ALL_ACCESS,
|
||||||
PsThreadType,
|
PsThreadType,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue