Xentales

Talk about stuff, and if you must, about Xenimus
It is currently 28 Jun 2017 23:48

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Xenimus & Sound
PostPosted: 14 Jun 2013 02:48 
Offline
User avatar

Joined: 30 Apr 2013 00:03
Posts: 221
Well this is a question for anyone to answer, but i think only a few people here (that rarely check here) can answer.


How does xenimus play sound?

I have attempted to hook DirectSound and it seems to never call any functions OTHER then the directsoundcreate8 function.

I was hoping i could hook the SetVolume() function, but it seems he never calls anything. There is a DLL that gets loaded call AUDIOSES.dll, i have not looked into this yet but maybe he uses some other method of playing sound?

Anyone have any ideas on this?


Top
 Profile  
 
 Post subject: Re: Xenimus & Sound
PostPosted: 14 Jun 2013 13:44 
Offline

Joined: 05 Nov 2007 11:14
Posts: 107
Uses DSOUND8. It's a COM interface, you need to override the interface to get into it.


Top
 Profile  
 
 Post subject: Re: Xenimus & Sound
PostPosted: 14 Jun 2013 17:39 
Offline
User avatar

Joined: 30 Apr 2013 00:03
Posts: 221
Im not at home so I cant check right now, but is dsound8 a part of the dsound.dll and layed out in dsound.h?

I hooked DirectSoundCreate8 and tried to use vtables to hook the other functions but to no avail. Ill dig around the sdk and online more tonight I guess to see what else I can find.


EDIT: Im...Im an idiot. Lol starting to get things working now. My mistake.


Top
 Profile  
 
 Post subject: Re: Xenimus & Sound
PostPosted: 14 Jun 2013 22:34 
Offline
User avatar

Joined: 30 Apr 2013 00:03
Posts: 221
Annnnd DONE! Once i got past the first hurdle of trying to get the CORRECT vtable addresses, it was much easier.


I plan to put this into my next version of xenscan, allowing people to ACTUALLY control the volume of the freaking game. I see people ask all the time how to mute the game since EJ's controls in the option menu doesnt actually mute the game.

Andy, feel free to steal this, mod this, do whatever with it.


As for volume level, -10000 is silent. At full volume, stuff like button clicks and stuff are at about -3000.


Code:
LPDIRECTSOUND8 hDS8;
LPDIRECTSOUNDBUFFER8 hDSB8;
bool svHook = false;

typedef HRESULT (WINAPI* tDirectSoundCreate8)(LPCGUID lpcGuidDevice, LPDIRECTSOUND8 * ppDS8, LPUNKNOWN pUnkOuter);
tDirectSoundCreate8 oDirectSoundCreate8 = NULL;

typedef HRESULT (__stdcall* tCreateSoundBuffer)(void *pthis, LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER8 *ppDSBuffer, LPUNKNOWN pUnkOuter);
tCreateSoundBuffer oCreateSoundBuffer = NULL;

typedef HRESULT (__stdcall* tSetVolume)(void *pthis, LONG lVolume);
tSetVolume oSetVolume = NULL;


HRESULT __stdcall hkSetVolume(void *pthis, LONG lVolume)
{
   HRESULT ret = oSetVolume(pthis, lVolume);
   printf("SetVolume Called with %i\n", lVolume);
   return ret;
}

HRESULT __stdcall hkCreateSoundBuffer(void *pthis, LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER8 *ppDSBuffer, LPUNKNOWN pUnkOuter)
{
   HRESULT ret;
   if(!svHook && pcDSBufferDesc->dwBufferBytes != 0) //The != 0 is so we dont catch the primary buffer. Not sure if this is necessary but meh
      ret = oCreateSoundBuffer(pthis, pcDSBufferDesc, &hDSB8, pUnkOuter);
      *ppDSBuffer = hDSB8;
      DWORD* pVTable = (DWORD*)hDSB8;
      pVTable = (DWORD*)pVTable[0];

      printf("CreateSoundBuffer hooked\n");

      oSetVolume = (tSetVolume)DetourFunction((PBYTE)pVTable[15], (PBYTE)hkSetVolume);

      svHook = true;
   }
   else
   {
      ret = oCreateSoundBuffer(pthis, pcDSBufferDesc, ppDSBuffer, pUnkOuter);
   }
   return ret;
}

HRESULT WINAPI hkDirectSoundCreate8(LPCGUID lpcGuidDevice, LPDIRECTSOUND8 * ppDS8, LPUNKNOWN pUnkOuter)
{
   HRESULT ret = oDirectSoundCreate8(lpcGuidDevice, &hDS8, pUnkOuter);

   *ppDS8 = hDS8;

   printf("DirectSoundCreate8 Hooked\n");

   DWORD* pVTable = (DWORD*)hDS8;
   pVTable = (DWORD*)pVTable[0];

   oCreateSoundBuffer = (tCreateSoundBuffer)DetourFunction((PBYTE)pVTable[3], (PBYTE)hkCreateSoundBuffer);

   return ret;
}

DWORD WINAPI dsoundhook(LPVOID lpBuffer)
{
   HMODULE hD3D9 = GetModuleHandle("dsound.dll");
   PBYTE pD3D9Create = (PBYTE)GetProcAddress(hD3D9, "DirectSoundCreate8");
   oDirectSoundCreate8 = (tDirectSoundCreate8)DetourFunction(pD3D9Create, (PBYTE)hkDirectSoundCreate8);
   return 0;
}


Top
 Profile  
 
 Post subject: Re: Xenimus & Sound
PostPosted: 18 Jun 2013 19:51 
Offline
User avatar

Joined: 13 Mar 2008 16:45
Posts: 61
f- awesome. I will donate to xenscan soon.

Could you update beingable to add/remove items that show up... I dont like seeing Vis bart scrolls and keys =D if you had a menu for this it'd be f- awesome.

_________________
Image>Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group