1 #include <OS.h> 2 #include <stdio.h> 3 4 int main() 5 { 6 int * ptr = new int[1]; 7 char *adr; 8 area_id id; 9 int offset; 10 11 12 area_info info; 13 id = area_for(ptr); 14 get_area_info(id, &info); 15 adr = (char *)info.address; 16 offset = (uint32)ptr - (uint32)adr; 17 18 19 char * adrclone1; 20 char * adrclone2; 21 int * ptrclone1; 22 int * ptrclone2; 23 area_id idclone1; 24 area_id idclone2; 25 26 idclone1 = clone_area("clone 1", (void **)&adrclone1, B_ANY_ADDRESS,B_READ_AREA | B_WRITE_AREA,id); 27 idclone2 = clone_area("clone 2", (void **)&adrclone2, B_ANY_ADDRESS,B_READ_AREA | B_WRITE_AREA,id); 28 29 ptrclone1 = (int *)(adrclone1 + offset); 30 ptrclone2 = (int *)(adrclone2 + offset); 31 32 printf("offset = 0x%08x\n",(int)offset); 33 printf("id = 0x%08x\n",(int)id); 34 printf("id clone 1 = 0x%08x\n",(int)idclone1); 35 printf("id clone 2 = 0x%08x\n",(int)idclone2); 36 printf("adr = 0x%08x\n",(int)adr); 37 printf("adr clone 1 = 0x%08x\n",(int)adrclone1); 38 printf("adr clone 2 = 0x%08x\n",(int)adrclone2); 39 printf("ptr = 0x%08x\n",(int)ptr); 40 printf("ptr clone 1 = 0x%08x\n",(int)ptrclone1); 41 printf("ptr clone 2 = 0x%08x\n",(int)ptrclone2); 42 43 ptr[0] = 0x12345678; 44 45 printf("ptr[0] = 0x%08x\n",(int)ptr[0]); 46 printf("ptr clone 1[0] = 0x%08x\n",(int)ptrclone1[0]); 47 printf("ptr clone 2[0] = 0x%08x\n",(int)ptrclone2[0]); 48 49 } 50