Click here to Skip to main content
16,006,006 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem linking stl strings Pin
Londo23-Feb-02 22:53
Londo23-Feb-02 22:53 
GeneralRe: Problem linking stl strings Pin
Paul M Watt23-Feb-02 23:04
mentorPaul M Watt23-Feb-02 23:04 
QuestionWS_SCROLL handle...?? Pin
alex.barylski23-Feb-02 18:57
alex.barylski23-Feb-02 18:57 
AnswerRe: WS_SCROLL handle...?? Pin
Paul M Watt23-Feb-02 19:14
mentorPaul M Watt23-Feb-02 19:14 
QuestionHow do i Initialize a dll when injecting Pin
23-Feb-02 18:45
suss23-Feb-02 18:45 
AnswerRe: How do i Initialize a dll when injecting Pin
Paul M Watt23-Feb-02 18:58
mentorPaul M Watt23-Feb-02 18:58 
GeneralRe: How do i Initialize a dll when injecting Pin
23-Feb-02 20:20
suss23-Feb-02 20:20 
GeneralRe: How do i Initialize a dll when injecting Pin
Paul M Watt23-Feb-02 21:04
mentorPaul M Watt23-Feb-02 21:04 
What you will have to do then is determine the address of the entry point into the DLL, basically DLLMain, and call that function.

There will be a little bit of work involved, and at first it is intimidating, but it is fairly straight forward.

Look up Matt Petriek's PEDUMP program on MSDN, or even the internet. This is a very good reference program for walking through the PE file format in order to get information such as the address of an entry point. There is even alot of source code that you will be able to use and modify for yourself. I found this article looking in MSDN Peering Inside the PE: A Tour of the Win32 Portable Executable File Format

This is the basic process:

1. With the base address, ADDR, that you have loaded your DLL into memory, cast this pointer to a PIMAGE_DOS_HEADER structure. This will get you started.

<br />
    PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)ADDR;<br />


2. You will get the next structure that you are interested in by taking ADDR + dosHeader->e_lfanew and casting that pointer to a IMAGE_NT_HEADERS inh structure.

3. Verify that the inh->Signature == 0x50450000 this signature is actually "PE/0/0", it signifies that you are using a PE file format. If this is not true, then you will need to do some research and determine what file type you are actually using, but I am certain that you will be OK with PE.

4. Finally the address that you have been waiting for is inh->OptionalHeader->AddressOfEntryPoint.

5. From here, you can declare a function pointer in your application with the same prototype as the DLL main function:

<br />
BOOL (DllMainPtr*)(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/);<br />


6. Declare a variable of this type:

<br />
DllMainPtr InjectEntry = inh->OptionalHeader->AddressOfEntryPoint;<br />


You may have to cast it, I do not know for sure.

7. And finally call the function:

<br />
InjectEntry(Hinst, DLL_PROCESS_ATTACH, NULL);<br />


This will initialize your DLL.
Let me know if this is what you need, and if it works.
GeneralRe: How do i Initialize a dll when injecting Pin
24-Feb-02 0:25
suss24-Feb-02 0:25 
GeneralCSliderCtrl ownerdraw Pin
alex.barylski23-Feb-02 15:42
alex.barylski23-Feb-02 15:42 
GeneralRe: CSliderCtrl ownerdraw Pin
Michael Dunn23-Feb-02 16:10
sitebuilderMichael Dunn23-Feb-02 16:10 
GeneralRe: CSliderCtrl ownerdraw Pin
alex.barylski23-Feb-02 18:50
alex.barylski23-Feb-02 18:50 
QuestionDoese GDI+ provide the functions such as SetROP2 in GDI? Pin
G.Richard23-Feb-02 14:20
G.Richard23-Feb-02 14:20 
AnswerRe: Doese GDI+ provide the functions such as SetROP2 in GDI? Pin
Mazdak23-Feb-02 20:33
Mazdak23-Feb-02 20:33 
GeneralRe: Doese GDI+ provide the functions such as SetROP2 in GDI? Pin
G.Richard24-Feb-02 3:59
G.Richard24-Feb-02 3:59 
AnswerRe: Doese GDI+ provide the functions such as SetROP2 in GDI? Pin
Christian Graus23-Feb-02 22:01
protectorChristian Graus23-Feb-02 22:01 
GeneralRe: Doese GDI+ provide the functions such as SetROP2 in GDI? Pin
G.Richard25-Feb-02 14:23
G.Richard25-Feb-02 14:23 
GeneralRe: Doese GDI+ provide the functions such as SetROP2 in GDI? Pin
Christian Graus27-Mar-02 0:25
protectorChristian Graus27-Mar-02 0:25 
AnswerRe: Doese GDI+ provide the functions such as SetROP2 in GDI? Pin
Swinefeaster27-Mar-02 0:27
Swinefeaster27-Mar-02 0:27 
Generalsystem debug symbols Pin
Gabriel.P.G23-Feb-02 11:56
Gabriel.P.G23-Feb-02 11:56 
GeneralQuestion about CPoint objects... Pin
CDuddley23-Feb-02 10:41
CDuddley23-Feb-02 10:41 
GeneralRe: Question about CPoint objects... Pin
Christian Graus23-Feb-02 10:43
protectorChristian Graus23-Feb-02 10:43 
GeneralRe: Question about CPoint objects... Pin
CDuddley23-Feb-02 10:49
CDuddley23-Feb-02 10:49 
GeneralRe: Question about CPoint objects... Pin
Peter Godec23-Feb-02 11:58
Peter Godec23-Feb-02 11:58 
GeneralRe: Question about CPoint objects... Pin
CDuddley23-Feb-02 12:16
CDuddley23-Feb-02 12:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.