• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help DLL Injector Fails [C++]
#1
Need help!
I have my little DLLInjector code and it can inject DLLs!
But...
it ONLY can inject a DLL in a process, when i already injected the DLL with Winject.
So i wrote a DLL to display a messageBox, when injected, and then ive tried to inject it to Notepad++...but it didnt work. But when i inject the DLL in notepad++ with Winject it works...and then when i try it with my Injector again it works, too o.0.

Also i cant inject the DLL to the basic notepad(not ++)...neither with my injector nor with Winject. Maybe because of 64bit stuff?
Anyways need help.

Here is the Injector source:

PHP Code:
#include <windows.h>
#include <tlhelp32.h>
#include <shlwapi.h>
#include "cus.h"

#define CREATE_THREAD_ACCESS (PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ)

using namespace std;

//für errorcode
DWORD dErr;
TCHAR sErrStatus[256];    
//

DWORD ProcID;
bool InjectSuccess;
bool hasProcID;

string sDLLStatus;
string sProcessStatus;
string sEndStatus "Press [F2] to quit";
string sCusInjectStatus "Press [F1] to inject DLL";

charDLLName NULL;
charProcName NULL;
string sProcName;
string sDLLName;

bool getProcID(charcPName,DWORD *idAdd);
bool InjectDLL(DWORD pID);
void UI();


int main()
{
    
eigen::central("----------DLL INJECTOR---------");
    
cout << endl;
    
eigen::central("by Tomsen1410");
    
cout << endl;
    
eigen::central("-------------------------------");
    
cout << endl;
    
cout << endl;
    
    
cout << "Type in process name: ";
    
cin >> sProcName;
    
ProcName = new char[sProcName.length()];
    
strcpy(ProcNamesProcName.c_str());
    
    
cout << endl;
    
cout << "Type in the DLL name: ";
    
cin >> sDLLName;
    
DLLName = new char[sDLLName.length()];
    
strcpy(DLLNamesDLLName.c_str());
    
    
sDLLStatus "-";
    
sProcessStatus "-";
    
UI();
    while(!
InjectSuccess){
    
        if(
GetAsyncKeyState(VK_F1))
        {    
            
hasProcID getProcID(ProcName,&ProcID);
            
InjectSuccess InjectDLL(ProcID);
            if(
InjectSuccess){sEndStatus "";sCusInjectStatus "";}
            
UI();
            
Sleep(100);
        }
        if(
GetAsyncKeyState(VK_F2))
        {    
            return 
0;
        }
    }
    
Beep(1600,200);
    
UI();
    
cout << endl << endl;
    
cout << "---INJECTED---"<<endl;
    for(
int i=3;i>0;i--){
        
cout << "Closing in " << << endl;
        
Sleep(1000);
    }

    
    return 
0;
}

bool getProcID(charcPName,DWORD *idAdd){

    
bool isHere;
    
PROCESSENTRY32 pe32;
    
HANDLE hSnapShot;

    
hSnapShot CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS0);
    if(
hSnapShot == INVALID_HANDLE_VALUE){
               
dErr GetLastError();
               
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEMNULLdErrMAKELANGID(LANG_NEUTRALSUBLANG_DEFAULT), (LPTSTR)sErrStatus,0,NULL);return false;}
    
pe32.dwSize sizeof(PROCESSENTRY32);

    
isHere Process32First(hSnapShot,&pe32);

    while(
isHere){

        if(
strcmp(cPName,pe32.szExeFile) == 0){
            *
idAdd pe32.th32ProcessID;
            
CloseHandle(hSnapShot);
            
sProcessStatus "--Fine--";
            return 
true;}
        
isHere Process32Next(hSnapShot,&pe32);
        
pe32.dwSize sizeof(PROCESSENTRY32);
    }

    
CloseHandle(hSnapShot);
    
sProcessStatus "Process not found!";


    return 
false;
}

bool InjectDLL(DWORD pID){


    
//check if DLL exists
    
ifstream fDLL(DLLName);
    if(!
fDLL){

            
sDLLStatus "File not found!";
            return 
false;}
    
   
HANDLE Proc;
   
HANDLE hWirt;
   
char buf[50]={0};
   
LPVOID RemoteStringLoadLibAddy;

   
Proc OpenProcess(CREATE_THREAD_ACCESSFALSEpID);

   if(!
Proc)
   {    
       
dErr GetLastError();
       
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEMNULLdErrMAKELANGID(LANG_NEUTRALSUBLANG_DEFAULT), (LPTSTR)sErrStatus,0,NULL);
       return 
false;
   }

   
LoadLibAddy = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
   if(
LoadLibAddy == NULL){
       
dErr GetLastError();
       
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEMNULLdErrMAKELANGID(LANG_NEUTRALSUBLANG_DEFAULT), (LPTSTR)sErrStatus,0,NULL);
       return 
false;}
   
RemoteString = (LPVOID)VirtualAllocEx(ProcNULLstrlen(DLLName)+1MEM_RESERVE|MEM_COMMITPAGE_READWRITE);
   if(
RemoteString == NULL){
       
dErr GetLastError();
       
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEMNULLdErrMAKELANGID(LANG_NEUTRALSUBLANG_DEFAULT), (LPTSTR)sErrStatus,0,NULL);
       return 
false;}
   if(
WriteProcessMemory(Proc, (LPVOID)RemoteStringDLLNamestrlen(DLLName)+1NULL) == 0){
       
dErr GetLastError();
       
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEMNULLdErrMAKELANGID(LANG_NEUTRALSUBLANG_DEFAULT), (LPTSTR)sErrStatus,0,NULL);
       return 
false;}
   
hWirt CreateRemoteThread(ProcNULLNULL, (LPTHREAD_START_ROUTINE)LoadLibAddy, (LPVOID)RemoteStringNULLNULL);
   if(
hWirt NULL){
       
dErr GetLastError();
       
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEMNULLdErrMAKELANGID(LANG_NEUTRALSUBLANG_DEFAULT), (LPTSTR)sErrStatus,0,NULL);
       return 
false;}
   
sDLLStatus "--Fine--";
   
CloseHandle(Proc);   
   return 
true;
}

//
void UI(){

    
system("CLS");
    
eigen::central("----------DLL INJECTOR---------");
    
cout << endl;
    
eigen::central("by Tomsen1410");
    
cout << endl;
    
eigen::central("-------------------------------");
    
cout << endl;
    
cout << endl;
    
cout << endl;
    
cout << sCusInjectStatus << endl;
    
cout << sEndStatus << endl << endl;
    
cout << "Process Status: " << sProcessStatus << endl;
    
cout << "DLL Status    : " << sDLLStatus << endl;
    if(
sErrStatus != ""){
        
cout << endl;
        
cout << "Error: " << sErrStatus;}



And here is the DLL source:
PHP Code:
#include "main.h"

BOOL WINAPI DllMain(HINSTANCE hinstDLLDWORD fdwReasonLPVOID lpvReserved)
{
    
MessageBoxA(0"test"""0);

    return 
TRUE;

[Image: ctoc.jpg]
  Reply
#2
im not experienced in this shit but maybe you must first open the offset or something like that?
  Reply
#3
Sorry, i only inject jelly. Tongue
[-] The following 4 users say Thank You to JellyInjector for this post:
  • iAegle, JariZ, kokole, OrangePL
  Reply
#4
(02-23-2012, 14:00)kokole Wrote: im not experienced in this shit but maybe you must first open the offset or something like that?

what do u mean with that? :>
[Image: ctoc.jpg]
  Reply
#5
no really... i dont know how to do that what u said^^
[Image: ctoc.jpg]
  Reply
#6
Try this

Console injector by PhyX

main.cpp
Code:
#include <windows.h>
#include <iostream>
#include <tlhelp32.h>
#define MAXWAIT 10000
#include "injection.h"

using namespace std;

int main()
{
    char exename[MAX_PATH];
    char dllname[MAX_PATH];

    cout << "Welcome to PhyX injector v1.0" << endl;
    Sleep(1000);
    cout << "Please enter dll name Example: c:\\PhyX.dll\n" << endl;
    cin >> dllname;
    cout << "Dll name is:" << dllname << endl;
    Sleep(1000);
    cout << " Please enter window name of the processor example:notepad " << endl;
    cin >> exename;
    cout << "Widnow name is" << exename << endl;
    Sleep(1000);

    BOOL bFound;
    PROCESSENTRY32 pe;
    HANDLE hSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    pe.dwSize=sizeof(pe);
    bFound=Process32First(hSnap,&pe);
    do {
        if (strstr(pe.szExeFile,exename)) {
            insertDll(pe.th32ProcessID, dllname); // c:\\PhyX.dll
            cout << "Injection successful!" << endl;
        }else{ cout << "Injection failed!" << endl; }

        pe.dwSize=sizeof(pe);
        bFound=Process32Next(hSnap,&pe);
    } while(bFound);
    getchar();
}

injection.h
Code:
bool insertDll(DWORD procID, char *dll)
{
    //Find the address of the LoadLibrary api, luckily for us, it is loaded in the same address for every process
    HMODULE hLocKernel32 = GetModuleHandle("Kernel32");
    FARPROC hLocLoadLibrary = GetProcAddress(hLocKernel32, "LoadLibraryA");

    HANDLE hProc = OpenProcess(PROCESS_CREATE_THREAD|PROCESS_QUERY_INFORMATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION, FALSE, procID);

    printf("prochandle %d %d\n",hProc,procID);
    //Allocate memory to hold the path to the Dll File in the process's memory

    LPVOID hRemoteMem = VirtualAllocEx(hProc, NULL,strlen( dll)+1, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
    printf("%x\n",hRemoteMem);

    //Write the path to the Dll File in the location just created
    WriteProcessMemory(hProc, hRemoteMem, dll, strlen(dll)+1,0);

    //Create a remote thread that starts begins at the LoadLibrary function and is passed are memory pointer
    HANDLE hRemoteThread = CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)hLocLoadLibrary, hRemoteMem, 0, NULL);

    //Release the handle to the other process
    CloseHandle(hProc);

    return 0;
}
  Reply
#7
thanks but thats nearly the same as mine Awesome
[Image: ctoc.jpg]
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Release] FXAA Injector Battlefield 3+Best Settings [Update danoc1 v1.3 Beta] iPaddie 31 51,770 08-30-2013, 00:51
Last Post: Squideh
  T0P 10ish Fails Stocker 1 666 01-04-2013, 01:28
Last Post: alvarogt95
  [Release] CS Injector Silencemod 14 3,829 11-08-2012, 08:48
Last Post: d0h!
  [Release] [C++]DLL Injector Tomsen1410 7 11,636 02-10-2012, 15:56
Last Post: Tomsen1410
Brick [Release] [FREE] Optimous dll Injector | Easy to use optimous 5 2,371 02-06-2012, 13:18
Last Post: SuperNovaAO
  [Release] FXAA Injector Battlefield 3 Mod JariZ 6 7,974 01-28-2012, 12:18
Last Post: iPaddie
  Help Gametype fails? iAegle 9 1,764 11-04-2011, 06:21
Last Post: Pozzuh
  Battlefield 3 Fails Elite_Nudel 20 7,079 10-31-2011, 13:10
Last Post: House
  Ninja fails Yamato 1 627 08-31-2011, 14:04
Last Post: Arteq
  Any1 hes working on a mod injector? Mikkelul 9 2,097 07-18-2011, 13:42
Last Post: d0h!

Forum Jump:


Users browsing this thread: 1 Guest(s)