Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 23:10

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

Advertisement



call function of injected dll

Discussion on call function of injected dll within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2006
Posts: 170
Received Thanks: 61
call function of injected dll

Hey guys,
i injected a dll which i want to use for custom packet sending to my game client. the problem now is how to use it.

the code of the dll is the following:

Code:
#include <Winsock2.h> 
#include <Windows.h> 
#include <fstream> 
#include <detours.h>

#pragma comment(lib, "detours.lib") 
#pragma comment(lib, "ws2_32.lib") 

using namespace std; 

ofstream out("C:\\logW32sock.txt", ios::out | ios::binary); 

DETOUR_TRAMPOLINE(int WINAPI Real_send(SOCKET a0, char* a1, int a2, int a3), send); 
DETOUR_TRAMPOLINE(int WINAPI Real_recv(SOCKET a0, char* a1, int a2, int a3), recv); 
DETOUR_TRAMPOLINE(int WINAPI Real_connect(SOCKET s,const struct sockaddr *name, int namelen), connect); 


void WriteLog(char FAR* buf, bool type); 

int WINAPI custom_send(SOCKET sock, char* buf, int len, int flags); 
int WINAPI custom_recv(SOCKET sock, char FAR* buf, int len, int flags); 
int WINAPI custom_connect(SOCKET s,const struct sockaddr *name, int namelen); 

char* TextToHex( char *text) 
{ 
    if (!text) return 0; 

    int len = strlen(text); 

    char *buffer = new char[2*len]+1; 
    if (!buffer) return 0; 

    for (int i=0; i<len; i++) 
        sprintf( buffer+2*i, "%x", (unsigned int) text[i]); 

    return buffer; 
} 
void InjNachricht()//der erstellte Thread
{
    MessageBox(0, L"Siehe da! Es klappt :P", L" Whohoo", 0);//4. Eine Message Box
}
void InjNachricht2()//der erstellte Thread
{
    MessageBox(0, L"Siehe da! Es klappt2 :P", L" Whohoo", 0);//4. Eine Message Box
}
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) 
{ 
    if ( reason == DLL_PROCESS_ATTACH ) 
    { 
		//3.erstelle einen SubProzess, der die übergebene Funktion ausführt
		CreateThread(0, 0, (LPTHREAD_START_ROUTINE) InjNachricht, 0, 0, 0);
        DetourFunctionWithTrampoline((PBYTE)Real_send,(PBYTE)custom_send);     
        DetourFunctionWithTrampoline((PBYTE)Real_recv,(PBYTE)custom_recv); 
        DetourFunctionWithTrampoline((PBYTE)Real_connect, (PBYTE)custom_connect); 
    } 
    else if ( reason == DLL_PROCESS_DETACH ) 
    { 
        DetourRemove((PBYTE)Real_send,(PBYTE)custom_send); 
        DetourRemove((PBYTE)Real_recv,(PBYTE)custom_recv); 
        DetourRemove((PBYTE)Real_connect, (PBYTE)custom_connect); 
        out.close(); 
    }     
    return true; 
} 

SOCKET mysock;
int WINAPI custom_send(SOCKET sock, char* buf, int len, int flags) 
{ 
	mysock = sock;
    WriteLog (buf, true); 
    return Real_send(sock, buf, len, flags); 
} 
int WINAPI custom_recv(SOCKET sock, char FAR* buf, int len, int flags) 
{ 
	mysock = sock;
    WriteLog (buf, false); 
    return Real_recv(sock, buf, len, flags); 
} 

int WINAPI custom_connect(SOCKET s, const struct sockaddr *name, int namelen) 
{ 
    return Real_connect(s, name, namelen); 
} 


void WriteLog(char FAR* buf, bool type) 
{ 
    if (type == true) 
    { 
        out << "SEND:" << TextToHex(buf) << "Socket" << mysock  << "\n\n\n\n";   
    } else 
    { 
        out << "RECIEVED: " << TextToHex(buf) << "Socket" << mysock  << "\n\n\n\n";   
    } 
}

my problem now is hpw to call a function to inject packets? i just know how to inject the dll but not how to call funtions of the injected dll. Maybe you can help me.
The Language im trying to call the functions from is c#

thanks in advance

Pain
Pain1234 is offline  
Old 09/22/2010, 00:38   #2
 
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
goodjob on copying stuff you do not understand.
MoepMeep is offline  
Old 09/22/2010, 06:03   #3
 
elite*gold: 0
Join Date: Jul 2010
Posts: 5
Received Thanks: 0
asdasdasdasd
mohamad ghonem is offline  
Old 09/22/2010, 13:22   #4
 
elite*gold: 0
Join Date: Nov 2005
Posts: 95
Received Thanks: 9


paste got a little messy. You should be able to do the Imports. yourself. Its merely a matter of p/invoking the right methods.

HWND is the processhandle that is used. Global variable. For now, i hardcoded the functionname to be "start". Change it in the method if you wish.
mgX is offline  
Reply


Similar Threads Similar Threads
Fatal error: Call to undefined function session_start() in /usr/local/www/apache22/d
04/03/2010 - Metin2 Private Server - 3 Replies
Fehler kann mir jmd. da helfen? Fatal error: Call to undefined function session_start() in /usr/local/www/apache22/data/regist_yes.php on line 50
Fatal error: Call to undefined function mysql_connect()
02/16/2010 - Metin2 Private Server - 3 Replies
hi elitepvpers da ich bei einem problem einfach nicht weiterkomme, hoffe ich hier hilfe zu finden. Ich habe auf FreeBsd Apache Mysql und Php installiert nun möchte ich eine page damit online stellen, die z.b. ein registrierungsformular besitzt und diese daten dann in ne mysql datenbank eingibt. ist zum accounts machen für ein game. wenn ich nun jedoch auf absenden gehe kommt folgender error:
Call Function in Process from another
09/04/2009 - General Coding - 7 Replies
Hi, how the topic says i'm wondering if it's possible to call an function from your application(no dll loaded from a loader) via jmp or call? example: i have app1 that has a function which opens a messagebox "Hello!". Now i'm tryin to call that function from another application while the app1 is running. thanks for your advice
[HELP-CO2] runtime error R6025 - pure virtual function call
05/31/2009 - CO2 Programming - 2 Replies
Hey guys, I know whats going wrong w/ my code, its described on a M$ website which follows. Description of the R6025 run-time error in Visual C++ And its all well and good to fix that problem in C++... but i'm not using c++ for that function call, i'm using assembly language. Namely the following...
Call COs jump function in masm?
10/28/2006 - Conquer Online 2 - 0 Replies
well i followed the tutorial on how to do this but it didnt give a very good masm example. how would i call the function in masm? does anyone have a good example or code? i have a bunch of other functions to use for hacks but i need to get this done first. im new to masm so i dont really know wat to do. i know how to call functions that dont have variables in other games but no clue when it comes to variables (x and y for jumping.) thanks, high6. p.s. here is the jump function location...



All times are GMT +1. The time now is 23:10.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.