Esempio n. 1
0
int find_name(pid_t pid, const char *name, const char *libn,
              unsigned long *addr) {
    struct mm mm[1000] = { 0 };
    unsigned long libcaddr;
    int nmm;
    char libc[1024] = { 0 };
    symtab_t s;

    if (0 > load_memmap(pid, mm, &nmm)) {
        ALOGD("cannot read memory map\n");
        return -1;
    }
    if (0
        > find_libname((char *) libn, (char *) libc, sizeof(libc),
                       &libcaddr, mm, nmm)) {
        ALOGD("cannot find lib: %s\n", libn);
        return -1;
    }
    //ALOGD("lib: >%s<\n", libc)
    s = load_symtab(libc);
    if (!s) {
        ALOGD("cannot read symbol table\n");
        return -1;
    }
    if (0 > lookup_func_sym(s, (char *) name, addr)) {
        ALOGD("cannot find function: %s\n", name);
        return -1;
    }
    *addr += libcaddr;
    return 0;
}
Esempio n. 2
0
static int find_linker(pid_t pid, unsigned long *addr)
{
	struct mm mm[1000];
	unsigned long libcaddr;
	int nmm;
	char libc[256];
	symtab_t s;

	if (0 > load_memmap(pid, mm, &nmm)) {
#ifdef DEBUG 
		printf("cannot read memory map\n");
#endif
		return -1;
	}
	if (0 > find_linker_mem(libc, sizeof(libc), &libcaddr, mm, nmm)) {
#ifdef DEBUG 
		printf("cannot find libc\n");
#endif
		return -1;
	}
	
	*addr = libcaddr;
	
	return 1;
}
Esempio n. 3
0
static int
find_name(pid_t pid, char *name, unsigned long *addr)
{
	struct mm mm[1000];
	unsigned long libcaddr;
	int nmm;
	char libc[256];
	symtab_t s;

	if (0 > load_memmap(pid, mm, &nmm)) {
		printf("cannot read memory map\n");
		return -1;
	}
	if (0 > find_libc(libc, sizeof(libc), &libcaddr, mm, nmm)) {
		printf("cannot find libc\n");
		return -1;
	}
	s = load_symtab(libc);
	if (!s) {
		printf("cannot read symbol table\n");
		return -1;
	}
	if (0 > lookup_func_sym(s, name, addr)) {
		printf("cannot find %s\n", name);
		return -1;
	}
	*addr += libcaddr;
	return 0;
}
Esempio n. 4
0
int find_name(pid_t pid, char *name, char *libn, unsigned long *addr)
{
	struct mm mm[250];
	unsigned long libcaddr;
	int nmm;
	char libc[256];
	symtab_t s;
	int load_memmap_return;


	load_memmap_return =  load_memmap(pid, mm, &nmm);

	if (0 > load_memmap_return) {
		//printf("cannot read memory map\n");
		return load_memmap_return;
	}
	if (0 > find_libname(libn, libc, sizeof(libc), &libcaddr, mm, nmm)) {
		log("cannot find libc\n");
		return -2;
	}
	s = load_symtab(libc);
	if (!s) {
		//printf("cannot read symbol table\n");
		return -3;
	}
	if (0 > lookup_func_sym(s, name, addr)) {
		//printf("cannot find %s\n", name);
		return -4;
	}
	*addr += libcaddr;
	return 0;
}
Esempio n. 5
0
int find_name(pid_t pid, char *name, char *libn, unsigned long *addr)
{
	struct mm mm[250];
	unsigned long libcaddr;
	int nmm;
	char libc[512];
	symtab_t s;
	int load_memmap_return;
	int tmp;


	load_memmap_return =  load_memmap(pid, mm, &nmm);

	if (0 > load_memmap_return) {
		//printf("cannot read memory map\n");
		return load_memmap_return;
	}
	if (0 > find_libname(libn, libc, sizeof(libc), &libcaddr, mm, nmm)) {
/* #ifdef DEBUG_UTIL  */
/* 	  log("cannot find %s\n", libn); */
/* #endif */
	  return -2;
	}
	s = load_symtab(libc);
	if (!s) {
		//printf("cannot read symbol table\n");
		return -3;
	}

/* #ifdef DEBUG_UTIL  */
/* 	log("pid %d, name %s, libn %s\n", pid, name, libn); */
/* #endif */

	if (0 > lookup_func_sym(s, name, addr)) {

/* #ifdef DEBUG_UTIL  */
/* 	  log("fail\n"); */
/* 	  log("find_name: cannot find %s\n", name); */
/* #endif */
	  return -4;

	}


/* #ifdef DEBUG_UTIL */
/* 	log("not fail %p %d\n", addr, *addr); */
/* #endif */
	
	//tmp = 4;

	*addr += libcaddr;

	return 0;
}
Esempio n. 6
0
int find_libbase(pid_t pid, const char *libn, unsigned long *addr) {
    struct mm mm[1000] = { 0 };
    unsigned long libcaddr;
    int nmm;
    char libc[1024] = { 0 };
    symtab_t s;

    if (0 > load_memmap(pid, mm, &nmm)) {
        ALOGD("cannot read memory map\n");
        return -1;
    }
    if (0 > find_libname(libn, libc, sizeof(libc), &libcaddr, mm, nmm)) {
        ALOGD("cannot find lib\n");
        return -1;
    }
    *addr = libcaddr;
    return 0;
}
Esempio n. 7
0
int main()
{
 // system("echo out > /sys/class/gpio/gpio128/direction");
 system("echo in > /sys/class/gpio/gpio129/direction");

 printf("after init\n");

uint8_t* mmap_reg = load_memmap();
 int pin= 129; //128; 
printf("after mmap\n");
 uint32_t mask=(uint32_t)(1 << (pin % 32));
 uint8_t valoffsetOn = 0x34;
 uint8_t valoffsetOff = 0x4c;
 
 uint8_t* loc=(pin / 32) * sizeof(uint32_t)+ mmap_reg;

 for (;;) {
    //printf("inside for\n");
  *(volatile uint32_t*) (loc + valoffsetOn) = mask;
  *(volatile uint32_t*) (loc + valoffsetOff) = mask;
 }
 return MRAA_SUCCESS;
}