Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The document has 14 pages and the only information I see is the mlock description, nothing about how they were unable to use System.Runtime.InteropServices, unsafe and DllImport to make use of it.


Sorry, wrong link: https://www.net.in.tum.de/fileadmin/bibtex/publications/thes...

>"As C# cannot call mlock or get a raw pointer from a memory mapped file, DMA memory allocation is performed in C and called with the C# P/Invoke mechanism. Fortunately, this is the only instance of the driver calling a C function and the total amount of C code is only around 30 lines."


Odd that they couldn't call mlock using PInvoke; it sounds like the PInvoke export metadata wasn't there rather than C actually being required.

On Windows even for really obscure FNs you can almost always PInvoke if you know the offsets, and if you really want to be evil you can traverse the PEB. There isn't much in low level terms that is beyond the reach of C# since you can manipulate memory directly. I've also accessed hidden COM interfaces by traversing V-Tables using similar direct memory techniques as you would in C.


> C# cannot call mlock or get a raw pointer from a memory mapped file

Why not? What am I missing? https://gist.github.com/Const-me/49f3da0ae744194fbf5be535527...


So something like

    [DllImport(..., EntryPoint = "mlock")]
    extern int MLock(UIntPtr addr, uint len);
And then getting the pointer either from MemoryMappedViewAccessor or AllocHGlobal?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: