From 94fc13d20d483846d091b618bd267cf2f411cdda Mon Sep 17 00:00:00 2001 From: Tarvis451 Date: Tue, 27 Oct 2015 04:38:30 -0400 Subject: [PATCH] Don't call Load/FreeLibrary from DllMain Other thread related stuff has been altered as well. The music player thread now persists after playback is stopped. It is suspended until the next MCI_PLAY command, instead of a new thread being made for each MCI_PLAY command. This fixes a deadlock case when playback was stopped and played several times in very short succession. --- Makefile | 4 +- player.h | 5 +- stubs.c | 1003 ++++++++++++++++++++++++++------------------------- wav-winmm.c | 148 ++++---- 4 files changed, 605 insertions(+), 555 deletions(-) diff --git a/Makefile b/Makefile index 18ebe05..3dcca81 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ wav-winmm.rc.o: wav-winmm.rc.in sed 's/__REV__/$(REV)/g' wav-winmm.rc.in | sed 's/__FILE__/wav-winmm/g' | mingw32-windres -O coff -o wav-winmm.rc.o wav-winmm.dll: wav-winmm.c wav-winmm.rc.o wav-winmm.def player.c stubs.c - mingw32-gcc -std=gnu99 -Wl,--enable-stdcall-fixup -Ilibs/include -O2 -shared -s -o winmm.dll wav-winmm.c player.c stubs.c wav-winmm.def wav-winmm.rc.o -L. -lvorbisfile-3 -lwinmm -static-libgcc + mingw32-gcc -std=gnu99 -Wl,--enable-stdcall-fixup -Ilibs/include -O2 -shared -s -o wav-winmm.dll wav-winmm.c player.c stubs.c wav-winmm.def wav-winmm.rc.o -L. -lvorbisfile-3 -lwinmm -static-libgcc clean: - rm -f winmm.dll wav-winmm.rc.o + rm -f wav-winmm.dll wav-winmm.rc.o diff --git a/player.h b/player.h index c469a10..b0eb961 100644 --- a/player.h +++ b/player.h @@ -1,7 +1,10 @@ +#ifndef PLAYER_H +#define PLAYER_H + void plr_stop(); void plr_volume(int vol); int plr_pump(); int plr_length(const char *path); int plr_play(const char *path); -void setWinmmDll(HINSTANCE inPtr); +#endif diff --git a/stubs.c b/stubs.c index d135d34..d6dc412 100644 --- a/stubs.c +++ b/stubs.c @@ -1,1301 +1,1330 @@ #include +#include "player.h" -HINSTANCE realWinmmDll; +static HINSTANCE realWinmmDLL = 0; -void setWinmmDll(HINSTANCE inPtr) +HINSTANCE getWinmmHandle() { - realWinmmDll = inPtr; + return realWinmmDLL; +} + +//watches for the app to close, unloads the library when it does +//since FreeLibrary is dangerous in DllMain +void ExitMonitor(LPVOID DLLHandle) +{ + WaitForSingleObject(DLLHandle, INFINITE); + FreeLibrary(getWinmmHandle()); +} + +//if winmm.dll is already loaded, return its handle +//otherwise, load it +HINSTANCE loadRealDLL() +{ + if (realWinmmDLL) + return realWinmmDLL; + + char winmm_path[MAX_PATH]; + + GetSystemDirectory(winmm_path, MAX_PATH); + strncat(winmm_path, "//winmm.DLL", MAX_PATH); + + realWinmmDLL = LoadLibrary(winmm_path); + + //start watcher thread to close the library + CreateThread(NULL, 500, (LPTHREAD_START_ROUTINE)ExitMonitor, GetCurrentThread(), 0, NULL); + + return realWinmmDLL; } // -//Stubs for functions to call from the real winmm.dll +//stubs for functions to call from the real winmm.dll // LRESULT WINAPI fake_CloseDriver(HDRVR a0, LONG a1, LONG a2) { - - static LRESULT (*funcp)(HDRVR a0, LONG a1, LONG a2); - funcp = (void*)GetProcAddress(realWinmmDll, "CloseDriver"); + static LRESULT(WINAPI *funcp)(HDRVR a0, LONG a1, LONG a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "CloseDriver"); return (*funcp)(a0, a1, a2); } HDRVR WINAPI fake_OpenDriver(LPCWSTR a0, LPCWSTR a1, LONG a2) { - - static HDRVR (*funcp)(LPCWSTR a0, LPCWSTR a1, LONG a2); - funcp = (void*)GetProcAddress(realWinmmDll, "OpenDriver"); + static HDRVR(WINAPI *funcp)(LPCWSTR a0, LPCWSTR a1, LONG a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "OpenDriver"); return (*funcp)(a0, a1, a2); } LRESULT WINAPI fake_SendDriverMessage(HDRVR a0, UINT a1, LONG a2, LONG a3) { - - static LRESULT (*funcp)(HDRVR a0, UINT a1, LONG a2, LONG a3); - funcp = (void*)GetProcAddress(realWinmmDll, "SendDriverMessage"); + static LRESULT(WINAPI *funcp)(HDRVR a0, UINT a1, LONG a2, LONG a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "SendDriverMessage"); return (*funcp)(a0, a1, a2, a3); } HMODULE WINAPI fake_DrvGetModuleHandle(HDRVR a0) { - - static HMODULE (*funcp)(HDRVR a0); - funcp = (void*)GetProcAddress(realWinmmDll, "DrvGetModuleHandle"); + static HMODULE(WINAPI *funcp)(HDRVR a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "DrvGetModuleHandle"); return (*funcp)(a0); } HMODULE WINAPI fake_GetDriverModuleHandle(HDRVR a0) { - - static HMODULE (*funcp)(HDRVR a0); - funcp = (void*)GetProcAddress(realWinmmDll, "GetDriverModuleHandle"); + static HMODULE(WINAPI *funcp)(HDRVR a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "GetDriverModuleHandle"); return (*funcp)(a0); } LRESULT WINAPI fake_DefDriverProc(DWORD a0, HDRVR a1, UINT a2, LPARAM a3, LPARAM a4) { - - static LRESULT (*funcp)(DWORD a0, HDRVR a1, UINT a2, LPARAM a3, LPARAM a4); - funcp = (void*)GetProcAddress(realWinmmDll, "DefDriverProc"); + static LRESULT(WINAPI *funcp)(DWORD a0, HDRVR a1, UINT a2, LPARAM a3, LPARAM a4) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "DefDriverProc"); return (*funcp)(a0, a1, a2, a3, a4); } UINT WINAPI fake_mmsystemGetVersion() { - - static UINT (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "mmsystemGetVersion"); + static UINT(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmsystemGetVersion"); return (*funcp)(); } BOOL WINAPI fake_sndPlaySoundA(LPCSTR a0, UINT a1) { - - static BOOL (*funcp)(LPCSTR a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "sndPlaySoundA"); + static BOOL(WINAPI *funcp)(LPCSTR a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "sndPlaySoundA"); return (*funcp)(a0, a1); } BOOL WINAPI fake_sndPlaySoundW(LPCWSTR a0, UINT a1) { - - static BOOL (*funcp)(LPCWSTR a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "sndPlaySoundW"); + static BOOL(WINAPI *funcp)(LPCWSTR a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "sndPlaySoundW"); return (*funcp)(a0, a1); } BOOL WINAPI fake_PlaySound(LPCSTR a0, HMODULE a1, DWORD a2) { - - static BOOL (*funcp)(LPCSTR a0, HMODULE a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "PlaySound"); + static BOOL(WINAPI *funcp)(LPCSTR a0, HMODULE a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "PlaySound"); return (*funcp)(a0, a1, a2); } BOOL WINAPI fake_PlaySoundA(LPCSTR a0, HMODULE a1, DWORD a2) { - - static BOOL (*funcp)(LPCSTR a0, HMODULE a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "PlaySoundA"); + static BOOL(WINAPI *funcp)(LPCSTR a0, HMODULE a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "PlaySoundA"); return (*funcp)(a0, a1, a2); } BOOL WINAPI fake_PlaySoundW(LPCWSTR a0, HMODULE a1, DWORD a2) { - - static BOOL (*funcp)(LPCWSTR a0, HMODULE a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "PlaySoundW"); + static BOOL(WINAPI *funcp)(LPCWSTR a0, HMODULE a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "PlaySoundW"); return (*funcp)(a0, a1, a2); } UINT WINAPI fake_waveOutGetNumDevs() { - - static UINT (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetNumDevs"); + static UINT(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetNumDevs"); return (*funcp)(); } MMRESULT WINAPI fake_waveOutGetDevCapsA(UINT a0, LPWAVEOUTCAPSA a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPWAVEOUTCAPSA a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetDevCapsA"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPWAVEOUTCAPSA a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetDevCapsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutGetDevCapsW(UINT a0, LPWAVEOUTCAPSW a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPWAVEOUTCAPSW a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetDevCapsW"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPWAVEOUTCAPSW a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetDevCapsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutGetVolume(HWAVEOUT a0, PDWORD a1) { - - static MMRESULT (*funcp)(HWAVEOUT a0, PDWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetVolume"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, PDWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetVolume"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveOutSetVolume(HWAVEOUT a0, DWORD a1) { - - static MMRESULT (*funcp)(HWAVEOUT a0, DWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutSetVolume"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, DWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutSetVolume"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveOutGetErrorTextA(MMRESULT a0, LPSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetErrorTextA"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetErrorTextA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutGetErrorTextW(MMRESULT a0, LPWSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPWSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetErrorTextW"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPWSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetErrorTextW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutOpen(LPHWAVEOUT a0, UINT a1, LPCWAVEFORMATEX a2, DWORD a3, DWORD a4, DWORD a5) { - - static MMRESULT (*funcp)(LPHWAVEOUT a0, UINT a1, LPCWAVEFORMATEX a2, DWORD a3, DWORD a4, DWORD a5); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutOpen"); + static MMRESULT(WINAPI *funcp)(LPHWAVEOUT a0, UINT a1, LPCWAVEFORMATEX a2, DWORD a3, DWORD a4, DWORD a5) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutOpen"); return (*funcp)(a0, a1, a2, a3, a4, a5); } MMRESULT WINAPI fake_waveOutClose(HWAVEOUT a0) { - - static MMRESULT (*funcp)(HWAVEOUT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutClose"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutClose"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveOutPrepareHeader(HWAVEOUT a0, LPWAVEHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEOUT a0, LPWAVEHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutPrepareHeader"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, LPWAVEHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutPrepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutUnprepareHeader(HWAVEOUT a0, LPWAVEHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEOUT a0, LPWAVEHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutUnprepareHeader"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, LPWAVEHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutUnprepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutWrite(HWAVEOUT a0, LPWAVEHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEOUT a0, LPWAVEHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutWrite"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, LPWAVEHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutWrite"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutPause(HWAVEOUT a0) { - - static MMRESULT (*funcp)(HWAVEOUT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutPause"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutPause"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveOutRestart(HWAVEOUT a0) { - - static MMRESULT (*funcp)(HWAVEOUT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutRestart"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutRestart"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveOutReset(HWAVEOUT a0) { - - static MMRESULT (*funcp)(HWAVEOUT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutReset"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutReset"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveOutBreakLoop(HWAVEOUT a0) { - - static MMRESULT (*funcp)(HWAVEOUT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutBreakLoop"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutBreakLoop"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveOutGetPosition(HWAVEOUT a0, LPMMTIME a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEOUT a0, LPMMTIME a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetPosition"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, LPMMTIME a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetPosition"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveOutGetPitch(HWAVEOUT a0, PDWORD a1) { - - static MMRESULT (*funcp)(HWAVEOUT a0, PDWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetPitch"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, PDWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetPitch"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveOutSetPitch(HWAVEOUT a0, DWORD a1) { - - static MMRESULT (*funcp)(HWAVEOUT a0, DWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutSetPitch"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, DWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutSetPitch"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveOutGetPlaybackRate(HWAVEOUT a0, PDWORD a1) { - - static MMRESULT (*funcp)(HWAVEOUT a0, PDWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetPlaybackRate"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, PDWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetPlaybackRate"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveOutSetPlaybackRate(HWAVEOUT a0, DWORD a1) { - - static MMRESULT (*funcp)(HWAVEOUT a0, DWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutSetPlaybackRate"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, DWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutSetPlaybackRate"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveOutGetID(HWAVEOUT a0, LPUINT a1) { - - static MMRESULT (*funcp)(HWAVEOUT a0, LPUINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutGetID"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, LPUINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutGetID"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveOutMessage(HWAVEOUT a0, UINT a1, DWORD a2, DWORD a3) { - - static MMRESULT (*funcp)(HWAVEOUT a0, UINT a1, DWORD a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "waveOutMessage"); + static MMRESULT(WINAPI *funcp)(HWAVEOUT a0, UINT a1, DWORD a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutMessage"); return (*funcp)(a0, a1, a2, a3); } UINT WINAPI fake_waveInGetNumDevs() { - - static UINT (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInGetNumDevs"); + static UINT(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInGetNumDevs"); return (*funcp)(); } MMRESULT WINAPI fake_waveInGetDevCapsA(UINT a0, LPWAVEINCAPSA a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPWAVEINCAPSA a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInGetDevCapsA"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPWAVEINCAPSA a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInGetDevCapsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInGetDevCapsW(UINT a0, LPWAVEINCAPSW a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPWAVEINCAPSW a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInGetDevCapsW"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPWAVEINCAPSW a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInGetDevCapsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInGetErrorTextA(MMRESULT a0, LPSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInGetErrorTextA"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInGetErrorTextA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInGetErrorTextW(MMRESULT a0, LPWSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPWSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInGetErrorTextW"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPWSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInGetErrorTextW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInOpen(LPHWAVEIN a0, UINT a1, LPCWAVEFORMATEX a2, DWORD a3, DWORD a4, DWORD a5) { - - static MMRESULT (*funcp)(LPHWAVEIN a0, UINT a1, LPCWAVEFORMATEX a2, DWORD a3, DWORD a4, DWORD a5); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInOpen"); + static MMRESULT(WINAPI *funcp)(LPHWAVEIN a0, UINT a1, LPCWAVEFORMATEX a2, DWORD a3, DWORD a4, DWORD a5) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInOpen"); return (*funcp)(a0, a1, a2, a3, a4, a5); } MMRESULT WINAPI fake_waveInClose(HWAVEIN a0) { - - static MMRESULT (*funcp)(HWAVEIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInClose"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInClose"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveInPrepareHeader(HWAVEIN a0, LPWAVEHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEIN a0, LPWAVEHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInPrepareHeader"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0, LPWAVEHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInPrepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInUnprepareHeader(HWAVEIN a0, LPWAVEHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEIN a0, LPWAVEHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInUnprepareHeader"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0, LPWAVEHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInUnprepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInAddBuffer(HWAVEIN a0, LPWAVEHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEIN a0, LPWAVEHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInAddBuffer"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0, LPWAVEHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInAddBuffer"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInStart(HWAVEIN a0) { - - static MMRESULT (*funcp)(HWAVEIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInStart"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInStart"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveInStop(HWAVEIN a0) { - - static MMRESULT (*funcp)(HWAVEIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInStop"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInStop"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveInReset(HWAVEIN a0) { - - static MMRESULT (*funcp)(HWAVEIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInReset"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInReset"); return (*funcp)(a0); } MMRESULT WINAPI fake_waveInGetPosition(HWAVEIN a0, LPMMTIME a1, UINT a2) { - - static MMRESULT (*funcp)(HWAVEIN a0, LPMMTIME a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInGetPosition"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0, LPMMTIME a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInGetPosition"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_waveInGetID(HWAVEIN a0, LPUINT a1) { - - static MMRESULT (*funcp)(HWAVEIN a0, LPUINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInGetID"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0, LPUINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInGetID"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_waveInMessage(HWAVEIN a0, UINT a1, DWORD a2, DWORD a3) { - - static MMRESULT (*funcp)(HWAVEIN a0, UINT a1, DWORD a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "waveInMessage"); + static MMRESULT(WINAPI *funcp)(HWAVEIN a0, UINT a1, DWORD a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "waveInMessage"); return (*funcp)(a0, a1, a2, a3); } UINT WINAPI fake_midiOutGetNumDevs() { - - static UINT (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutGetNumDevs"); + static UINT(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutGetNumDevs"); return (*funcp)(); } MMRESULT WINAPI fake_midiStreamOpen(LPHMIDISTRM a0, LPUINT a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5) { - - static MMRESULT (*funcp)(LPHMIDISTRM a0, LPUINT a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamOpen"); + static MMRESULT(WINAPI *funcp)(LPHMIDISTRM a0, LPUINT a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamOpen"); return (*funcp)(a0, a1, a2, a3, a4, a5); } MMRESULT WINAPI fake_midiStreamClose(HMIDISTRM a0) { - - static MMRESULT (*funcp)(HMIDISTRM a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamClose"); + static MMRESULT(WINAPI *funcp)(HMIDISTRM a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamClose"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiStreamProperty(HMIDISTRM a0, LPBYTE a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIDISTRM a0, LPBYTE a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamProperty"); + static MMRESULT(WINAPI *funcp)(HMIDISTRM a0, LPBYTE a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamProperty"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiStreamPosition(HMIDISTRM a0, LPMMTIME a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDISTRM a0, LPMMTIME a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamPosition"); + static MMRESULT(WINAPI *funcp)(HMIDISTRM a0, LPMMTIME a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamPosition"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiStreamOut(HMIDISTRM a0, LPMIDIHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDISTRM a0, LPMIDIHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamOut"); + static MMRESULT(WINAPI *funcp)(HMIDISTRM a0, LPMIDIHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamOut"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiStreamPause(HMIDISTRM a0) { - - static MMRESULT (*funcp)(HMIDISTRM a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamPause"); + static MMRESULT(WINAPI *funcp)(HMIDISTRM a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamPause"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiStreamRestart(HMIDISTRM a0) { - - static MMRESULT (*funcp)(HMIDISTRM a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamRestart"); + static MMRESULT(WINAPI *funcp)(HMIDISTRM a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamRestart"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiStreamStop(HMIDISTRM a0) { - - static MMRESULT (*funcp)(HMIDISTRM a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiStreamStop"); + static MMRESULT(WINAPI *funcp)(HMIDISTRM a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamStop"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiConnect(HMIDI a0, HMIDIOUT a1, PVOID a2) { - - static MMRESULT (*funcp)(HMIDI a0, HMIDIOUT a1, PVOID a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiConnect"); + static MMRESULT(WINAPI *funcp)(HMIDI a0, HMIDIOUT a1, PVOID a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiConnect"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiDisconnect(HMIDI a0, HMIDIOUT a1, PVOID a2) { - - static MMRESULT (*funcp)(HMIDI a0, HMIDIOUT a1, PVOID a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiDisconnect"); + static MMRESULT(WINAPI *funcp)(HMIDI a0, HMIDIOUT a1, PVOID a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiDisconnect"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutGetDevCapsA(UINT a0, LPMIDIOUTCAPSA a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPMIDIOUTCAPSA a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutGetDevCapsA"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPMIDIOUTCAPSA a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutGetDevCapsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutGetDevCapsW(UINT a0, LPMIDIOUTCAPSW a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPMIDIOUTCAPSW a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutGetDevCapsW"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPMIDIOUTCAPSW a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutGetDevCapsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutGetVolume(HMIDIOUT a0, PDWORD a1) { - - static MMRESULT (*funcp)(HMIDIOUT a0, PDWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutGetVolume"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, PDWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutGetVolume"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_midiOutSetVolume(HMIDIOUT a0, DWORD a1) { - - static MMRESULT (*funcp)(HMIDIOUT a0, DWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutSetVolume"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, DWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutSetVolume"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_midiOutGetErrorTextA(MMRESULT a0, LPSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutGetErrorTextA"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutGetErrorTextA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutGetErrorTextW(MMRESULT a0, LPWSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPWSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutGetErrorTextW"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPWSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutGetErrorTextW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutOpen(LPHMIDIOUT a0, UINT a1, DWORD a2, DWORD a3, DWORD a4) { - - static MMRESULT (*funcp)(LPHMIDIOUT a0, UINT a1, DWORD a2, DWORD a3, DWORD a4); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutOpen"); + static MMRESULT(WINAPI *funcp)(LPHMIDIOUT a0, UINT a1, DWORD a2, DWORD a3, DWORD a4) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutOpen"); return (*funcp)(a0, a1, a2, a3, a4); } MMRESULT WINAPI fake_midiOutClose(HMIDIOUT a0) { - - static MMRESULT (*funcp)(HMIDIOUT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutClose"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutClose"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiOutPrepareHeader(HMIDIOUT a0, LPMIDIHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDIOUT a0, LPMIDIHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutPrepareHeader"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, LPMIDIHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutPrepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutUnprepareHeader(HMIDIOUT a0, LPMIDIHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDIOUT a0, LPMIDIHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutUnprepareHeader"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, LPMIDIHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutUnprepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutShortMsg(HMIDIOUT a0, DWORD a1) { - - static MMRESULT (*funcp)(HMIDIOUT a0, DWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutShortMsg"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, DWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutShortMsg"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_midiOutLongMsg(HMIDIOUT a0, LPMIDIHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDIOUT a0, LPMIDIHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutLongMsg"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, LPMIDIHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutLongMsg"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiOutReset(HMIDIOUT a0) { - - static MMRESULT (*funcp)(HMIDIOUT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutReset"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutReset"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiOutCachePatches(HMIDIOUT a0, UINT a1, LPWORD a2, UINT a3) { - - static MMRESULT (*funcp)(HMIDIOUT a0, UINT a1, LPWORD a2, UINT a3); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutCachePatches"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, UINT a1, LPWORD a2, UINT a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutCachePatches"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_midiOutCacheDrumPatches(HMIDIOUT a0, UINT a1, LPWORD a2, UINT a3) { - - static MMRESULT (*funcp)(HMIDIOUT a0, UINT a1, LPWORD a2, UINT a3); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutCacheDrumPatches"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, UINT a1, LPWORD a2, UINT a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutCacheDrumPatches"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_midiOutGetID(HMIDIOUT a0, LPUINT a1) { - - static MMRESULT (*funcp)(HMIDIOUT a0, LPUINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutGetID"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, LPUINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutGetID"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_midiOutMessage(HMIDIOUT a0, UINT a1, DWORD a2, DWORD a3) { - - static MMRESULT (*funcp)(HMIDIOUT a0, UINT a1, DWORD a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "midiOutMessage"); + static MMRESULT(WINAPI *funcp)(HMIDIOUT a0, UINT a1, DWORD a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiOutMessage"); return (*funcp)(a0, a1, a2, a3); } UINT WINAPI fake_midiInGetNumDevs() { - - static UINT (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInGetNumDevs"); + static UINT(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInGetNumDevs"); return (*funcp)(); } MMRESULT WINAPI fake_midiInGetDevCapsA(UINT a0, LPMIDIINCAPSA a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPMIDIINCAPSA a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInGetDevCapsA"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPMIDIINCAPSA a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInGetDevCapsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiInGetDevCapsW(UINT a0, LPMIDIINCAPSW a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPMIDIINCAPSW a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInGetDevCapsW"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPMIDIINCAPSW a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInGetDevCapsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiInGetErrorTextA(MMRESULT a0, LPSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInGetErrorTextA"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInGetErrorTextA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiInGetErrorTextW(MMRESULT a0, LPWSTR a1, UINT a2) { - - static MMRESULT (*funcp)(MMRESULT a0, LPWSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInGetErrorTextW"); + static MMRESULT(WINAPI *funcp)(MMRESULT a0, LPWSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInGetErrorTextW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiInOpen(LPHMIDIIN a0, UINT a1, DWORD a2, DWORD a3, DWORD a4) { - - static MMRESULT (*funcp)(LPHMIDIIN a0, UINT a1, DWORD a2, DWORD a3, DWORD a4); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInOpen"); + static MMRESULT(WINAPI *funcp)(LPHMIDIIN a0, UINT a1, DWORD a2, DWORD a3, DWORD a4) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInOpen"); return (*funcp)(a0, a1, a2, a3, a4); } MMRESULT WINAPI fake_midiInClose(HMIDIIN a0) { - - static MMRESULT (*funcp)(HMIDIIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInClose"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInClose"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiInPrepareHeader(HMIDIIN a0, LPMIDIHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDIIN a0, LPMIDIHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInPrepareHeader"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0, LPMIDIHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInPrepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiInUnprepareHeader(HMIDIIN a0, LPMIDIHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDIIN a0, LPMIDIHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInUnprepareHeader"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0, LPMIDIHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInUnprepareHeader"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiInAddBuffer(HMIDIIN a0, LPMIDIHDR a1, UINT a2) { - - static MMRESULT (*funcp)(HMIDIIN a0, LPMIDIHDR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInAddBuffer"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0, LPMIDIHDR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInAddBuffer"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_midiInStart(HMIDIIN a0) { - - static MMRESULT (*funcp)(HMIDIIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInStart"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInStart"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiInStop(HMIDIIN a0) { - - static MMRESULT (*funcp)(HMIDIIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInStop"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInStop"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiInReset(HMIDIIN a0) { - - static MMRESULT (*funcp)(HMIDIIN a0); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInReset"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInReset"); return (*funcp)(a0); } MMRESULT WINAPI fake_midiInGetID(HMIDIIN a0, LPUINT a1) { - - static MMRESULT (*funcp)(HMIDIIN a0, LPUINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInGetID"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0, LPUINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInGetID"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_midiInMessage(HMIDIIN a0, UINT a1, DWORD a2, DWORD a3) { - - static MMRESULT (*funcp)(HMIDIIN a0, UINT a1, DWORD a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "midiInMessage"); + static MMRESULT(WINAPI *funcp)(HMIDIIN a0, UINT a1, DWORD a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "midiInMessage"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_auxGetDevCapsW(UINT a0, LPAUXCAPSW a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPAUXCAPSW a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "auxGetDevCapsW"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPAUXCAPSW a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "auxGetDevCapsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_auxOutMessage(UINT a0, UINT a1, DWORD a2, DWORD a3) { - - static MMRESULT (*funcp)(UINT a0, UINT a1, DWORD a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "auxOutMessage"); + static MMRESULT(WINAPI *funcp)(UINT a0, UINT a1, DWORD a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "auxOutMessage"); return (*funcp)(a0, a1, a2, a3); } UINT WINAPI fake_mixerGetNumDevs() { - - static UINT (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetNumDevs"); + static UINT(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetNumDevs"); return (*funcp)(); } MMRESULT WINAPI fake_mixerGetDevCapsA(UINT a0, LPMIXERCAPSA a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPMIXERCAPSA a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetDevCapsA"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPMIXERCAPSA a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetDevCapsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerGetDevCapsW(UINT a0, LPMIXERCAPSW a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPMIXERCAPSW a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetDevCapsW"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPMIXERCAPSW a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetDevCapsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerOpen(LPHMIXER a0, UINT a1, DWORD a2, DWORD a3, DWORD a4) { - - static MMRESULT (*funcp)(LPHMIXER a0, UINT a1, DWORD a2, DWORD a3, DWORD a4); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerOpen"); + static MMRESULT(WINAPI *funcp)(LPHMIXER a0, UINT a1, DWORD a2, DWORD a3, DWORD a4) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerOpen"); return (*funcp)(a0, a1, a2, a3, a4); } MMRESULT WINAPI fake_mixerClose(HMIXER a0) { - - static MMRESULT (*funcp)(HMIXER a0); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerClose"); + static MMRESULT(WINAPI *funcp)(HMIXER a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerClose"); return (*funcp)(a0); } DWORD WINAPI fake_mixerMessage(HMIXER a0, UINT a1, DWORD a2, DWORD a3) { - - static DWORD (*funcp)(HMIXER a0, UINT a1, DWORD a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerMessage"); + static DWORD(WINAPI *funcp)(HMIXER a0, UINT a1, DWORD a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerMessage"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_mixerGetLineInfoA(HMIXEROBJ a0, LPMIXERLINEA a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, LPMIXERLINEA a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetLineInfoA"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, LPMIXERLINEA a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetLineInfoA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerGetLineInfoW(HMIXEROBJ a0, LPMIXERLINEW a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, LPMIXERLINEW a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetLineInfoW"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, LPMIXERLINEW a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetLineInfoW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerGetID(HMIXEROBJ a0, PUINT a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, PUINT a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetID"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, PUINT a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetID"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerGetLineControlsA(HMIXEROBJ a0, LPMIXERLINECONTROLSA a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, LPMIXERLINECONTROLSA a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetLineControlsA"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, LPMIXERLINECONTROLSA a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetLineControlsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerGetLineControlsW(HMIXEROBJ a0, LPMIXERLINECONTROLSW a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, LPMIXERLINECONTROLSW a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetLineControlsW"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, LPMIXERLINECONTROLSW a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetLineControlsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerGetControlDetailsA(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetControlDetailsA"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetControlDetailsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerGetControlDetailsW(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerGetControlDetailsW"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerGetControlDetailsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mixerSetControlDetails(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2) { - - static MMRESULT (*funcp)(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mixerSetControlDetails"); + static MMRESULT(WINAPI *funcp)(HMIXEROBJ a0, LPMIXERCONTROLDETAILS a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mixerSetControlDetails"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_timeGetSystemTime(LPMMTIME a0, UINT a1) { - - static MMRESULT (*funcp)(LPMMTIME a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "timeGetSystemTime"); + static MMRESULT(WINAPI *funcp)(LPMMTIME a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "timeGetSystemTime"); return (*funcp)(a0, a1); } DWORD WINAPI fake_timeGetTime() { - - static DWORD (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "timeGetTime"); + static DWORD(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "timeGetTime"); return (*funcp)(); } MMRESULT WINAPI fake_timeSetEvent(UINT a0, UINT a1, LPTIMECALLBACK a2, DWORD a3, UINT a4) { - - static MMRESULT (*funcp)(UINT a0, UINT a1, LPTIMECALLBACK a2, DWORD a3, UINT a4); - funcp = (void*)GetProcAddress(realWinmmDll, "timeSetEvent"); + static MMRESULT(WINAPI *funcp)(UINT a0, UINT a1, LPTIMECALLBACK a2, DWORD a3, UINT a4) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "timeSetEvent"); return (*funcp)(a0, a1, a2, a3, a4); } MMRESULT WINAPI fake_timeKillEvent(UINT a0) { - - static MMRESULT (*funcp)(UINT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "timeKillEvent"); + static MMRESULT(WINAPI *funcp)(UINT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "timeKillEvent"); return (*funcp)(a0); } MMRESULT WINAPI fake_timeGetDevCaps(LPTIMECAPS a0, UINT a1) { - - static MMRESULT (*funcp)(LPTIMECAPS a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "timeGetDevCaps"); + static MMRESULT(WINAPI *funcp)(LPTIMECAPS a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "timeGetDevCaps"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_timeBeginPeriod(UINT a0) { - - static MMRESULT (*funcp)(UINT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "timeBeginPeriod"); + static MMRESULT(WINAPI *funcp)(UINT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "timeBeginPeriod"); return (*funcp)(a0); } MMRESULT WINAPI fake_timeEndPeriod(UINT a0) { - - static MMRESULT (*funcp)(UINT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "timeEndPeriod"); + static MMRESULT(WINAPI *funcp)(UINT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "timeEndPeriod"); return (*funcp)(a0); } UINT WINAPI fake_joyGetNumDevs() { - - static UINT (*funcp)(); - funcp = (void*)GetProcAddress(realWinmmDll, "joyGetNumDevs"); + static UINT(WINAPI *funcp)() = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joyGetNumDevs"); return (*funcp)(); } MMRESULT WINAPI fake_joyGetDevCapsA(UINT a0, LPJOYCAPSA a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPJOYCAPSA a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "joyGetDevCapsA"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPJOYCAPSA a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joyGetDevCapsA"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_joyGetDevCapsW(UINT a0, LPJOYCAPSW a1, UINT a2) { - - static MMRESULT (*funcp)(UINT a0, LPJOYCAPSW a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "joyGetDevCapsW"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPJOYCAPSW a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joyGetDevCapsW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_joyGetPos(UINT a0, LPJOYINFO a1) { - - static MMRESULT (*funcp)(UINT a0, LPJOYINFO a1); - funcp = (void*)GetProcAddress(realWinmmDll, "joyGetPos"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPJOYINFO a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joyGetPos"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_joyGetPosEx(UINT a0, LPJOYINFOEX a1) { - - static MMRESULT (*funcp)(UINT a0, LPJOYINFOEX a1); - funcp = (void*)GetProcAddress(realWinmmDll, "joyGetPosEx"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPJOYINFOEX a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joyGetPosEx"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_joyGetThreshold(UINT a0, LPUINT a1) { - - static MMRESULT (*funcp)(UINT a0, LPUINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "joyGetThreshold"); + static MMRESULT(WINAPI *funcp)(UINT a0, LPUINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joyGetThreshold"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_joyReleaseCapture(UINT a0) { - - static MMRESULT (*funcp)(UINT a0); - funcp = (void*)GetProcAddress(realWinmmDll, "joyReleaseCapture"); + static MMRESULT(WINAPI *funcp)(UINT a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joyReleaseCapture"); return (*funcp)(a0); } MMRESULT WINAPI fake_joySetCapture(HWND a0, UINT a1, UINT a2, BOOL a3) { - - static MMRESULT (*funcp)(HWND a0, UINT a1, UINT a2, BOOL a3); - funcp = (void*)GetProcAddress(realWinmmDll, "joySetCapture"); + static MMRESULT(WINAPI *funcp)(HWND a0, UINT a1, UINT a2, BOOL a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joySetCapture"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_joySetThreshold(UINT a0, UINT a1) { - - static MMRESULT (*funcp)(UINT a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "joySetThreshold"); + static MMRESULT(WINAPI *funcp)(UINT a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "joySetThreshold"); return (*funcp)(a0, a1); } FOURCC WINAPI fake_mmioStringToFOURCCA(LPCSTR a0, UINT a1) { - - static FOURCC (*funcp)(LPCSTR a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioStringToFOURCCA"); + static FOURCC(WINAPI *funcp)(LPCSTR a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioStringToFOURCCA"); return (*funcp)(a0, a1); } FOURCC WINAPI fake_mmioStringToFOURCCW(LPCWSTR a0, UINT a1) { - - static FOURCC (*funcp)(LPCWSTR a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioStringToFOURCCW"); + static FOURCC(WINAPI *funcp)(LPCWSTR a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioStringToFOURCCW"); return (*funcp)(a0, a1); } LPMMIOPROC WINAPI fake_mmioInstallIOProcA(FOURCC a0, LPMMIOPROC a1, DWORD a2) { - - static LPMMIOPROC (*funcp)(FOURCC a0, LPMMIOPROC a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioInstallIOProcA"); + static LPMMIOPROC(WINAPI *funcp)(FOURCC a0, LPMMIOPROC a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioInstallIOProcA"); return (*funcp)(a0, a1, a2); } LPMMIOPROC WINAPI fake_mmioInstallIOProcW(FOURCC a0, LPMMIOPROC a1, DWORD a2) { - - static LPMMIOPROC (*funcp)(FOURCC a0, LPMMIOPROC a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioInstallIOProcW"); + static LPMMIOPROC(WINAPI *funcp)(FOURCC a0, LPMMIOPROC a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioInstallIOProcW"); return (*funcp)(a0, a1, a2); } HMMIO WINAPI fake_mmioOpenA(LPSTR a0, LPMMIOINFO a1, DWORD a2) { - - static HMMIO (*funcp)(LPSTR a0, LPMMIOINFO a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioOpenA"); + static HMMIO(WINAPI *funcp)(LPSTR a0, LPMMIOINFO a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioOpenA"); return (*funcp)(a0, a1, a2); } HMMIO WINAPI fake_mmioOpenW(LPWSTR a0, LPMMIOINFO a1, DWORD a2) { - - static HMMIO (*funcp)(LPWSTR a0, LPMMIOINFO a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioOpenW"); + static HMMIO(WINAPI *funcp)(LPWSTR a0, LPMMIOINFO a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioOpenW"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mmioRenameA(LPCSTR a0, LPCSTR a1, LPCMMIOINFO a2, DWORD a3) { - - static MMRESULT (*funcp)(LPCSTR a0, LPCSTR a1, LPCMMIOINFO a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioRenameA"); + static MMRESULT(WINAPI *funcp)(LPCSTR a0, LPCSTR a1, LPCMMIOINFO a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioRenameA"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_mmioRenameW(LPCWSTR a0, LPCWSTR a1, LPCMMIOINFO a2, DWORD a3) { - - static MMRESULT (*funcp)(LPCWSTR a0, LPCWSTR a1, LPCMMIOINFO a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioRenameW"); + static MMRESULT(WINAPI *funcp)(LPCWSTR a0, LPCWSTR a1, LPCMMIOINFO a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioRenameW"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_mmioClose(HMMIO a0, UINT a1) { - - static MMRESULT (*funcp)(HMMIO a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioClose"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioClose"); return (*funcp)(a0, a1); } LONG WINAPI fake_mmioRead(HMMIO a0, HPSTR a1, LONG a2) { - - static LONG (*funcp)(HMMIO a0, HPSTR a1, LONG a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioRead"); + static LONG(WINAPI *funcp)(HMMIO a0, HPSTR a1, LONG a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioRead"); return (*funcp)(a0, a1, a2); } LONG WINAPI fake_mmioWrite(HMMIO a0, LPCSTR a1, LONG a2) { - - static LONG (*funcp)(HMMIO a0, LPCSTR a1, LONG a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioWrite"); + static LONG(WINAPI *funcp)(HMMIO a0, LPCSTR a1, LONG a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioWrite"); return (*funcp)(a0, a1, a2); } LONG WINAPI fake_mmioSeek(HMMIO a0, LONG a1, int a2) { - - static LONG (*funcp)(HMMIO a0, LONG a1, int a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioSeek"); + static LONG(WINAPI *funcp)(HMMIO a0, LONG a1, int a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioSeek"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mmioGetInfo(HMMIO a0, LPMMIOINFO a1, UINT a2) { - - static MMRESULT (*funcp)(HMMIO a0, LPMMIOINFO a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioGetInfo"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, LPMMIOINFO a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioGetInfo"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mmioSetInfo(HMMIO a0, LPCMMIOINFO a1, UINT a2) { - - static MMRESULT (*funcp)(HMMIO a0, LPCMMIOINFO a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioSetInfo"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, LPCMMIOINFO a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioSetInfo"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mmioSetBuffer(HMMIO a0, LPSTR a1, LONG a2, UINT a3) { - - static MMRESULT (*funcp)(HMMIO a0, LPSTR a1, LONG a2, UINT a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioSetBuffer"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, LPSTR a1, LONG a2, UINT a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioSetBuffer"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_mmioFlush(HMMIO a0, UINT a1) { - - static MMRESULT (*funcp)(HMMIO a0, UINT a1); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioFlush"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, UINT a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioFlush"); return (*funcp)(a0, a1); } MMRESULT WINAPI fake_mmioAdvance(HMMIO a0, LPMMIOINFO a1, UINT a2) { - - static MMRESULT (*funcp)(HMMIO a0, LPMMIOINFO a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioAdvance"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, LPMMIOINFO a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioAdvance"); return (*funcp)(a0, a1, a2); } LRESULT WINAPI fake_mmioSendMessage(HMMIO a0, UINT a1, LPARAM a2, LPARAM a3) { - - static LRESULT (*funcp)(HMMIO a0, UINT a1, LPARAM a2, LPARAM a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioSendMessage"); + static LRESULT(WINAPI *funcp)(HMMIO a0, UINT a1, LPARAM a2, LPARAM a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioSendMessage"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_mmioDescend(HMMIO a0, LPMMCKINFO a1, const MMCKINFO* a2, UINT a3) { - - static MMRESULT (*funcp)(HMMIO a0, LPMMCKINFO a1, const MMCKINFO* a2, UINT a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioDescend"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, LPMMCKINFO a1, const MMCKINFO* a2, UINT a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioDescend"); return (*funcp)(a0, a1, a2, a3); } MMRESULT WINAPI fake_mmioAscend(HMMIO a0, LPMMCKINFO a1, UINT a2) { - - static MMRESULT (*funcp)(HMMIO a0, LPMMCKINFO a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioAscend"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, LPMMCKINFO a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioAscend"); return (*funcp)(a0, a1, a2); } MMRESULT WINAPI fake_mmioCreateChunk(HMMIO a0, LPMMCKINFO a1, UINT a2) { - - static MMRESULT (*funcp)(HMMIO a0, LPMMCKINFO a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mmioCreateChunk"); + static MMRESULT(WINAPI *funcp)(HMMIO a0, LPMMCKINFO a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mmioCreateChunk"); return (*funcp)(a0, a1, a2); } MCIERROR WINAPI fake_mciSendCommandW(MCIDEVICEID a0, UINT a1, DWORD a2, DWORD a3) { - - static MCIERROR (*funcp)(MCIDEVICEID a0, UINT a1, DWORD a2, DWORD a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mciSendCommandW"); + static MCIERROR(WINAPI *funcp)(MCIDEVICEID a0, UINT a1, DWORD a2, DWORD a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciSendCommandW"); return (*funcp)(a0, a1, a2, a3); } MCIERROR WINAPI fake_mciSendStringW(LPCWSTR a0, LPWSTR a1, UINT a2, HWND a3) { - - static MCIERROR (*funcp)(LPCWSTR a0, LPWSTR a1, UINT a2, HWND a3); - funcp = (void*)GetProcAddress(realWinmmDll, "mciSendStringW"); + static MCIERROR(WINAPI *funcp)(LPCWSTR a0, LPWSTR a1, UINT a2, HWND a3) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciSendStringW"); return (*funcp)(a0, a1, a2, a3); } MCIDEVICEID WINAPI fake_mciGetDeviceIDA(LPCSTR a0) { - - static MCIDEVICEID (*funcp)(LPCSTR a0); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetDeviceIDA"); + static MCIDEVICEID(WINAPI *funcp)(LPCSTR a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetDeviceIDA"); return (*funcp)(a0); } MCIDEVICEID WINAPI fake_mciGetDeviceIDW(LPCWSTR a0) { - - static MCIDEVICEID (*funcp)(LPCWSTR a0); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetDeviceIDW"); + static MCIDEVICEID(WINAPI *funcp)(LPCWSTR a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetDeviceIDW"); return (*funcp)(a0); } MCIDEVICEID WINAPI fake_mciGetDeviceIDFromElementIDA(DWORD a0, LPCSTR a1) { - - static MCIDEVICEID (*funcp)(DWORD a0, LPCSTR a1); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetDeviceIDFromElementIDA"); + static MCIDEVICEID(WINAPI *funcp)(DWORD a0, LPCSTR a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetDeviceIDFromElementIDA"); return (*funcp)(a0, a1); } MCIDEVICEID WINAPI fake_mciGetDeviceIDFromElementIDW(DWORD a0, LPCWSTR a1) { - - static MCIDEVICEID (*funcp)(DWORD a0, LPCWSTR a1); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetDeviceIDFromElementIDW"); + static MCIDEVICEID(WINAPI *funcp)(DWORD a0, LPCWSTR a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetDeviceIDFromElementIDW"); return (*funcp)(a0, a1); } BOOL WINAPI fake_mciGetErrorStringA(MCIERROR a0, LPSTR a1, UINT a2) { - - static BOOL (*funcp)(MCIERROR a0, LPSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetErrorStringA"); + static BOOL(WINAPI *funcp)(MCIERROR a0, LPSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetErrorStringA"); return (*funcp)(a0, a1, a2); } BOOL WINAPI fake_mciGetErrorStringW(MCIERROR a0, LPWSTR a1, UINT a2) { - - static BOOL (*funcp)(MCIERROR a0, LPWSTR a1, UINT a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetErrorStringW"); + static BOOL(WINAPI *funcp)(MCIERROR a0, LPWSTR a1, UINT a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetErrorStringW"); return (*funcp)(a0, a1, a2); } BOOL WINAPI fake_mciSetYieldProc(MCIDEVICEID a0, YIELDPROC a1, DWORD a2) { - - static BOOL (*funcp)(MCIDEVICEID a0, YIELDPROC a1, DWORD a2); - funcp = (void*)GetProcAddress(realWinmmDll, "mciSetYieldProc"); + static BOOL(WINAPI *funcp)(MCIDEVICEID a0, YIELDPROC a1, DWORD a2) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciSetYieldProc"); return (*funcp)(a0, a1, a2); } HTASK WINAPI fake_mciGetCreatorTask(MCIDEVICEID a0) { - - static HTASK (*funcp)(MCIDEVICEID a0); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetCreatorTask"); + static HTASK(WINAPI *funcp)(MCIDEVICEID a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetCreatorTask"); return (*funcp)(a0); } YIELDPROC WINAPI fake_mciGetYieldProc(MCIDEVICEID a0, PDWORD a1) { - - static YIELDPROC (*funcp)(MCIDEVICEID a0, PDWORD a1); - funcp = (void*)GetProcAddress(realWinmmDll, "mciGetYieldProc"); + static YIELDPROC(WINAPI *funcp)(MCIDEVICEID a0, PDWORD a1) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciGetYieldProc"); return (*funcp)(a0, a1); } BOOL WINAPI fake_mciExecute(LPCSTR a0) { - - static BOOL (*funcp)(LPCSTR a0); - funcp = (void*)GetProcAddress(realWinmmDll, "mciExecute"); + static BOOL(WINAPI *funcp)(LPCSTR a0) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "mciExecute"); return (*funcp)(a0); } BOOL WINAPI fake_DriverCallback(DWORD a0, DWORD a1, HDRVR a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6) { - - static BOOL (*funcp)(DWORD a0, DWORD a1, HDRVR a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6); - funcp = (void*)GetProcAddress(realWinmmDll, "DriverCallback"); + static BOOL(WINAPI *funcp)(DWORD a0, DWORD a1, HDRVR a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "DriverCallback"); return (*funcp)(a0, a1, a2, a3, a4, a5, a6); } BOOL WINAPI fake_NotifyCallbackData(DWORD a0, DWORD a1, DWORD a2, DWORD a3, DWORD a4) { - - static BOOL (*funcp)(DWORD a0, DWORD a1, DWORD a2, DWORD a3, DWORD a4); - funcp = (void*)GetProcAddress(realWinmmDll, "NotifyCallbackData"); + static BOOL(WINAPI *funcp)(DWORD a0, DWORD a1, DWORD a2, DWORD a3, DWORD a4) = NULL; + if (funcp == NULL) + funcp = (void*)GetProcAddress(loadRealDLL(), "NotifyCallbackData"); return (*funcp)(a0, a1, a2, a3, a4); } diff --git a/wav-winmm.c b/wav-winmm.c index e02e57b..876083c 100644 --- a/wav-winmm.c +++ b/wav-winmm.c @@ -1,18 +1,18 @@ /* - * Copyright (c) 2012 Toni Spets - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ +* Copyright (c) 2012 Toni Spets +* +* Permission to use, copy, modify, and distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ #include #include @@ -22,6 +22,12 @@ #define MAGIC_DEVICEID 0xBEEF #define MAX_TRACKS 99 +#ifdef WIN32 + +#define snprintf _snprintf + +#endif + struct track_info { char path[MAX_PATH]; // full path to ogg @@ -38,13 +44,15 @@ struct play_info }; #ifdef _DEBUG - #define dprintf(...) if (fh) { fprintf(fh, __VA_ARGS__); fflush(NULL); } - FILE *fh = NULL; +#define dprintf(...) if (fh) { fprintf(fh, __VA_ARGS__); fflush(NULL); } +FILE *fh = NULL; #else - #define dprintf(...) +#define dprintf(...) #endif int playing = 0; +int updateTrack = 0; +int closed = 0; HANDLE player = NULL; int firstTrack = -1; int lastTrack = 0; @@ -52,34 +60,60 @@ int numTracks = 0; char music_path[2048]; int time_format = MCI_FORMAT_TMSF; CRITICAL_SECTION cs; -HINSTANCE realWinmmDLL = 0; +static struct play_info info = { -1, -1 }; -int player_main(struct play_info *info) +int player_main() { - int first = info->first; - int last = info->last; - int current = first; - - playing = 1; + int first; + int last; + int current; - while (current <= last && playing) + while (!closed) { - dprintf("Next track: %s\r\n", tracks[current].path); - playing = plr_play(tracks[current].path); + //set track info + if (updateTrack) + { + first = info.first; + last = info.last; + current = first; + updateTrack = 0; + } + + //stop if at end of 'playlist' + //note "last" track is NON-inclusive + if (current == last) + playing = 0; + + //try to play song + else + { + dprintf("Next track: %s\r\n", tracks[current].path); + playing = plr_play(tracks[current].path); + } while (1) { - if (plr_pump() == 0) - break; + //check control signals - if (!playing) + if (closed) //MCI_CLOSE + break; + + if (!playing) //MCI_STOP { - return 0; + plr_stop(); //end playback + SuspendThread(player); //pause thread until next MCI_PLAY } + + if (plr_pump() == 0) //done playing song + break; + + if (updateTrack) //MCI_PLAY + break; } current++; } + plr_stop(); playing = 0; return 0; @@ -89,17 +123,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { if (fdwReason == DLL_PROCESS_ATTACH) { - //load real winmm.dll - char winmm_path[MAX_PATH]; - - GetSystemDirectory(winmm_path, MAX_PATH); - strncat(winmm_path, "\\winmm.dll", MAX_PATH); - - realWinmmDLL = LoadLibrary(winmm_path); - if (!realWinmmDLL) return FALSE; - - setWinmmDll(realWinmmDLL); - #ifdef _DEBUG fh = fopen("winmm.txt", "w"); #endif @@ -152,8 +175,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) #ifdef _DEBUG if (fdwReason == DLL_PROCESS_DETACH) { - FreeLibrary(realWinmmDLL); - if (fh) { fclose(fh); @@ -183,7 +204,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR if (uMsg == MCI_OPEN) { - LPMCI_OPEN_PARMS parms = (LPMCI_OPEN_PARMS)dwParam; + LPMCI_OPEN_PARMS parms = (LPVOID)dwParam; dprintf(" MCI_OPEN\r\n"); @@ -228,7 +249,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR { if (uMsg == MCI_SET) { - LPMCI_SET_PARMS parms = (LPMCI_SET_PARMS)dwParam; + LPMCI_SET_PARMS parms = (LPVOID)dwParam; dprintf(" MCI_SET\r\n"); @@ -281,7 +302,9 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR if (player) { - TerminateThread(player, 0); + ResumeThread(player); //just in case it's suspended, else deadlock + closed = 1; + playing = 0; } playing = 0; @@ -290,8 +313,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR if (uMsg == MCI_PLAY) { - LPMCI_PLAY_PARMS parms = (LPMCI_PLAY_PARMS)dwParam; - static struct play_info info = { -1, -1 }; + LPMCI_PLAY_PARMS parms = (LPVOID)dwParam; dprintf(" MCI_PLAY\r\n"); @@ -341,8 +363,6 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR if (fdwCommand & MCI_TO) { - parms->dwTo--; //dwTo should be non-inclusive - dprintf(" dwTo: %d\r\n", parms->dwTo); if (time_format == MCI_FORMAT_TMSF) @@ -358,7 +378,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR { info.last = info.first; - for (int i = info.first; i < MAX_TRACKS; i ++) + for (int i = info.first; i < MAX_TRACKS; i++) { // FIXME: use better matching if (tracks[i].position + tracks[i].length > parms->dwFrom / 1000) @@ -382,28 +402,26 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR if (info.first && (fdwCommand & MCI_FROM)) { + updateTrack = 1; + playing = 1; - if (player) - { - TerminateThread(player, 0); - } - - playing = 0; - player = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)player_main, (void *)&info, 0, NULL); + //track info is now a global variable for live updating + if (player == NULL) + player = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)player_main, NULL, 0, NULL); + else + ResumeThread(player); } } if (uMsg == MCI_STOP) { dprintf(" MCI_STOP\r\n"); - plr_stop(); - playing = 0; } if (uMsg == MCI_STATUS) { - LPMCI_STATUS_PARMS parms = (LPMCI_STATUS_PARMS)dwParam; + LPMCI_STATUS_PARMS parms = (LPVOID)dwParam; dprintf(" MCI_STATUS\r\n"); @@ -474,7 +492,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR if (parms->dwItem == MCI_STATUS_MODE) { dprintf(" MCI_STATUS_MODE\r\n"); - dprintf(" we are %s\r\n", playing ? "playing but reporting not" : "NOT playing"); + dprintf(" we are %s\r\n", playing ? "playing" : "NOT playing"); parms->dwReturn = playing ? MCI_MODE_PLAY : MCI_MODE_STOP; } @@ -529,7 +547,7 @@ MCIERROR WINAPI fake_mciSendStringA(LPCTSTR cmd, LPTSTR ret, UINT cchReturn, HAN static MCI_PLAY_PARMS parms; parms.dwFrom = from; parms.dwTo = to; - fake_mciSendCommandA(MAGIC_DEVICEID, MCI_PLAY, MCI_FROM|MCI_TO, (DWORD_PTR)&parms); + fake_mciSendCommandA(MAGIC_DEVICEID, MCI_PLAY, MCI_FROM | MCI_TO, (DWORD_PTR)&parms); return 0; } @@ -587,4 +605,4 @@ MMRESULT WINAPI fake_auxSetVolume(UINT uDeviceID, DWORD dwVolume) plr_volume((left / 65535.0f) * 100); return MMSYSERR_NOERROR; -} +} \ No newline at end of file