Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Injeccion Dll without dll

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Morph.C
Cheater
Reputation: 0

Joined: 15 Aug 2009
Posts: 29

PostPosted: Mon Sep 07, 2009 11:27 am    Post subject: Injeccion Dll without dll Reply with quote

Hello everyone, this time I found a E0N code, the programmer, it's about dll injection, no dll.

Someone could spend this code to C#, (original version is in C++)?, It gives me errors!

Sad! Thanks in advanced, code the here:

Code:
#pragma hdrstop
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>

//We create a pointer to the api that we inject
typedef int (WINAPI *datMessageBoxA) (HWND, LPCTSTR, LPCTSTR, UINT);

//the esctructure to inyect
struct datos
{
datMessageBoxA apiMessageBoxA;
char titulo [100];
char mensaje [100];
};


//declarating functions
DWORD GetAdres(char *module, char *function);

//the function to inyect
DWORD inyectada (datos *data)
{
data -> apiMessageBoxA (0, data->mensaje, data->titulo, 0);
return 0;
}

//inject function
void inyectora()
{
int pid;//This is the pid of the process in which you want to inject
HANDLE proc; //The handle of the process in which inject
datos dat; //The data type of the structure
DWORD TamFun; //The size of the function to inject
void* esp; // Memory location where we will copy our role
buscar

HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); //Get the PID
PROCESSENTRY32 procinfo = { sizeof(PROCESSENTRY32) };
while(Process32Next(handle, &procinfo))
{
if(!strcmp(procinfo.szExeFile, "notepad.exe"))
{
CloseHandle(handle);
pid = procinfo.th32ProcessID;
}
}
CloseHandle(handle);

//We open the process in which we inject

proc = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_VM_WRITE, false, pid);

//We put the address of the api in the structure function calling to GetAdres
dat.apiMessageBoxA = (datMessageBoxA) GetAdres ("USER32.DLL", "MessageBoxA");

//Inicializamos las variables que contendrán el mensaje
sprintf(dat.mensaje,"inyeccion Complete :D");
sprintf(dat.titulo,"Hiii");


//Reserve space for our structure in the process to inject and write
datos *dat_ = (datos*) VirtualAllocEx(proc, 0, sizeof(datos), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(proc, dat_, &dat, sizeof(datos), NULL);

//We estimate the size of the function to inject.
TamFun = (long unsigned int) inyectora - (long unsigned int)inyectada;

//Reserve space for the function, write it and create a thread
esp = VirtualAllocEx(proc, 0, TamFun, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
WriteProcessMemory(proc, esp, (void*)inyectada, TamFun, NULL);
CreateRemoteThread(proc, NULL, 0, (LPTHREAD_START_ROUTINE) esp, dat_, 0, NULL);
}

void main()
{
inyectora();
}

// Function returns a DWORD us with the address of an API
DWORD GetAdres(char *module, char *function)
{
HMODULE dh = LoadLibrary(module);
DWORD pf = (DWORD)GetProcAddress(dh,function);
FreeLibrary(dh);
return pf;
}



well, that's my problem, this code injects a msgbox, I want to change the values in the memory of notepad, how do I do?.

I want to do it the same way in which the msgbox was performed, because if I do it with notepad, i can do with other processes.

Thanks in advance, see you son!.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Sep 07, 2009 12:07 pm    Post subject: Reply with quote

what exactly do you want notepad to do with api injection?
i mean the allocated address must be called by other address for the api to execute?!
btw sounds cool api injection never heard it =D
Back to top
View user's profile Send private message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Mon Sep 07, 2009 1:09 pm    Post subject: Reply with quote

Your English is poor, so it is hard to understand what you want to do.

Do you want to change the text in notepad?
Back to top
View user's profile Send private message
Morph.C
Cheater
Reputation: 0

Joined: 15 Aug 2009
Posts: 29

PostPosted: Mon Sep 07, 2009 2:07 pm    Post subject: Reply with quote

Chaosis13 wrote:
Your English is poor, so it is hard to understand what you want to do.

Do you want to change the text in notepad?


oh man, my English is very bad, I do not speak English, use the google translator Sad.

Well, i want to do that, thats posible? Shocked
if you would leave, I want to change the text that is at this address: 0x1009624.

thanks in advance if you can tell me how... see you later.!

PD: Sorry for my english Crying or Very sad.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Sep 07, 2009 3:26 pm    Post subject: Reply with quote

that is a stupid method for just changing one address. i recommend writeprocessmemory

are you sure you want to use that method ?
Back to top
View user's profile Send private message
Morph.C
Cheater
Reputation: 0

Joined: 15 Aug 2009
Posts: 29

PostPosted: Mon Sep 07, 2009 5:30 pm    Post subject: Of Curse!!! Reply with quote

Slugsnack wrote:
that is a stupid method for just changing one address. i recommend writeprocessmemory

are you sure you want to use that method ?


Of course! I say because I'll do in Counter Strike, and inject SXE does not allow me to WriteProcessMemory therefore wish to use this method 100% Functional. Very Happy Smile

EH SOMEONE CAN HELP ME ? Embarassed
Back to top
View user's profile Send private message
ElJEffro
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Apr 2007
Posts: 1881
Location: La Tierra

PostPosted: Sun Sep 13, 2009 1:14 pm    Post subject: Reply with quote

No es posible convertirlo al C# porque tendrias que declarar la funcion inyectada() en su exe de C# para escribirlo en notepad con WriteProcessMemory y C# consiste de .NET que es diferente del assembly del C/++ (o sea x86). Entonces puedes escribir un DLL en C++ y exportar la funcion inyectora() (y cambiar messageboxA a cualquier API que quieres) y llamarlo por pInvoke

(It's not possible to convert this exact code to C# because C# uses .NET assembly which isn't the same as x86 assembly so you couldn't write the function to an x86 process, just make a C++ dll and export the inject() function and call it with pInvoke)
Back to top
View user's profile Send private message
Morph.C
Cheater
Reputation: 0

Joined: 15 Aug 2009
Posts: 29

PostPosted: Tue Sep 15, 2009 6:01 pm    Post subject: Reply with quote

ElJEffro wrote:
No es posible convertirlo al C# porque tendrias que declarar la funcion inyectada() en su exe de C# para escribirlo en notepad con WriteProcessMemory y C# consiste de .NET que es diferente del assembly del C/++ (o sea x86). Entonces puedes escribir un DLL en C++ y exportar la funcion inyectora() (y cambiar messageboxA a cualquier API que quieres) y llamarlo por pInvoke

(It's not possible to convert this exact code to C# because C# uses .NET assembly which isn't the same as x86 assembly so you couldn't write the function to an x86 process, just make a C++ dll and export the inject() function and call it with pInvoke)


Si no se puede hacer en C#, usted tiene la API que yo necesito para la edicion de memoria en C++?.

Lo que veo que me esta diciendo es que cree una Dll aparte y la inyecte, pero eso es lo que no deseo hacer.

Si en dado caso por ultimas busquedas que se hagan y aun asi sea imposible hacer inyeccion de dll sin dll en C#, se podría entonces hookear las APIS WriteProcessMemory, ReadProcessMemory, entre otras?, podría decirme como hookearlas para poder usarlas?; si no se puede hacer entonces me podría decir algún metodo para poder usarlas que no sea inyeccion dll?.

Gracias por su ayuda, espero una respuesta. Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites