Beispiel #1
0
        protected void PostInit()
        {
            using (_exe.EnterExit())
            {
                var areas = new LibWaterboxCore.MemoryArea[256];
                _core.GetMemoryAreas(areas);
                _memoryAreas = areas.Where(a => a.Data != IntPtr.Zero && a.Size != 0)
                               .ToArray();
                _saveramAreas = _memoryAreas.Where(a => (a.Flags & LibWaterboxCore.MemoryDomainFlags.Saverammable) != 0)
                                .ToArray();
                _saveramSize = (int)_saveramAreas.Sum(a => a.Size);

                var memoryDomains = _memoryAreas.Select(a => new LibWaterboxCore.WaterboxMemoryDomain(a, _exe));
                var primaryIndex  = _memoryAreas
                                    .Select((a, i) => new { a, i })
                                    .Single(a => (a.a.Flags & LibWaterboxCore.MemoryDomainFlags.Primary) != 0).i;
                var mdl = new MemoryDomainList(memoryDomains.Cast <MemoryDomain>().ToList());
                mdl.MainMemory = mdl[primaryIndex];
                _serviceProvider.Register <IMemoryDomains>(mdl);

                var sr = _core as ICustomSaveram;
                if (sr != null)
                {
                    _serviceProvider.Register <ISaveRam>(new CustomSaverammer(sr));                    // override the default implementation
                }
                _exe.Seal();
            }
        }
Beispiel #2
0
 protected T PreInit <T>(PeRunnerOptions options)
     where T : LibWaterboxCore
 {
     options.Path ??= CoreComm.CoreFileProvider.DllPath();
     _exe = new PeRunner(options);
     using (_exe.EnterExit())
     {
         var ret = BizInvoker.GetInvoker <T>(_exe, _exe, CallingConventionAdapters.Waterbox);
         _core = ret;
         return(ret);
     }
 }