library/src/memory/BP-LinuxMemMapping.cc
// Returns the memory map corresponding to a valid process pointer
Returns the memory map corresponding to a valid process pointer
Returns the memory map corresponding to a valid process pointer
P_MEMORY_MAP GetMemoryMapFromPointer(P_DEBUG_HANDLE dbgHandle, void *procAddr)
{
	if(dbgHandle == NULL)
		return NULL;
	if(dbgHandle->memory == NULL)
		return NULL;
	P_MEMORY_MAP first = dbgHandle->memory->first;
	P_MEMORY_MAP retPtr = NULL;
	if( IsPointerValidForProcess(dbgHandle, procAddr) != ERR_SUCCESS)
		return NULL;
	for(dbgHandle->memory = dbgHandle->memory->first;
		dbgHandle->memory != NULL;
		dbgHandle->memory = dbgHandle->memory->next){
		if(procAddr <= dbgHandle->memory->highAddr)
		if(procAddr >= dbgHandle->memory->lowAddr){
			retPtr = dbgHandle->memory;
			dbgHandle->memory = first;
			return retPtr;
		}
	}
	dbgHandle->memory = first;
	return NULL;
}
P_MEMORY_MAP GetMemoryMapFromPointer ( P_DEBUG_HANDLE dbgHandle , void * procAddr ) { if ( dbgHandle == NULL ) return NULL ; if ( dbgHandle -> memory == NULL ) return NULL ; P_MEMORY_MAP first = dbgHandle -> memory -> first ; P_MEMORY_MAP retPtr = NULL ; if ( IsPointerValidForProcess ( dbgHandle , procAddr ) != ERR_SUCCESS ) return NULL ; for ( dbgHandle -> memory = dbgHandle -> memory -> first ; dbgHandle -> memory != NULL ; dbgHandle -> memory = dbgHandle -> memory -> next ) { if ( procAddr <= dbgHandle -> memory -> highAddr ) if ( procAddr >= dbgHandle -> memory -> lowAddr ) { retPtr = dbgHandle -> memory ; dbgHandle -> memory = first ; return retPtr ; } } dbgHandle -> memory = first ; return NULL ; }
Returns the memory map corresponding to a valid process pointer
Returns the memory map corresponding to a valid process pointer
// store the first pointer // loop through all memory  // reset memory pointer