private bool disposedValue = false; // To detect redundant calls

        private void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (TerminateOnDispose)
                {
                    try
                    {
                        Terminate(NtStatus.STATUS_WAIT_1);
                    }
                    catch (NtException)
                    {
                    }
                }

                Process.Close();
                Thread.Close();
                ImageFile.Close();
                SectionHandle.Close();
                if (IFEOKeyHandle != null)
                {
                    IFEOKeyHandle.Close();
                }
                disposedValue = true;
            }
        }
Esempio n. 2
0
        internal static void Extract(string gameDirectory)
        {
            FileStream ImageFile;

            try
            {
                ImageFile = File.OpenRead(gameDirectory + "/scenes/scenes.image");
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine("Didn't find scenes.image");
                Console.WriteLine(e.Message);
                return;
            }
            catch (UnauthorizedAccessException f)
            {
                Console.WriteLine("Cannot read scenes.image file.");
                Console.WriteLine(f.Message);
                return;
            }
            MemoryStream image = new MemoryStream();

            ImageFile.CopyTo(image);
            ImageFile.Close();
            image.Position = 0;
            VSIF_Header Header = PopulateHeader(image);

            if (Header.ID != Common.FourCC("VSIF", false))
            {
                Console.WriteLine("Scenes.image has incorrect Magic");
                return;
            }
            if (Header.Version != 2)
            {
                Console.WriteLine("Scenes.image has incorrect version");
                return;
            }
            if (Header.ScenesCount == 0)
            {
                Console.WriteLine("Scenes.image is empty");
                return;
            }
            Console.WriteLine("Extracting scenes.image ({0} scenes)\n", Header.ScenesCount);

            /* Extraction */
            for (int i = 0; i < Header.ScenesCount; i++)
            {
                ExtractScene(ref image, i, Header); //there's only one VSIF Header
            }
            //VSIF_ExtractScene(Image, i, Maps, MapsCount, GameDirectory);

            //free(Image);
            //printf("Finished extracting scenes from game %s\n", GameDirectory);
            //return 0;
            image.Close();
            Console.WriteLine("Finished extracting scenes from {0}", gameDirectory);
        }
Esempio n. 3
0
        /// <summary>
        /// Dispose
        /// </summary>
        public void Dispose()
        {
            if (TerminateOnDispose)
            {
                Process?.Terminate(NtStatus.STATUS_SUCCESS, false);
            }

            Process?.Close();
            Thread?.Close();
            ImageFile?.Close();
            SectionHandle?.Close();
            IFEOKeyHandle?.Close();
        }