Re: stop sounds of a different process

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi (sorry for the long thread)...
I have another small issue which i can't seem to resolve.
using detour library i managed to cause the application i'm hooking not to
use dsound.dll (direct sound) and force it to use waveout API (i hooked the
LoadLibrary and return NULL when i received the LoadLibrary("dsound.dll")
request).
Anyway i know the application is using the fmod library (for sounds API)
which supports both (waveOut and direct sound) so it works fine (this is just
a temporary hook for testing).
the problem is - although i get waveOutOpen/Write/Close calls in my hooks,
these are only called once the application is initialized. Afterward during
its run, and when sound for example is played when user press button /
animation starts, i do not see any waveOutWrite calls (which one would
expect) but i can hear the sound.
I also see that if in the original waveOutWrite calls which i received (in
my hook) i do not perform the actual write and just return MMSYSERR_NOERROR,
there is no sound in the game at all (which does make sense...).
i couldn't find any other API (checked also waveOutRestart) which might be
used instead.
Any ideas?
10x.


"Oded" wrote:

i'm now using the detour library which seems to do the job.
thanks for the tip.

"Alessandro Angeli" wrote:

From: "Oded"

Thanks for the quick response. it took me a while but i
managed to make the hooking work (i'm using some
HookImportFunction which was written by codeproject
http://www.codeproject.com/KB/DLL/hookimport.aspx ).
however, i'm trying to hook some of the winmm.dll
functions, and while i can hook the waveOutOpen, i'm
unable to hook the PlaySound.
When i look at the "dll API" using "dependecy walker"
(going from the exe which i try to hook, not directly
from the dll winmm.dll) i see that i can only get access
to functions of winmm.dll with a "green C" box next to
them and which do not have a bounded entry point. while
all the rest (including among them PlaySound) are not
accesiable.
anyway idea what's the difference between the 2 function
groups?

The code you are using patches the DLL's IAT, which is
tricky and, not knowing the details on how and when you hook
what and where, it is hard to say. A safer hooking technique
works by patching the function itself (see my FAQ). In any
case, PlaySound() itself should only be an high-level
function that uses waveOut or DirectSound underneath, which
means that hooking those will automatically take care of
PlaySound and other high-level functions as well.

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm



.



Relevant Pages

  • Re: SysHook and STATUS_ACCESS_VIOLATION
    ... > Excuse me you claim Microsoft has a hooking library, ... Once you hook you can never unhook! ... > Don Burn (MVP, Windows DDK) ... >> So, before write so much STUPID, probably you have to listen my answer, ...
    (microsoft.public.development.device.drivers)
  • Re: How to avoid that a key can be hold down
    ... CallNextHookEx Hook, ncode, wParam, ByVal lParam ... But you must realise that any hooking of this kind is ... when running hooking code in the IDE any error ...
    (comp.lang.basic.visual.misc)
  • Re: Hooking to stop file move(ment)
    ... I do believe that my hooking function is actually being invoked; ... MoveFileW function prototype receives two long pointers to unicode strings. ... In theory, couldn't I use any type of long pointer to pass the data along, ... That about does it for how I hook the function...my Hooking function ...
    (microsoft.public.win32.programmer.kernel)
  • Re: SysHook and STATUS_ACCESS_VIOLATION
    ... The kernel function is ... > NTSTATUS MyZwOpenKey(IN OUT PHANDLE pHandle, IN ACCESS_MASK ReqAccess, ... >> Excuse me you claim Microsoft has a hooking library, ... Once you hook you can never unhook! ...
    (microsoft.public.development.device.drivers)
  • Intercepting WaveOut : hook / custom audio driver / fastest path?
    ... I just spent the last few hours reading tons of Google Groups posts ... I need to be able to hook into the WaveOut ... WaveOut audio stream with the minimum amount of work. ... If this is done by creating my own audio driver, ...
    (microsoft.public.win32.programmer.mmedia)