?? formats.inc
字號(hào):
jz string_entries_processed
process_string_entries:
push ecx
mov edx,edi
sub edx,[resource_data]
bts edx,31
xchg [esi],edx
mov ebx,edi
xor ax,ax
stos word [edi]
copy_string_data:
lea eax,[edi+2]
cmp eax,[display_buffer]
jae out_of_memory
mov ax,[edx]
or ax,ax
jz string_data_copied
stos word [edi]
inc word [ebx]
add edx,2
jmp copy_string_data
string_data_copied:
add esi,8
pop ecx
loop process_string_entries
string_entries_processed:
pop esi
cmp esi,[esp]
jb make_name_strings
mov eax,edi
sub eax,[resource_data]
test al,11b
jz resource_strings_alignment_ok
xor ax,ax
stos word [edi]
resource_strings_alignment_ok:
pop edx
pop ebx ; address of language directories
mov ebp,edi
update_language_directories:
add ebx,10h
movzx eax,word [ebx-2]
movzx ecx,word [ebx-4]
add ecx,eax
make_data_records:
push ecx
mov esi,edi
sub esi,[resource_data]
xchg esi,[ebx+4]
lea eax,[edi+16]
cmp eax,[display_buffer]
jae out_of_memory
mov eax,esi
stos dword [edi]
mov eax,[esi+12]
stos dword [edi]
xor eax,eax
stos dword [edi]
stos dword [edi]
pop ecx
add ebx,8
loop make_data_records
cmp ebx,edx
jb update_language_directories
pop ebx ; file handle
mov esi,ebp
mov ebp,edi
update_data_records:
push ebp
mov ecx,edi
mov eax,[current_section]
sub ecx,[eax+14h]
add ecx,[eax+0Ch]
xchg ecx,[esi]
mov edx,[ecx]
xor al,al
call lseek
mov edx,edi
mov ecx,[esi+4]
add edi,ecx
cmp edi,[display_buffer]
ja out_of_memory
call read
mov eax,edi
sub eax,[resource_data]
and eax,11b
jz resource_data_alignment_ok
mov ecx,4
sub ecx,eax
xor al,al
rep stos byte [edi]
resource_data_alignment_ok:
pop ebp
add esi,16
cmp esi,ebp
jb update_data_records
pop esi
call close
mov eax,edi
sub eax,[resource_data]
mov [resource_size],eax
resource_done:
ret
make_pe_fixups:
bts [resolver_flags],0
jc pe_relocatable_ok
or [next_pass_needed],-1
pe_relocatable_ok:
push esi
mov ecx,[number_of_relocations]
mov esi,[free_additional_memory]
mov eax,ecx
shl eax,2
sub esi,eax
mov [free_additional_memory],esi
or [number_of_relocations],-1
xor edx,edx
mov ebp,edi
make_fixups:
cmp [esi],edx
jb store_fixup
mov eax,edi
sub eax,ebp
test eax,11b
jz fixups_block
xor ax,ax
stos word [edi]
add dword [ebx],2
fixups_block:
mov eax,edx
add edx,1000h
cmp [esi],edx
jae fixups_block
stos dword [edi]
mov ebx,edi
mov eax,8
stos dword [edi]
store_fixup:
jecxz fixups_done
add dword [ebx],2
mov eax,[esi]
and ax,0FFFh
test [format_flags],8
jnz fixup_64bit
or ax,3000h
jmp fixup_ok
fixup_64bit:
or ax,0A000h
fixup_ok:
stos word [edi]
add esi,4
loop make_fixups
fixups_done:
pop esi
ret
close_pe:
call close_pe_section
mov edx,[code_start]
mov [edx+50h],eax
call make_timestamp
mov edx,[code_start]
mov [edx+8],eax
mov eax,[number_of_relocations]
cmp eax,-1
je pe_relocations_ok
shl eax,2
sub [free_additional_memory],eax
btr [resolver_flags],0
jnc pe_relocations_ok
or [next_pass_needed],-1
pe_relocations_ok:
mov eax,[number_of_sections]
mov [edx+6],ax
imul eax,28h
movzx ecx,word [edx+14h]
lea eax,[eax+18h+ecx]
add eax,[stub_size]
mov ecx,[edx+3Ch]
dec ecx
add eax,ecx
not ecx
and eax,ecx
cmp eax,[edx+54h]
je pe_sections_ok
or [next_pass_needed],-1
pe_sections_ok:
xor ecx,ecx
add edx,78h
test [format_flags],8
jz process_directories
add edx,10h
process_directories:
mov eax,[edx+ecx*8]
or eax,eax
jz directory_ok
cmp dword [edx+ecx*8+4],-1
jne directory_ok
section_data:
mov ebx,[edx+ecx*8]
mov eax,[ebx+0Ch]
mov [edx+ecx*8],eax ; directory rva
mov eax,[ebx+8]
mov [edx+ecx*8+4],eax ; directory size
directory_ok:
inc cl
cmp cl,10h
jb process_directories
mov ebx,[code_start]
sub ebx,[stub_size]
mov ecx,edi
sub ecx,ebx
mov ebp,ecx
shr ecx,1
xor eax,eax
cdq
calculate_checksum:
mov dx,[ebx]
add eax,edx
mov dx,ax
shr eax,16
add eax,edx
add ebx,2
loop calculate_checksum
add eax,ebp
mov ebx,[code_start]
mov [ebx+58h],eax
ret
format_coff:
mov eax,[additional_memory]
mov [symbols_stream],eax
mov ebx,eax
add eax,20h
cmp eax,[structures_buffer]
jae out_of_memory
mov [free_additional_memory],eax
xor eax,eax
mov [ebx],al
mov [ebx+4],eax
mov [ebx+8],edi
mov al,4
mov [ebx+10h],eax
mov al,60h
bt [format_flags],0
jnc flat_section_flags_ok
or eax,0E0000000h
flat_section_flags_ok:
mov dword [ebx+14h],eax
mov [current_section],ebx
mov [number_of_sections],0
mov dword [org_origin],edi
mov dword [org_origin+4],0
mov [org_registers],0
mov [org_start],edi
mov [org_symbol],ebx
mov [labels_type],2
mov [code_type],32
test [format_flags],8
jz instruction_assembled
mov [labels_type],4
mov [code_type],64
jmp instruction_assembled
coff_section:
call close_coff_section
mov ebx,[free_additional_memory]
lea eax,[ebx+20h]
cmp eax,[structures_buffer]
jae out_of_memory
mov [free_additional_memory],eax
mov [current_section],ebx
inc [number_of_sections]
xor eax,eax
mov [ebx],al
mov [ebx+8],edi
mov dword [org_origin],edi
mov dword [org_origin+4],0
mov [org_registers],0
mov [org_start],edi
mov [org_symbol],ebx
mov [labels_type],2
test [format_flags],8
jz coff_labels_type_ok
mov [labels_type],4
coff_labels_type_ok:
mov [ebx+10h],eax
mov [ebx+14h],eax
lods word [esi]
cmp ax,'('
jne invalid_argument
mov [ebx+4],esi
mov ecx,[esi]
lea esi,[esi+4+ecx+1]
cmp ecx,8
ja name_too_long
coff_section_flags:
cmp byte [esi],1Ch
je coff_section_alignment
cmp byte [esi],19h
jne coff_section_settings_ok
inc esi
lods byte [esi]
bt [format_flags],0
jc coff_section_flag_ok
cmp al,7
ja invalid_argument
coff_section_flag_ok:
mov cl,al
mov eax,1
shl eax,cl
test dword [ebx+14h],eax
jnz setting_already_specified
or dword [ebx+14h],eax
jmp coff_section_flags
coff_section_alignment:
bt [format_flags],0
jnc invalid_argument
inc esi
lods byte [esi]
or al,al
jnz invalid_argument
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
push ebx
call get_dword_value
pop ebx
cmp [value_type],0
jne invalid_use_of_symbol
mov edx,eax
dec edx
test eax,edx
jnz invalid_value
or eax,eax
jz invalid_value
cmp eax,2000h
ja invalid_value
bsf edx,eax
inc edx
shl edx,20
or [ebx+14h],edx
xchg [ebx+10h],eax
or eax,eax
jnz setting_already_specified
jmp coff_section_flags
coff_section_settings_ok:
cmp dword [ebx+10h],0
jne instruction_assembled
mov dword [ebx+10h],4
bt [format_flags],0
jnc instruction_assembled
or dword [ebx+14h],300000h
jmp instruction_assembled
close_coff_section:
mov ebx,[current_section]
mov eax,edi
mov edx,[ebx+8]
sub eax,edx
mov [ebx+0Ch],eax
xor eax,eax
xchg [undefined_data_end],eax
cmp eax,edi
jne coff_section_ok
cmp edx,[undefined_data_start]
jne coff_section_ok
mov edi,edx
or byte [ebx+14h],80h
coff_section_ok:
ret
mark_coff_relocation:
cmp [value_type],3
je coff_relocation_relative
push ebx eax
test [format_flags],8
jnz coff_64bit_relocation
mov al,6
jmp coff_relocation
coff_64bit_relocation:
mov al,1
cmp [value_type],4
je coff_relocation
mov al,2
jmp coff_relocation
coff_relocation_relative:
push ebx
bt [format_flags],0
jnc relative_ok
mov ebx,[current_section]
mov ebx,[ebx+8]
sub ebx,edi
sub eax,ebx
add eax,4
relative_ok:
push eax
mov al,20
test [format_flags],8
jnz relative_coff_64bit_relocation
cmp [labels_type],2
jne invalid_use_of_symbol
jmp coff_relocation
relative_coff_64bit_relocation:
mov al,4
cmp [labels_type],4
jne invalid_use_of_symbol
coff_relocation:
mov ebx,[free_additional_memory]
add ebx,0Ch
cmp ebx,[structures_buffer]
jae out_of_memory
mov [free_additional_memory],ebx
mov byte [ebx-0Ch],al
mov eax,[current_section]
mov eax,[eax+8]
neg eax
add eax,edi
mov [ebx-0Ch+4],eax
mov eax,[symbol_identifier]
mov [ebx-0Ch+8],eax
pop eax ebx
ret
close_coff:
call close_coff_section
cmp [next_pass_needed],0
je coff_closed
mov eax,[symbols_stream]
mov [free_additional_memory],eax
coff_closed:
ret
coff_formatter:
sub edi,[code_start]
mov [code_size],edi
call prepare_default_section
mov edi,[free_additional_memory]
mov ebx,edi
mov ecx,28h shr 2
imul ecx,[number_of_sections]
add ecx,14h shr 2
lea eax,[edi+ecx*4]
cmp eax,[structures_buffer]
jae out_of_memory
xor eax,eax
rep stos dword [edi]
mov word [ebx],14Ch
test [format_flags],8
jz coff_magic_ok
mov word [ebx],8664h
coff_magic_ok:
mov word [ebx+12h],104h
bt [format_flags],0
jnc coff_flags_ok
or byte [ebx+12h],80h
coff_flags_ok:
push ebx
call make_timestamp
pop ebx
mov [ebx+4],eax
mov eax,[number_of_sections]
mov [ebx+2],ax
mov esi,[symbols_stream]
xor eax,eax
xor ecx,ecx
enumerate_symbols:
cmp esi,[free_additional_memory]
je symbols_enumerated
mov dl,[esi]
or dl,dl
jz enumerate_section
cmp dl,80h
je enumerate_public
ja enumerate_extrn
add esi,0Ch
jmp enumerate_symbols
enumerate_section:
mov edx,eax
shl edx,8
mov [esi],edx
inc eax
inc ecx
mov [esi+1Eh],cx
add esi,20h
jmp enumerate_symbols
enumerate_public:
mov edx,eax
shl edx,8
mov dl,80h
mov [esi],edx
mov edx,[esi+8]
add esi,10h
inc eax
cmp byte [edx+11],2
jne enumerate_symbols
mov edx,[edx+20]
cmp byte [edx],81h
jne enumerate_symbols
inc eax
jmp enumerate_symbols
enumerate_extrn:
mov edx,eax
shl edx,8
mov dl,81h
mov [esi],edx
add esi,0Ch
inc eax
jmp enumerate_symbols
prepare_default_section:
mov ebx,[symbols_stream]
cmp dword [ebx+0Ch],0
jne default_section_ok
cmp [number_of_sections],0
je default_section_ok
mov edx,ebx
find_references_to_default_section:
cmp ebx,[free_additional_memory]
jne check_reference
add [symbols_stream],20h
ret
check_reference:
mov al,[ebx]
or al,al
jz skip_other_section
cmp al,80h
je check_public_reference
ja next_reference
cmp edx,[ebx+8]
je default_section_ok
next_reference:
add ebx,0Ch
jmp find_references_to_default_section
check_public_reference:
mov eax,[ebx+8]
add ebx,10h
test byte [eax+8],1
jz find_references_to_default_section
mov cx,[current_pass]
cmp cx,[eax+16]
jne find_references_to_default_section
cmp edx,[eax+20]
je default_section_ok
jmp find_references_to_default_section
skip_other_section:
add ebx,20h
jmp find_references_to_default_section
default_section_ok:
inc [number_of_sections]
ret
symbols_enumerated:
mov [ebx+0Ch],eax
mov ebp,edi
sub ebp,ebx
push ebp
lea edi,[ebx+14h]
mov esi,[symbols_stream]
find_section:
cmp esi,[free_additional_memory]
je sections_finished
mov al,[esi]
or al,al
jz section_found
add esi,0Ch
cmp al,80h
jne find_section
add esi,4
jmp find_section
section_found:
push esi edi
mov esi,[esi+4]
or esi,esi
jz default_section
mov ecx,[esi]
add esi,4
rep movs byte [edi],[esi]
jmp section_name_ok
default_section:
mov al,'.'
stos byte [edi]
mov eax,'flat'
stos dword [edi]
section_name_ok:
pop edi esi
mov eax,[esi+0Ch]
mov [edi+10h],eax
mov eax,[esi+14h]
mov [edi+24h],eax
test al,80h
jnz section_ptr_ok
mov eax,[esi+8]
sub eax,[code_start]
add eax,ebp
mov [edi+14h],eax
section_ptr_ok:
mov ebx,[code_start]
mov edx,[code_size]
add ebx,edx
add edx,ebp
xor ecx,ecx
add esi,20h
find_relocations:
cmp esi,[free_additional_memory]
je section_relocations_done
mov al,[esi]
or al,al
jz section_relocations_done
cmp al,80h
jb add_relocation
ja next_relocation
add esi,10h
jmp find_relocations
add_relocation:
lea eax,[ebx+0Ah]
cmp eax,[display_buffer]
ja out_of_memory
mov eax,[esi+4]
mov [ebx],eax
mov eax,[esi+8]
mov eax,[eax]
shr eax,8
mov [ebx+4],eax
movzx ax,byte [esi]
mov [ebx+8],ax
add ebx,0Ah
inc ecx
next_relocation:
add esi,0Ch
jmp find_relocations
section_relocations_done:
cmp ecx,10000h
jb section_relocations_count_16bit
bt [format_flags],0
jnc format_limitations_exceeded
mov word [edi+20h],0FFFFh
or dword [edi+24h],1000000h
mov [edi+18h],edx
push esi edi
push ecx
lea esi,[ebx-1]
add ebx,0Ah
lea edi,[ebx-1]
imul ecx,0Ah
std
rep movs byte [edi],[esi]
cld
pop ecx
inc esi
inc ecx
mov [esi],ecx
xor eax,eax
mov [esi+4],eax
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -