public CabFile(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            using (MemoryStream data = new MemoryStream())
            {
                stream.CopyTo(data);
                _data = data.ToArray();
            }
            _erf     = new ERF();
            _alloc   = new FNALLOC(FnAlloc);
            _free    = new FNFREE(FnFree);
            _close   = new FNCLOSE(FnClose);
            _open    = new FNOPEN(FnOpen);
            _read    = new FNREAD(FnRead);
            _write   = new FNWRITE(FnWrite);
            _seek    = new FNSEEK(FnSeek);
            _extract = new FNFDINOTIFY(FnNotifyExtract);

            _erfHandle = GCHandle.Alloc(_erf, GCHandleType.Pinned);
            _hfdi      = FDICreate(
                Marshal.GetFunctionPointerForDelegate(_alloc),
                Marshal.GetFunctionPointerForDelegate(_free),
                Marshal.GetFunctionPointerForDelegate(_open),
                Marshal.GetFunctionPointerForDelegate(_read),
                Marshal.GetFunctionPointerForDelegate(_write),
                Marshal.GetFunctionPointerForDelegate(_close),
                Marshal.GetFunctionPointerForDelegate(_seek)
                , -1, _erfHandle.AddrOfPinnedObject());
        }
Example #2
0
 public static extern IntPtr FDICreate(
     FNALLOC pfnalloc,
     FNFREE pfnfree,
     FNOPEN pfnopen,
     FNREAD pfnread,
     FNWRITE pfnwrite,
     FNCLOSE pfnclose,
     FNSEEK pfnseek,
     int cpuType,
     ref ExtractResult perf);
Example #3
0
 public static unsafe extern FdiHandle FDICreate(
     FNALLOC pfnalloc,
     FNFREE pfnfree,
     FNOPEN pfnopen,
     FNREAD pfnread,
     FNWRITE pfnwrite,
     FNCLOSE pfnclose,
     FNSEEK pfnseek,
     CpuType cpuType,
     [Friendly(FriendlyFlags.Out)] ERF *perf);