Author Topic: How to read from any memory address?  (Read 2124 times)

nzeemin

  • Guest
How to read from any memory address?
« on: June 09, 2010, 10:00:03 pm »
Hello!
I have a question about Dingoo memory.
Suppose I want to see what I have on some address of Dingoo memory -- can I just read it or I have to use some special technics to access the data?
I tried to just read and my .app hangs.

flatmush

  • *
  • Posts: 283
Re: How to read from any memory address?
« Reply #1 on: June 11, 2010, 04:10:08 pm »
It is possible just to read the entire memory without any issues, here is my code for doing it:
Code: [Select]
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mips/asm.h>
#include <jz4740/jz4740.h>
#include "mipsregs.h"


extern void* isTVON;

void* dl_dereference(void* inPtr) {
uint32_t tempAddr = *((uint32_t*)inPtr);
tempAddr <<= 2;
tempAddr  &= 0x0FFFFFFF;
tempAddr  |= ((uint32_t)inPtr & 0xF0000000);
return (void*)tempAddr;
}

#define A_K0BASE 0x80000000

int main(int argc, char** argv) {
/*FILE* tempFile = fopen("dump.bin", "wb");
if(tempFile == NULL)
return EXIT_FAILURE;
uint32_t stat = read_c0_status();
write_c0_status(0x10000400);
uint8_t* addr = (uint32_t*)A_K0BASE;
for(addr = (uint8_t*)A_K0BASE; (uintptr_t)addr < (A_K0BASE + (8 << 20)); addr += 16384)
fwrite(addr, 1, 16384, tempFile);
write_c0_status(stat);
fclose(tempFile);*/

FILE* tempIFile = fmemopen((void*)A_K0BASE, (32 << 20), "rb");
if(tempIFile == NULL)
return EXIT_FAILURE;
FILE* tempOFile = fopen("dump.bin", "wb");
if(tempOFile == NULL) {
fclose(tempIFile);
return EXIT_FAILURE;
}

uint8_t tempBuff[1 << 14];
uintptr_t i;
for(i = 0; i < (32 << 20); i += (1 << 14)) {
fread(tempBuff, 1, (1 << 14), tempIFile);
fwrite(tempBuff, 1, (1 << 14), tempOFile);
}

fclose(tempOFile);
fclose(tempIFile);

/*tempFile = fopen("dump.s", "wb");
if(tempFile == NULL)
return EXIT_FAILURE;
char* tempStr = asm_disassemble_block((uint32_t*)A_K0BASE, 4096);
if(tempStr != NULL) {
fputs(tempStr, tempFile);
free(tempStr);
}
fclose(tempFile);*/

return EXIT_SUCCESS;
}

nzeemin

  • Guest
Re: How to read from any memory address?
« Reply #2 on: June 12, 2010, 07:02:06 am »
Thanks for the sample! Really works.

 

Post a new topic
Post a new topic