Subversion Repositories Kolibri OS

Rev

Rev 8948 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8948 Rev 9927
Line 59... Line 59...
59
	EPEP_ERR_INVALID_BASE_RELOCATION_BLOCK_OFFSET,
59
	EPEP_ERR_INVALID_BASE_RELOCATION_BLOCK_OFFSET,
60
	EPEP_ERR_INVALID_NEXT_BASE_RELOCATION_BLOCK_OFFSET,
60
	EPEP_ERR_INVALID_NEXT_BASE_RELOCATION_BLOCK_OFFSET,
61
	EPEP_ERR_INVALID_BASE_RELOCATION_BLOCK_BASE_RELOCATION_OFFSET,
61
	EPEP_ERR_INVALID_BASE_RELOCATION_BLOCK_BASE_RELOCATION_OFFSET,
62
	EPEP_ERR_INVALID_SECTION_RELOCATION_OFFSET,
62
	EPEP_ERR_INVALID_SECTION_RELOCATION_OFFSET,
63
	EPEP_ERR_INVALID_LINENUMBER_OFFSET,
63
	EPEP_ERR_INVALID_LINENUMBER_OFFSET,
-
 
64
	EPEP_ERR_INVALID_NUMBER_OF_RELOCATIONS_FOR_EXTENDED,
-
 
65
	EPEP_ERR_END
64
} EpepError;
66
} EpepError;
Line 65... Line 67...
65
 
67
 
66
//
68
//
67
// Generic
69
// Generic
Line 283... Line 285...
283
} EpepExportAddress;
285
} EpepExportAddress;
Line 284... Line 286...
284
 
286
 
285
/// Returns non-zero if export table exists in the file
287
/// Returns non-zero if export table exists in the file
Line 286... Line 288...
286
int epep_has_export_table(Epep *epep);
288
int epep_has_export_table(Epep *epep);
287
 
289
 
Line 288... Line 290...
288
/// Palces offset of export table into epep structrue
290
/// Palces offset of export table into epep structure
289
int epep_read_export_table_offset(Epep *epep);
291
int epep_read_export_table_offset(Epep *epep);
290
 
292
 
Line 291... Line 293...
291
/// Palces export table into epep structrue
293
/// Palces export table into epep structure
292
//! Needs to be called before next export functions
294
//! Needs to be called before next export functions
Line 358... Line 360...
358
	uint32_t VirtualAddress;
360
	uint32_t VirtualAddress;
359
	uint32_t SymbolTableIndex;
361
	uint32_t SymbolTableIndex;
360
	uint16_t Type;
362
	uint16_t Type;
361
} EpepCoffRelocation;
363
} EpepCoffRelocation;
Line -... Line 364...
-
 
364
 
362
 
365
/// Gives a COFF Relocation by its index
Line -... Line 366...
-
 
366
int epep_get_section_relocation_by_index(Epep *epep, EpepSectionHeader *sh, EpepCoffRelocation *rel, size_t index);
-
 
367
 
-
 
368
/// Checks if the section contains more than 2^16 - 1 relocations
-
 
369
int epep_section_contains_extended_relocations(Epep *epep, EpepSectionHeader *sh, int *result);
-
 
370
 
-
 
371
/// Gives the section relocation count if the section contains more than 2^16 - 1 relocations
-
 
372
int epep_get_section_extended_number_of_relocations(Epep *epep, EpepSectionHeader *sh, size_t *result);
-
 
373
 
-
 
374
/// Gives the meaningful COFF Relocation count
-
 
375
//! Returns the value to pass to the following _x functions in the last parameter
-
 
376
int epep_get_section_number_of_relocations_x(Epep *epep, EpepSectionHeader *sh, size_t *result, int *extended);
-
 
377
 
-
 
378
/// Gives a meaningful COFF Relocation by its index
-
 
379
//! Requires the value returned by epep_get_section_number_of_relocations_x as the last argument
363
int epep_get_section_relocation_by_index(Epep *epep, EpepSectionHeader *sh, EpepCoffRelocation *rel, size_t index);
380
int epep_get_section_relocation_by_index_x(Epep *epep, EpepSectionHeader *sh, EpepCoffRelocation *rel, size_t index, int extended);
364
 
381
 
365
//
382
//
Line 366... Line 383...
366
// COFF Line Numbers
383
// COFF Line Numbers
Line 1002... Line 1019...
1002
	epep_seek(epep, offset);
1019
	epep_seek(epep, offset);
1003
	epep_read_block(epep, 10, rel);
1020
	epep_read_block(epep, 10, rel);
1004
	return 1;
1021
	return 1;
1005
}
1022
}
Line -... Line 1023...
-
 
1023
 
-
 
1024
int epep_section_contains_extended_relocations(Epep *epep, EpepSectionHeader *sh, int *result) {
-
 
1025
	const uint32_t flag_IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000;
-
 
1026
	if (sh->Characteristics & flag_IMAGE_SCN_LNK_NRELOC_OVFL) {
-
 
1027
                if (sh->NumberOfRelocations != 0xffff) {
-
 
1028
                        epep->error_code = EPEP_ERR_INVALID_NUMBER_OF_RELOCATIONS_FOR_EXTENDED;
-
 
1029
                        return 0;
-
 
1030
                }
-
 
1031
		*result = 1;
-
 
1032
	} else {
-
 
1033
		*result = 0;
-
 
1034
	}
-
 
1035
	return 1;
-
 
1036
}
-
 
1037
 
-
 
1038
int epep_get_section_extended_number_of_relocations(Epep *epep, EpepSectionHeader *sh, size_t *result) {
-
 
1039
	EpepCoffRelocation first_relocation;
-
 
1040
	if (!epep_get_section_relocation_by_index(epep, sh, &first_relocation, 0)) {
-
 
1041
		return 0;
-
 
1042
	}
-
 
1043
	*result = first_relocation.VirtualAddress;
-
 
1044
	return 1;
-
 
1045
}
-
 
1046
 
-
 
1047
int epep_get_section_number_of_relocations_x(Epep *epep, EpepSectionHeader *sh, size_t *result, int *extended) {
-
 
1048
	if (!epep_section_contains_extended_relocations(epep, sh, extended)) {
-
 
1049
		return 0;
-
 
1050
	}
-
 
1051
	if (*extended) {
-
 
1052
		size_t real_number_of_relocations;
-
 
1053
		if (!epep_get_section_extended_number_of_relocations(epep, sh, &real_number_of_relocations)) {
-
 
1054
			return 0;
-
 
1055
		}
-
 
1056
		*result = real_number_of_relocations - 1;
-
 
1057
	} else {
-
 
1058
		*result = sh->NumberOfRelocations;
-
 
1059
	}
-
 
1060
	return 1;
-
 
1061
}
-
 
1062
 
-
 
1063
int epep_get_section_relocation_by_index_x(Epep *epep, EpepSectionHeader *sh, EpepCoffRelocation *rel, size_t index, int extended) {
-
 
1064
	return epep_get_section_relocation_by_index(epep, sh, rel, index + extended);
-
 
1065
}
1006
 
1066
 
1007
//
1067
//
1008
// COFF Line Numbers
1068
// COFF Line Numbers
Line 1009... Line 1069...
1009
//
1069
//