Subversion Repositories Kolibri OS

Rev

Rev 1054 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1054 Rev 1115
Line 479... Line 479...
479
	add	eax,0Fh
479
	add	eax,0Fh
480
	and	eax,1111b
480
	and	eax,1111b
481
	sub	ecx,eax
481
	sub	ecx,eax
482
	mov	edx,edi
482
	mov	edx,edi
483
	xor	al,al
483
	xor	eax,eax
484
	rep	stos byte [edi]
484
	rep	stos byte [edi]
485
	mov	dword [org_origin],edi
485
	mov	dword [org_origin],edi
486
	mov	dword [org_origin+4],0
486
	mov	dword [org_origin+4],eax
487
	mov	[org_registers],0
487
	mov	[org_registers],eax
488
	mov	[org_start],edi
488
	mov	[org_start],edi
489
	mov	eax,edx
489
	mov	eax,edx
490
	call	undefined_data
490
	call	undefined_data
491
	mov	eax,edi
491
	mov	eax,edi
492
	sub	eax,[code_start]
492
	sub	eax,[code_start]
493
	shr	eax,4
493
	shr	eax,4
Line 666... Line 666...
666
	rep	stos dword [edi]
666
	rep	stos dword [edi]
667
	mov	eax,40h+default_stub_end-default_stub
667
	mov	eax,40h+default_stub_end-default_stub
668
	mov	cx,100h+default_stub_end-default_stub
668
	mov	cx,100h+default_stub_end-default_stub
669
	mov	word [edx],'MZ'
669
	mov	word [edx],'MZ'
670
	mov	word [edx+4],1
670
	mov	byte [edx+4],1
671
	mov	word [edx+2],ax
671
	mov	word [edx+2],ax
672
	mov	word [edx+8],4
672
	mov	byte [edx+8],4
673
	mov	word [edx+0Ah],10h
673
	mov	byte [edx+0Ah],10h
674
	mov	word [edx+0Ch],0FFFFh
674
	mov	word [edx+0Ch],0FFFFh
675
	mov	word [edx+10h],cx
675
	mov	word [edx+10h],cx
676
	mov	word [edx+3Ch],ax
676
	mov	word [edx+3Ch],ax
677
	mov	word [edx+18h],40h
677
	mov	byte [edx+18h],40h
678
	lea	edi,[edx+40h]
678
	lea	edi,[edx+40h]
679
	mov	esi,default_stub
679
	mov	esi,default_stub
680
	mov	ecx,default_stub_end-default_stub
680
	mov	ecx,default_stub_end-default_stub
681
	rep	movs byte [edi],[esi]
681
	rep	movs byte [edi],[esi]
682
	pop	esi
682
	pop	esi
683
	jmp	stub_ok
683
	jmp	stub_ok
Line 802... Line 802...
802
	shr	eax,4
802
	shr	eax,4
803
	mov	[esi+0Ah],ax
803
	mov	[esi+0Ah],ax
804
      binary_heap_ok:
804
      binary_heap_ok:
805
	mov	word [esi],'MZ'
805
	mov	word [esi],'MZ'
806
	mov	word [esi+8],4
806
	mov	byte [esi+8],4
807
	mov	ax,0FFFFh
807
	mov	ax,0FFFFh
808
	mov	[esi+0Ch],ax
808
	mov	[esi+0Ch],ax
809
	dec	ax
809
	dec	ax
810
	mov	[esi+10h],ax
810
	mov	[esi+10h],ax
811
	sub	ax,0Eh
811
	sub	ax,0Eh
812
	mov	[esi+0Eh],ax
812
	mov	[esi+0Eh],ax
813
	mov	[esi+16h],ax
813
	mov	[esi+16h],ax
814
	mov	word [esi+14h],100h
814
	mov	word [esi+14h],100h
815
	mov	word [esi+18h],40h
815
	mov	byte [esi+18h],40h
816
	mov	eax,[display_buffer]
816
	mov	eax,[display_buffer]
817
	sub	eax,ecx
817
	sub	eax,ecx
818
	cmp	edi,eax
818
	cmp	edi,eax
819
	jae	out_of_memory
819
	jae	out_of_memory
820
	mov	edx,edi
820
	mov	edx,edi
821
	shr	ecx,2
821
	shr	ecx,2
Line 975... Line 975...
975
	rep	stos dword [edi]
975
	rep	stos dword [edi]
976
	mov	word [edx],'PE' 	; signature
976
	mov	word [edx],'PE' 	; signature
977
	mov	ax,[machine]
977
	mov	ax,[machine]
978
	mov	word [edx+4],ax
978
	mov	word [edx+4],ax
979
	mov	dword [edx+38h],1000h	; section alignment
979
	mov	byte [edx+38h+1],10h	; section alignment
980
	mov	dword [edx+3Ch],200h	; file alignment
980
	mov	byte [edx+3Ch+1],2	; file alignment
981
	mov	word [edx+40h],1	; OS version
981
	mov	byte [edx+40h],1	; OS version
982
	mov	eax,[subsystem_version]
982
	mov	eax,[subsystem_version]
983
	mov	[edx+48h],eax
983
	mov	[edx+48h],eax
984
	mov	ax,[subsystem]
984
	mov	ax,[subsystem]
985
	mov	[edx+5Ch],ax
985
	mov	[edx+5Ch],ax
986
	cmp	ax,1
986
	cmp	ax,1
987
	jne	pe_alignment_ok
987
	jne	pe_alignment_ok
Line 991... Line 991...
991
      pe_alignment_ok:
991
      pe_alignment_ok:
992
	mov	word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8
992
	mov	word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8
993
	test	[format_flags],8
993
	test	[format_flags],8
994
	jnz	init_peplus_specific
994
	jnz	init_peplus_specific
995
	mov	dword [edx+14h],0E0h	; size of optional header
995
	mov	byte [edx+14h],0E0h	; size of optional header
996
	mov	dword [edx+16h],10B010Eh; flags and magic value
996
	mov	dword [edx+16h],10B010Eh; flags and magic value
997
	mov	eax,[image_base]
997
	mov	eax,[image_base]
998
	mov	dword [edx+34h],eax
998
	mov	[edx+34h],eax
999
	mov	dword [edx+60h],1000h	; stack reserve
999
	mov	byte [edx+60h+1],10h	; stack reserve
1000
	mov	dword [edx+64h],1000h	; stack commit
1000
	mov	byte [edx+64h+1],10h	; stack commit
1001
	mov	dword [edx+68h],10000h	; heap reserve
1001
	mov	byte [edx+68h+2],1	; heap reserve
1002
	mov	dword [edx+6Ch],0	; heap commit
1002
	mov	byte [edx+74h],16	; number of directories
1003
	mov	dword [edx+74h],16	; number of directories
-
 
1004
	jmp	pe_header_ok
1003
	jmp	pe_header_ok
1005
      init_peplus_specific:
1004
      init_peplus_specific:
1006
	mov	dword [edx+14h],0F0h	; size of optional header
1005
	mov	byte [edx+14h],0F0h	; size of optional header
1007
	mov	dword [edx+16h],20B002Eh; flags and magic value
1006
	mov	dword [edx+16h],20B002Eh; flags and magic value
1008
	mov	eax,[image_base]
1007
	mov	eax,[image_base]
1009
	mov	dword [edx+30h],eax
1008
	mov	[edx+30h],eax
1010
	mov	eax,[image_base_high]
1009
	mov	eax,[image_base_high]
1011
	mov	dword [edx+34h],eax
1010
	mov	[edx+34h],eax
1012
	mov	dword [edx+60h],1000h	; stack reserve
1011
	mov	byte [edx+60h+1],10h	; stack reserve
1013
	mov	dword [edx+68h],1000h	; stack commit
1012
	mov	byte [edx+68h+1],10h	; stack commit
1014
	mov	dword [edx+70h],10000h	; heap reserve
1013
	mov	byte [edx+70h+2],1	; heap reserve
1015
	mov	dword [edx+78h],0	; heap commit
1014
	mov	byte [edx+84h],16	; number of directories
1016
	mov	dword [edx+84h],16	; number of directories
-
 
1017
      pe_header_ok:
1015
      pe_header_ok:
1018
	bsf	ecx,[edx+3Ch]
1016
	bsf	ecx,[edx+3Ch]
1019
	imul	ebx,[number_of_sections],28h
1017
	imul	ebx,[number_of_sections],28h
1020
	or	ebx,ebx
1018
	or	ebx,ebx
1021
	jnz	reserve_space_for_section_headers
1019
	jnz	reserve_space_for_section_headers
1022
	mov	ebx,28h
1020
	mov	ebx,28h
Line 1087... Line 1085...
1087
	mov	[org_registers],0
1085
	mov	[org_registers],0
1088
	mov	[org_start],edi
1086
	mov	[org_start],edi
1089
	bt	[format_flags],8
1087
	bt	[format_flags],8
1090
	jnc	dll_flag_ok
1088
	jnc	dll_flag_ok
1091
	or	dword [edx+16h],2000h
1089
	or	byte [edx+16h+1],20h
1092
      dll_flag_ok:
1090
      dll_flag_ok:
1093
	bt	[format_flags],9
1091
	bt	[format_flags],9
1094
	jnc	wdm_flag_ok
1092
	jnc	wdm_flag_ok
1095
	or	word [edx+5Eh],2000h
1093
	or	byte [edx+5Eh+1],20h
1096
      wdm_flag_ok:
1094
      wdm_flag_ok:
1097
	jmp	format_defined
1095
	jmp	format_defined
1098
pe_section:
1096
pe_section:
1099
	call	close_pe_section
1097
	call	close_pe_section
1100
	bts	[format_flags],5
1098
	bts	[format_flags],5
1101
	lea	ecx,[ebx+28h]
1099
	lea	ecx,[ebx+28h]
Line 1232... Line 1230...
1232
	rep	stos byte [edi]
1230
	rep	stos byte [edi]
1233
	mov	eax,[code_start]
1231
	mov	eax,[code_start]
1234
	sub	eax,[stub_size]
1232
	sub	eax,[stub_size]
1235
	sub	[ebx+14h],eax
1233
	sub	[ebx+14h],eax
1236
 
1234
	mov	ecx,[ebx+10h]
1237
	mov	ecx,[ebx+10h]
-
 
1238
	test	byte [ebx+24h],20h
1235
	test	byte [ebx+24h],20h
1239
	jz	pe_code_sum_ok
1236
	jz	pe_code_sum_ok
1240
	add	[edx+1Ch],ecx
1237
	add	[edx+1Ch],ecx
1241
	cmp	dword [edx+2Ch],0
1238
	cmp	dword [edx+2Ch],0
1242
	jne	pe_code_sum_ok
1239
	jne	pe_code_sum_ok
Line 1252... Line 1249...
1252
	jne	pe_data_sum_ok
1249
	jne	pe_data_sum_ok
1253
	mov	eax,[ebx+0Ch]
1250
	mov	eax,[ebx+0Ch]
1254
	mov	[edx+30h],eax
1251
	mov	[edx+30h],eax
1255
      pe_data_sum_ok:
1252
      pe_data_sum_ok:
1256
 
1253
	mov	eax,[ebx+8]
1257
	mov	eax,[ebx+8]
-
 
1258
	or	eax,eax
1254
	or	eax,eax
1259
	jz	udata_ok
1255
	jz	udata_ok
1260
	cmp	dword [ebx+10h],0
1256
	cmp	dword [ebx+10h],0
1261
	jne	udata_ok
1257
	jne	udata_ok
1262
	or	byte [ebx+24h],80h
1258
	or	byte [ebx+24h],80h
1263
	add	[edx+24h],ecx
1259
	add	[edx+24h],ecx
1264
      udata_ok:
1260
      udata_ok:
1265
 
1261
	mov	ecx,[edx+38h]
1266
	mov	ecx,[edx+38h]
-
 
1267
	dec	ecx
1262
	dec	ecx
1268
	add	eax,ecx
1263
	add	eax,ecx
1269
	not	ecx
1264
	not	ecx
1270
	and	eax,ecx
1265
	and	eax,ecx
1271
	add	eax,[ebx+0Ch]
1266
	add	eax,[ebx+0Ch]
Line 2259... Line 2254...
2259
	or	eax,0E0000000h
2254
	or	eax,0E0000000h
2260
      flat_section_flags_ok:
2255
      flat_section_flags_ok:
2261
	mov	dword [ebx+14h],eax
2256
	mov	dword [ebx+14h],eax
2262
	mov	[current_section],ebx
2257
	mov	[current_section],ebx
2263
	mov	[number_of_sections],0
2258
	xor	eax,eax
-
 
2259
	mov	[number_of_sections],eax
2264
	mov	dword [org_origin],edi
2260
	mov	dword [org_origin],edi
2265
	mov	dword [org_origin+4],0
2261
	mov	dword [org_origin+4],eax
2266
	mov	[org_registers],0
2262
	mov	[org_registers],eax
2267
	mov	[org_start],edi
2263
	mov	[org_start],edi
2268
	mov	[org_symbol],ebx
2264
	mov	[org_symbol],ebx
2269
	mov	[labels_type],2
2265
	mov	[labels_type],2
2270
	mov	[code_type],32
2266
	mov	[code_type],32
2271
	test	[format_flags],8
2267
	test	[format_flags],8
2272
	jz	format_defined
2268
	jz	format_defined
Line 2285... Line 2281...
2285
	xor	eax,eax
2281
	xor	eax,eax
2286
	mov	[ebx],al
2282
	mov	[ebx],al
2287
	mov	[ebx+8],edi
2283
	mov	[ebx+8],edi
2288
	mov	dword [org_origin],edi
2284
	mov	dword [org_origin],edi
2289
	mov	dword [org_origin+4],0
2285
	mov	dword [org_origin+4],eax
2290
	mov	[org_registers],0
2286
	mov	[org_registers],eax
2291
	mov	[org_start],edi
2287
	mov	[org_start],edi
2292
	mov	[org_symbol],ebx
2288
	mov	[org_symbol],ebx
2293
	mov	[labels_type],2
2289
	mov	[labels_type],2
2294
	test	[format_flags],8
2290
	test	[format_flags],8
2295
	jz	coff_labels_type_ok
2291
	jz	coff_labels_type_ok
2296
	mov	[labels_type],4
2292
	mov	[labels_type],4
Line 2933... Line 2929...
2933
	xor	eax,eax
2929
	xor	eax,eax
2934
	mov	[ebx],al
2930
	mov	[ebx],al
2935
	mov	[ebx+8],edi
2931
	mov	[ebx+8],edi
2936
	mov	dword [org_origin],edi
2932
	mov	dword [org_origin],edi
2937
	mov	dword [org_origin+4],0
2933
	mov	dword [org_origin+4],eax
2938
	mov	[org_registers],0
2934
	mov	[org_registers],eax
2939
	mov	[org_start],edi
2935
	mov	[org_start],edi
2940
	mov	[org_symbol],ebx
2936
	mov	[org_symbol],ebx
2941
	test	[format_flags],8
2937
	test	[format_flags],8
2942
	jnz	elf64_labels_type
2938
	jnz	elf64_labels_type
2943
	mov	[labels_type],2
2939
	mov	[labels_type],2
2944
	jmp	elf_labels_type_ok
2940
	jmp	elf_labels_type_ok
Line 3975... Line 3971...
3975
	ret
3971
	ret
3976
 
3972
 
Line 3977... Line 3973...
3977
dump_symbols:
3973
dump_symbols:
3978
	mov	ebx,[code_start]
3974
	mov	ebx,[code_start]
3979
	mov	dword [ebx],'fas'+27 shl 24
3975
	mov	dword [ebx],'fas'+1Ah shl 24
3980
	mov	dword [ebx+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16
3976
	mov	dword [ebx+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16
3981
	add	ebx,38h
3977
	add	ebx,38h
3982
	mov	edi,ebx
3978
	mov	edi,ebx
3983
	mov	dword [ebx-38h+10h],38h
3979
	mov	dword [ebx-38h+10h],38h
3984
	mov	dword [ebx-38h+8],0
3980
	mov	dword [ebx-38h+8],0