⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample_pe2.asm

📁 一个用纯汇编 写的操作系统 源代码 是用 TASM 编译器写的
💻 ASM
字号:
;Simplest Solar_OS Window
;Compile and run inside SOLAR_OS

format PE console
use32


;-----------------------------------------------------
; macro for indirectly call of STDCALL procedure
; used by SOLAR_OS API
;-----------------------------------------------------
macro invoke proc,[arg] 		
 { common
    if ~ arg eq
   reverse
     push arg
   common
    end if
    call [proc] }

;-------------------------------------------
; a few SOLAR_OS equates (not all)
;-------------------------------------------
WND_TYPE_TOP		EQU	0
WND_TYPE_BUTTON		EQU	10
WND_TYPE_EDIT		EQU	20

FLAG_WND_NO_MOVE	EQU	4h
FLAG_WND_NO_RESIZE	EQU	8h
FLAG_WND_MINI		EQU	80h

;----------------------------------
; OS Known callbacks
;----------------------------------
OS_CALL_BEFORE		EQU	1
OS_CALL_DEFAULT		EQU	2
OS_CALL_AFTER		EQU	3
OS_CALL_NOTIFY		EQU	4

;-------------------------------------
; Solar_OS events
;-------------------------------------
ACT_LEFT_DOWN_CHILD	EQU	2
ACT_LEFT_UP_CHILD	EQU	5
ACT_PAINT_CHILD		EQU	16
ACT_CLOSE_CHILD		EQU	20


;-----------------------------
; MAIN PROGRAM
;-----------------------------

start:

	;------------------------------
	; Create the Main app window
	;------------------------------	
	invoke	API_Window_Create, 0,100,128,460,156, FLAG_WND_MINI, WND_TYPE_TOP
	mov	[wnd_main_handle],eax

	;-----------------------------
	; set main window caption
	;-----------------------------
	invoke	API_Window_Set_Caption, [wnd_main_handle], wnd_main_caption

	xor eax,eax
	ret

;-----------------------
; data zone
;-----------------------
wnd_main_handle		dd	0
wnd_main_caption	db	"FASM compiled executable on SOL",0

;------------------
; Program END
;------------------


;------------------------------------------------
; FASM PE Imports
; SOL will resolve this when PE is mapped
;------------------------------------------------

section '.idata' import data readable writeable

	dd 0,0,0,rva sol_dll_name, rva sol_iat_table
	dd 0,0,0,0,0


sol_iat_table:

	API_Debug_Out_String		dd	rva _api_debug_out_string
	API_File_Open			dd	rva _api_file_open
	API_File_Close			dd	rva _api_file_close
	API_File_Read			dd	rva _api_file_read
	API_File_Get_Size		dd	rva _api_file_get_size


	API_Memory_Allocate		dd	rva _api_memory_allocate
	API_Memory_Release		dd	rva _api_memory_release

	API_Text_Draw			dd	rva _api_text_draw

	API_Window_Create		dd	rva _api_window_create
	API_Window_Set_Caption		dd	rva _api_window_set_caption
	API_Window_Set_Callback		dd	rva _api_window_set_callback
	API_Window_Get_Caption		dd	rva _api_window_get_caption	
	
	App_View_Memory_Init		dd	rva _app_view_memory_init
	App_View_Pe_Init		dd	rva _app_view_pe_init
	App_View_Text_Init		dd	rva _app_view_text_init

; end of IAT imports	
dd 0		
	
; DLL Name
sol_dll_name	db	"sol_os_coff.dll",0

; Import function names

	_api_debug_out_string		db	0,0,"API_Debug_Out_String",0

	_api_file_open			db	0,0,"API_File_Open",0
	_api_file_close			db	0,0,"API_File_Close",0
	_api_file_read			db	0,0,"API_File_Read",0
	_api_file_get_size		db	0,0,"API_File_Get_Size",0
	

	_api_memory_allocate		db	0,0,"API_Memory_Allocate",0
	_api_memory_release		db	0,0,"API_Memory_Release",0

	_api_text_draw			db	0,0,"API_Text_Draw",0
	
	_api_window_create		db	0,0,"API_Window_Create",0
	_api_window_set_caption		db	0,0,"API_Window_Set_Caption",0	
	_api_window_set_callback	db	0,0,"API_Window_Set_Callback",0
	_api_window_get_caption		db	0,0,"API_Window_Get_Caption",0				
	
	; funny: importing full applications as an API ;)
	_app_view_memory_init		db	0,0,"App_View_Memory_Init",0
	_app_view_pe_init		db	0,0,"App_View_Pe_Init",0
	_app_view_text_init		db	0,0,"App_View_Text_Init",0
	

;------------------------------------------------
; FASM PE Relocations
; SOL needs this when PE is mapped
;------------------------------------------------	

section '.reloc' fixups data readable discardable

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -