Ver 1.0
This commit is contained in:
147
FasmDll/SOURCE/DLL/ERRORS.INC
Normal file
147
FasmDll/SOURCE/DLL/ERRORS.INC
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2017, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
invalid_parameter:
|
||||
mov eax,FASM_INVALID_PARAMETER
|
||||
jmp general_error
|
||||
out_of_memory:
|
||||
mov eax,FASM_OUT_OF_MEMORY
|
||||
jmp general_error
|
||||
stack_overflow:
|
||||
mov eax,FASM_STACK_OVERFLOW
|
||||
jmp general_error
|
||||
main_file_not_found:
|
||||
mov eax,FASM_SOURCE_NOT_FOUND
|
||||
jmp general_error
|
||||
unexpected_end_of_file:
|
||||
mov eax,FASM_UNEXPECTED_END_OF_SOURCE
|
||||
jmp general_error
|
||||
code_cannot_be_generated:
|
||||
mov eax,FASM_CANNOT_GENERATE_CODE
|
||||
jmp general_error
|
||||
format_limitations_exceeded:
|
||||
mov eax,FASM_FORMAT_LIMITATIONS_EXCEDDED
|
||||
jmp general_error
|
||||
invalid_definition:
|
||||
mov eax,FASM_INVALID_DEFINITION
|
||||
jmp general_error
|
||||
write_failed:
|
||||
mov eax,FASM_WRITE_FAILED
|
||||
jmp general_error
|
||||
|
||||
file_not_found:
|
||||
mov eax,FASMERR_FILE_NOT_FOUND
|
||||
jmp assembler_error
|
||||
error_reading_file:
|
||||
mov eax,FASMERR_ERROR_READING_FILE
|
||||
jmp assembler_error
|
||||
invalid_file_format:
|
||||
mov eax,FASMERR_INVALID_FILE_FORMAT
|
||||
jmp assembler_error
|
||||
invalid_macro_arguments:
|
||||
mov eax,FASMERR_INVALID_MACRO_ARGUMENTS
|
||||
jmp assembler_error
|
||||
incomplete_macro:
|
||||
mov eax,FASMERR_INCOMPLETE_MACRO
|
||||
jmp assembler_error
|
||||
unexpected_characters:
|
||||
mov eax,FASMERR_UNEXPECTED_CHARACTERS
|
||||
jmp assembler_error
|
||||
invalid_argument:
|
||||
mov eax,FASMERR_INVALID_ARGUMENT
|
||||
jmp assembler_error
|
||||
illegal_instruction:
|
||||
mov eax,FASMERR_ILLEGAL_INSTRUCTION
|
||||
jmp assembler_error
|
||||
invalid_operand:
|
||||
mov eax,FASMERR_INVALID_OPERAND
|
||||
jmp assembler_error
|
||||
invalid_operand_size:
|
||||
mov eax,FASMERR_INVALID_OPERAND_SIZE
|
||||
jmp assembler_error
|
||||
operand_size_not_specified:
|
||||
mov eax,FASMERR_OPERAND_SIZE_NOT_SPECIFIED
|
||||
jmp assembler_error
|
||||
operand_sizes_do_not_match:
|
||||
mov eax,FASMERR_OPERAND_SIZES_DO_NOT_MATCH
|
||||
jmp assembler_error
|
||||
invalid_address_size:
|
||||
mov eax,FASMERR_INVALID_ADDRESS_SIZE
|
||||
jmp assembler_error
|
||||
address_sizes_do_not_agree:
|
||||
mov eax,FASMERR_ADDRESS_SIZES_DO_NOT_AGREE
|
||||
jmp assembler_error
|
||||
disallowed_combination_of_registers:
|
||||
mov eax,FASMERR_DISALLOWED_COMBINATION_OF_REGISTERS
|
||||
jmp assembler_error
|
||||
long_immediate_not_encodable:
|
||||
mov eax,FASMERR_LONG_IMMEDIATE_NOT_ENCODABLE
|
||||
jmp assembler_error
|
||||
relative_jump_out_of_range:
|
||||
mov eax,FASMERR_RELATIVE_JUMP_OUT_OF_RANGE
|
||||
jmp assembler_error
|
||||
invalid_expression:
|
||||
mov eax,FASMERR_INVALID_EXPRESSION
|
||||
jmp assembler_error
|
||||
invalid_address:
|
||||
mov eax,FASMERR_INVALID_ADDRESS
|
||||
jmp assembler_error
|
||||
invalid_value:
|
||||
mov eax,FASMERR_INVALID_VALUE
|
||||
jmp assembler_error
|
||||
value_out_of_range:
|
||||
mov eax,FASMERR_VALUE_OUT_OF_RANGE
|
||||
jmp assembler_error
|
||||
undefined_symbol:
|
||||
mov eax,FASMERR_UNDEFINED_SYMBOL
|
||||
jmp assembler_error
|
||||
invalid_use_of_symbol:
|
||||
mov eax,FASMERR_INVALID_USE_OF_SYMBOL
|
||||
jmp assembler_error
|
||||
name_too_long:
|
||||
mov eax,FASMERR_NAME_TOO_LONG
|
||||
jmp assembler_error
|
||||
invalid_name:
|
||||
mov eax,FASMERR_INVALID_NAME
|
||||
jmp assembler_error
|
||||
reserved_word_used_as_symbol:
|
||||
mov eax,FASMERR_RESERVED_WORD_USED_AS_SYMBOL
|
||||
jmp assembler_error
|
||||
symbol_already_defined:
|
||||
mov eax,FASMERR_SYMBOL_ALREADY_DEFINED
|
||||
jmp assembler_error
|
||||
symbol_out_of_scope:
|
||||
mov eax,FASMERR_SYMBOL_OUT_OF_SCOPE
|
||||
jmp assembler_error
|
||||
missing_end_quote:
|
||||
mov eax,FASMERR_MISSING_END_QUOTE
|
||||
jmp assembler_error
|
||||
missing_end_directive:
|
||||
mov eax,FASMERR_MISSING_END_DIRECTIVE
|
||||
jmp assembler_error
|
||||
unexpected_instruction:
|
||||
mov eax,FASMERR_UNEXPECTED_INSTRUCTION
|
||||
jmp assembler_error
|
||||
extra_characters_on_line:
|
||||
mov eax,FASMERR_EXTRA_CHARACTERS_ON_LINE
|
||||
jmp assembler_error
|
||||
section_not_aligned_enough:
|
||||
mov eax,FASMERR_SECTION_NOT_ALIGNED_ENOUGH
|
||||
jmp assembler_error
|
||||
setting_already_specified:
|
||||
mov eax,FASMERR_SETTING_ALREADY_SPECIFIED
|
||||
jmp assembler_error
|
||||
data_already_defined:
|
||||
mov eax,FASMERR_DATA_ALREADY_DEFINED
|
||||
jmp assembler_error
|
||||
too_many_repeats:
|
||||
mov eax,FASMERR_TOO_MANY_REPEATS
|
||||
jmp assembler_error
|
||||
invoked_error:
|
||||
mov eax,FASMERR_USER_ERROR
|
||||
jmp assembler_error
|
||||
assertion_failed:
|
||||
mov eax,FASMERR_ASSERTION_FAILED
|
||||
jmp assembler_error
|
||||
104
FasmDll/SOURCE/DLL/FASM.ASH
Normal file
104
FasmDll/SOURCE/DLL/FASM.ASH
Normal file
@@ -0,0 +1,104 @@
|
||||
|
||||
; The following structure resides at the beginning of memory block provided
|
||||
; to the fasm_Assemble function. The condition field contains the same value
|
||||
; as the one returned by function.
|
||||
; When function returns FASM_OK condition, the output_length and
|
||||
; output_data fields are filled - with pointer to generated output
|
||||
; (somewhere within the provided memory block) and the count of bytes stored
|
||||
; there.
|
||||
; When function returns FASM_ERROR, the error_code is filled with the
|
||||
; code of specific error that happened and error_line is a pointer to the
|
||||
; LINE_HEADER structure, providing information about the line that caused
|
||||
; the error.
|
||||
|
||||
struct FASM_STATE
|
||||
condition dd ?
|
||||
union
|
||||
output_length dd ?
|
||||
error_code dd ?
|
||||
ends
|
||||
union
|
||||
output_data dd ?
|
||||
error_line dd ?
|
||||
ends
|
||||
ends
|
||||
|
||||
; The following structure has two variants - it either defines the line
|
||||
; that was loaded directly from source, or the line that was generated by
|
||||
; macroinstruction. First case has the highest bit of line_number set to 0,
|
||||
; while the second case has this bit set.
|
||||
; In the first case, the file_path field contains pointer to the path of
|
||||
; source file (empty string if it's the source that was provided directly to
|
||||
; fasm_Assemble function), the line_number is the number of line within
|
||||
; that file (starting from 1) and the file_offset field contains the offset
|
||||
; within the file where the line starts.
|
||||
; In the second case the macro_calling_line field contains the pointer to
|
||||
; LINE_HEADER structure for the line which called the macroinstruction, and
|
||||
; the macro_line field contains the pointer to LINE_HEADER structure for the
|
||||
; line within the definition of macroinstruction, which generated this one.
|
||||
|
||||
struct LINE_HEADER
|
||||
file_path dd ?
|
||||
line_number dd ?
|
||||
union
|
||||
file_offset dd ?
|
||||
macro_calling_line dd ?
|
||||
ends
|
||||
macro_line dd ?
|
||||
ends
|
||||
|
||||
; General errors and conditions
|
||||
|
||||
FASM_OK = 0 ; FASM_STATE points to output
|
||||
FASM_WORKING = 1
|
||||
FASM_ERROR = 2 ; FASM_STATE contains error code
|
||||
FASM_INVALID_PARAMETER = -1
|
||||
FASM_OUT_OF_MEMORY = -2
|
||||
FASM_STACK_OVERFLOW = -3
|
||||
FASM_SOURCE_NOT_FOUND = -4
|
||||
FASM_UNEXPECTED_END_OF_SOURCE = -5
|
||||
FASM_CANNOT_GENERATE_CODE = -6
|
||||
FASM_FORMAT_LIMITATIONS_EXCEDDED = -7
|
||||
FASM_WRITE_FAILED = -8
|
||||
FASM_INVALID_DEFINITION = -9
|
||||
|
||||
; Error codes for FASM_ERROR condition
|
||||
|
||||
FASMERR_FILE_NOT_FOUND = -101
|
||||
FASMERR_ERROR_READING_FILE = -102
|
||||
FASMERR_INVALID_FILE_FORMAT = -103
|
||||
FASMERR_INVALID_MACRO_ARGUMENTS = -104
|
||||
FASMERR_INCOMPLETE_MACRO = -105
|
||||
FASMERR_UNEXPECTED_CHARACTERS = -106
|
||||
FASMERR_INVALID_ARGUMENT = -107
|
||||
FASMERR_ILLEGAL_INSTRUCTION = -108
|
||||
FASMERR_INVALID_OPERAND = -109
|
||||
FASMERR_INVALID_OPERAND_SIZE = -110
|
||||
FASMERR_OPERAND_SIZE_NOT_SPECIFIED = -111
|
||||
FASMERR_OPERAND_SIZES_DO_NOT_MATCH = -112
|
||||
FASMERR_INVALID_ADDRESS_SIZE = -113
|
||||
FASMERR_ADDRESS_SIZES_DO_NOT_AGREE = -114
|
||||
FASMERR_DISALLOWED_COMBINATION_OF_REGISTERS = -115
|
||||
FASMERR_LONG_IMMEDIATE_NOT_ENCODABLE = -116
|
||||
FASMERR_RELATIVE_JUMP_OUT_OF_RANGE = -117
|
||||
FASMERR_INVALID_EXPRESSION = -118
|
||||
FASMERR_INVALID_ADDRESS = -119
|
||||
FASMERR_INVALID_VALUE = -120
|
||||
FASMERR_VALUE_OUT_OF_RANGE = -121
|
||||
FASMERR_UNDEFINED_SYMBOL = -122
|
||||
FASMERR_INVALID_USE_OF_SYMBOL = -123
|
||||
FASMERR_NAME_TOO_LONG = -124
|
||||
FASMERR_INVALID_NAME = -125
|
||||
FASMERR_RESERVED_WORD_USED_AS_SYMBOL = -126
|
||||
FASMERR_SYMBOL_ALREADY_DEFINED = -127
|
||||
FASMERR_MISSING_END_QUOTE = -128
|
||||
FASMERR_MISSING_END_DIRECTIVE = -129
|
||||
FASMERR_UNEXPECTED_INSTRUCTION = -130
|
||||
FASMERR_EXTRA_CHARACTERS_ON_LINE = -131
|
||||
FASMERR_SECTION_NOT_ALIGNED_ENOUGH = -132
|
||||
FASMERR_SETTING_ALREADY_SPECIFIED = -133
|
||||
FASMERR_DATA_ALREADY_DEFINED = -134
|
||||
FASMERR_TOO_MANY_REPEATS = -135
|
||||
FASMERR_SYMBOL_OUT_OF_SCOPE = -136
|
||||
FASMERR_USER_ERROR = -140
|
||||
FASMERR_ASSERTION_FAILED = -141
|
||||
458
FasmDll/SOURCE/DLL/FASM.ASM
Normal file
458
FasmDll/SOURCE/DLL/FASM.ASM
Normal file
@@ -0,0 +1,458 @@
|
||||
|
||||
; flat assembler DLL interface for Win32
|
||||
; Copyright (c) 1999-2017, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
format PE DLL GUI 4.0
|
||||
entry DLLEntryPoint
|
||||
|
||||
include 'win32a.inc'
|
||||
include 'fasm.ash'
|
||||
|
||||
section '.data' data readable writeable
|
||||
|
||||
include '..\variable.inc'
|
||||
|
||||
state dd ?
|
||||
esp_save dd ?
|
||||
source dd ?
|
||||
source_position dd ?
|
||||
first_write dd ?
|
||||
first_write_length dd ?
|
||||
second_write dd ?
|
||||
second_write_length dd ?
|
||||
display_pipe dd ?
|
||||
|
||||
systime SYSTEMTIME
|
||||
|
||||
tmp dd ?
|
||||
buffer rb 1000h
|
||||
|
||||
section '.text' code readable executable
|
||||
|
||||
DLLEntryPoint:
|
||||
mov eax,TRUE
|
||||
ret 12
|
||||
|
||||
fasm_GetVersion:
|
||||
mov eax,VERSION_MAJOR + VERSION_MINOR shl 16
|
||||
ret
|
||||
|
||||
fasm_AssembleFile:
|
||||
|
||||
mov eax,[lpSource]
|
||||
mov [input_file],eax
|
||||
mov [output_file],null_byte
|
||||
|
||||
jmp setup_assembler
|
||||
|
||||
fasm_Assemble:
|
||||
|
||||
virtual at esp+4
|
||||
lpSource dd ?
|
||||
lpMemory dd ?
|
||||
cbMemorySize dd ?
|
||||
nPassesLimit dd ?
|
||||
hDisplayPipe dd ?
|
||||
end virtual
|
||||
|
||||
mov eax,[lpSource]
|
||||
mov [source],eax
|
||||
mov [source_position],0
|
||||
|
||||
mov [input_file],null_byte
|
||||
mov [output_file],null_byte
|
||||
|
||||
setup_assembler:
|
||||
|
||||
mov eax,[nPassesLimit]
|
||||
cmp eax,10000h
|
||||
ja invalid_parameter
|
||||
or eax,eax
|
||||
jz invalid_parameter
|
||||
mov [passes_limit],ax
|
||||
|
||||
mov eax,[lpMemory]
|
||||
mov ecx,[cbMemorySize]
|
||||
mov [state],eax
|
||||
mov [eax+FASM_STATE.condition],FASM_WORKING
|
||||
sub ecx,sizeof.FASM_STATE
|
||||
jbe out_of_memory
|
||||
add eax,sizeof.FASM_STATE
|
||||
mov [memory_start],eax
|
||||
mov edx,ecx
|
||||
shr edx,2
|
||||
sub ecx,edx
|
||||
add eax,ecx
|
||||
mov [memory_end],eax
|
||||
mov [additional_memory],eax
|
||||
add eax,edx
|
||||
mov [additional_memory_end],eax
|
||||
|
||||
xor eax,eax
|
||||
mov [initial_definitions],eax
|
||||
|
||||
mov [first_write],eax
|
||||
mov [second_write],eax
|
||||
|
||||
mov eax,[hDisplayPipe]
|
||||
mov [display_pipe],eax
|
||||
|
||||
push ebp ebx esi edi
|
||||
mov eax,esp
|
||||
mov [esp_save],eax
|
||||
and eax,not 0FFFh
|
||||
add eax,1000h-10000h
|
||||
mov [stack_limit],eax
|
||||
|
||||
call preprocessor
|
||||
call parser
|
||||
call assembler
|
||||
call formatter
|
||||
|
||||
mov ebx,[state]
|
||||
mov [ebx+FASM_STATE.condition],FASM_OK
|
||||
|
||||
done:
|
||||
mov eax,[ebx+FASM_STATE.condition]
|
||||
pop edi esi ebx ebp
|
||||
ret 20
|
||||
|
||||
general_error:
|
||||
mov esp,[esp_save]
|
||||
mov ebx,[state]
|
||||
mov [ebx+FASM_STATE.condition],eax
|
||||
jmp done
|
||||
|
||||
assembler_error:
|
||||
mov esp,[esp_save]
|
||||
mov ebx,[state]
|
||||
mov [ebx+FASM_STATE.error_code],eax
|
||||
mov eax,[current_line]
|
||||
mov [ebx+FASM_STATE.error_line],eax
|
||||
mov eax,FASM_ERROR
|
||||
jmp general_error
|
||||
|
||||
get_environment_variable:
|
||||
invoke GetEnvironmentVariable,esi,buffer,1000h
|
||||
retn
|
||||
|
||||
open:
|
||||
cmp byte [edx],0
|
||||
je open_memory
|
||||
invoke CreateFile,edx,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0
|
||||
cmp eax,-1
|
||||
je file_error
|
||||
mov ebx,eax
|
||||
clc
|
||||
retn
|
||||
file_error:
|
||||
stc
|
||||
retn
|
||||
open_memory:
|
||||
xor ebx,ebx
|
||||
retn
|
||||
read:
|
||||
or ebx,ebx
|
||||
jz read_memory
|
||||
mov ebp,ecx
|
||||
invoke ReadFile,ebx,edx,ecx,tmp,0
|
||||
or eax,eax
|
||||
jz file_error
|
||||
cmp ebp,[tmp]
|
||||
jne file_error
|
||||
clc
|
||||
retn
|
||||
read_memory:
|
||||
push esi edi
|
||||
mov esi,[source]
|
||||
add esi,[source_position]
|
||||
mov edi,edx
|
||||
call move_block
|
||||
pop edi esi
|
||||
clc
|
||||
retn
|
||||
move_block:
|
||||
mov al,cl
|
||||
shr ecx,2
|
||||
rep movsd
|
||||
mov cl,al
|
||||
and cl,11b
|
||||
rep movsb
|
||||
retn
|
||||
lseek:
|
||||
or ebx,ebx
|
||||
jz seek_memory
|
||||
movzx eax,al
|
||||
invoke SetFilePointer,ebx,edx,0,eax
|
||||
cmp eax,-1
|
||||
je file_error
|
||||
retn
|
||||
seek_memory:
|
||||
push esi
|
||||
mov esi,[source]
|
||||
mov ecx,edx
|
||||
or al,al
|
||||
jz seek_forward
|
||||
add esi,[source_position]
|
||||
cmp al,2
|
||||
je seek_source_end
|
||||
seek_forward:
|
||||
sub ecx,1
|
||||
jc seek_complete
|
||||
seek_in_source:
|
||||
lodsb
|
||||
or al,al
|
||||
loopnz seek_in_source
|
||||
jnz seek_complete
|
||||
dec esi
|
||||
seek_complete:
|
||||
mov eax,esi
|
||||
sub eax,[source]
|
||||
mov [source_position],eax
|
||||
pop esi
|
||||
retn
|
||||
seek_source_end:
|
||||
lodsb
|
||||
or al,al
|
||||
jnz seek_source_end
|
||||
dec esi
|
||||
sub esi,edx
|
||||
cmp esi,[source]
|
||||
jae seek_complete
|
||||
mov esi,[source]
|
||||
jmp seek_complete
|
||||
create:
|
||||
or ebx,-1
|
||||
clc
|
||||
retn
|
||||
write:
|
||||
cmp [first_write],0
|
||||
jne make_second_write
|
||||
mov [first_write],edx
|
||||
mov [first_write_length],ecx
|
||||
clc
|
||||
retn
|
||||
make_second_write:
|
||||
cmp [second_write],0
|
||||
jne cannot_write
|
||||
mov [second_write],edx
|
||||
mov [second_write_length],ecx
|
||||
clc
|
||||
retn
|
||||
cannot_write:
|
||||
stc
|
||||
retn
|
||||
close:
|
||||
or ebx,ebx
|
||||
jz file_closed
|
||||
cmp ebx,-1
|
||||
je output_ready
|
||||
invoke CloseHandle,ebx
|
||||
file_closed:
|
||||
retn
|
||||
output_ready:
|
||||
mov ebx,[state]
|
||||
cmp [second_write],0
|
||||
jne two_part_output
|
||||
mov eax,[first_write]
|
||||
mov [ebx+FASM_STATE.output_data],eax
|
||||
mov eax,[first_write_length]
|
||||
mov [ebx+FASM_STATE.output_length],eax
|
||||
retn
|
||||
two_part_output:
|
||||
mov eax,[second_write]
|
||||
mov [ebx+FASM_STATE.output_data],eax
|
||||
shuffle_output:
|
||||
mov ecx,[first_write_length]
|
||||
cmp ecx,[second_write_length]
|
||||
ja small_second_part
|
||||
sub [second_write_length],ecx
|
||||
mov esi,[first_write]
|
||||
mov edi,[second_write]
|
||||
call xchg_block
|
||||
mov [second_write],edi
|
||||
jmp shuffle_output
|
||||
xchg_block:
|
||||
shr ecx,1
|
||||
jnc xchgb_ok
|
||||
mov al,[edi]
|
||||
xchg al,[esi]
|
||||
stosb
|
||||
inc esi
|
||||
xchgb_ok:
|
||||
shr ecx,1
|
||||
jnc xchgw_ok
|
||||
mov ax,[edi]
|
||||
xchg ax,[esi]
|
||||
stosw
|
||||
add esi,2
|
||||
xchgw_ok:
|
||||
jz xchgd_ok
|
||||
xchgd:
|
||||
mov eax,[edi]
|
||||
xchg eax,[esi]
|
||||
stosd
|
||||
add esi,4
|
||||
loop xchgd
|
||||
xchgd_ok:
|
||||
retn
|
||||
small_second_part:
|
||||
mov edi,[second_write]
|
||||
mov esi,edi
|
||||
add edi,[first_write_length]
|
||||
cmp edi,[first_write]
|
||||
jbe move_second_part
|
||||
mov edi,[first_write]
|
||||
add edi,[first_write_length]
|
||||
move_second_part:
|
||||
push edi
|
||||
mov ecx,[second_write_length]
|
||||
lea eax,[edi+ecx]
|
||||
cmp eax,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
call move_block
|
||||
mov edi,[second_write]
|
||||
mov esi,[first_write]
|
||||
mov ecx,[first_write_length]
|
||||
call move_block
|
||||
pop esi
|
||||
mov ecx,[second_write_length]
|
||||
call move_block
|
||||
mov ecx,edi
|
||||
sub ecx,[ebx+FASM_STATE.output_data]
|
||||
mov [ebx+FASM_STATE.output_length],ecx
|
||||
retn
|
||||
|
||||
display_block:
|
||||
mov eax,[display_pipe]
|
||||
or eax,eax
|
||||
jz display_ok
|
||||
invoke WriteFile,eax,esi,ecx,tmp,NULL
|
||||
display_ok:
|
||||
retn
|
||||
|
||||
make_timestamp:
|
||||
invoke GetSystemTime,systime
|
||||
movzx ecx,[systime.wYear]
|
||||
mov eax,ecx
|
||||
sub eax,1970
|
||||
mov ebx,365
|
||||
mul ebx
|
||||
mov ebp,eax
|
||||
mov eax,ecx
|
||||
sub eax,1969
|
||||
shr eax,2
|
||||
add ebp,eax
|
||||
mov eax,ecx
|
||||
sub eax,1901
|
||||
mov ebx,100
|
||||
div ebx
|
||||
sub ebp,eax
|
||||
mov eax,ecx
|
||||
xor edx,edx
|
||||
sub eax,1601
|
||||
mov ebx,400
|
||||
div ebx
|
||||
add ebp,eax
|
||||
movzx ecx,[systime.wMonth]
|
||||
mov eax,ecx
|
||||
dec eax
|
||||
mov ebx,30
|
||||
mul ebx
|
||||
add ebp,eax
|
||||
cmp ecx,8
|
||||
jbe months_correction
|
||||
mov eax,ecx
|
||||
sub eax,7
|
||||
shr eax,1
|
||||
add ebp,eax
|
||||
mov ecx,8
|
||||
months_correction:
|
||||
mov eax,ecx
|
||||
shr eax,1
|
||||
add ebp,eax
|
||||
cmp ecx,2
|
||||
jbe day_correction_ok
|
||||
sub ebp,2
|
||||
movzx ecx,word [systime.wYear]
|
||||
test ecx,11b
|
||||
jnz day_correction_ok
|
||||
xor edx,edx
|
||||
mov eax,ecx
|
||||
mov ebx,100
|
||||
div ebx
|
||||
or edx,edx
|
||||
jnz day_correction
|
||||
mov eax,ecx
|
||||
mov ebx,400
|
||||
div ebx
|
||||
or edx,edx
|
||||
jnz day_correction_ok
|
||||
day_correction:
|
||||
inc ebp
|
||||
day_correction_ok:
|
||||
movzx eax,[systime.wDay]
|
||||
dec eax
|
||||
add eax,ebp
|
||||
mov ebx,24
|
||||
mul ebx
|
||||
movzx ecx,[systime.wHour]
|
||||
add eax,ecx
|
||||
mov ebx,60
|
||||
mul ebx
|
||||
movzx ecx,[systime.wMinute]
|
||||
add eax,ecx
|
||||
mov ebx,60
|
||||
mul ebx
|
||||
movzx ecx,[systime.wSecond]
|
||||
add eax,ecx
|
||||
retn
|
||||
|
||||
dump_symbols:
|
||||
retn
|
||||
|
||||
include 'errors.inc'
|
||||
|
||||
include '..\preproce.inc'
|
||||
include '..\parser.inc'
|
||||
include '..\exprpars.inc'
|
||||
include '..\exprcalc.inc'
|
||||
include '..\assemble.inc'
|
||||
include '..\formats.inc'
|
||||
include '..\x86_64.inc'
|
||||
include '..\avx.inc'
|
||||
include '..\tables.inc'
|
||||
|
||||
include '..\version.inc'
|
||||
|
||||
null_byte db 0
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
library kernel32,'KERNEL32.DLL'
|
||||
|
||||
include 'api\kernel32.inc'
|
||||
|
||||
section '.edata' export data readable
|
||||
|
||||
export 'FASM.DLL',\
|
||||
fasm_GetVersion,'fasm_GetVersion',\
|
||||
fasm_Assemble,'fasm_Assemble',\
|
||||
fasm_AssembleFile,'fasm_AssembleFile'
|
||||
|
||||
section '.reloc' fixups data readable discardable
|
||||
|
||||
section '.rsrc' resource data readable
|
||||
|
||||
directory RT_VERSION,versions
|
||||
|
||||
resource versions,\
|
||||
1,LANG_NEUTRAL,version
|
||||
|
||||
versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
|
||||
'FileDescription','flat assembler',\
|
||||
'LegalCopyright',<'Copyright ',0A9h,' 2001-2017 Tomasz Grysztar.'>,\
|
||||
'FileVersion',VERSION_STRING,\
|
||||
'ProductVersion',VERSION_STRING,\
|
||||
'OriginalFilename','FASM.DLL'
|
||||
195
FasmDll/SOURCE/IDE/FASMW/FEDIT.ASM
Normal file
195
FasmDll/SOURCE/IDE/FASMW/FEDIT.ASM
Normal file
@@ -0,0 +1,195 @@
|
||||
|
||||
; flat editor DLL interface for Win32
|
||||
; Copyright (c) 2001-2014, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
format PE DLL GUI 4.0
|
||||
entry DLLEntryPoint
|
||||
|
||||
include 'win32a.inc'
|
||||
|
||||
include 'fedit.ash'
|
||||
|
||||
section '.data' data readable writeable
|
||||
|
||||
_fedit_class db 'FEDIT',0
|
||||
|
||||
_user_library db 'USER32.DLL',0
|
||||
_setgestureconfig_api db 'SetGestureConfig',0
|
||||
_getgestureinfo_api db 'GetGestureInfo',0
|
||||
_closegestureinfohandle_api db 'CloseGestureInfoHandle',0
|
||||
|
||||
align 4
|
||||
|
||||
SetGestureConfig dd 0
|
||||
GetGestureInfo dd 0
|
||||
CloseGestureInfoHandle dd 0
|
||||
|
||||
wheel_scroll_lines dd 3
|
||||
|
||||
fedit_font dd ?
|
||||
|
||||
char rb 4
|
||||
kbstate rb 100h
|
||||
line_colors rb 100h
|
||||
line_buffer rb 100h
|
||||
text_buffer rb 100h
|
||||
upper_case_table rb 100h
|
||||
|
||||
wc WNDCLASS
|
||||
ps PAINTSTRUCT
|
||||
tm TEXTMETRIC
|
||||
sc SCROLLINFO
|
||||
rect RECT
|
||||
|
||||
section '.text' code readable executable
|
||||
|
||||
proc DLLEntryPoint uses ebx esi edi,hinstDLL,fdwReason,lpvReserved
|
||||
cmp [fdwReason],DLL_PROCESS_ATTACH
|
||||
jne .done
|
||||
invoke GetModuleHandle,_user_library
|
||||
or eax,eax
|
||||
jz .gesture_api_unavailable
|
||||
mov ebx,eax
|
||||
invoke GetProcAddress,ebx,_setgestureconfig_api
|
||||
or eax,eax
|
||||
jz .gesture_api_unavailable
|
||||
mov esi,eax
|
||||
invoke GetProcAddress,ebx,_getgestureinfo_api
|
||||
or eax,eax
|
||||
jz .gesture_api_unavailable
|
||||
mov edi,eax
|
||||
invoke GetProcAddress,ebx,_closegestureinfohandle_api
|
||||
or eax,eax
|
||||
jz .gesture_api_unavailable
|
||||
mov [CloseGestureInfoHandle],eax
|
||||
mov [SetGestureConfig],esi
|
||||
mov [GetGestureInfo],edi
|
||||
.gesture_api_unavailable:
|
||||
invoke LoadCursor,0,IDC_IBEAM
|
||||
mov [wc.hCursor],eax
|
||||
mov [wc.style],CS_GLOBALCLASS+CS_DBLCLKS
|
||||
mov [wc.lpfnWndProc],FlatEditor
|
||||
mov eax,[hinstDLL]
|
||||
mov [wc.hInstance],eax
|
||||
mov [wc.cbWndExtra],4
|
||||
xor eax,eax
|
||||
mov [wc.hbrBackground],eax
|
||||
mov [wc.cbClsExtra],eax
|
||||
mov [wc.lpszMenuName],eax
|
||||
mov [wc.lpszClassName],_fedit_class
|
||||
invoke RegisterClass,wc
|
||||
or eax,eax
|
||||
jz .failed
|
||||
invoke CreateFont,0,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL
|
||||
or eax,eax
|
||||
jz .failed
|
||||
mov [fedit_font],eax
|
||||
push ebx esi edi
|
||||
mov edi,upper_case_table
|
||||
xor ebx,ebx
|
||||
mov esi,100h
|
||||
.make_upper_case_table:
|
||||
invoke CharUpper,ebx
|
||||
stosb
|
||||
inc bl
|
||||
dec esi
|
||||
jnz .make_upper_case_table
|
||||
pop edi esi ebx
|
||||
.done:
|
||||
mov eax,TRUE
|
||||
ret
|
||||
.failed:
|
||||
mov eax,FALSE
|
||||
ret
|
||||
endp
|
||||
|
||||
include 'fedit.inc'
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
library kernel,'KERNEL32.DLL',\
|
||||
user,'USER32.DLL',\
|
||||
gdi,'GDI32.DLL'
|
||||
|
||||
import kernel,\
|
||||
GetModuleHandle,'GetModuleHandleA',\
|
||||
GetProcAddress,'GetProcAddress',\
|
||||
GlobalAlloc,'GlobalAlloc',\
|
||||
GlobalReAlloc,'GlobalReAlloc',\
|
||||
GlobalLock,'GlobalLock',\
|
||||
GlobalUnlock,'GlobalUnlock',\
|
||||
GlobalFree,'GlobalFree',\
|
||||
VirtualAlloc,'VirtualAlloc',\
|
||||
VirtualFree,'VirtualFree',\
|
||||
ExitProcess,'ExitProcess'
|
||||
|
||||
import user,\
|
||||
RegisterClass,'RegisterClassA',\
|
||||
CreateCaret,'CreateCaret',\
|
||||
ShowCaret,'ShowCaret',\
|
||||
HideCaret,'HideCaret',\
|
||||
SetCaretPos,'SetCaretPos',\
|
||||
DestroyCaret,'DestroyCaret',\
|
||||
BeginPaint,'BeginPaint',\
|
||||
EndPaint,'EndPaint',\
|
||||
GetDC,'GetDC',\
|
||||
GetUpdateRect,'GetUpdateRect',\
|
||||
ReleaseDC,'ReleaseDC',\
|
||||
GetCursorPos,'GetCursorPos',\
|
||||
ClientToScreen,'ClientToScreen',\
|
||||
TrackPopupMenu,'TrackPopupMenu',\
|
||||
DrawText,'DrawTextA',\
|
||||
FillRect,'FillRect',\
|
||||
InvalidateRect,'InvalidateRect',\
|
||||
GetKeyboardState,'GetKeyboardState',\
|
||||
ToAscii,'ToAscii',\
|
||||
GetScrollInfo,'GetScrollInfo',\
|
||||
SetScrollInfo,'SetScrollInfo',\
|
||||
SetCapture,'SetCapture',\
|
||||
ReleaseCapture,'ReleaseCapture',\
|
||||
OpenClipboard,'OpenClipboard',\
|
||||
CloseClipboard,'CloseClipboard',\
|
||||
EmptyClipboard,'EmptyClipboard',\
|
||||
GetClipboardData,'GetClipboardData',\
|
||||
SetClipboardData,'SetClipboardData',\
|
||||
LoadCursor,'LoadCursorA',\
|
||||
IsClipboardFormatAvailable,'IsClipboardFormatAvailable',\
|
||||
CharUpper,'CharUpperA',\
|
||||
GetWindowLong,'GetWindowLongA',\
|
||||
SetWindowLong,'SetWindowLongA',\
|
||||
DefWindowProc,'DefWindowProcA',\
|
||||
GetClientRect,'GetClientRect',\
|
||||
UpdateWindow,'UpdateWindow',\
|
||||
SetFocus,'SetFocus',\
|
||||
GetSysColor,'GetSysColor',\
|
||||
MessageBox,'MessageBoxA',\
|
||||
SendMessage,'SendMessageA',\
|
||||
PostMessage,'PostMessageA'
|
||||
|
||||
import gdi,\
|
||||
SetBkColor,'SetBkColor',\
|
||||
SetTextColor,'SetTextColor',\
|
||||
CreateSolidBrush,'CreateSolidBrush',\
|
||||
CreateFont,'CreateFontA',\
|
||||
GetTextMetrics,'GetTextMetricsA',\
|
||||
GetTextExtentPoint32,'GetTextExtentPoint32A',\
|
||||
DeleteDC,'DeleteDC',\
|
||||
SelectObject,'SelectObject',\
|
||||
DeleteObject,'DeleteObject'
|
||||
|
||||
section '.reloc' fixups data readable discardable
|
||||
|
||||
section '.rsrc' resource data readable
|
||||
|
||||
directory RT_VERSION,versions
|
||||
|
||||
resource versions,\
|
||||
1,LANG_NEUTRAL,version
|
||||
|
||||
versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
|
||||
'FileDescription','flat editor',\
|
||||
'LegalCopyright',<'Copyright ',0A9h,' 1999-2014 Tomasz Grysztar.'>,\
|
||||
'FileVersion',FEDIT_VERSION_STRING,\
|
||||
'ProductVersion',FEDIT_VERSION_STRING,\
|
||||
'OriginalFilename','FEDIT.DLL'
|
||||
Reference in New Issue
Block a user