Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation #2

Open
LennyPenny opened this issue Oct 23, 2016 · 6 comments
Open

Documentation #2

LennyPenny opened this issue Oct 23, 2016 · 6 comments

Comments

@LennyPenny
Copy link

LennyPenny commented Oct 23, 2016

Hey,
I couldn't find a way to contact you so I will ask here.
Could you supply any documentation on how to use this? I tried to play around with the code but it doesn't really seem finished

@0of
Copy link
Owner

0of commented Oct 24, 2016

Hi Lenny,

It's just a experimental project and more complex than it may seem.
Besides, the mixing result is not so good and still missing some clean-up procedures when hook's done.

If you still want to play around with the code, here're some workflows I illustrated below

Overview

The whole system is consisted of three logic modules: hook manager, audio input stream mixer and audio output streams(being hooked processes). In normal case hook manager and input stream mixer can be combined into one executive as the server, and the clients would be the running processes attached by standalone hook DLL.

  • To build hook DLL

Build the source code from dir audiohook and audiostream. audiostream is kind of shared source and both server and client sides depend on it. You can either build a standalone DLL from audiostream and import the APIs or directly integrate all the sources into audiohook

  • Setup server main.cpp
#include "hookserver.h"
#include "audiostream/include/AudioMixer.h"

// Instantiate HookTask  (@param offset LoadLibraryW  RVA)
...
// Invoke _Run_ and return hooked corresponding process info if no exception been thrown
...

auto mixer = new AudioMixer;
// waveInfo your wave format
mixer->Open(&waveInfo,  waveFilePath);

// Instantiate  AudioInputStream  for each hooked process
for (…) {
  auto stream = new AudioInputStream ;
  stream->Open("audiohook", pid); 
  mixer->AddStream(stream);
}
// record into wave file until you stop the process
mixer->Update();    

Sorry for late reply and I devote too much time to civilization 6 great game though

@0of
Copy link
Owner

0of commented Oct 24, 2016

I forget to say you need to remove some pieces of code for building

// file hookserver.h L:6
#include "Promise.h"

// file hookserver.h L:14
: public Task<HookedProcess>

// file hookserver.h L:34
: public Task<void>

Promise is another async calling framework

@LennyPenny
Copy link
Author

I figured taking out the promise stuff myself 8)
Another question though: Can I choose the waveformat myself or do I have to use the same as the hooked source stream?

@0of
Copy link
Owner

0of commented Oct 24, 2016

Awkwardly yes or no... yes for it's originally designed for multi source streams mixing into one stream with format conversions. And no for i just find some format conversion bugs by revisiting the code.

You can look into this method _AppendBuffer which reads incoming buffer and converts to your desired format

@LennyPenny
Copy link
Author

LennyPenny commented Oct 24, 2016

I follwed your steps, except the
@param offset LoadLibraryW RV
because I have no idea what it means
This is what I'm getting

https://aww.moe/yuldwm.png

Using another injector lib I had lying around I got it injected, but the program I'm trying to capture just hanged and the hookserver just exited. It did save a corrupted 44 byte file however!

Ok through advanced out-commenting of code I came to the conclusion that the hang is caused by the DirectSoundCreate call in audiohook.dll

@0of
Copy link
Owner

0of commented Oct 25, 2016

Sorry my bad
The offset (last parameter of HookTask ctor) needs to be the symbol LoadLibrary's relative virtual address to the kernel32.dll cuz when injecting, injector will create a remote thread by given specific PID and the thread procedure is LoadLibrary which is about to loading audiohook.dll. Since ASLR is enabled the real virtual address needs to be re-caculated by given offset parameter.

This program is intended to run on WinXP cuz later Windows versions officially provide audio hook and mixer APIs

Eh, I don't know what you're trying to achieve and maybe i could give you some help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants