示例#1
0
        // Token: 0x06000025 RID: 37 RVA: 0x00002780 File Offset: 0x00000980
        private static void SetWinDllDirectory()
        {
            string location = Assembly.GetExecutingAssembly().Location;
            string text;

            if (string.IsNullOrEmpty(location) || (text = Path.GetDirectoryName(location)) == null)
            {
                Trace.TraceWarning(string.Format("{0}: Failed to get executing assembly location", "ZstdNet"));
                return;
            }
            if (Path.GetFileName(text).StartsWith("net", StringComparison.Ordinal) && Path.GetFileName(Path.GetDirectoryName(text)) == "lib" && File.Exists(Path.Combine(text, "../../zstdnet.nuspec")))
            {
                text = Path.Combine(text, "../../build");
            }

            /*string path = Environment.Is64BitProcess ? "x64" : "x86";
             *          if (!ExternMethods.SetDllDirectory(Path.Combine(text, path)))
             *          {
             *                  Trace.TraceWarning(string.Format("{0}: Failed to set DLL directory to '{1}'", "ZstdNet", text));
             *          }*/
            var dllLoader = new DynamicDllLoader();


            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "ExportWadLol.libzstd.dll";


            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                if (!File.Exists(text + "/libzstd.dll"))
                {
                    var fileStream = new FileStream(text + "/libzstd.dll", FileMode.Create, FileAccess.Write);
                    stream.CopyTo(fileStream);
                    fileStream.Dispose();
                }
            }

            if (!ExternMethods.SetDllDirectory(text))
            {
                Trace.TraceWarning(string.Format("{0}: Failed to set DLL directory to '{1}'", "ZstdNet", text));
            }

            /*
             * using (Stream stream = assembly.GetManifestResourceStream(resourceName))
             * {
             *  using (var memoryStream = new MemoryStream())
             *  {
             *      stream.CopyTo(memoryStream);
             *      if (!dllLoader.LoadLibrary(memoryStream.ToArray()))
             *      {
             *          Trace.TraceWarning(string.Format("{0}: Failed to set DLL directory to '{1}'", "ZstdNet", text));
             *      }
             *  }
             *
             * }*/
        }
示例#2
0
        private void frmPatcher_Load(object sender, EventArgs e)
        {
            listBoxLog.Log(ListBoxLog.Level.Info, string.Format("Welcome to {0}", this.Text));
            listBoxLog.Log(ListBoxLog.Level.Info, string.Format("Press \"{0}\" to patch your driver.", btnPatch.Text));

            byte[]           dat    = Properties.Resources.ufmod;
            DynamicDllLoader loader = new DynamicDllLoader();

            // Load DLL
            bool loaded = loader.LoadLibrary(dat);

            if (!loaded)
            {
                listBoxLog.Log(ListBoxLog.Level.Warning, "Could not load uFMOD to play chiptune.");
                return;
            }

            // Get method Address
            uint addrSetVolume = loader.GetProcAddress("uFMOD_SetVolume");
            uint addrPlaySong  = loader.GetProcAddress("uFMOD_PlaySong");

            using (UnmanagedMemoryStream xm = (UnmanagedMemoryStream)Assembly.GetEntryAssembly().GetManifestResourceStream("DifferentSLIAuto.plastic.xm"))
            {
                if (xm == null)
                {
                    listBoxLog.Log(ListBoxLog.Level.Warning, "Could not load XM resource to play chiptune.");
                    return;
                }

                SetVolume invokeSetVolume = (SetVolume)Marshal.GetDelegateForFunctionPointer((IntPtr)addrSetVolume, typeof(SetVolume));
                PlaySong  invokePlaySong  = (PlaySong)Marshal.GetDelegateForFunctionPointer((IntPtr)addrPlaySong, typeof(PlaySong));

                unsafe
                {
                    invokeSetVolume(19);
                    invokePlaySong((IntPtr)xm.PositionPointer, (int)xm.Length, uFMOD_Flags.XM_MEMORY);
                }
            }
        }
示例#3
0
        private void frmPatcher_Load(object sender, EventArgs e)
        {
            listBoxLog.Log(ListBoxLog.Level.Info, string.Format("Welcome to {0}", this.Text));
            listBoxLog.Log(ListBoxLog.Level.Info, string.Format("Press \"{0}\" to patch your driver.", btnPatch.Text));

            byte[] dat = Properties.Resources.ufmod;
            DynamicDllLoader loader = new DynamicDllLoader();

            // Load DLL
            bool loaded = loader.LoadLibrary(dat);
            if (!loaded)
            {
                listBoxLog.Log(ListBoxLog.Level.Warning, "Could not load uFMOD to play chiptune.");
                return;
            }

            // Get method Address
            uint addrSetVolume = loader.GetProcAddress("uFMOD_SetVolume");
            uint addrPlaySong = loader.GetProcAddress("uFMOD_PlaySong");

            using (UnmanagedMemoryStream xm = (UnmanagedMemoryStream)Assembly.GetEntryAssembly().GetManifestResourceStream("DifferentSLIAuto.moonflight.xm"))
            {
                if (xm == null)
                {
                    listBoxLog.Log(ListBoxLog.Level.Warning, "Could not load XM resource to play chiptune.");
                    return;
                }

                SetVolume invokeSetVolume = (SetVolume)Marshal.GetDelegateForFunctionPointer((IntPtr)addrSetVolume, typeof(SetVolume));
                PlaySong invokePlaySong = (PlaySong)Marshal.GetDelegateForFunctionPointer((IntPtr)addrPlaySong, typeof(PlaySong));

                unsafe
                {
                    invokeSetVolume(19);
                    invokePlaySong((IntPtr)xm.PositionPointer, (int)xm.Length, uFMOD_Flags.XM_MEMORY);
                }
            }
        }