/** Get the filename from which the given process was loaded from. * * \param process Pointer to the process structure. * \return NULL if program not loaded by minilink, or a string containing * the file name. */ const char * minilink_get_filename(struct process *process) { Minilink_ProgramInfoHeader *instprog = instprog_next(NULL); DPUTS("Searching program in Ram..."); for (;;) { if (instprog == NULL) break; if ( (uintptr_t) (void*) process >= (uintptr_t) instprog->mem[MINILINK_DATA].ptr && (uintptr_t) (void*) process < (uintptr_t) instprog->mem[MINILINK_DATA].ptr + instprog->mem[MINILINK_DATA].size) { DPRINTF("Found %s\n", instprog->sourcefile); return instprog->sourcefile; } instprog = instprog_next(instprog); } DPUTS("Not found."); return NULL; }
/** Check if given program was already linked into rom area. * * \param proginfo Information structure of the program to find. * \return NULL if program not found, or a pointer to the metadata * in case a matching header was found. * \todo Check whether the file is installed */ static Minilink_ProgramInfoHeader* program_already_loaded(Minilink_ProgramInfoHeader *proginfo) { Minilink_ProgramInfoHeader *instprog = instprog_next(NULL); DPUTS("Searching program..."); for (;;) { if (instprog == NULL) break; if (proginfo->crc == instprog->crc && proginfo->mem[MINILINK_TEXT].size == instprog->mem[MINILINK_TEXT].size && !strncmp(proginfo->sourcefile, instprog->sourcefile, MINILINK_MAX_FILENAME)) { DPUTS("Found!"); return instprog; } instprog = instprog_next(instprog); } DPUTS("Not found."); return NULL; }
/** * Get the Info-header of a process * @param proc The process to get the header of. * @return a pointer to the program info header */ Minilink_ProgramInfoHeader * minilink_programm_ih(struct process *proc){ Minilink_ProgramInfoHeader * pih = NULL; struct process **proclist; //puts("pih:"); while((pih = instprog_next(pih)) != NULL){ proclist = pih->process; //int c; //for(c=0; c < 5 ; c++) printf("MEM: %x, %i\n", c, pih->mem[c].size); //printf("FL: %s\n", pih->sourcefile); //while(proclist != NULL){ DPRINTF("L:%x F:%x\n", (uint16_t)proc, (uint16_t)(*proclist)); if((uint16_t)(*proclist) == (uint16_t)(proc)) return pih; //proclist++; //} } return NULL; }