library/src/ELF/ELF32/BP-ELFExtraction_mem.cc
// This function is responsible for the extraction of all elf
// sections in memory, given a valid debug handle, and memory map.
// Will return a linked list with each element containing a
// elf lookup table which can be used to make determinations about
// process health.
This function is responsible for the extraction of all elf
sections in memory, given a valid debug handle, and memory map.
Will return a linked list with each element containing a
elf lookup table which can be used to make determinations about
process health.
This function is responsible for the extraction of all elf sections in memory given a valid debug handle and memory map . Will return a linked list with each element containing a elf lookup table which can be used to make determinations about process health .
P_ELF_32BIT_LOOKUP_TABLE_LIST ELF32_ExtractHeaderListAll_Mem(P_DEBUG_HANDLE dbgHandle){
	if(dbgHandle == NULL)
		return NULL;
	if(dbgHandle->memory == NULL)
		return NULL;
	P_MEMORY_MAP memMap = NULL;
	P_MEMORY_MAP memMapFirst = dbgHandle->memory->first;
	P_ELF_32BIT_LOOKUP_TABLE_LIST elfLookupList = (P_ELF_32BIT_LOOKUP_TABLE_LIST ) bpmalloc(sizeof(ELF_32BIT_LOOKUP_TABLE_LIST));
	memset(elfLookupList, 0x00, sizeof(ELF_32BIT_LOOKUP_TABLE_LIST));
	elfLookupList->first = elfLookupList;
	elfLookupList->prev = NULL;
	elfLookupList->next = NULL;
	int fullELFCount = 0;
	int counter = 0;
	for(memMap = dbgHandle->memory->first; memMap != NULL; memMap = memMap->next){
		if(memMap->elf > 0){
			fullELFCount++;
		}
	}
	for(memMap = dbgHandle->memory->first; memMap != NULL; memMap = memMap->next){
		 if(memMap->elf > 0){
        	elfLookupList->header = ELF32_ExtractAll_Mem(dbgHandle, memMap);
        	elfLookupList->header->memMap = memMap;
        	elfLookupList->header->memMap->elfHeader = (void *) elfLookupList;
        	 if(elfLookupList->header != NULL){
        	 }
        	 counter++;
        	 if(counter == fullELFCount){
        		 elfLookupList->next = NULL;
        		 break;
        	 }
        	 elfLookupList->next = (P_ELF_32BIT_LOOKUP_TABLE_LIST ) bpmalloc(sizeof(ELF_32BIT_LOOKUP_TABLE_LIST));
        	 	memset(elfLookupList->next, 0x00, sizeof(ELF_32BIT_LOOKUP_TABLE_LIST));
        	 	elfLookupList->next->first = elfLookupList->first;
        	 	elfLookupList->next->prev = elfLookupList;
        	 	elfLookupList = elfLookupList->next;
        	 	elfLookupList->next = NULL;
		 }
	}
	if(	elfLookupList != NULL )
		return elfLookupList->first;
	return NULL;
}
P_ELF_32BIT_LOOKUP_TABLE_LIST ELF32_ExtractHeaderListAll_Mem ( P_DEBUG_HANDLE dbgHandle ) { if ( dbgHandle == NULL ) return NULL ; if ( dbgHandle -> memory == NULL ) return NULL ; P_MEMORY_MAP memMap = NULL ; P_MEMORY_MAP memMapFirst = dbgHandle -> memory -> first ; P_ELF_32BIT_LOOKUP_TABLE_LIST elfLookupList = ( P_ELF_32BIT_LOOKUP_TABLE_LIST ) bpmalloc ( sizeof ( ELF_32BIT_LOOKUP_TABLE_LIST ) ) ; memset ( elfLookupList , 0x00 , sizeof ( ELF_32BIT_LOOKUP_TABLE_LIST ) ) ; elfLookupList -> first = elfLookupList ; elfLookupList -> prev = NULL ; elfLookupList -> next = NULL ; int fullELFCount = 0 ; int counter = 0 ; for ( memMap = dbgHandle -> memory -> first ; memMap != NULL ; memMap = memMap -> next ) { if ( memMap -> elf > 0 ) { fullELFCount ++ ; } } for ( memMap = dbgHandle -> memory -> first ; memMap != NULL ; memMap = memMap -> next ) { if ( memMap -> elf > 0 ) { elfLookupList -> header = ELF32_ExtractAll_Mem ( dbgHandle , memMap ) ; elfLookupList -> header -> memMap = memMap ; elfLookupList -> header -> memMap -> elfHeader = ( void * ) elfLookupList ; if ( elfLookupList -> header != NULL ) { } counter ++ ; if ( counter == fullELFCount ) { elfLookupList -> next = NULL ; break ; } elfLookupList -> next = ( P_ELF_32BIT_LOOKUP_TABLE_LIST ) bpmalloc ( sizeof ( ELF_32BIT_LOOKUP_TABLE_LIST ) ) ; memset ( elfLookupList -> next , 0x00 , sizeof ( ELF_32BIT_LOOKUP_TABLE_LIST ) ) ; elfLookupList -> next -> first = elfLookupList -> first ; elfLookupList -> next -> prev = elfLookupList ; elfLookupList = elfLookupList -> next ; elfLookupList -> next = NULL ; } } if ( elfLookupList != NULL ) return elfLookupList -> first ; return NULL ; }
This function is responsible for the extraction of all elf
sections in memory, given a valid debug handle, and memory map.
This function is responsible for the extraction of all elf sections in memory given a valid debug handle and memory map .
// Used to make runtime calculations for list operations //  ELF32_PrintAll(elfLookupList->elf); // Terminate list and exit if the last // elf section was retrived // Link up a new list and continue at top