DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.62k stars 554 forks source link

provide general raw_syscall() interface? #199

Open derekbruening opened 9 years ago

derekbruening commented 9 years ago

From derek.br...@gmail.com on August 13, 2009 13:11:30

Our general philosophy has been to provide platform-independent utilities. But advanced clients sometimes need to make raw system calls. Previously we assumed that if they were advanced enough to know what call to make they could do it themselves: and that's what my clients have done, whether with Nt wrappers calls on Windows or inline asm int80 on Linux.

On reason to provide an API routine is if DR then acts on any memory/control changes that affect its operations. Or, we could provide it for convenience and heavily document it as "at own risk". I suppose I'm not convinced it's a good idea to have in the API

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=199

derekbruening commented 9 years ago

From zhao...@google.com on June 16, 2012 21:29:11

xref DrMemory issue #918.

Labels: -Priority-Low Priority-High

derekbruening commented 9 years ago

From bruen...@google.com on April 18, 2013 15:53:23

Dr. Memory's malloc replacement is hitting this:

tests/patterns hits DR assert: <all_memory_areas is missing region 0x091f3000-0x091f4000!>

heap orig brk=0x091f3000 adding heap region 0x091f3000-0x091f4000 arena

replace_malloc calls SYS_brk, SYS_mmap, and SYS_mremap directly. on windows it calls NtAllocateVirtualMemory directly.

*\ CANCELED add dr_notify_raw_alloc()? => voted down CLOSED: [2013-04-18 Thu 18:52]

*\ TODO we now have dr_raw_mem_alloc(): can I replace my raw mmap with that?

it passes just DR_ALLOC_NON_DR: not DR_ALLOC_LOW_2GB (so no MAP_32BIT) ends up calling this with flags=0: p = mmap_syscall(preferred, size, os_prot, MAP_PRIVATE|MAP_ANONYMOUS|flags, -1, 0); so can replace on linux.

windows: *error_code = nt_allocate_virtual_memory(&p, size, os_prot, MEMORY_COMMIT); => no good b/c I reserve! I free via MEM_RELEASE so don't need MEM_DECOMMIT support.

Could add new flags for dr_custom_alloc: DR_ALLOC_RESERVE_ONLY and DR_ALLOC_COMMIT_ONLY, windows-only.

Could also add DR_ALLOC_BRK, which ends up calling SYS_brk w/ the passed-in addr and ignores the other params. => dr_raw_brk() instead.

*\ DONE drmem also calls SYS_mremap CLOSED: [2013-04-18 Thu 18:53]

add dr_raw_mremap()?

could add dr_raw_mem_realloc() instead of dr_raw_mremap() -- though there is no realloc for Windows: supposed to reserve yourself and then commit in pieces

derekbruening commented 9 years ago

From bruen...@google.com on September 09, 2014 11:30:43

Xref https://code.google.com/p/drmemory/issues/detail?id=1621