@@ -934,6 +934,82 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *bytes,
934934UNICORN_EXPORT
935935uc_err uc_mem_read (uc_engine *uc, uint64_t address, void *bytes, uint64_t size);
936936
937+ /*
938+ Read a range of bytes in memory after mmu translation.
939+
940+ @uc: handle returned by uc_open()
941+ @address: starting virtual memory address of bytes to get.
942+ @prot: The access type for the tlb lookup
943+ @bytes: pointer to a variable containing data copied from memory.
944+ @size: size of memory to read.
945+
946+ NOTE: @bytes must be big enough to contain @size bytes.
947+
948+ This function will translate the address with the MMU. Therefore all
949+ pages needs to be memory mapped with the proper access rights. The MMU
950+ will not translate the virtual address when the pages are not mapped
951+ with the given access rights.
952+
953+ When the pages are mapped with the given access rights the read will
954+ happen indipenden from the access rights of the mapping. So when you
955+ have a page write only mapped, a call with prot == UC_PROT_WRITE will
956+ be able to read the stored data.
957+
958+ @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
959+ for detailed error).
960+ */
961+ UNICORN_EXPORT
962+ uc_err uc_vmem_read (uc_engine *uc, uint64_t address, uint32_t prot,
963+ void *bytes, size_t size);
964+
965+ /*
966+ Write to a range of bytes in memory after mmu translation.
967+
968+ @uc: handle returned by uc_open()
969+ @address: starting memory address of bytes to set.
970+ @prot: The access type for the tlb lookup
971+ @bytes: pointer to a variable containing data to be written to memory.
972+ @size: size of memory to write to.
973+
974+ This function will translate the address with the MMU. Therefore all
975+ pages needs to be memory mapped with the proper access rights. The MMU
976+ will not translate the virtual address when the pages are not mapped
977+ with the given access rights.
978+
979+ When the pages are mapped with the given access rights the write will
980+ happen indipenden from the access rights of the mapping. So when you
981+ have a page read only mapped, a call with prot == UC_PROT_READ will
982+ be able to write the data.
983+
984+ NOTE: @bytes must be big enough to contain @size bytes.
985+
986+ @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
987+ for detailed error).
988+ */
989+ UNICORN_EXPORT
990+ uc_err uc_vmem_write (uc_engine *uc, uint64_t address, uint32_t prot,
991+ void *bytes, size_t size);
992+
993+ /*
994+ Translate a virtuall address to a physical address
995+
996+ @uc:
997+ @address: virtual address to translate
998+ @prot: The access type for the tlb lookup
999+ @paddress: A pointer to store the result
1000+
1001+ This function will translate the address with the MMU. Therefore all
1002+ pages needs to be memory mapped with the proper access rights. The MMU
1003+ will not translate the virtual address when the pages are not mapped
1004+ with the given access rights.
1005+
1006+ @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
1007+ for detailed error).
1008+ */
1009+ UNICORN_EXPORT
1010+ uc_err uc_vmem_translate (uc_engine *uc, uint64_t address, uint32_t prot,
1011+ uint64_t *paddress);
1012+
9371013/*
9381014 Emulate machine code in a specific duration of time.
9391015
0 commit comments