Rev 1242 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1242 | Rev 2287 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; flat assembler core |
1 | ; flat assembler core |
2 | ; Copyright (c) 1999-2009, Tomasz Grysztar. |
2 | ; Copyright (c) 1999-2011, Tomasz Grysztar. |
3 | ; All rights reserved. |
3 | ; All rights reserved. |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | formatter: |
5 | formatter: |
6 | mov [current_offset],edi |
6 | mov [current_offset],edi |
Line 202... | Line 202... | ||
202 | jne unexpected_instruction |
202 | jne unexpected_instruction |
203 | cmp [output_format],0 |
203 | cmp [output_format],0 |
204 | jne unexpected_instruction |
204 | jne unexpected_instruction |
205 | lods byte [esi] |
205 | lods byte [esi] |
206 | cmp al,17h |
206 | cmp al,1Ch |
207 | je format_prefix |
207 | je format_prefix |
208 | cmp al,18h |
208 | cmp al,18h |
209 | jne invalid_argument |
209 | jne invalid_argument |
210 | lods byte [esi] |
210 | lods byte [esi] |
211 | select_format: |
211 | select_format: |
212 | mov dl,al |
212 | mov dl,al |
Line 832... | Line 832... | ||
832 | mov [machine],14Ch |
832 | mov [machine],14Ch |
833 | mov [subsystem],3 |
833 | mov [subsystem],3 |
834 | mov [subsystem_version],3 + 10 shl 16 |
834 | mov [subsystem_version],3 + 10 shl 16 |
835 | mov [image_base],400000h |
835 | mov [image_base],400000h |
836 | test [format_flags],8 |
836 | mov [image_base_high],0 |
- | 837 | test [format_flags],8 |
|
837 | jz pe_settings |
838 | jz pe_settings |
838 | mov [machine],8664h |
839 | mov [machine],8664h |
839 | mov [subsystem_version],5 + 0 shl 16 |
840 | mov [subsystem_version],5 + 0 shl 16 |
840 | mov [image_base_high],0 |
841 | pe_settings: |
841 | pe_settings: |
- | |
842 | cmp byte [esi],84h |
842 | cmp byte [esi],84h |
843 | je get_stub_name |
843 | je get_stub_name |
844 | cmp byte [esi],80h |
844 | cmp byte [esi],80h |
845 | je get_pe_base |
845 | je get_pe_base |
846 | cmp byte [esi],1Bh |
846 | cmp byte [esi],1Bh |
Line 852... | Line 852... | ||
852 | cmp al,80h |
852 | cmp al,80h |
853 | je dll_flag |
853 | je dll_flag |
854 | cmp al,81h |
854 | cmp al,81h |
855 | je wdm_flag |
855 | je wdm_flag |
856 | jmp pe_settings |
856 | cmp al,82h |
- | 857 | je large_flag |
|
- | 858 | cmp al,83h |
|
- | 859 | je nx_flag |
|
- | 860 | jmp pe_settings |
|
857 | dll_flag: |
861 | dll_flag: |
858 | bts [format_flags],8 |
862 | bts [format_flags],8 |
859 | jc setting_already_specified |
863 | jc setting_already_specified |
860 | jmp pe_settings |
864 | jmp pe_settings |
861 | wdm_flag: |
865 | wdm_flag: |
862 | bts [format_flags],9 |
866 | bts [format_flags],9 |
863 | jc setting_already_specified |
867 | jc setting_already_specified |
864 | jmp pe_settings |
868 | jmp pe_settings |
865 | subsystem_setting: |
869 | large_flag: |
- | 870 | bts [format_flags],11 |
|
- | 871 | jc setting_already_specified |
|
- | 872 | test [format_flags],8 |
|
- | 873 | jnz invalid_argument |
|
- | 874 | jmp pe_settings |
|
- | 875 | nx_flag: |
|
- | 876 | bts [format_flags],12 |
|
- | 877 | jc setting_already_specified |
|
- | 878 | jmp pe_settings |
|
- | 879 | subsystem_setting: |
|
866 | bts [format_flags],7 |
880 | bts [format_flags],7 |
867 | jc setting_already_specified |
881 | jc setting_already_specified |
868 | and ax,3Fh |
882 | and ax,3Fh |
869 | mov [subsystem],ax |
883 | mov [subsystem],ax |
870 | cmp ax,10 |
884 | cmp ax,10 |
871 | jb subsystem_type_ok |
885 | jb subsystem_type_ok |
872 | or [format_flags],8 |
886 | or [format_flags],4 |
873 | subsystem_type_ok: |
887 | subsystem_type_ok: |
874 | cmp byte [esi],'(' |
888 | cmp byte [esi],'(' |
875 | jne pe_settings |
889 | jne pe_settings |
876 | inc esi |
890 | inc esi |
877 | cmp byte [esi],'.' |
891 | cmp byte [esi],'.' |
878 | jne invalid_value |
892 | jne invalid_value |
Line 922... | Line 936... | ||
922 | cmp byte [esi],'.' |
936 | cmp byte [esi],'.' |
923 | je invalid_value |
937 | je invalid_value |
924 | push edx edi |
938 | push edx edi |
925 | add edi,[stub_size] |
939 | add edi,[stub_size] |
926 | test [format_flags],8 |
940 | test [format_flags],4 |
927 | jnz get_peplus_base |
941 | jnz get_peplus_base |
928 | call get_dword_value |
942 | call get_dword_value |
929 | mov [image_base],eax |
943 | mov [image_base],eax |
930 | jmp pe_base_ok |
944 | jmp pe_base_ok |
931 | get_peplus_base: |
945 | get_peplus_base: |
932 | call get_qword_value |
946 | call get_qword_value |
Line 964... | Line 978... | ||
964 | mov ebp,eax |
978 | mov ebp,eax |
965 | pe_stub_ok: |
979 | pe_stub_ok: |
966 | mov edx,edi |
980 | mov edx,edi |
967 | mov ecx,18h+0E0h |
981 | mov ecx,18h+0E0h |
968 | test [format_flags],8 |
982 | test [format_flags],4 |
969 | jz zero_pe_header |
983 | jz zero_pe_header |
970 | add ecx,10h |
984 | add ecx,10h |
971 | zero_pe_header: |
985 | zero_pe_header: |
972 | add ebp,ecx |
986 | add ebp,ecx |
973 | shr ecx,2 |
987 | shr ecx,2 |
974 | xor eax,eax |
988 | xor eax,eax |
Line 989... | Line 1003... | ||
989 | mov dword [edx+38h],eax |
1003 | mov dword [edx+38h],eax |
990 | mov dword [edx+3Ch],eax |
1004 | mov dword [edx+3Ch],eax |
991 | pe_alignment_ok: |
1005 | pe_alignment_ok: |
992 | mov word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8 |
1006 | mov word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8 |
993 | test [format_flags],8 |
1007 | test [format_flags],4 |
994 | jnz init_peplus_specific |
1008 | jnz init_peplus_specific |
995 | mov byte [edx+14h],0E0h ; size of optional header |
1009 | mov byte [edx+14h],0E0h ; size of optional header |
996 | mov dword [edx+16h],10B010Eh; flags and magic value |
1010 | mov dword [edx+16h],10B010Fh; flags and magic value |
997 | mov eax,[image_base] |
1011 | mov eax,[image_base] |
998 | mov [edx+34h],eax |
1012 | mov [edx+34h],eax |
999 | mov byte [edx+60h+1],10h ; stack reserve |
1013 | mov byte [edx+60h+1],10h ; stack reserve |
1000 | mov byte [edx+64h+1],10h ; stack commit |
1014 | mov byte [edx+64h+1],10h ; stack commit |
1001 | mov byte [edx+68h+2],1 ; heap reserve |
1015 | mov byte [edx+68h+2],1 ; heap reserve |
1002 | mov byte [edx+74h],16 ; number of directories |
1016 | mov byte [edx+74h],16 ; number of directories |
1003 | jmp pe_header_ok |
1017 | jmp pe_header_ok |
1004 | init_peplus_specific: |
1018 | init_peplus_specific: |
1005 | mov byte [edx+14h],0F0h ; size of optional header |
1019 | mov byte [edx+14h],0F0h ; size of optional header |
1006 | mov dword [edx+16h],20B002Eh; flags and magic value |
1020 | mov dword [edx+16h],20B002Fh; flags and magic value |
1007 | mov eax,[image_base] |
1021 | mov eax,[image_base] |
1008 | mov [edx+30h],eax |
1022 | mov [edx+30h],eax |
1009 | mov eax,[image_base_high] |
1023 | mov eax,[image_base_high] |
1010 | mov [edx+34h],eax |
1024 | mov [edx+34h],eax |
1011 | mov byte [edx+60h+1],10h ; stack reserve |
1025 | mov byte [edx+60h+1],10h ; stack reserve |
1012 | mov byte [edx+68h+1],10h ; stack commit |
1026 | mov byte [edx+68h+1],10h ; stack commit |
Line 1061... | Line 1075... | ||
1061 | add eax,1 |
1075 | add eax,1 |
1062 | adc ecx,0 |
1076 | adc ecx,0 |
1063 | add eax,edi |
1077 | add eax,edi |
1064 | adc ecx,0 |
1078 | adc ecx,0 |
1065 | test [format_flags],8 |
1079 | test [format_flags],4 |
1066 | jnz peplus_org |
1080 | jnz peplus_org |
1067 | sub eax,[edx+34h] |
1081 | sub eax,[edx+34h] |
1068 | sbb ecx,0 |
1082 | sbb ecx,0 |
1069 | mov bl,2 |
1083 | jmp pe_org_ok |
1070 | mov [code_type],32 |
- | |
1071 | jmp pe_org_ok |
- | |
1072 | peplus_org: |
1084 | peplus_org: |
1073 | sub eax,[edx+30h] |
1085 | sub eax,[edx+30h] |
1074 | sbb ecx,[edx+34h] |
1086 | sbb ecx,[edx+34h] |
1075 | mov bl,4 |
1087 | pe_org_ok: |
- | 1088 | test [format_flags],8 |
|
- | 1089 | jnz pe64_code |
|
- | 1090 | mov bl,2 |
|
- | 1091 | mov [code_type],32 |
|
- | 1092 | jmp pe_code_type_ok |
|
- | 1093 | pe64_code: |
|
- | 1094 | mov bl,4 |
|
1076 | mov [code_type],64 |
1095 | mov [code_type],64 |
1077 | pe_org_ok: |
1096 | pe_code_type_ok: |
1078 | bt [resolver_flags],0 |
1097 | bt [resolver_flags],0 |
1079 | jc pe_labels_type_ok |
1098 | jc pe_labels_type_ok |
1080 | xor bl,bl |
1099 | xor bl,bl |
1081 | pe_labels_type_ok: |
1100 | pe_labels_type_ok: |
1082 | mov [labels_type],bl |
1101 | mov [labels_type],bl |
1083 | mov dword [org_origin],eax |
1102 | mov dword [org_origin],eax |
Line 1091... | Line 1110... | ||
1091 | bt [format_flags],9 |
1110 | bt [format_flags],9 |
1092 | jnc wdm_flag_ok |
1111 | jnc wdm_flag_ok |
1093 | or byte [edx+5Eh+1],20h |
1112 | or byte [edx+5Eh+1],20h |
1094 | wdm_flag_ok: |
1113 | wdm_flag_ok: |
1095 | jmp format_defined |
1114 | bt [format_flags],11 |
- | 1115 | jnc large_flag_ok |
|
- | 1116 | or byte [edx+16h],20h |
|
- | 1117 | large_flag_ok: |
|
- | 1118 | bt [format_flags],12 |
|
- | 1119 | jnc nx_ok |
|
- | 1120 | or byte [edx+5Eh+1],1 |
|
- | 1121 | nx_ok: |
|
- | 1122 | jmp format_defined |
|
1096 | pe_section: |
1123 | pe_section: |
1097 | call close_pe_section |
1124 | call close_pe_section |
1098 | bts [format_flags],5 |
1125 | bts [format_flags],5 |
1099 | lea ecx,[ebx+28h] |
1126 | lea ecx,[ebx+28h] |
1100 | add edx,[edx+54h] |
1127 | add edx,[edx+54h] |
Line 1133... | Line 1160... | ||
1133 | mov eax,edi |
1160 | mov eax,edi |
1134 | xor ecx,ecx |
1161 | xor ecx,ecx |
1135 | sub eax,[ebx+0Ch] |
1162 | sub eax,[ebx+0Ch] |
1136 | sbb ecx,0 |
1163 | sbb ecx,0 |
1137 | test [format_flags],8 |
1164 | mov [labels_type],2 |
- | 1165 | mov [code_type],32 |
|
- | 1166 | test [format_flags],8 |
|
1138 | jnz peplus_section_org |
1167 | jz pe_section_code_type_ok |
- | 1168 | mov [labels_type],4 |
|
- | 1169 | mov [code_type],64 |
|
- | 1170 | pe_section_code_type_ok: |
|
- | 1171 | test [format_flags],4 |
|
- | 1172 | jnz peplus_section_org |
|
1139 | sub eax,[edx+34h] |
1173 | sub eax,[edx+34h] |
1140 | sbb ecx,0 |
1174 | sbb ecx,0 |
1141 | mov [labels_type],2 |
1175 | bt [resolver_flags],0 |
1142 | mov [code_type],32 |
- | |
1143 | bt [resolver_flags],0 |
- | |
1144 | jc pe_section_org_ok |
1176 | jc pe_section_org_ok |
1145 | mov [labels_type],0 |
1177 | mov [labels_type],0 |
1146 | jmp pe_section_org_ok |
1178 | jmp pe_section_org_ok |
1147 | peplus_section_org: |
1179 | peplus_section_org: |
1148 | sub eax,[edx+30h] |
1180 | sub eax,[edx+30h] |
1149 | sbb ecx,[edx+34h] |
1181 | sbb ecx,[edx+34h] |
1150 | mov [labels_type],4 |
1182 | bt [resolver_flags],0 |
1151 | mov [code_type],64 |
- | |
1152 | bt [resolver_flags],0 |
- | |
1153 | jc pe_section_org_ok |
1183 | jc pe_section_org_ok |
1154 | mov [labels_type],0 |
1184 | mov [labels_type],0 |
1155 | pe_section_org_ok: |
1185 | pe_section_org_ok: |
1156 | mov dword [org_origin],eax |
1186 | mov dword [org_origin],eax |
1157 | mov dword [org_origin+4],ecx |
1187 | mov dword [org_origin+4],ecx |
Line 1168... | Line 1198... | ||
1168 | set_directory: |
1198 | set_directory: |
1169 | movzx eax,byte [esi] |
1199 | movzx eax,byte [esi] |
1170 | inc esi |
1200 | inc esi |
1171 | mov ecx,ebx |
1201 | mov ecx,ebx |
1172 | test [format_flags],8 |
1202 | test [format_flags],4 |
1173 | jnz peplus_directory |
1203 | jnz peplus_directory |
1174 | xchg ecx,[edx+78h+eax*8] |
1204 | xchg ecx,[edx+78h+eax*8] |
1175 | mov dword [edx+78h+eax*8+4],-1 |
1205 | mov dword [edx+78h+eax*8+4],-1 |
1176 | jmp pe_directory_set |
1206 | jmp pe_directory_set |
1177 | peplus_directory: |
1207 | peplus_directory: |
1178 | xchg ecx,[edx+88h+eax*8] |
1208 | xchg ecx,[edx+88h+eax*8] |
Line 1242... | Line 1272... | ||
1242 | pe_code_sum_ok: |
1272 | pe_code_sum_ok: |
1243 | test byte [ebx+24h],40h |
1273 | test byte [ebx+24h],40h |
1244 | jz pe_data_sum_ok |
1274 | jz pe_data_sum_ok |
1245 | add [edx+20h],ecx |
1275 | add [edx+20h],ecx |
1246 | test [format_flags],8 |
1276 | test [format_flags],4 |
1247 | jnz pe_data_sum_ok |
1277 | jnz pe_data_sum_ok |
1248 | cmp dword [edx+30h],0 |
1278 | cmp dword [edx+30h],0 |
1249 | jne pe_data_sum_ok |
1279 | jne pe_data_sum_ok |
1250 | mov eax,[ebx+0Ch] |
1280 | mov eax,[ebx+0Ch] |
1251 | mov [edx+30h],eax |
1281 | mov [edx+30h],eax |
1252 | pe_data_sum_ok: |
1282 | pe_data_sum_ok: |
Line 1289... | Line 1319... | ||
1289 | mov ecx,edi |
1319 | mov ecx,edi |
1290 | sub ecx,[ebx+14h] |
1320 | sub ecx,[ebx+14h] |
1291 | add ecx,[ebx+0Ch] |
1321 | add ecx,[ebx+0Ch] |
1292 | mov edx,[code_start] |
1322 | mov edx,[code_start] |
1293 | test [format_flags],8 |
1323 | test [format_flags],4 |
1294 | jnz peplus_data |
1324 | jnz peplus_data |
1295 | xchg ecx,[edx+78h+eax*8] |
1325 | xchg ecx,[edx+78h+eax*8] |
1296 | jmp init_pe_data |
1326 | jmp init_pe_data |
1297 | peplus_data: |
1327 | peplus_data: |
1298 | xchg ecx,[edx+88h+eax*8] |
1328 | xchg ecx,[edx+88h+eax*8] |
1299 | init_pe_data: |
1329 | init_pe_data: |
Line 1316... | Line 1346... | ||
1316 | mov ecx,edi |
1346 | mov ecx,edi |
1317 | sub ecx,[edx+14h] |
1347 | sub ecx,[edx+14h] |
1318 | add ecx,[edx+0Ch] |
1348 | add ecx,[edx+0Ch] |
1319 | mov edx,[code_start] |
1349 | mov edx,[code_start] |
1320 | test [format_flags],8 |
1350 | test [format_flags],4 |
1321 | jnz end_peplus_data |
1351 | jnz end_peplus_data |
1322 | sub ecx,[edx+78h+eax*8] |
1352 | sub ecx,[edx+78h+eax*8] |
1323 | mov [edx+78h+eax*8+4],ecx |
1353 | mov [edx+78h+eax*8+4],ecx |
1324 | jmp remove_structure_data |
1354 | jmp remove_structure_data |
1325 | end_peplus_data: |
1355 | end_peplus_data: |
1326 | sub ecx,[edx+88h+eax*8] |
1356 | sub ecx,[edx+88h+eax*8] |
Line 1332... | Line 1362... | ||
1332 | jne invalid_argument |
1362 | jne invalid_argument |
1333 | cmp byte [esi],'.' |
1363 | cmp byte [esi],'.' |
1334 | je invalid_value |
1364 | je invalid_value |
1335 | test [format_flags],8 |
1365 | test [format_flags],8 |
1336 | jnz peplus_entry |
1366 | jnz pe64_entry |
1337 | call get_dword_value |
1367 | call get_dword_value |
1338 | mov bl,2 |
1368 | mov bl,2 |
1339 | bt [resolver_flags],0 |
1369 | bt [resolver_flags],0 |
1340 | jc check_pe_entry_label_type |
1370 | jc check_pe_entry_label_type |
1341 | xor bl,bl |
1371 | xor bl,bl |
1342 | check_pe_entry_label_type: |
1372 | check_pe_entry_label_type: |
Line 1347... | Line 1377... | ||
1347 | mov edx,[current_line] |
1377 | mov edx,[current_line] |
1348 | mov [error_line],edx |
1378 | mov [error_line],edx |
1349 | mov [error],invalid_address |
1379 | mov [error],invalid_address |
1350 | pe_entry_ok: |
1380 | pe_entry_ok: |
1351 | mov edx,[code_start] |
1381 | cdq |
- | 1382 | test [format_flags],4 |
|
- | 1383 | jnz pe64_entry_type_ok |
|
- | 1384 | mov edx,[code_start] |
|
1352 | sub eax,[edx+34h] |
1385 | sub eax,[edx+34h] |
1353 | mov [edx+28h],eax |
1386 | mov [edx+28h],eax |
1354 | jmp instruction_assembled |
1387 | jmp instruction_assembled |
1355 | peplus_entry: |
1388 | pe64_entry: |
1356 | call get_qword_value |
1389 | call get_qword_value |
1357 | mov bl,4 |
1390 | mov bl,4 |
1358 | bt [resolver_flags],0 |
1391 | bt [resolver_flags],0 |
1359 | jc check_peplus_entry_label_type |
1392 | jc check_pe64_entry_label_type |
1360 | xor bl,bl |
1393 | xor bl,bl |
1361 | check_peplus_entry_label_type: |
1394 | check_pe64_entry_label_type: |
1362 | cmp [value_type],bl |
1395 | cmp [value_type],bl |
1363 | je peplus_entry_type_ok |
1396 | je pe64_entry_type_ok |
1364 | cmp [error_line],0 |
1397 | cmp [error_line],0 |
1365 | jne peplus_entry_type_ok |
1398 | jne pe64_entry_type_ok |
1366 | mov edx,[current_line] |
1399 | mov edx,[current_line] |
1367 | mov [error_line],edx |
1400 | mov [error_line],edx |
1368 | mov [error],invalid_address |
1401 | mov [error],invalid_address |
1369 | peplus_entry_type_ok: |
1402 | pe64_entry_type_ok: |
1370 | mov ecx,[code_start] |
1403 | mov ecx,[code_start] |
1371 | sub eax,[ecx+30h] |
1404 | sub eax,[ecx+30h] |
1372 | sbb edx,[ecx+34h] |
1405 | sbb edx,[ecx+34h] |
1373 | jz peplus_entry_range_ok |
1406 | jz pe64_entry_range_ok |
1374 | mov edx,[current_line] |
1407 | mov edx,[current_line] |
1375 | mov [error_line],edx |
1408 | mov [error_line],edx |
1376 | mov [error],value_out_of_range |
1409 | mov [error],value_out_of_range |
1377 | peplus_entry_range_ok: |
1410 | pe64_entry_range_ok: |
1378 | mov [ecx+28h],eax |
1411 | mov [ecx+28h],eax |
1379 | jmp instruction_assembled |
1412 | jmp instruction_assembled |
1380 | pe_stack: |
1413 | pe_stack: |
1381 | lods byte [esi] |
1414 | lods byte [esi] |
1382 | cmp al,'(' |
1415 | cmp al,'(' |
1383 | jne invalid_argument |
1416 | jne invalid_argument |
1384 | cmp byte [esi],'.' |
1417 | cmp byte [esi],'.' |
1385 | je invalid_value |
1418 | je invalid_value |
1386 | test [format_flags],8 |
1419 | test [format_flags],4 |
1387 | jnz peplus_stack |
1420 | jnz peplus_stack |
1388 | call get_dword_value |
1421 | call get_count_value |
1389 | cmp [value_type],0 |
1422 | mov edx,[code_start] |
1390 | jne invalid_use_of_symbol |
- | |
1391 | mov edx,[code_start] |
- | |
1392 | mov [edx+60h],eax |
1423 | mov [edx+60h],eax |
1393 | cmp byte [esi],',' |
1424 | cmp byte [esi],',' |
1394 | jne default_stack_commit |
1425 | jne default_stack_commit |
1395 | lods byte [esi] |
1426 | lods byte [esi] |
1396 | lods byte [esi] |
1427 | lods byte [esi] |
1397 | cmp al,'(' |
1428 | cmp al,'(' |
1398 | jne invalid_argument |
1429 | jne invalid_argument |
1399 | cmp byte [esi],'.' |
1430 | cmp byte [esi],'.' |
1400 | je invalid_value |
1431 | je invalid_value |
1401 | call get_dword_value |
1432 | call get_count_value |
1402 | cmp [value_type],0 |
1433 | mov edx,[code_start] |
1403 | jne invalid_use_of_symbol |
- | |
1404 | mov edx,[code_start] |
- | |
1405 | mov [edx+64h],eax |
1434 | mov [edx+64h],eax |
1406 | cmp eax,[edx+60h] |
1435 | cmp eax,[edx+60h] |
1407 | ja value_out_of_range |
1436 | ja value_out_of_range |
1408 | jmp instruction_assembled |
1437 | jmp instruction_assembled |
1409 | default_stack_commit: |
1438 | default_stack_commit: |
Line 1454... | Line 1483... | ||
1454 | cmp al,'(' |
1483 | cmp al,'(' |
1455 | jne invalid_argument |
1484 | jne invalid_argument |
1456 | cmp byte [esi],'.' |
1485 | cmp byte [esi],'.' |
1457 | je invalid_value |
1486 | je invalid_value |
1458 | test [format_flags],8 |
1487 | test [format_flags],4 |
1459 | jnz peplus_heap |
1488 | jnz peplus_heap |
1460 | call get_dword_value |
1489 | call get_count_value |
1461 | cmp [value_type],0 |
1490 | mov edx,[code_start] |
1462 | jne invalid_use_of_symbol |
- | |
1463 | mov edx,[code_start] |
- | |
1464 | mov [edx+68h],eax |
1491 | mov [edx+68h],eax |
1465 | cmp byte [esi],',' |
1492 | cmp byte [esi],',' |
1466 | jne instruction_assembled |
1493 | jne instruction_assembled |
1467 | lods byte [esi] |
1494 | lods byte [esi] |
1468 | lods byte [esi] |
1495 | lods byte [esi] |
1469 | cmp al,'(' |
1496 | cmp al,'(' |
1470 | jne invalid_argument |
1497 | jne invalid_argument |
1471 | cmp byte [esi],'.' |
1498 | cmp byte [esi],'.' |
1472 | je invalid_value |
1499 | je invalid_value |
1473 | call get_dword_value |
1500 | call get_count_value |
1474 | cmp [value_type],0 |
1501 | mov edx,[code_start] |
1475 | jne invalid_use_of_symbol |
- | |
1476 | mov edx,[code_start] |
- | |
1477 | mov [edx+6Ch],eax |
1502 | mov [edx+6Ch],eax |
1478 | cmp eax,[edx+68h] |
1503 | cmp eax,[edx+68h] |
1479 | ja value_out_of_range |
1504 | ja value_out_of_range |
1480 | jmp instruction_assembled |
1505 | jmp instruction_assembled |
1481 | peplus_heap: |
1506 | peplus_heap: |
Line 1506... | Line 1531... | ||
1506 | ja value_out_of_range |
1531 | ja value_out_of_range |
1507 | jmp instruction_assembled |
1532 | jmp instruction_assembled |
1508 | mark_pe_relocation: |
1533 | mark_pe_relocation: |
1509 | push eax ebx |
1534 | push eax ebx |
1510 | test [format_flags],8 |
1535 | test [format_flags],4 |
1511 | jz check_pe32_relocation_type |
1536 | jz check_standard_pe_relocation_type |
1512 | cmp [value_type],4 |
1537 | cmp [value_type],4 |
1513 | je pe_relocation_type_ok |
1538 | je pe_relocation_type_ok |
1514 | check_pe32_relocation_type: |
1539 | check_standard_pe_relocation_type: |
1515 | cmp [value_type],2 |
1540 | cmp [value_type],2 |
1516 | je pe_relocation_type_ok |
1541 | je pe_relocation_type_ok |
1517 | cmp [error_line],0 |
1542 | cmp [error_line],0 |
1518 | jne pe_relocation_type_ok |
1543 | jne pe_relocation_type_ok |
1519 | mov eax,[current_line] |
1544 | mov eax,[current_line] |
1520 | mov [error_line],eax |
1545 | mov [error_line],eax |
Line 1525... | Line 1550... | ||
1525 | sub eax,[ebx+14h] |
1550 | sub eax,[ebx+14h] |
1526 | add eax,[ebx+0Ch] |
1551 | add eax,[ebx+0Ch] |
1527 | mov ebx,[free_additional_memory] |
1552 | mov ebx,[free_additional_memory] |
1528 | inc [number_of_relocations] |
1553 | inc [number_of_relocations] |
1529 | jz invalid_use_of_symbol |
1554 | add ebx,5 |
1530 | add ebx,5 |
- | |
1531 | cmp ebx,[structures_buffer] |
1555 | cmp ebx,[structures_buffer] |
1532 | jae out_of_memory |
1556 | jae out_of_memory |
1533 | mov [free_additional_memory],ebx |
1557 | mov [free_additional_memory],ebx |
1534 | mov [ebx-5],eax |
1558 | mov [ebx-5],eax |
1535 | cmp [value_type],2 |
1559 | cmp [value_type],2 |
Line 1547... | Line 1571... | ||
1547 | cmp al,5 |
1571 | cmp al,5 |
1548 | je make_pe_fixups |
1572 | je make_pe_fixups |
1549 | ret |
1573 | ret |
1550 | make_pe_fixups: |
1574 | make_pe_fixups: |
1551 | bts [resolver_flags],0 |
1575 | mov edx,[code_start] |
- | 1576 | and byte [edx+16h],not 1 |
|
- | 1577 | or byte [edx+5Eh],40h |
|
- | 1578 | bts [resolver_flags],0 |
|
1552 | jc pe_relocatable_ok |
1579 | jc fixups_ready |
1553 | or [next_pass_needed],-1 |
1580 | or [next_pass_needed],-1 |
1554 | pe_relocatable_ok: |
1581 | fixups_ready: |
- | 1582 | mov [last_fixup_base],0 |
|
- | 1583 | call make_fixups |
|
- | 1584 | xchg eax,[actual_fixups_size] |
|
- | 1585 | sub eax,[actual_fixups_size] |
|
- | 1586 | ja reserve_forward_fixups |
|
- | 1587 | xor eax,eax |
|
- | 1588 | reserve_forward_fixups: |
|
1555 | push esi |
1589 | mov [reserved_fixups],edi |
- | 1590 | add edi,eax |
|
- | 1591 | mov [reserved_fixups_size],eax |
|
- | 1592 | ret |
|
- | 1593 | make_fixups: |
|
- | 1594 | push esi |
|
1556 | mov ecx,[number_of_relocations] |
1595 | xor ecx,ecx |
- | 1596 | xchg ecx,[number_of_relocations] |
|
1557 | mov esi,[free_additional_memory] |
1597 | mov esi,[free_additional_memory] |
1558 | lea eax,[ecx*5] |
1598 | lea eax,[ecx*5] |
1559 | sub esi,eax |
1599 | sub esi,eax |
1560 | mov [free_additional_memory],esi |
1600 | mov [free_additional_memory],esi |
1561 | or [number_of_relocations],-1 |
1601 | mov edx,[last_fixup_base] |
1562 | xor edx,edx |
- | |
1563 | mov ebp,edi |
1602 | mov ebp,edi |
1564 | make_fixups: |
1603 | jecxz fixups_done |
- | 1604 | make_fixup: |
|
1565 | cmp [esi],edx |
1605 | cmp [esi],edx |
1566 | jb store_fixup |
1606 | jb store_fixup |
1567 | mov eax,edi |
1607 | mov eax,edi |
1568 | sub eax,ebp |
1608 | sub eax,ebp |
1569 | test eax,11b |
1609 | test eax,11b |
1570 | jz fixups_block |
1610 | jz fixups_block |
Line 1580... | Line 1620... | ||
1580 | mov ebx,edi |
1620 | mov ebx,edi |
1581 | mov eax,8 |
1621 | mov eax,8 |
1582 | stos dword [edi] |
1622 | stos dword [edi] |
1583 | store_fixup: |
1623 | store_fixup: |
1584 | jecxz fixups_done |
1624 | add dword [ebx],2 |
1585 | add dword [ebx],2 |
- | |
1586 | mov ah,[esi+1] |
1625 | mov ah,[esi+1] |
1587 | and ah,0Fh |
1626 | and ah,0Fh |
1588 | mov al,[esi+4] |
1627 | mov al,[esi+4] |
1589 | shl al,4 |
1628 | shl al,4 |
1590 | or ah,al |
1629 | or ah,al |
1591 | mov al,[esi] |
1630 | mov al,[esi] |
1592 | stos word [edi] |
1631 | stos word [edi] |
1593 | add esi,5 |
1632 | add esi,5 |
1594 | loop make_fixups |
1633 | loop make_fixup |
1595 | fixups_done: |
1634 | fixups_done: |
1596 | pop esi |
1635 | mov [last_fixup_base],edx |
- | 1636 | pop esi |
|
1597 | ret |
1637 | mov eax,edi |
- | 1638 | sub eax,ebp |
|
- | 1639 | ret |
|
1598 | make_pe_resource: |
1640 | make_pe_resource: |
1599 | cmp byte [esi],82h |
1641 | cmp byte [esi],82h |
1600 | jne resource_done |
1642 | jne resource_done |
1601 | inc esi |
1643 | inc esi |
1602 | lods word [esi] |
1644 | lods word [esi] |
Line 2167... | Line 2209... | ||
2167 | mov [edx+50h],eax |
2209 | mov [edx+50h],eax |
2168 | call make_timestamp |
2210 | call make_timestamp |
2169 | mov edx,[code_start] |
2211 | mov edx,[code_start] |
2170 | mov [edx+8],eax |
2212 | mov [edx+8],eax |
2171 | mov eax,[number_of_relocations] |
2213 | mov eax,[number_of_sections] |
2172 | cmp eax,-1 |
- | |
2173 | je pe_relocations_ok |
- | |
2174 | shl eax,2 |
- | |
2175 | sub [free_additional_memory],eax |
- | |
2176 | btr [resolver_flags],0 |
- | |
2177 | jnc pe_relocations_ok |
- | |
2178 | or [next_pass_needed],-1 |
- | |
2179 | pe_relocations_ok: |
- | |
2180 | mov eax,[number_of_sections] |
- | |
2181 | mov [edx+6],ax |
2214 | mov [edx+6],ax |
2182 | imul eax,28h |
2215 | imul eax,28h |
2183 | movzx ecx,word [edx+14h] |
2216 | movzx ecx,word [edx+14h] |
2184 | lea eax,[eax+18h+ecx] |
2217 | lea eax,[eax+18h+ecx] |
2185 | add eax,[stub_size] |
2218 | add eax,[stub_size] |
Line 2193... | Line 2226... | ||
2193 | or [next_pass_needed],-1 |
2226 | or [next_pass_needed],-1 |
2194 | pe_sections_ok: |
2227 | pe_sections_ok: |
2195 | xor ecx,ecx |
2228 | xor ecx,ecx |
2196 | add edx,78h |
2229 | add edx,78h |
2197 | test [format_flags],8 |
2230 | test [format_flags],4 |
2198 | jz process_directories |
2231 | jz process_directories |
2199 | add edx,10h |
2232 | add edx,10h |
2200 | process_directories: |
2233 | process_directories: |
2201 | mov eax,[edx+ecx*8] |
2234 | mov eax,[edx+ecx*8] |
2202 | or eax,eax |
2235 | or eax,eax |
2203 | jz directory_ok |
2236 | jz directory_ok |
Line 2212... | Line 2245... | ||
2212 | directory_ok: |
2245 | directory_ok: |
2213 | inc cl |
2246 | inc cl |
2214 | cmp cl,10h |
2247 | cmp cl,10h |
2215 | jb process_directories |
2248 | jb process_directories |
2216 | mov ebx,[code_start] |
2249 | cmp dword [edx+5*8],0 |
- | 2250 | jne finish_pe_relocations |
|
- | 2251 | mov eax,[number_of_relocations] |
|
- | 2252 | shl eax,2 |
|
- | 2253 | sub [free_additional_memory],eax |
|
- | 2254 | btr [resolver_flags],0 |
|
- | 2255 | jnc pe_relocations_ok |
|
- | 2256 | or [next_pass_needed],-1 |
|
- | 2257 | jmp pe_relocations_ok |
|
- | 2258 | finish_pe_relocations: |
|
- | 2259 | push edi |
|
- | 2260 | mov edi,[reserved_fixups] |
|
- | 2261 | call make_fixups |
|
- | 2262 | pop edi |
|
- | 2263 | add [actual_fixups_size],eax |
|
- | 2264 | cmp eax,[reserved_fixups_size] |
|
- | 2265 | je pe_relocations_ok |
|
- | 2266 | or [next_pass_needed],-1 |
|
- | 2267 | pe_relocations_ok: |
|
- | 2268 | mov ebx,[code_start] |
|
2217 | sub ebx,[stub_size] |
2269 | sub ebx,[stub_size] |
2218 | mov ecx,edi |
2270 | mov ecx,edi |
2219 | sub ecx,ebx |
2271 | sub ecx,ebx |
2220 | mov ebp,ecx |
2272 | mov ebp,ecx |
2221 | shr ecx,1 |
2273 | shr ecx,1 |
Line 2301... | Line 2353... | ||
2301 | lea esi,[esi+4+ecx+1] |
2353 | lea esi,[esi+4+ecx+1] |
2302 | cmp ecx,8 |
2354 | cmp ecx,8 |
2303 | ja name_too_long |
2355 | ja name_too_long |
2304 | coff_section_flags: |
2356 | coff_section_flags: |
2305 | cmp byte [esi],1Ch |
2357 | cmp byte [esi],8Ch |
2306 | je coff_section_alignment |
2358 | je coff_section_alignment |
2307 | cmp byte [esi],19h |
2359 | cmp byte [esi],19h |
2308 | jne coff_section_settings_ok |
2360 | jne coff_section_settings_ok |
2309 | inc esi |
2361 | inc esi |
2310 | lods byte [esi] |
2362 | lods byte [esi] |
2311 | bt [format_flags],0 |
2363 | bt [format_flags],0 |
Line 2324... | Line 2376... | ||
2324 | bt [format_flags],0 |
2376 | bt [format_flags],0 |
2325 | jnc invalid_argument |
2377 | jnc invalid_argument |
2326 | inc esi |
2378 | inc esi |
2327 | lods byte [esi] |
2379 | lods byte [esi] |
2328 | or al,al |
2380 | cmp al,'(' |
2329 | jnz invalid_argument |
- | |
2330 | lods byte [esi] |
- | |
2331 | cmp al,'(' |
- | |
2332 | jne invalid_argument |
2381 | jne invalid_argument |
2333 | cmp byte [esi],'.' |
2382 | cmp byte [esi],'.' |
2334 | je invalid_value |
2383 | je invalid_value |
2335 | push ebx |
2384 | push ebx |
2336 | call get_dword_value |
2385 | call get_count_value |
2337 | pop ebx |
2386 | pop ebx |
2338 | cmp [value_type],0 |
2387 | mov edx,eax |
2339 | jne invalid_use_of_symbol |
- | |
2340 | mov edx,eax |
- | |
2341 | dec edx |
2388 | dec edx |
2342 | test eax,edx |
2389 | test eax,edx |
2343 | jnz invalid_value |
2390 | jnz invalid_value |
2344 | or eax,eax |
2391 | or eax,eax |
2345 | jz invalid_value |
2392 | jz invalid_value |
Line 2740... | Line 2787... | ||
2740 | cmp cl,2 |
2787 | cmp cl,2 |
2741 | je public_symbol_type_ok |
2788 | je public_symbol_type_ok |
2742 | jmp invalid_use_of_symbol |
2789 | jmp invalid_use_of_symbol |
2743 | undefined_coff_public: |
2790 | undefined_coff_public: |
2744 | mov eax,[eax+24] |
2791 | mov [error_info],eax |
2745 | mov [error_info],eax |
- | |
2746 | jmp undefined_symbol |
2792 | jmp undefined_symbol |
2747 | check_64bit_public_symbol: |
2793 | check_64bit_public_symbol: |
2748 | cmp cl,4 |
2794 | cmp cl,4 |
2749 | jne invalid_use_of_symbol |
2795 | jne invalid_use_of_symbol |
2750 | public_symbol_type_ok: |
2796 | public_symbol_type_ok: |
Line 2950... | Line 2996... | ||
2950 | mov [ebx+4],esi |
2996 | mov [ebx+4],esi |
2951 | mov ecx,[esi] |
2997 | mov ecx,[esi] |
2952 | lea esi,[esi+4+ecx+1] |
2998 | lea esi,[esi+4+ecx+1] |
2953 | elf_section_flags: |
2999 | elf_section_flags: |
2954 | cmp byte [esi],1Ch |
3000 | cmp byte [esi],8Ch |
2955 | je elf_section_alignment |
3001 | je elf_section_alignment |
2956 | cmp byte [esi],19h |
3002 | cmp byte [esi],19h |
2957 | jne elf_section_settings_ok |
3003 | jne elf_section_settings_ok |
2958 | inc esi |
3004 | inc esi |
2959 | lods byte [esi] |
3005 | lods byte [esi] |
2960 | sub al,28 |
3006 | sub al,28 |
Line 2970... | Line 3016... | ||
2970 | jmp elf_section_flags |
3016 | jmp elf_section_flags |
2971 | elf_section_alignment: |
3017 | elf_section_alignment: |
2972 | inc esi |
3018 | inc esi |
2973 | lods byte [esi] |
3019 | lods byte [esi] |
2974 | or al,al |
3020 | cmp al,'(' |
2975 | jnz invalid_argument |
- | |
2976 | lods byte [esi] |
- | |
2977 | cmp al,'(' |
- | |
2978 | jne invalid_argument |
3021 | jne invalid_argument |
2979 | cmp byte [esi],'.' |
3022 | cmp byte [esi],'.' |
2980 | je invalid_value |
3023 | je invalid_value |
2981 | push ebx |
3024 | push ebx |
2982 | call get_dword_value |
3025 | call get_count_value |
2983 | pop ebx |
3026 | pop ebx |
2984 | cmp [value_type],0 |
3027 | mov edx,eax |
2985 | jne invalid_use_of_symbol |
- | |
2986 | mov edx,eax |
- | |
2987 | dec edx |
3028 | dec edx |
2988 | test eax,edx |
3029 | test eax,edx |
2989 | jnz invalid_value |
3030 | jnz invalid_value |
2990 | or eax,eax |
3031 | or eax,eax |
2991 | jz invalid_value |
3032 | jz invalid_value |
Line 4005... | Line 4046... | ||
4005 | adc edx,0 |
4046 | adc edx,0 |
4006 | elf64_segment_position_ok: |
4047 | elf64_segment_position_ok: |
4007 | and eax,not 0FFFh |
4048 | and eax,not 0FFFh |
4008 | ret |
4049 | ret |
4009 | 4050 | close_elf_exe: |
|
4010 | close_elf_exe: |
- | |
4011 | test [format_flags],8 |
4051 | test [format_flags],8 |
4012 | jnz close_elf64_exe |
4052 | jnz close_elf64_exe |
4013 | call close_elf_segment |
4053 | call close_elf_segment |
4014 | mov edx,[code_start] |
4054 | mov edx,[code_start] |
4015 | mov eax,[number_of_sections] |
4055 | mov eax,[number_of_sections] |
Line 4036... | Line 4076... | ||
4036 | je elf64_exe_ok |
4076 | je elf64_exe_ok |
4037 | or [next_pass_needed],-1 |
4077 | or [next_pass_needed],-1 |
4038 | elf64_exe_ok: |
4078 | elf64_exe_ok: |
4039 | ret |
4079 | ret |
4040 | 4080 | ||
4041 | dump_symbols: |
- | |
4042 | mov ebx,[code_start] |
- | |
4043 | mov dword [ebx],'fas'+1Ah shl 24 |
- | |
4044 | mov dword [ebx+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16 |
- | |
4045 | add ebx,38h |
- | |
4046 | mov edi,ebx |
- | |
4047 | mov dword [ebx-38h+10h],38h |
- | |
4048 | mov dword [ebx-38h+8],0 |
- | |
4049 | mov esi,[input_file] |
- | |
4050 | call copy_asciiz |
- | |
4051 | cmp edi,[display_buffer] |
- | |
4052 | jae out_of_memory |
- | |
4053 | mov eax,edi |
- | |
4054 | sub eax,ebx |
- | |
4055 | mov [ebx-38h+0Ch],eax |
- | |
4056 | mov esi,[output_file] |
- | |
4057 | call copy_asciiz |
- | |
4058 | cmp edi,[display_buffer] |
- | |
4059 | jae out_of_memory |
- | |
4060 | mov edx,[symbols_stream] |
- | |
4061 | mov ebp,[free_additional_memory] |
- | |
4062 | mov [number_of_sections],0 |
- | |
4063 | cmp [output_format],4 |
- | |
4064 | je prepare_strings_table |
- | |
4065 | cmp [output_format],5 |
- | |
4066 | jne strings_table_ready |
- | |
4067 | bt [format_flags],0 |
- | |
4068 | jc strings_table_ready |
- | |
4069 | prepare_strings_table: |
- | |
4070 | cmp edx,ebp |
- | |
4071 | je strings_table_ready |
- | |
4072 | mov al,[edx] |
- | |
4073 | test al,al |
- | |
4074 | jz prepare_string |
- | |
4075 | cmp al,80h |
- | |
4076 | je prepare_string |
- | |
4077 | add edx,0Ch |
- | |
4078 | cmp al,0C0h |
- | |
4079 | jb prepare_strings_table |
- | |
4080 | add edx,4 |
- | |
4081 | jmp prepare_strings_table |
- | |
4082 | prepare_string: |
- | |
4083 | mov esi,edi |
- | |
4084 | sub esi,ebx |
- | |
4085 | xchg esi,[edx+4] |
- | |
4086 | test al,al |
- | |
4087 | jz prepare_section_string |
- | |
4088 | or dword [edx+4],1 shl 31 |
- | |
4089 | add edx,0Ch |
- | |
4090 | prepare_external_string: |
- | |
4091 | mov ecx,[esi] |
- | |
4092 | add esi,4 |
- | |
4093 | rep movs byte [edi],[esi] |
- | |
4094 | mov byte [edi],0 |
- | |
4095 | inc edi |
- | |
4096 | cmp edi,[display_buffer] |
- | |
4097 | jae out_of_memory |
- | |
4098 | jmp prepare_strings_table |
- | |
4099 | prepare_section_string: |
- | |
4100 | mov ecx,[number_of_sections] |
- | |
4101 | mov eax,ecx |
- | |
4102 | inc eax |
- | |
4103 | mov [number_of_sections],eax |
- | |
4104 | xchg eax,[edx+4] |
- | |
4105 | shl ecx,2 |
- | |
4106 | add ecx,[free_additional_memory] |
- | |
4107 | mov [ecx],eax |
- | |
4108 | add edx,20h |
- | |
4109 | test esi,esi |
- | |
4110 | jz prepare_default_section_string |
- | |
4111 | cmp [output_format],5 |
- | |
4112 | jne prepare_external_string |
- | |
4113 | bt [format_flags],0 |
- | |
4114 | jc prepare_external_string |
- | |
4115 | mov esi,[esi] |
- | |
4116 | add esi,[resource_data] |
- | |
4117 | copy_elf_section_name: |
- | |
4118 | lods byte [esi] |
- | |
4119 | cmp edi,[display_buffer] |
- | |
4120 | jae out_of_memory |
- | |
4121 | stos byte [edi] |
- | |
4122 | test al,al |
- | |
4123 | jnz copy_elf_section_name |
- | |
4124 | jmp prepare_strings_table |
- | |
4125 | prepare_default_section_string: |
- | |
4126 | mov eax,'.fla' |
- | |
4127 | stos dword [edi] |
- | |
4128 | mov ax,'t' |
- | |
4129 | stos word [edi] |
- | |
4130 | cmp edi,[display_buffer] |
- | |
4131 | jae out_of_memory |
- | |
4132 | jmp prepare_strings_table |
- | |
4133 | strings_table_ready: |
- | |
4134 | mov edx,[display_buffer] |
- | |
4135 | mov ebp,[memory_end] |
- | |
4136 | sub ebp,[labels_list] |
- | |
4137 | add ebp,edx |
- | |
4138 | prepare_labels_dump: |
- | |
4139 | cmp edx,ebp |
- | |
4140 | je labels_dump_ok |
- | |
4141 | mov eax,[edx+24] |
- | |
4142 | test eax,eax |
- | |
4143 | jz label_dump_name_ok |
- | |
4144 | cmp eax,[memory_start] |
- | |
4145 | jb label_name_outside_source |
- | |
4146 | cmp eax,[source_start] |
- | |
4147 | ja label_name_outside_source |
- | |
4148 | sub eax,[memory_start] |
- | |
4149 | dec eax |
- | |
4150 | mov [edx+24],eax |
- | |
4151 | jmp label_dump_name_ok |
- | |
4152 | label_name_outside_source: |
- | |
4153 | mov esi,eax |
- | |
4154 | mov eax,edi |
- | |
4155 | sub eax,ebx |
- | |
4156 | or eax,1 shl 31 |
- | |
4157 | mov [edx+24],eax |
- | |
4158 | movzx ecx,byte [esi-1] |
- | |
4159 | lea eax,[edi+ecx+1] |
- | |
4160 | cmp edi,[display_buffer] |
- | |
4161 | jae out_of_memory |
- | |
4162 | rep movsb |
- | |
4163 | xor al,al |
- | |
4164 | stosb |
- | |
4165 | label_dump_name_ok: |
- | |
4166 | mov eax,[edx+28] |
- | |
4167 | test eax,eax |
- | |
4168 | jz label_dump_line_ok |
- | |
4169 | sub eax,[memory_start] |
- | |
4170 | mov [edx+28],eax |
- | |
4171 | label_dump_line_ok: |
- | |
4172 | mov eax,[edx+20] |
- | |
4173 | test eax,eax |
- | |
4174 | jz base_symbol_for_label_ok |
- | |
4175 | cmp eax,[symbols_stream] |
- | |
4176 | mov eax,[eax+4] |
- | |
4177 | jae base_symbol_for_label_ok |
- | |
4178 | xor eax,eax |
- | |
4179 | base_symbol_for_label_ok: |
- | |
4180 | mov [edx+20],eax |
- | |
4181 | add edx,LABEL_STRUCTURE_SIZE |
- | |
4182 | jmp prepare_labels_dump |
- | |
4183 | labels_dump_ok: |
- | |
4184 | mov eax,edi |
- | |
4185 | sub eax,ebx |
- | |
4186 | mov [ebx-38h+14h],eax |
- | |
4187 | add eax,38h |
- | |
4188 | mov [ebx-38h+18h],eax |
- | |
4189 | mov ecx,[memory_end] |
- | |
4190 | sub ecx,[labels_list] |
- | |
4191 | mov [ebx-38h+1Ch],ecx |
- | |
4192 | add eax,ecx |
- | |
4193 | mov [ebx-38h+20h],eax |
- | |
4194 | mov ecx,[source_start] |
- | |
4195 | sub ecx,[memory_start] |
- | |
4196 | mov [ebx-38h+24h],ecx |
- | |
4197 | add eax,ecx |
- | |
4198 | mov [ebx-38h+28h],eax |
- | |
4199 | mov eax,[number_of_sections] |
- | |
4200 | shl eax,2 |
- | |
4201 | mov [ebx-38h+34h],eax |
- | |
4202 | mov esi,[memory_start] |
- | |
4203 | prepare_preprocessed_source: |
- | |
4204 | cmp esi,[source_start] |
- | |
4205 | jae preprocessed_source_ok |
- | |
4206 | mov eax,[memory_start] |
- | |
4207 | mov edx,[input_file] |
- | |
4208 | cmp [esi],edx |
- | |
4209 | jne line_not_from_main_input |
- | |
4210 | mov [esi],eax |
- | |
4211 | line_not_from_main_input: |
- | |
4212 | sub [esi],eax |
- | |
4213 | test byte [esi+7],1 shl 7 |
- | |
4214 | jz prepare_next_preprocessed_line |
- | |
4215 | sub [esi+8],eax |
- | |
4216 | sub [esi+12],eax |
- | |
4217 | prepare_next_preprocessed_line: |
- | |
4218 | add esi,16 |
- | |
4219 | skip_preprocessed_line: |
- | |
4220 | lods byte [esi] |
- | |
4221 | cmp al,1Ah |
- | |
4222 | je skip_preprocessed_symbol |
- | |
4223 | cmp al,3Bh |
- | |
4224 | je skip_preprocessed_symbol |
- | |
4225 | cmp al,22h |
- | |
4226 | je skip_preprocessed_string |
- | |
4227 | or al,al |
- | |
4228 | jnz skip_preprocessed_line |
- | |
4229 | jmp prepare_preprocessed_source |
- | |
4230 | skip_preprocessed_string: |
- | |
4231 | lods dword [esi] |
- | |
4232 | add esi,eax |
- | |
4233 | jmp skip_preprocessed_line |
- | |
4234 | skip_preprocessed_symbol: |
- | |
4235 | lods byte [esi] |
- | |
4236 | movzx eax,al |
- | |
4237 | add esi,eax |
- | |
4238 | jmp skip_preprocessed_line |
- | |
4239 | preprocessed_source_ok: |
- | |
4240 | mov esi,[labels_list] |
- | |
4241 | mov ebp,edi |
- | |
4242 | make_lines_dump: |
- | |
4243 | cmp esi,[display_buffer] |
- | |
4244 | je lines_dump_ok |
- | |
4245 | mov eax,[esi-4] |
- | |
4246 | mov ecx,[esi-8] |
- | |
4247 | sub esi,8 |
- | |
4248 | sub esi,ecx |
- | |
4249 | cmp eax,1 |
- | |
4250 | jne make_lines_dump |
- | |
4251 | mov eax,[esi+4] |
- | |
4252 | sub eax,[code_start] |
- | |
4253 | add eax,[headers_size] |
- | |
4254 | cmp byte [esi+1Ah],0 |
- | |
4255 | je store_offset |
- | |
4256 | xor eax,eax |
- | |
4257 | store_offset: |
- | |
4258 | stos dword [edi] |
- | |
4259 | mov eax,[esi] |
- | |
4260 | sub eax,[memory_start] |
- | |
4261 | stos dword [edi] |
- | |
4262 | mov eax,[esi+4] |
- | |
4263 | xor edx,edx |
- | |
4264 | sub eax,[esi+8] |
- | |
4265 | sbb edx,[esi+8+4] |
- | |
4266 | stos dword [edi] |
- | |
4267 | mov eax,edx |
- | |
4268 | stos dword [edi] |
- | |
4269 | mov eax,[esi+10h] |
- | |
4270 | stos dword [edi] |
- | |
4271 | mov eax,[esi+14h] |
- | |
4272 | test eax,eax |
- | |
4273 | jz base_symbol_for_line_ok |
- | |
4274 | cmp eax,[symbols_stream] |
- | |
4275 | mov eax,[eax+4] |
- | |
4276 | jae base_symbol_for_line_ok |
- | |
4277 | xor eax,eax |
- | |
4278 | base_symbol_for_line_ok: |
- | |
4279 | stos dword [edi] |
- | |
4280 | mov eax,[esi+18h] |
- | |
4281 | and eax,001FFFFh |
- | |
4282 | stos dword [edi] |
- | |
4283 | jmp make_lines_dump |
- | |
4284 | lines_dump_ok: |
- | |
4285 | mov edx,edi |
- | |
4286 | mov eax,[current_offset] |
- | |
4287 | sub eax,[code_start] |
- | |
4288 | add eax,[headers_size] |
- | |
4289 | stos dword [edi] |
- | |
4290 | mov ecx,edi |
- | |
4291 | sub ecx,ebx |
- | |
4292 | sub ecx,[ebx-38h+14h] |
- | |
4293 | mov [ebx-38h+2Ch],ecx |
- | |
4294 | add ecx,[ebx-38h+28h] |
- | |
4295 | mov [ebx-38h+30h],ecx |
- | |
4296 | find_inexisting_offsets: |
- | |
4297 | sub edx,1Ch |
- | |
4298 | cmp edx,ebp |
- | |
4299 | jb write_symbols |
- | |
4300 | test byte [edx+1Ah],1 |
- | |
4301 | jnz find_inexisting_offsets |
- | |
4302 | cmp eax,[edx] |
- | |
4303 | jb correct_inexisting_offset |
- | |
4304 | mov eax,[edx] |
- | |
4305 | jmp find_inexisting_offsets |
- | |
4306 | correct_inexisting_offset: |
- | |
4307 | mov dword [edx],0 |
- | |
4308 | or byte [edx+1Ah],2 |
- | |
4309 | jmp find_inexisting_offsets |
- | |
4310 | write_symbols: |
- | |
4311 | mov edx,[symbols_file] |
- | |
4312 | call create |
- | |
4313 | jc write_failed |
- | |
4314 | mov edx,[code_start] |
- | |
4315 | mov ecx,[edx+14h] |
- | |
4316 | add ecx,38h |
- | |
4317 | call write |
- | |
4318 | mov edx,[display_buffer] |
- | |
4319 | mov ecx,[memory_end] |
- | |
4320 | sub ecx,[labels_list] |
- | |
4321 | call write |
- | |
4322 | mov edx,[memory_start] |
- | |
4323 | mov ecx,[source_start] |
- | |
4324 | sub ecx,edx |
- | |
4325 | call write |
- | |
4326 | mov edx,ebp |
- | |
4327 | mov ecx,edi |
- | |
4328 | sub ecx,edx |
- | |
4329 | call write |
- | |
4330 | mov edx,[free_additional_memory] |
- | |
4331 | mov ecx,[number_of_sections] |
- | |
4332 | shl ecx,2 |
- | |
4333 | call write |
- | |
4334 | call close |
- | |
4335 | ret |
- | |
4336 | - |