Mumble & Injection menu

User Tag List

Results 1 to 2 of 2
  1. #1
    PyGuy's Avatar Corporal
    Reputation
    14
    Join Date
    Jan 2011
    Posts
    20
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mumble & Injection

    I know how to inject a DLL using VirtualAllocEx and CreateRemoteThread. The trouble with this is that in order to hook EndScene, you need to know where the target application stores its pointer to the D3D9 device. While this isn't too big an issue for WoW, it can cause trouble in some other apps.

    Mumble takes a different approach with its overlay. (Mumble is a open source competitor to Ventrilo.) It hooks Direct3DCreate9 and Direct3DCreate9Ex and then after the device is created, it hooks a number of vtable functions off the device, including reference counting and Present. Mumble can then use the Present hook to draw the user that's currently speaking, who's in channel, etc. over top of any D3D9 application.

    All the source is available for browsing here. I'd like to do something similar, but I'm having trouble figuring out how its actually injecting the mumble_ol.dll (which contains the overlay code) into other processes. I THOUGHT it was using a windows hook:
    Code:
    extern "C" __declspec(dllexport) void __cdecl RemoveHooks() {
    	DWORD dwWaitResult = WaitForSingleObject(hHookMutex, 1000L);
    	if (dwWaitResult == WAIT_OBJECT_0) {
    		if (sd->bHooked) {
    			if (hhookWnd) {
    				UnhookWindowsHookEx(hhookWnd);
    				hhookWnd = NULL;
    			}
    			sd->bHooked = false;
    		}
    		ReleaseMutex(hHookMutex);
    	}
    }
    
    extern "C" __declspec(dllexport) void __cdecl InstallHooks() {
    	DWORD dwWaitResult = WaitForSingleObject(hHookMutex, 1000L);
    	if (dwWaitResult == WAIT_OBJECT_0) {
    		if (! sd->bHooked) {
    			GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (char *) &InstallHooks, &hSelf);
    			if (hSelf == NULL) {
    				ods("Lib: Failed to find myself");
    			} else {
    				hhookWnd = SetWindowsHookEx(WH_CBT, CallWndProc, hSelf, 0);
    				if (hhookWnd == NULL)
    					ods("Lib: Failed to insert WNDProc hook");
    			}
    
    			sd->bHooked = true;
    		}
    		ReleaseMutex(hHookMutex);
    	}
    }
    The trouble is that CallWndProc doesn't DO anything except continue the chain:
    Code:
    static LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam) {
    	return CallNextHookEx(hhookWnd, nCode, wParam, lParam);
    }
    I've confirmed in other files that InstallHooks() and RemoveHooks() are called at startup and shutdown, but I can't find any place where this would result in code being run in another address space. I expected that CallWndProc would look for a HCBT_CREATEWND event and then use GetWindowThreadProcessId on the window handle to get the process ID and perform normal injection stuff from there, but it doesn't do that.

    I did find the following function that is called from the main setup routine:
    Code:
    OverlayPrivateWin::OverlayPrivateWin(QObject *p) : OverlayPrivate(p) {
    	QString path=QString::fromLatin1("%1/mumble_ol.dll").arg(qApp->applicationDirPath());
    
    	qlOverlay = new QLibrary(this);
    	hpInstall = NULL;
    	hpRemove = NULL;
    
    	qlOverlay->setFileName(path);
    	if (! qlOverlay->load()) {
    		QMessageBox::critical(NULL, QLatin1String("Mumble"), tr("Failed to load overlay library. This means either that:\n"
    		                      "- the library (mumble_ol.dll) wasn't found in the directory you ran Mumble from\n"
    		                      "- you're on an OS earlier than WinXP SP2"), QMessageBox::Ok, QMessageBox::NoButton);
    		qWarning("Overlay failure");
    		return;
    	}
    
    	GetOverlayMagicVersionProc gompvp = (GetOverlayMagicVersionProc)qlOverlay->resolve("GetOverlayMagicVersion");
    	if (! gompvp)
    		return;
    
    	if (gompvp() != OVERLAY_MAGIC_NUMBER)
    		return;
    
    	hpInstall = (HooksProc)qlOverlay->resolve("InstallHooks");
    	hpRemove = (HooksProc)qlOverlay->resolve("RemoveHooks");
    	PrepProc pp = (PrepProc) qlOverlay->resolve("PrepareD3D9");
    	PrepDXGIProc pdxgi = (PrepDXGIProc) qlOverlay->resolve("PrepareDXGI");
    
    	if (pp)
    		pp();
    
    	if (pdxgi)
    		pdxgi();
    }
    To me, it looks like its loading the mumble_ol.dll into the main mumble's address space and then installing the various hooks there. PrepareD3D9 is the function that installs hooks for Direct3DCreate9 and Direct3DCreate9Ex.

    The only thing I can think of is that installing the Direct3DCreate9 and Direct3DCreate9Ex hooks against the D3D9.dll in its own application, this allows the hooks to be executed in other processes as well, but that really doesn't make sense to me. Does anyone have any insights here?

    Mumble & Injection
  2. #2
    PyGuy's Avatar Corporal
    Reputation
    14
    Join Date
    Jan 2011
    Posts
    20
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the answer... the action of installing a global hook via SetWindowsHookEx causes every application to load the DLL where SetWindowsHookEx is called from. The mumble_ol.dll has a DllMain function which will get called on load. This, in turn, hooks LoadLibrary and LoadLibraryA to determine when D3D9.dll is loaded and then hooks Direct3DCreate9 / Direct3DCreate9Ex.

Similar Threads

  1. [Model Injection] Bobble Head
    By Glitchy in forum World of Warcraft Model Editing
    Replies: 16
    Last Post: 02-18-2008, 08:17 PM
  2. Giant Speakers Or Amps
    By Dhorak in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 08-25-2007, 12:00 AM
  3. Packet Injecting Items
    By yungen2003 in forum World of Warcraft General
    Replies: 7
    Last Post: 08-07-2007, 07:02 AM
  4. Using DLL's to inject values without CE.
    By Matsy in forum World of Warcraft Bots and Programs
    Replies: 7
    Last Post: 06-29-2007, 02:26 PM
  5. [Bot] Anti-AFK Bot (No Injection & Focus not Needed)
    By Cypher in forum World of Warcraft Bots and Programs
    Replies: 12
    Last Post: 09-10-2006, 11:14 AM
All times are GMT -5. The time now is 06:32 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search