library/src/ELF/ELF32/BP-ELFExtraction_mem.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_Mem(P_DEBUG_HANDLE dbgHandle, P_MEMORY_MAP memMap){
	if(dbgHandle == NULL)
		return NULL;
	if(memMap == NULL)
		return NULL;
	if(memMap != NULL){
	}
	if(dbgHandle->attached != 1)
		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));
	if(memMap->path != NULL){
		fullHeader->filePath = bpstrndup(memMap->path, MAX_CMD_LENGTH);
	} else {
		fullHeader->filePath = (char *) NULL;
	}
	fullHeader->header = ELF32_ExtractHeader_Mem(dbgHandle, memMap);
	if(fullHeader->header == NULL)
	 	return NULL;
	fullHeader->pHeaders = ELF32_ExtractProgramHeaders_Mem(fullHeader, dbgHandle, memMap);
	fullHeader->sections = ELF32_ExtractSectionHeaders_Mem(fullHeader, dbgHandle, memMap);
	ELF32_ExtractSections_Mem(fullHeader, dbgHandle, memMap);
	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_Mem ( P_DEBUG_HANDLE dbgHandle , P_MEMORY_MAP memMap ) { if ( dbgHandle == NULL ) return NULL ; if ( memMap == NULL ) return NULL ; if ( memMap != NULL ) { } if ( dbgHandle -> attached != 1 ) 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 ) ) ; if ( memMap -> path != NULL ) { fullHeader -> filePath = bpstrndup ( memMap -> path , MAX_CMD_LENGTH ) ; } else { fullHeader -> filePath = ( char * ) NULL ; } fullHeader -> header = ELF32_ExtractHeader_Mem ( dbgHandle , memMap ) ; if ( fullHeader -> header == NULL ) return NULL ; fullHeader -> pHeaders = ELF32_ExtractProgramHeaders_Mem ( fullHeader , dbgHandle , memMap ) ; fullHeader -> sections = ELF32_ExtractSectionHeaders_Mem ( fullHeader , dbgHandle , memMap ) ; ELF32_ExtractSections_Mem ( fullHeader , dbgHandle , memMap ) ; 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
// Default NULL checks // Destroy the elf header before continuing // ELF32_DestroyAll. // Make sure the debugger appears to be attached // before attempting to read in header. // create space for our data // Copy the path of the memory map 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 // printf("\n header?: %p", fullHeader->symTab); // Extract all relocations // Extract Dynamics // Extract GOT