return EXIT_SUCCESS;
}
-int readmem(char* address, int access_type, unsigned long read_result)
+int readmem(char* address, int access_type, unsigned long *result)
{
int fd;
void *map_base, *virt_addr;
off_t target;
+ unsigned long read_result = 0;
target = strtoul(address, 0, 0);
+ if(result == NULL)
+ {
+ //Print error on failure
+ ERROR("Result Parameter is a nullpointer!");
+ return EXIT_FAILURE;
+ }
+
// Try to open /dev/mem
if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)
return EXIT_FAILURE;
}
+ *result = read_result;
+
close(fd);
return EXIT_SUCCESS;
}
readmem("0x01E00130", 'w', readfrommemory);
- printf("Value: 0x%X", readfrommemory);
+ printf("Value: 0x%X", (unsigned int)readfrommemory);
return 0;
}