library/src/ELF/ELF32/BP-ELFExtraction.cc
// extracts relevant data from the elf header
extracts relevant data from the elf header
extracts relevant data from the elf header
P_ELF_32BIT_LOOKUP_TABLE ELF32_ExtractAll_File(char * executablePath){
	FILE * elfFile = FOpen(executablePath, "r");
	if(elfFile == NULL)
		return NULL;
	P_ELF_32BIT_LOOKUP_TABLE fullHeader = (P_ELF_32BIT_LOOKUP_TABLE) bpmalloc(sizeof(ELF_32BIT_LOOKUP_TABLE));
		memset(fullHeader, 0x00, sizeof(ELF_32BIT_LOOKUP_TABLE));
	fullHeader->filePath = bpstrndup(executablePath, MAX_CMD_LENGTH);
	fullHeader->header = ELF32_ExtractHeader_File(elfFile);
	if(fullHeader->header == NULL)
		return NULL;
	fullHeader->pHeaders = ELF32_ExtractProgramHeaders_File(fullHeader, elfFile);
	fullHeader->sections = ELF32_ExtractSectionHeaders_File(fullHeader, elfFile);
	if(fullHeader->sections == NULL)
		return NULL;
	ELF32_ExtractSections_File(fullHeader, elfFile);
	fullHeader->symTab = ELF32_TranslateSymbolTableFromData(fullHeader);
	fullHeader->relocs = ELF32_TranslateRelocationsFromData(fullHeader);
	fullHeader->dynamics = ELF32_TranslateDynamicsFromData(fullHeader);
	fullHeader->got = ELF32_TranslateGOTFromData(fullHeader);
	return fullHeader;
}
P_ELF_32BIT_LOOKUP_TABLE ELF32_ExtractAll_File ( char * executablePath ) { FILE * elfFile = FOpen ( executablePath , " " ) ; if ( elfFile == NULL ) return NULL ; P_ELF_32BIT_LOOKUP_TABLE fullHeader = ( P_ELF_32BIT_LOOKUP_TABLE ) bpmalloc ( sizeof ( ELF_32BIT_LOOKUP_TABLE ) ) ; memset ( fullHeader , 0x00 , sizeof ( ELF_32BIT_LOOKUP_TABLE ) ) ; fullHeader -> filePath = bpstrndup ( executablePath , MAX_CMD_LENGTH ) ; fullHeader -> header = ELF32_ExtractHeader_File ( elfFile ) ; if ( fullHeader -> header == NULL ) return NULL ; fullHeader -> pHeaders = ELF32_ExtractProgramHeaders_File ( fullHeader , elfFile ) ; fullHeader -> sections = ELF32_ExtractSectionHeaders_File ( fullHeader , elfFile ) ; if ( fullHeader -> sections == NULL ) return NULL ; ELF32_ExtractSections_File ( fullHeader , elfFile ) ; fullHeader -> symTab = ELF32_TranslateSymbolTableFromData ( fullHeader ) ; fullHeader -> relocs = ELF32_TranslateRelocationsFromData ( fullHeader ) ; fullHeader -> dynamics = ELF32_TranslateDynamicsFromData ( fullHeader ) ; fullHeader -> got = ELF32_TranslateGOTFromData ( fullHeader ) ; return fullHeader ; }
extracts relevant data from the elf header
extracts relevant data from the elf header
// first open our target file for reading // create space for our data // Copy the path into the struct // ------- BEGIN HEADER EXTRACTION -------------------------------- // Extract ELF32 Header // Extract Program Headers // Extract all the section headers from the file // Now extract all sections from the file // Extract Symbol Table from the header // Extract all relocations // Extract Dynamics // Extract GOT