00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "CATOpenALIntercept.h"
00014
00015 #ifdef CAT_CONFIG_WIN32
00016
00017 CATINTERCEPT_DLL_TABLE_ENTRY kOpenALIntercept[] =
00018 {
00019 {"alSourcePlay", CATOpenALIntercept::OnALSourcePlay, 5},
00020 {"alSourceStop", CATOpenALIntercept::OnALSourceStop, 5},
00021 {"alSourceStopV", CATOpenALIntercept::OnALSourceStopV, 5},
00022 {"alQueueBuffers", CATOpenALIntercept::OnALQueueBuffers, 5},
00023 {"alBufferData", CATOpenALIntercept::OnALBufferData, 5},
00024 { 0, 0, 0}
00025 };
00026
00027 CATOpenALIntercept::CATOpenALIntercept()
00028 {
00029
00030
00031
00032 fOpenALDLL = ::LoadLibrary(L"OpenAL32.dll");
00033 }
00034
00035 CATOpenALIntercept::~CATOpenALIntercept()
00036 {
00037
00038 RestoreAll();
00039
00040 if (fOpenALDLL)
00041 FreeLibrary(fOpenALDLL);
00042 }
00043
00044 CATResult CATOpenALIntercept::HookFunctions()
00045 {
00046 CATResult result = CAT_SUCCESS;
00047
00048
00049 if (this->fOpenALDLL)
00050 {
00051 ::OutputDebugString(L"Hooking OpenAL...\n");
00052 result = InterceptDLL(fOpenALDLL,&kOpenALIntercept[0],0);
00053 if (CATFAILED(result))
00054 ::OutputDebugString(L"Failed hooking OpenAL.\n");
00055 }
00056 else
00057 ::OutputDebugString(L"Failed to load OpenAL.\n");
00058
00059 return result;
00060 }
00061
00062
00063 CATHOOKFUNC void CATOpenALIntercept::OnALSourcePlay( CATHOOK* hookInst,
00064 CATUInt32 sourceId)
00065 {
00066 CATHOOK_PROLOGUE(1);
00067
00068 ::OutputDebugString(L"OnALSourcePlay\n");
00069
00070 CATHOOK_CALLORIGINAL_CDECL(hookInst, 1);
00071
00072 CATHOOK_EPILOGUE_CDECL(1);
00073 }
00074
00075 CATHOOKFUNC void CATOpenALIntercept::OnALSourcePlayV( CATHOOK* hookInst,
00076 CATInt32 numSources,
00077 CATUInt32* sourceIds)
00078 {
00079 CATHOOK_PROLOGUE(2);
00080 ::OutputDebugString(L"OnALSourcePlayV\n");
00081
00082 CATHOOK_CALLORIGINAL_CDECL(hookInst, 2);
00083 CATHOOK_EPILOGUE_CDECL(2);
00084 }
00085
00086 CATHOOKFUNC void CATOpenALIntercept::OnALSourceStop( CATHOOK* hookInst,
00087 CATUInt32 sourceId)
00088 {
00089 CATHOOK_PROLOGUE(1);
00090
00091 ::OutputDebugString(L"OnALSourceStop\n");
00092
00093 CATHOOK_CALLORIGINAL_CDECL(hookInst, 1);
00094 CATHOOK_EPILOGUE_CDECL(1);
00095 }
00096
00097 CATHOOKFUNC void CATOpenALIntercept::OnALSourceStopV( CATHOOK* hookInst,
00098 CATInt32 numSources,
00099 CATUInt32* sourceIds)
00100 {
00101 CATHOOK_PROLOGUE(2);
00102
00103 ::OutputDebugString(L"OnALSourceStopV\n");
00104
00105 CATHOOK_CALLORIGINAL_CDECL(hookInst, 2);
00106 CATHOOK_EPILOGUE_CDECL(2);
00107 }
00108
00109 CATHOOKFUNC void CATOpenALIntercept::OnALQueueBuffers( CATHOOK* hookInst,
00110 CATUInt32 sourceId,
00111 CATInt32 numEntries,
00112 CATUInt32* bufferIds)
00113 {
00114 CATHOOK_PROLOGUE(3);
00115
00116 ::OutputDebugString(L"OnALQueueBuffers\n");
00117
00118 CATHOOK_CALLORIGINAL_CDECL(hookInst, 3);
00119 CATHOOK_EPILOGUE_CDECL(3);
00120 }
00121
00122 CATHOOKFUNC void CATOpenALIntercept::OnALBufferData( CATHOOK* hookInst,
00123 CATUInt32 bufferId,
00124 CATUInt32 format,
00125 void* data,
00126 CATInt32 size,
00127 CATInt32 frequency)
00128 {
00129 CATHOOK_PROLOGUE(5);
00130
00131
00132
00133 CATHOOK_CALLORIGINAL_CDECL(hookInst, 5);
00134 CATHOOK_EPILOGUE_CDECL(5);
00135 }
00136
00137 #endif // CAT_CONFIG_WIN32