Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 06:50

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



DirectInput Injected DLL

Discussion on DirectInput Injected DLL within the General Coding forum part of the Coders Den category.

Reply
 
Old 02/24/2012, 11:41   #16
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
So ich bin dann jetzt soweit , dass ich das GetDeviceState gehookt habe nur möchte ich jetzt auch gern eigene Keys senden. So wie ich das bisher verstanden habe wird GetDeviceState ja nur verwendet wenn auch eine Bewegung(Maus)/Tastaturdruck(Tasta...) stattgefunden hat oder liege ich da falsch?
wäre cool wenn mir jemand einen gedankenanstoß geben könnte
theredvex is offline  
Old 02/24/2012, 11:45   #17
 
elite*gold: 42
Join Date: Jun 2008
Posts: 5,426
Received Thanks: 1,888
Was wollt ihr alle immer mit Tastendrücken? Wollt ihr nicht ernstgenommen werden? :/ Such die entsprechenden Funktionen bzw hook/detour send und recv.
MoepMeep is offline  
Old 02/24/2012, 14:49   #18
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
GetDeviceState wird vermutlich in einer endlosschleife abgefragt.
wenn du eine taste simulieren möchtest, verfälschst du einfach beim nächsten aufruf deines hooks den übergebenen buffer.
Dr. Coxxy is offline  
Old 02/24/2012, 17:39   #19
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
HRESULT __stdcall hookedGetDeviceState(LPDIRECTINPUTDEVICE Device,DWORD dData,LPVOID lpvData)
{
//static BYTE buffer[256];
char* ptr = (char*)lpvData;
HRESULT temp = DI_OK;
temp = MyGetDeviceState(Device,dData,lpvData);
if(dData == 256)
{
ptr[DIK_E] = 0;
}
return temp;
}

müsste es durch diesen code nicht möglich sein keine E taste zuzulassen? bei mir geht es nämlich trotzdem noch <<
theredvex is offline  
Old 02/24/2012, 17:47   #20
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
ja, d.h.:
1. entweder du hast bei deinem hook was schiefgebaut.
2. das spiel hat zwar directinput drin, benutzt es aber nicht
3. das spiel macht doublechecks
4. das spiel hat deinen hook erkannt und wieder dehookt
5. etc...

schonmal ausgeben lassen ob/wie oft dein hook überhaupt aufgerufen wird?

es kann btw. gut sein, dass das chatsystem unabhängig vom directinput ist, also du im chatfenster immer noch E eingeben kannst, aber ingame hotkeys ignoriert werden etc...
Dr. Coxxy is offline  
Old 02/24/2012, 17:55   #21
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
Quote:
Originally Posted by Dr. Coxxy View Post
es kann btw. gut sein, dass das chatsystem unabhängig vom directinput ist, also du im chatfenster immer noch E eingeben kannst, aber ingame hotkeys ignoriert werden etc...
Das ist es auf jedenfall denn dort kann man sogar mit PostMessage arbeiten..
theredvex is offline  
Old 02/24/2012, 18:17   #22
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
Quote:
"schonmal ausgeben lassen ob/wie oft dein hook überhaupt aufgerufen wird?"
...
Dr. Coxxy is offline  
Old 02/24/2012, 18:23   #23
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
Quote:
Originally Posted by Dr. Coxxy View Post
...
Ja ich habe eine LogFunktion eingebaut.
Ich sehe das er jedesmal die dData/cbData mit 256 ausgibt. dehooked wird das ganze auch nicht denn ich sehe nebenbei wie die Log größer wird.

aber eine andere frage habe ich die richtigen overloads für die Funktion? ich hab im internet ein paar seiten gefunden wo das nur mit cbData und lpvData angegeben wird. quasi ohne Device
theredvex is offline  
Old 02/24/2012, 18:30   #24
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
ja, ist richtig, wenn du das tut aufmerksam gelesen hättest wüsstest du auch warum.
Dr. Coxxy is offline  
Old 02/24/2012, 19:36   #25
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
Quote:
Originally Posted by Dr. Coxxy View Post
ja, ist richtig, wenn du das tut aufmerksam gelesen hättest wüsstest du auch warum.
So ich hab mir jetzt auch mal die lpvData Loggen lassen.. da ist mir aufgefallen, dass es nur 1x Loggt wenn ich das Fenster Aktiviere.
Wenn ich im Spiel einfach 10x hintereinander W drücke loggt er nichts. heißt das, dass das spiel doch kein DInput zum bewegen nimmt??
theredvex is offline  
Old 02/24/2012, 20:42   #26
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
getdevicestate sollte mehrmals in der sekunde aufgerufen werden, nicht wenn du eine taste drückst oder sonstwas machst.
entweder bei deinem hook läuft gehörig was schief, oder das spiel benutzt directinput nur sporadisch für i-etwas.
kannst ja mal den ganzen buffer jedes mal NULLen und gucken, ob sich i-was ändert.
Dr. Coxxy is offline  
Old 02/28/2012, 19:40   #27
 
elite*gold: 0
Join Date: Dec 2011
Posts: 35
Received Thanks: 123
das Ganze könnte etwa sp ausehn fals das spiel dinput8.dll zum abfragen der tasten nutzt
Code:
#pragma once
 
#define _CRT_SECURE_NO_WARNINGS								// ignore some warnings...
#define _CRT_NON_CONFORMING_SWPRINTFS						// ...
 
#include <Windows.h>
#include <cstdio>
#include <time.h> 
#include <dinput.h>
 
const DWORD GDS_OFFSET = 0x62B1;
 
DWORD WINAPI HookThread();
void* DetourFunc(BYTE *src, const BYTE *dst, const int len);
void add_log(char* format, ...);
 
typedef HRESULT(__stdcall* GetDeviceState_t)(LPDIRECTINPUTDEVICE, DWORD, LPVOID);
HRESULT __stdcall hkGetDeviceState(LPDIRECTINPUTDEVICE pDevice, DWORD cbData, LPVOID lpvData);
 
HANDLE tmpHandle = NULL;
HMODULE hModDInput8 = NULL;
FARPROC dwGetDeviceState = NULL;
FARPROC dwDirectInput8Create = NULL;
 
GetDeviceState_t pGetDeviceState;
 
BOOL WINAPI DllMain(HINSTANCE hinstDll,DWORD Reason,LPVOID Reserved)
{
	switch(Reason)
	{
		case DLL_PROCESS_ATTACH:
			add_log("==========LOG START==========");
			add_log("DLL Attached");
			add_log("Creating Thread...");
			tmpHandle = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&HookThread, 0, 0, 0);
			if (!tmpHandle)
			{
				add_log("ThreadCreation Failed!");
			}
			break;
		case DLL_PROCESS_DETACH:
			add_log("DLL Detached");
			add_log("==========LOG END==========\n\n\n");
			break;
	}
	return 1;
}
 
 
DWORD WINAPI HookThread()
{
	add_log("Thread Created");
 
	while (!hModDInput8)
	{
		add_log("Searching dinput8.dll...");
		hModDInput8 = GetModuleHandle(L"dinput8.dll");
		Sleep(100);
	}
	add_log("Found dinput8.dll: %x !", hModDInput8);
 
	while (!dwDirectInput8Create)
	{
		add_log("Searching GetDeviceState...");
		dwDirectInput8Create = GetProcAddress(hModDInput8, "DirectInput8Create");
		Sleep(100);
	}
	add_log("Found DirectInput8Create: %x !", dwDirectInput8Create);
 
	dwGetDeviceState = (FARPROC) ((DWORD)dwDirectInput8Create - GDS_OFFSET);
	add_log("GetDevicestate is here (DirectInput8Create - 0x62B1): %x", dwGetDeviceState);
 
	add_log("Hooking GetDeviceState...");
	pGetDeviceState = (GetDeviceState_t) DetourFunc((PBYTE) dwGetDeviceState, (PBYTE) hkGetDeviceState, 5);
	add_log("Hooked GetDeviceState - Trampolin: %x - New: %x !", pGetDeviceState, hkGetDeviceState);
 
	add_log("Going into Main Loop...");
	while (true)
	{
		// ...
		Sleep(1000);
	}
	return 0;
}
 
HRESULT __stdcall hkGetDeviceState(LPDIRECTINPUTDEVICE lpDevice, DWORD cbData, LPVOID lpvData)	// Parameter: die device - die größe der daten - der buffer in den geschrieben wird
{
	HRESULT temp = NULL;
	char* ptr = (char*) lpvData;
	temp = pGetDeviceState(lpDevice, cbData, lpvData);			// originalfunktion aufrufen
	if (cbData == 256) // wenn eine keyboard abfrage stattfindet... siehe: http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.idirectinputdevice8.idirectinputdevice8.getdevicestate%28v=VS.85%29.aspx
	{
		// memset(lpvData, 0, cbData);								// buffer leeren -> keine taste gedrückt
		ptr[DIK_E] = 0;												// um z.b. die taste E komplett zu blocken...
	}
	return temp;
}
 
 
void* DetourFunc(BYTE *src, const BYTE *dst, const int len)		//saved <len> bytes in ein trampolin, überschreibt die ersten 5 bytes der originalfunktion mit einem jump auf die hookfunktion und gibt einen pointer auf das trampolin zurück, der die gesicherten bytes und einen jump auf die originalfunktion NACH dem hook beinhaltet.
{
	BYTE *jmp = (BYTE*)malloc(len+5);
	DWORD dwback;
	VirtualProtect(src, len, PAGE_READWRITE, &dwback);
	memcpy(jmp, src, len);
	jmp += len;
	jmp[0] = 0xE9;
	*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
	src[0] = 0xE9;
	*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
	VirtualProtect(src, len, dwback, &dwback);
	return (jmp-len);
}
 
 
void add_log(char* format, ...)
{
	HANDLE filehandle;
	DWORD dwReadBytes;
	char buffer[2048];
	char writebuffer[2048];
	va_list args;
	va_start(args, format);
	vsprintf (buffer, format, args);
	filehandle = CreateFile(L"Log.txt", GENERIC_WRITE, 0, 0, OPEN_ALWAYS, 0, 0);
	SetFilePointer(filehandle, 0, 0, FILE_END);
	char date[18];
	_strdate(date);
	date[8] = ' ';
	_strtime(date+9);
	sprintf_s(writebuffer, 2048, "Log Added (%s): %s\r\n", date, buffer);
	WriteFile(filehandle, writebuffer, strlen(writebuffer), &dwReadBytes, 0);
	CloseHandle(filehandle);
und kommunizieren könntest du über eine pipe

ps der code ist aus
insert-name-here is offline  
Old 02/28/2012, 20:38   #28
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
Quote:
Originally Posted by insert-name-here View Post
das Ganze könnte etwa sp ausehn fals das spiel dinput8.dll zum abfragen der tasten nutzt
Code:
#pragma once
 
#define _CRT_SECURE_NO_WARNINGS                                // ignore some warnings...
#define _CRT_NON_CONFORMING_SWPRINTFS                        // ...
 
#include <Windows.h>
#include <cstdio>
#include <time.h> 
#include <dinput.h>
 
const DWORD GDS_OFFSET = 0x62B1;
 
DWORD WINAPI HookThread();
void* DetourFunc(BYTE *src, const BYTE *dst, const int len);
void add_log(char* format, ...);
 
typedef HRESULT(__stdcall* GetDeviceState_t)(LPDIRECTINPUTDEVICE, DWORD, LPVOID);
HRESULT __stdcall hkGetDeviceState(LPDIRECTINPUTDEVICE pDevice, DWORD cbData, LPVOID lpvData);
 
HANDLE tmpHandle = NULL;
HMODULE hModDInput8 = NULL;
FARPROC dwGetDeviceState = NULL;
FARPROC dwDirectInput8Create = NULL;
 
GetDeviceState_t pGetDeviceState;
 
BOOL WINAPI DllMain(HINSTANCE hinstDll,DWORD Reason,LPVOID Reserved)
{
    switch(Reason)
    {
        case DLL_PROCESS_ATTACH:
            add_log("==========LOG START==========");
            add_log("DLL Attached");
            add_log("Creating Thread...");
            tmpHandle = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&HookThread, 0, 0, 0);
            if (!tmpHandle)
            {
                add_log("ThreadCreation Failed!");
            }
            break;
        case DLL_PROCESS_DETACH:
            add_log("DLL Detached");
            add_log("==========LOG END==========\n\n\n");
            break;
    }
    return 1;
}
 
 
DWORD WINAPI HookThread()
{
    add_log("Thread Created");
 
    while (!hModDInput8)
    {
        add_log("Searching dinput8.dll...");
        hModDInput8 = GetModuleHandle(L"dinput8.dll");
        Sleep(100);
    }
    add_log("Found dinput8.dll: %x !", hModDInput8);
 
    while (!dwDirectInput8Create)
    {
        add_log("Searching GetDeviceState...");
        dwDirectInput8Create = GetProcAddress(hModDInput8, "DirectInput8Create");
        Sleep(100);
    }
    add_log("Found DirectInput8Create: %x !", dwDirectInput8Create);
 
    dwGetDeviceState = (FARPROC) ((DWORD)dwDirectInput8Create - GDS_OFFSET);
    add_log("GetDevicestate is here (DirectInput8Create - 0x62B1): %x", dwGetDeviceState);
 
    add_log("Hooking GetDeviceState...");
    pGetDeviceState = (GetDeviceState_t) DetourFunc((PBYTE) dwGetDeviceState, (PBYTE) hkGetDeviceState, 5);
    add_log("Hooked GetDeviceState - Trampolin: %x - New: %x !", pGetDeviceState, hkGetDeviceState);
 
    add_log("Going into Main Loop...");
    while (true)
    {
        // ...
        Sleep(1000);
    }
    return 0;
}
 
HRESULT __stdcall hkGetDeviceState(LPDIRECTINPUTDEVICE lpDevice, DWORD cbData, LPVOID lpvData)    // Parameter: die device - die größe der daten - der buffer in den geschrieben wird
{
    HRESULT temp = NULL;
    char* ptr = (char*) lpvData;
    temp = pGetDeviceState(lpDevice, cbData, lpvData);            // originalfunktion aufrufen
    if (cbData == 256) // wenn eine keyboard abfrage stattfindet... siehe: http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.idirectinputdevice8.idirectinputdevice8.getdevicestate%28v=VS.85%29.aspx
    {
        // memset(lpvData, 0, cbData);                                // buffer leeren -> keine taste gedrückt
        ptr[DIK_E] = 0;                                                // um z.b. die taste E komplett zu blocken...
    }
    return temp;
}
 
 
void* DetourFunc(BYTE *src, const BYTE *dst, const int len)        //saved <len> bytes in ein trampolin, überschreibt die ersten 5 bytes der originalfunktion mit einem jump auf die hookfunktion und gibt einen pointer auf das trampolin zurück, der die gesicherten bytes und einen jump auf die originalfunktion NACH dem hook beinhaltet.
{
    BYTE *jmp = (BYTE*)malloc(len+5);
    DWORD dwback;
    VirtualProtect(src, len, PAGE_READWRITE, &dwback);
    memcpy(jmp, src, len);
    jmp += len;
    jmp[0] = 0xE9;
    *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
    src[0] = 0xE9;
    *(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
    VirtualProtect(src, len, dwback, &dwback);
    return (jmp-len);
}
 
 
void add_log(char* format, ...)
{
    HANDLE filehandle;
    DWORD dwReadBytes;
    char buffer[2048];
    char writebuffer[2048];
    va_list args;
    va_start(args, format);
    vsprintf (buffer, format, args);
    filehandle = CreateFile(L"Log.txt", GENERIC_WRITE, 0, 0, OPEN_ALWAYS, 0, 0);
    SetFilePointer(filehandle, 0, 0, FILE_END);
    char date[18];
    _strdate(date);
    date[8] = ' ';
    _strtime(date+9);
    sprintf_s(writebuffer, 2048, "Log Added (%s): %s\r\n", date, buffer);
    WriteFile(filehandle, writebuffer, strlen(writebuffer), &dwReadBytes, 0);
    CloseHandle(filehandle);
und kommunizieren könntest du über eine pipe

ps der code ist aus
Ist alles logisch. mein Code sieht sogar teilweise so aus. habe mittlerweile aber rausgefunden, dass das Spiel die "GetDeviceData"-Funktion ausnutzt.

bin nur leider noch nicht schlauer wie ich da jetzt Tasten sende
theredvex is offline  
Old 03/01/2012, 14:46   #29
 
elite*gold: 0
Join Date: Dec 2011
Posts: 35
Received Thanks: 123
also in den obigen fall war sieht das senden glaub so aus
ptr[DIK_F1] |= 1<<7;
insert-name-here is offline  
Old 03/01/2012, 23:41   #30


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,904
Received Thanks: 25,394
^Exakt.

Ob eine Taste gedrückt ist, sieht man nämlich daran, dass ptr[DIK_CODE] & 0x80 true ergibt; der obige Code setzt die Bits genau so, dass dies zutrifft.
MrSm!th is offline  
Reply


Similar Threads Similar Threads
DirectInput hook
09/01/2013 - General Coding - 9 Replies
Da die Frage in einem anderen Thread aufkam, benutzt ihr fremde Libraries um einen Hook durchzuführen und wenn ja welche ? Kann man damit HackShield oder GameGuard umgehen und einen Bot mit virtuellen Tastendrücken ansteuern?
injected
09/13/2011 - DarkOrbit - 3 Replies
i injected bonus box. Vacuum Roscatel Xml To İbot 3.20 and i have Lisence its safe ? in 1 hour 4900 uri minumum. but im afraid. İts safe? R
Making a bot: DirectInput
08/16/2010 - Perfect World - 2 Replies
I have been looking for the place where it checks the keyboard for keypresses, but I haven't been able to get there yet. It's probably not done in the Elementclient.exe, but in one of the dlls. (ifc22, or immwrapper.dll). I'm pretty sure it uses DirectInput (it loads dinput.dll). I need this because I want to make a bot in C++ and don't want to send keystrokes to the client, so that it is easy to use. I have found the virtual mouse function in ifc22.dll: .text:10012A40 ; public:...
CA Injected v4
06/19/2010 - Combat Arms - 9 Replies
Hi, Habe das neulich im Netz gefunden. Sollte UD sein, war aber keine Readme dabei! Hier ein Screen: http://3.bp.blogspot.com/_Kp_8Vpy1lj4/SujMfUtT7mI /AAAAAAAAAqY/jUns53uXeAo/s1600/Engine%2B2009-10-28 %2B18-42-53-26.jpg Das sind nur Chams... kein Aimbot!



All times are GMT +2. The time now is 06:50.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.