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 


¿How create Dlls to inject In Visual C++ 2008 Or Delphi 7?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Pantaleon
Newbie cheater
Reputation: 0

Joined: 08 Mar 2009
Posts: 17
Location: New York

PostPosted: Thu Mar 26, 2009 3:40 pm    Post subject: ¿How create Dlls to inject In Visual C++ 2008 Or Delphi 7? Reply with quote

Hello I in search of a code to create dlls to inject with a injector
Forward Create more than such ves with his help already I searched quite info and no meeting almost nothing to rioja than desire clear I using
Visual C++ 2008 and I believe that there is no code I've seen so far, thank you very much to who can tell me as well as create them in Visual C + + or Delphi, then use the 2 languages.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
blackmorpheus
Expert Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 159

PostPosted: Thu Mar 26, 2009 4:05 pm    Post subject: Reply with quote

A dll to do what?

In visual Studio 2008, u can select a Win32 program with C++, then make it empty DLL.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 473

Joined: 09 May 2003
Posts: 25907
Location: The netherlands

PostPosted: Thu Mar 26, 2009 4:06 pm    Post subject: Reply with quote

with delphi(7):
file->new->other->Dll Wizard

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Pantaleon
Newbie cheater
Reputation: 0

Joined: 08 Mar 2009
Posts: 17
Location: New York

PostPosted: Thu Mar 26, 2009 5:58 pm    Post subject: Thank you very much. Reply with quote

Perfect, as I succeeded in Delphi, thanks Dark Byte.

This is the code that I got in google:


Code:
library CreationDll;

uses
   Windows;
 
Var
   j:Integer;
   x:cardinal;

const
Address1:dword=$00400000;
ArrayValue:Array[1..12] of Byte = ($4D,$5A,$90,$0,$3,$0,$0,$0,$4,$0,$0,$0);

Procedure EditMEmory;
Begin  VirtualProtectEx(GetCurrentProcess,ptr(Address1),12,PAGE_EXECUTE_READWRITE,nil);
      for j := 0 To Length(ArrayValue) do
         PByte(Address1 + j)^:=ArrayValue[j];
end;

Begin
   CreateThread(nil,0,@EditMEmory,nil,0,x);
end.


That was the code that will find and fix, but the question is: it works, I have no editor to check it out ... if it could tell?

Rioja than no I find went a code to Visual C++ 2008 may tell as do?
I do not talk about how to create the project, I speak of creating the code of the dll.

As already I create the project more no I idea of as create the code of the dll me can say how? thanks by his generous help until later.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Thu Mar 26, 2009 6:22 pm    Post subject: Reply with quote

Code:

#include <windows.h>

  int j;
  DWORD x;
  DWORD Address1 = 0x400000;
  BYTE ArrayValue[12] = (0x4D,0x5A,0x90,0x0,0x3,0x0,0x0,0x0,0x4,0x0,0x0,0x0);

BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved )
{
    switch( fdwReason )
    {
        case DLL_PROCESS_ATTACH:
            CreateThread(0,0,(LPTHREAD_START_ROUTINE)EditMEmory,0,0,x);
            break;

        case DLL_THREAD_ATTACH:
            break;

        case DLL_THREAD_DETACH:
            break;

        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}
BOOL EditMEmory()
{
        if(VirtualProtectEx(GetCurrentProcess(),&Address1,12,PAGE_EXECUTE_READWRITE,NULL))
        {
              memcpy((void*)Address1,(void*)ArrayValue,sizeof(ArrayValue));
              return TRUE;
         }
         else
         {
              return FALSE;
         }
}

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.


Last edited by BanMe on Thu Mar 26, 2009 6:53 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 473

Joined: 09 May 2003
Posts: 25907
Location: The netherlands

PostPosted: Thu Mar 26, 2009 6:33 pm    Post subject: Reply with quote

I might be retarded, but I am just wondering why you'd make a new thread if you could just do it at dllentry
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Thu Mar 26, 2009 6:55 pm    Post subject: Reply with quote

@Dark Byte: I was merely showing C++ code relation to the delphi code provided..

@nwongfeiying...lol deleted..

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
Pantaleon
Newbie cheater
Reputation: 0

Joined: 08 Mar 2009
Posts: 17
Location: New York

PostPosted: Thu Mar 26, 2009 8:35 pm    Post subject: Perfect!!! Reply with quote

Oh thank you very much for answering BanMe.

The code had several errors, but I solved;).

Actually thank you very much.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Thu Mar 26, 2009 9:08 pm    Post subject: Reply with quote

no problem Very Happy
of course it had errors it was a rough interpretation of delphi on the fly Smile
you are most welcome.. Very Happy

but Dark Byte is correct in that you do not need a thread to do the action of EditMEmory(). you can simple call it after Begin or in DLL_PROCESS_ATTACH..

Code:

Begin
EditMEmory()
end


or the C++ way
Code:

case DLL_PROCESS_ATTACH:
            EditMEmory();
            break


In both languages you could also create a TLS Callback that would execute this code even before DLL_PROCESS_ATTACH .. the caveat being you have to add controller code that recognizes if its been executed or not..as TLS callbacks execute before execution and after.. Very Happy

kind regards BanMe

_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
Pantaleon
Newbie cheater
Reputation: 0

Joined: 08 Mar 2009
Posts: 17
Location: New York

PostPosted: Thu Mar 26, 2009 11:13 pm    Post subject: Yeah I understand.!! Reply with quote

BanMe wrote:
no problem Very Happy
of course it had errors it was a rough interpretation of delphi on the fly Smile
you are most welcome.. Very Happy

but Dark Byte is correct in that you do not need a thread to do the action of EditMEmory(). you can simple call it after Begin or in DLL_PROCESS_ATTACH..

Code:

Begin
EditMEmory()
end


or the C++ way
Code:

case DLL_PROCESS_ATTACH:
            EditMEmory();
            break


In both languages you could also create a TLS Callback that would execute this code even before DLL_PROCESS_ATTACH .. the caveat being you have to add controller code that recognizes if its been executed or not..as TLS callbacks execute before execution and after.. Very Happy

kind regards BanMe


oh if I understand, thanks for the clarification on the 2 ... very good forum . Very Happy
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Mar 27, 2009 3:49 am    Post subject: Reply with quote

In delphi Dll Wizard, you don't have to use DllMain just like in C, but i would recommend using it, and as db mentioned you don't need to create a thread, you could just edit it as soon as it's injected (same for DllMain) but i guess people love creating a thread druing process attach, so whatever.
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Fri Mar 27, 2009 12:08 pm    Post subject: Reply with quote

Sometimes you have to create a thread because:
- Not all api's work from dllmain. They might hang for example (I experienced that with InternetOpenUrl)
- Msdn states something about not doing certain things from dll main. I'm not sure what exactly.
- LoadLibrary won't return untill dllmain has finished, so sometimes the calling thread needs to continue after LoadLibrary, but that depends on the injector used (if it uses CreateRemoteThread or 'hijacks' an existing thread)
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