private void InitIMemoryDomains() { var mmd = new List <MemoryDomain>(); for (int i = 0;; i++) { IntPtr name; int size; IntPtr data; if (!BizSwan.bizswan_getmemoryarea(Core, i, out name, out size, out data)) { break; } if (size == 0) { continue; } string sname = Marshal.PtrToStringAnsi(name); mmd.Add(new MemoryDomainIntPtr(sname, MemoryDomain.Endian.Little, data, size, true, 1)); } (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(new MemoryDomainList(mmd)); }
unsafe void SetMemoryDomains() { var mmd = new List <MemoryDomain>(); for (int i = 0; ; i++) { IntPtr name; int size; IntPtr data; if (!BizSwan.bizswan_getmemoryarea(Core, i, out name, out size, out data)) { break; } if (size == 0) { continue; } string sname = Marshal.PtrToStringAnsi(name); byte * p = (byte *)data; mmd.Add(new MemoryDomain( sname, size, MemoryDomain.Endian.Little, delegate(int addr) { if (addr < 0 || addr >= size) { throw new ArgumentOutOfRangeException(); } return(p[addr]); }, delegate(int addr, byte value) { if (addr < 0 || addr >= size) { throw new ArgumentOutOfRangeException(); } p[addr] = value; })); } MemoryDomains = new MemoryDomainList(mmd, 0); }