4 ms·
Page 15 of https://www.net.in.tum.de/fileadmin/bibtex/publications/papers/ixy-writing-user-space-network-drivers.pdf https://www.net.in.tum.de/fileadmin/bibtex/
by voltagex_ 7y ago
Page 15 of https://www.net.in.tum.de/fileadmin/bibtex/publications/papers/ixy-writing-user-space-network-drivers.pdf https://www.net.in.tum.de/fileadmin/bibtex/publications/pape.... They couldn't access mlock in .NET. The amount of C involved is tiny.
- pjmlp 7y agoThe 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.
- voltagex_ 7y agoSorry, wrong link: https://www.net.in.tum.de/fileadmin/bibtex/publications/theses/2018-ixy-c-sharp.pdf 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."
- optimiz3 7y agoOdd 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.
- pjmlp 7y agoSo something like [DllImport(..., EntryPoint = "mlock")] extern int MLock(UIntPtr addr, uint len); And then getting the pointer either from MemoryMappedViewAccessor or AllocHGlobal?
- Const-me 7y ago> 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/49f3da0ae744194fbf5be53552735431 https://gist.github.com/Const-me/49f3da0ae744194fbf5be535527...