library/src/ELF/ELF32/BP-ELFExtraction.cc
// Search A Section List by Name
Search A Section List by Name
Search A Section List by Name
P_ELF_SECTION_LIST_32BIT ELF32_GetSectionListElementByName(P_ELF_32BIT_LOOKUP_TABLE fullHeader, char *name){
	if(fullHeader == NULL)
		return NULL;
	if(fullHeader->sections == NULL)
		return NULL;
	if(name == NULL)
		return NULL;
	if(bpstrlen(name) > 50)
		return NULL;
	P_ELF_SECTION_LIST_32BIT firstPtr = fullHeader->sections->first;
	P_ELF_SECTION_LIST_32BIT retPtr = NULL;
	for(fullHeader->sections = fullHeader->sections->first;\
		fullHeader->sections != NULL;\
		fullHeader->sections = fullHeader->sections->next){
		if( bpstrlen(fullHeader->sections->name) == bpstrlen(name) ){
			if(memcmp(fullHeader->sections->name, name, bpstrlen(fullHeader->sections->name))	== 0){
				retPtr = fullHeader->sections;
				fullHeader->sections = firstPtr;
				return retPtr;
			}
		}
	}
	fullHeader->sections = firstPtr;
	return NULL;
}
P_ELF_SECTION_LIST_32BIT ELF32_GetSectionListElementByName ( P_ELF_32BIT_LOOKUP_TABLE fullHeader , char * name ) { if ( fullHeader == NULL ) return NULL ; if ( fullHeader -> sections == NULL ) return NULL ; if ( name == NULL ) return NULL ; if ( bpstrlen ( name ) > 50 ) return NULL ; P_ELF_SECTION_LIST_32BIT firstPtr = fullHeader -> sections -> first ; P_ELF_SECTION_LIST_32BIT retPtr = NULL ; for ( fullHeader -> sections = fullHeader -> sections -> first ; fullHeader -> sections != NULL ; fullHeader -> sections = fullHeader -> sections -> next ) { if ( bpstrlen ( fullHeader -> sections -> name ) == bpstrlen ( name ) ) { if ( memcmp ( fullHeader -> sections -> name , name , bpstrlen ( fullHeader -> sections -> name ) ) == 0 ) { retPtr = fullHeader -> sections ; fullHeader -> sections = firstPtr ; return retPtr ; } } } fullHeader -> sections = firstPtr ; return NULL ; }
Search A Section List by Name
Search A Section List by Name
// Section Name Should Never Be Greater then 50 bytes // first check length // next do string comparison // Return the correct section list