Rev 1292 | Rev 1311 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1292 | Rev 1296 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 1292 $ |
8 | $Revision: 1296 $ |
9 | 9 | ||
Line 1016... | Line 1016... | ||
1016 | .exit: |
1016 | .exit: |
1017 | xor eax, eax |
1017 | xor eax, eax |
1018 | ret |
1018 | ret |
1019 | endp |
1019 | endp |
Line -... | Line 1020... | ||
- | 1020 | ||
- | 1021 | ; in: edx -> COFF_SECTION struct |
|
- | 1022 | ; out: eax = alignment as mask for bits to drop |
|
- | 1023 | coff_get_align: |
|
- | 1024 | ; Rules: |
|
- | 1025 | ; - if alignment is not given, use default = 4K; |
|
- | 1026 | ; - if alignment is given and is no more than 4K, use it; |
|
- | 1027 | ; - if alignment is more than 4K, revert to 4K. |
|
- | 1028 | push ecx |
|
- | 1029 | mov cl, byte [edx+CFS.Characteristics+2] |
|
- | 1030 | mov eax, 1 |
|
- | 1031 | shr cl, 4 |
|
- | 1032 | dec cl |
|
- | 1033 | js .default |
|
- | 1034 | cmp cl, 12 |
|
- | 1035 | jbe @f |
|
- | 1036 | .default: |
|
- | 1037 | mov cl, 12 |
|
- | 1038 | @@: |
|
- | 1039 | shl eax, cl |
|
- | 1040 | pop ecx |
|
- | 1041 | dec eax |
|
- | 1042 | ret |
|
1020 | 1043 | ||
1021 | align 4 |
1044 | align 4 |
1022 | proc load_library stdcall, file_name:dword |
1045 | proc load_library stdcall, file_name:dword |
1023 | locals |
1046 | locals |
1024 | fullname rb 260 |
1047 | fullname rb 260 |
Line 1134... | Line 1157... | ||
1134 | movzx ecx, [edx+CFH.nSections] |
1157 | movzx ecx, [edx+CFH.nSections] |
1135 | xor ebx, ebx |
1158 | xor ebx, ebx |
Line 1136... | Line 1159... | ||
1136 | 1159 | ||
1137 | add edx, 20 |
1160 | add edx, 20 |
- | 1161 | @@: |
|
- | 1162 | call coff_get_align |
|
- | 1163 | add ebx, eax |
|
- | 1164 | not eax |
|
1138 | @@: |
1165 | and ebx, eax |
1139 | add ebx, [edx+CFS.SizeOfRawData] |
- | |
1140 | add ebx, 15 |
- | |
1141 | and ebx, not 15 |
1166 | add ebx, [edx+CFS.SizeOfRawData] |
1142 | add edx, COFF_SECTION_SIZE |
1167 | add edx, COFF_SECTION_SIZE |
1143 | dec ecx |
1168 | dec ecx |
1144 | jnz @B |
1169 | jnz @B |
1145 | ; it must be nonzero and not too big |
1170 | ; it must be nonzero and not too big |
Line 1170... | Line 1195... | ||
1170 | push esi |
1195 | push esi |
1171 | mov edx, [coff] |
1196 | mov edx, [coff] |
1172 | movzx ebx, [edx+CFH.nSections] |
1197 | movzx ebx, [edx+CFH.nSections] |
1173 | mov edi, eax |
1198 | mov edi, eax |
1174 | add edx, 20 |
1199 | add edx, 20 |
1175 | xor eax, eax |
- | |
1176 | cld |
1200 | cld |
1177 | @@: |
1201 | @@: |
- | 1202 | call coff_get_align |
|
- | 1203 | add ecx, eax |
|
- | 1204 | add edi, eax |
|
- | 1205 | not eax |
|
- | 1206 | and ecx, eax |
|
- | 1207 | and edi, eax |
|
1178 | mov [edx+CFS.VirtualAddress], ecx |
1208 | mov [edx+CFS.VirtualAddress], ecx |
1179 | add ecx, [edx+CFS.SizeOfRawData] |
1209 | add ecx, [edx+CFS.SizeOfRawData] |
1180 | mov esi, [edx+CFS.PtrRawData] |
1210 | mov esi, [edx+CFS.PtrRawData] |
1181 | push ecx |
1211 | push ecx |
1182 | mov ecx, [edx+CFS.SizeOfRawData] |
1212 | mov ecx, [edx+CFS.SizeOfRawData] |
1183 | test esi, esi |
1213 | test esi, esi |
1184 | jnz .copy |
1214 | jnz .copy |
- | 1215 | xor eax, eax |
|
1185 | rep stosb |
1216 | rep stosb |
1186 | jmp .next |
1217 | jmp .next |
1187 | .copy: |
1218 | .copy: |
1188 | add esi, [coff] |
1219 | add esi, [coff] |
1189 | rep movsb |
1220 | rep movsb |
1190 | .next: |
1221 | .next: |
1191 | pop ecx |
1222 | pop ecx |
1192 | add edi, 15 ;-new_app_base |
- | |
1193 | add ecx, 15 |
- | |
1194 | and edi, -16 |
- | |
1195 | and ecx, -16 |
- | |
1196 | add edx, COFF_SECTION_SIZE |
1223 | add edx, COFF_SECTION_SIZE |
1197 | dec ebx |
1224 | dec ebx |
1198 | jnz @B |
1225 | jnz @B |
1199 | pop esi |
1226 | pop esi |