|
Aaaargh...
Thanks for your help guys. I had a break and came back at it with a fresh look.
It turns out that the lib was being compiled with debug single threaded and... you guessed it, the app was compiled with debug multi threaded.
Doh!
|
|
|
|
|
It was still fun racking my brain.
|
|
|
|
|
Is there a way to get the handle for scrollbars created with the WS_VSCROLL bits set at creation.
Thanx again!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I think that answer is... It Depends.
You first need to decide if the scrollbar of the window or control that you want the handle of actually exists.
You can do this with Spy++, one of the tools that comes with DevStudio. Go into the Spy menu and click Find Window. A dialog will appear with a little icon of a window with a crosshair in the middle of it. Drag this cross hair over the top of any window that you would like and the outline of the window below the crosshair will be highlighted.
The handle of the window that is highlighted will also appear in the edit box on the find window dialog of the Spy++ window. If the scroll bar that you want the handle of does not appear hightlighted, then there is no way that you will be able to get the handle of that control, because it does not exist. Try this with Notepad.
If the scrollbar exists, then you will be able to call GetWindow, with the GW_CHILD flag and continue search all of the child controls until you find the scroll bar.
The scroll bar may or may not appear depending on how the control is implemented and how it decided to handle the WS_VSCROLL style.
|
|
|
|
|
Once i get it into the target process's addy space, how do i then initialize it, and get it up and running?
I need to know how to use to initialize the dll after it has been injected into the other process,
Thank you
|
|
|
|
|
I take it that you are not loading the DLL with the LoadLibrary function.
Are you mapping it into your processes address space?
If so there are two things that need to be known.
1. If this is a resource only DLL, then you can simply use the objects inside.
2. If this is a DLL with executable code then you have other issues to worry about, like making sure that the different segments of the file have sufficient rights with the kernel to execute code and things like that.
If I am wrong in assuming what you are doing, please let me know what you are doing and whet your intent is for doing this and I can help you.
|
|
|
|
|
Well the library does contain executable code, the lib is accualy a hook, suposed to intercept calls made between the game executable and the true dll, im trying to make the loader call the executable, and then go ahead and load the dll, but after that im not sure what to do,
I am using LoadLibrary, Inderectly, And rights are not a problem with this specific loader, it takes care of all of that,
i wish i could post up some sample code but in order to get any idea of how it works it would take to much space,
info from somone that has done similer things had said that i need to call the base address of the executable for the initialazation to occure, Im not sure if this is right and i dont know how this is done,
Im trying to creat a small mod for a game that will aid in the administration of servers, But i need to intercept those calls, and im searching for ways to do this, The game is Quake3,
let me know what ya think. if you need more info, let me know, thanx for your respons
|
|
|
|
|
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 );<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.
|
|
|
|
|
Wow thx man big help, i looked up a couple of examples on it this should go alot easyer now, i understand the initialztion process a little better,
Thx again ill keep ya informed
|
|
|
|
|
How do I make a CSliderCtrl ownerdrawn...?
I've made buttons, combos, list and menus all ownerdrawn before, but the answer doesn't seem so obvious with CSliderCtrl...is it...?
What am I missing...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
I was afraid of that.
Thanx
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I want to know how to use GDI+ to draw a rubber line?
Let's use GDI+ to draw! hoho
|
|
|
|
|
What do you mean by "rubber line"?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
draw a XOR line useing GDI+!
thanks to all the programmers who have helped me.
|
|
|
|
|
No, it does not. I did this by using OnPrtepareDC, and drawing the rubber band or shape to the screen directly, only drawing it to the bitmap at the end of the operation.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
can you explain it in more detail? the background in the client area is a bitmap, i draw my shape to the screen directly,too. but i don't know how to erase it.
thanks to all the programmers who have helped me.
|
|
|
|
|
It erases itself, because you draw the bitmap to the screen, then draw the line to the screen. Next time you draw the bitmap, the line is not there, so only the new one is drawn.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
You can intermingle gdi and gdi+ code, so yes. SetROP2() is not supported in gdi+ anymore i believe, but you can still call the old SetROP2() as you still have a dc handle somewhere in your code.
cheers,
swinfeaster
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Hi, i´ve downloaded the XP debug symbols but i cannot find a way to make the vc.net ide to recognize where they are installed. Any ideas???
Thanks
Gabriel
don´t worry drink happy
|
|
|
|
|
Hi I'm new to this forum, but I think it's pretty cool. I had a question about CPoint object. I need to be able to randomly generate an array of them. Which I got that far, but my problem was when the user entered a point, and I was supposed to tell the program to find the closest point in the array. Do any of you know how to do that? I tried using like the '<' compare operator but the CPoint class doesn't have that operator. Don't worry I'm not trying to get free homework (I'm using Introduction to MFC with Visual C++ to learn MFC) or anything I just don't understand and I would like to understand it. Thanks in advance for your help.
-CDudd
|
|
|
|
|
You need to use < on the members of CPoint, which are x and y.
And I'd answer this question if it *was* homework, because you're trying to do something, not just asking for a complete solution on a plate.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
I have tried that. I'm not really sure where to go from there. Another hint please? I'm not trying to do 'anything' I'm just trying to learn. Thanks for the quick post.
-CDudd
|
|
|
|
|
CDuddley wrote:
to find the closest point
If i understand correctly, you need to define a measure of distance between CPoints to do that. Most probably that would be euclidean distance , i.e.
d = sqrt((x1 - x2)^2 + (y1 - y2)^2)
So define a function that calculates the euclidean distance between two CPoints, maybe something like this:
#include <math.h>
double distance(const CPoint& p1, const CPoint& p2)
{
return sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y));
}
a nicer variant (performance?) of this would be
double distance(const CPoint& p1, const CPoint& p2)
{
CSize diff = p1 - p2;
return sqrt(diff.x * diff.x + diff.y * diff.y);
}
(of course, for your purpose, you don't need to calculate the sqrt, but now i'm blabbering)
Now all you's gotta do is iterate over the array of CPoints, calculating the distance between your given test point and each point in the array and keeping track of the array index of the point that is the closest to the test point (now read this paragraph again).
that-exercise-is-left-to-the-OP-ly y'rs --pg
|
|
|
|
|
Thanks a bunch for the post. I was having trouble with the fact that if a random point was greater than the given point the point would be negative when I took the difference. I forgot all about the euclidian distance formula thanks a ton! I'll try to get the test program working now!
Thanks again,
CDudd
|
|
|
|