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); } } }
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); } } }