Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
media
danimation.controls
danimation.programming
devices
drm
dshow.programming
dtransform
encoder
encoder.optimization
hometheaterpc
media
media.beta
media.beta.encoder
mediacenter
mediacenter.portable
mediaplayer
music.products
musicproducer
player
player.plugins
player.skins
player.solaris
player.visualizations
player.web
sdk
server
tools
  
 
date: Fri, 4 Jul 2008 03:21:11 -0700 (PDT),    group: microsoft.public.windowsmedia.sdk        back       


waveout/direct sound call to get audio output stream   
Hi all,
I have a requirement that i need to inject a directsound/waveout
method to hook on to get output audio stream. Please anybody tell me
which function do i need to use it for this purpose.

Thanks
date: Fri, 4 Jul 2008 03:21:11 -0700 (PDT)   author:   rajani_sp

Re: waveout/direct sound call to get audio output stream   
From: "rajani_sp"

> I have a requirement that i need to inject a
> directsound/waveout method to hook on to get output audio
> stream. Please anybody tell me which function do i need
> to use it for this purpose.

Hooking is not supported by Windows. Short of writing a 
virtual audio driver, read my FAQ (the link is below) for a 
few hooking techniques.



-- 
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
date: Fri, 4 Jul 2008 08:01:16 -0400   author:   Alessandro Angeli

Re: waveout/direct sound call to get audio output stream   
On Jul 4, 5:01 pm, "Alessandro Angeli" 
wrote:
> From: "rajani_sp"
>
> > I have a requirement that i need to inject a
> > directsound/waveout method to hook on to get output audio
> > stream. Please anybody tell me which function do i need
> > to use it for this purpose.
>
> Hooking is not supported by Windows. Short of writing a
> virtual audio driver, read my FAQ (the link is below) for a
> few hooking techniques.
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> //http://www.riseoftheants.com/mmx/faq.htm

Thanks a lot for your reply. I have seen your FAQ.
Actually my requirement is that ,i have a software to take snap on
clicking a button in its user interface.
I need to capture output audio stream of  the click sound of the
button and i dont want to record any sound for this purpose
.so which API need to be hooked onto using the detour library. I am
not able to see which waveout/directsound apis are being called from
that software for playing the sound . I used  depends - profiling for
this purpose. If i start profile and then click on the button the
profiling seems to be stopping.   So  how can I know which Waveout/
directsound calls do i need to use for detour. ?



Thanks in advance
Rajani
date: Tue, 8 Jul 2008 04:52:46 -0700 (PDT)   author:   rajani_sp

Re: waveout/direct sound call to get audio output stream   
From: "rajani_sp"

> So  how can I know which Waveout/ directsound calls do i
> need to use for detour. ?

You start by hooking the opening/creation calls and then 
other calls until you find the data you need.



-- 
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
date: Tue, 8 Jul 2008 13:53:39 -0400   author:   Alessandro Angeli

Re: waveout/direct sound call to get audio output stream   
On Jul 8, 10:53 pm, "Alessandro Angeli" 
wrote:
> From: "rajani_sp"
>
> > So  how can I know which Waveout/ directsound calls do i
> > need to use for detour. ?
>
> You start by hooking the opening/creation calls and then
> other calls until you find the data you need.
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> //http://www.riseoftheants.com/mmx/faq.htm

Hi ,
sorry for replying after a long time. Now I am able to
hook WaveOut calls. But lpdata of WAVEHDR
when i try to save it into a file and play file using
"audacity" it is different from the original wav file i
used.This the code used in Detour WaveOutwrite
function.

//Modify waveOutWrite
 __declspec(dllexport) MMRESULT  WINAPI DetourwaveOutWrite(HWAVEOUT
hwo,LPWAVEHDR pwh,UINT cbwh)
{
	// Get o/p stream here.
	printf(" DetourwaveOutWrite\n");
	LPSTR str = pwh->lpData ;
	HANDLE hFile ;
	DWORD dwBytes;
	int numwrite;
	printf("sampling started...");
                FILE* stream=fopen("kelvin.tin","ab");
	numwrite = fwrite( pwh->lpData,sizeof(pwh->lpData),pwh-
>dwBufferLength,stream);
	fclose(stream);
	return Real_waveOutWrite(hwo,pwh,cbwh);
}

Thanks
Rajani
date: Tue, 22 Jul 2008 02:29:07 -0700 (PDT)   author:   rajani_sp

Re: waveout/direct sound call to get audio output stream   
"rajani_sp" wrote:

> On Jul 8, 10:53 pm, "Alessandro Angeli" 
> wrote:
> > From: "rajani_sp"
> >
> > > So  how can I know which Waveout/ directsound calls do i
> > > need to use for detour. ?
> >
> > You start by hooking the opening/creation calls and then
> > other calls until you find the data you need.
> >
> > --
> > // Alessandro Angeli
> > // MVP :: DirectShow / MediaFoundation
> > // mvpnews at riseoftheants dot com
> > //http://www.riseoftheants.com/mmx/faq.htm
> 
> Hi ,
> sorry for replying after a long time. Now I am able to
> hook WaveOut calls. But lpdata of WAVEHDR
> when i try to save it into a file and play file using
> "audacity" it is different from the original wav file i
> used.This the code used in Detour WaveOutwrite
> function.
> 
> //Modify waveOutWrite
>  __declspec(dllexport) MMRESULT  WINAPI DetourwaveOutWrite(HWAVEOUT
> hwo,LPWAVEHDR pwh,UINT cbwh)
> {
> 	// Get o/p stream here.
> 	printf(" DetourwaveOutWrite\n");
> 	LPSTR str = pwh->lpData ;
> 	HANDLE hFile ;
> 	DWORD dwBytes;
> 	int numwrite;
> 	printf("sampling started...");
>                 FILE* stream=fopen("kelvin.tin","ab");
> 	numwrite = fwrite( pwh->lpData,sizeof(pwh->lpData),pwh-
> >dwBufferLength,stream);
> 	fclose(stream);
> 	return Real_waveOutWrite(hwo,pwh,cbwh);
> }
> 
> Thanks
> Rajani
> 

Did you ever get this resolved?
I am trying the same, but I need to hook dsound. On investigation hooking 
directx as apposed to winmm  has some challenges since dsound.dll as a COM 
has only really a few entry points ,all the "create" functions , but 
thereafter related functions  are actually pointers to the functions accessed 
via the interface.
Have you ever hooked a com interface before? Not sure if it is possible!
Derek.
date: Sun, 3 Aug 2008 12:55:00 -0700   author:   Derekm

Re: waveout/direct sound call to get audio output stream   
From: "Derekm"

> Have you ever hooked a com interface before? Not sure if
> it is possible! Derek.

What's the difference? You don't hook an interface, you hook 
a specific method of an interface, which is no different 
from any other function. You only need to know how to get a 
pointer to the method (the compiler will not help you there) 
and what the real prototype is.

For example:

class ISomeInterface : public IUnknown
{
  public: HRESULT STDMETHODCALLTYPE SomeMethod(int arg) = 0;
};

The method has the following "real" prototype:

typedef HRESULT (STDMETHODCALLTYPE 
*tSomeMethod)(ISomeInterface* pThis, int arg);

And its pointer is:

ISomeInterface* p;
tSomeMethod f = (tSomeMethod)(*(void***)p)[3];

where 3 is the index, in vtable order, of the method (you 
need to count the inherited methods).

More about this here:

http://groups.google.com/group/microsoft.public.windowsmedia.sdk/msg/e4eb055465c505bc

-- 
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
date: Mon, 4 Aug 2008 10:38:20 -0400   author:   Alessandro Angeli

Re: waveout/direct sound call to get audio output stream   
"Alessandro Angeli" wrote:

> From: "Derekm"
> 
> > Have you ever hooked a com interface before? Not sure if
> > it is possible! Derek.
> 
> What's the difference? You don't hook an interface, you hook 
> a specific method of an interface, which is no different 
> from any other function. You only need to know how to get a 
> pointer to the method (the compiler will not help you there) 
> and what the real prototype is.
> 
> For example:
> 
> class ISomeInterface : public IUnknown
> {
>   public: HRESULT STDMETHODCALLTYPE SomeMethod(int arg) = 0;
> };
> 
> The method has the following "real" prototype:
> 
> typedef HRESULT (STDMETHODCALLTYPE 
> *tSomeMethod)(ISomeInterface* pThis, int arg);
> 
> And its pointer is:
> 
> ISomeInterface* p;
> tSomeMethod f = (tSomeMethod)(*(void***)p)[3];
> 
> where 3 is the index, in vtable order, of the method (you 
> need to count the inherited methods).
> 
> More about this here:
> 
> http://groups.google.com/group/microsoft.public.windowsmedia.sdk/msg/e4eb055465c505bc
> 
> -- 
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> // http://www.riseoftheants.com/mmx/faq.htm 
> 
> 
> 
Thanks for your response - much appreciated, I also found a com example in 
the Detours package that demonstrates this. 

BTW the problem with the waveout hook code submitted by Rajani is in the 
file write function. The second parameter should be sizeof(char).

Derek
date: Mon, 4 Aug 2008 08:04:03 -0700   author:   Derekm

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us