LinuxPageAllocator.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using MonoMod.Utils;
  4. namespace BepInEx.IL2CPP.Allocator
  5. {
  6. internal class LinuxPageAllocator : UnixPageAllocator
  7. {
  8. protected override IMemoryMapper OpenMemoryMap()
  9. {
  10. throw new NotImplementedException();
  11. }
  12. protected class LinuxMemoryMapper : IMemoryMapper
  13. {
  14. public void Dispose()
  15. {
  16. throw new NotImplementedException();
  17. }
  18. public bool FindNextFree(ref IntPtr start, ref ulong size)
  19. {
  20. throw new NotImplementedException();
  21. }
  22. }
  23. static class Unix
  24. {
  25. public delegate IntPtr mmapDelegate(IntPtr addr, UIntPtr length, int prot, int flags, int fd, int offset);
  26. [DynDllImport("mmap")]
  27. public static mmapDelegate mmap;
  28. public delegate int munmapDelegate(IntPtr addr, UIntPtr length);
  29. [DynDllImport("munmap")]
  30. public static munmapDelegate munmap;
  31. public delegate IntPtr fdopenDelegate(int fd, string mode);
  32. [DynDllImport("libc")]
  33. public static fdopenDelegate fdopen;
  34. static Unix()
  35. {
  36. typeof(Unix).ResolveDynDllImports(new Dictionary<string, List<DynDllMapping>>
  37. {
  38. ["libc"] = new List<DynDllMapping>
  39. {
  40. "libc.so.6", // Ubuntu glibc
  41. "libc", // Linux glibc
  42. }
  43. });
  44. }
  45. }
  46. }
  47. }