Re: DLL Injection with slots... ?!?!?
At which point in time does DLL_PROCESS_ATTACH happen?
If it happens when the dll gets loaded before the main event loop is running, you're too soon to create the dialog.
Note that the main event loop is the one you want to use to create your dialog.
Try installing a hook into the main application event function. Then, when the application started event happens, create your dialog.
Re: DLL Injection with slots... ?!?!?
I'm injecting my DLL when the application is fully running.
I took the QApplication:instance(), than I checked the applicationFilePath and got the injected exe file path. I guess that this means that My Dialog will be part of the exe application...
It looks like it's going to be inevitable... I will have to debug QT :-(
What's keeping a QDialog alive?
Re: DLL Injection with slots... ?!?!?
Quote:
Originally Posted by
gilamran
What's keeping a QDialog alive?
Please define "alive".
Re: DLL Injection with slots... ?!?!?
"alive" means that it's in an events loop.
I did some debugging and got an ASSERT that said: "widgets must be created in the GUI thread"...
now I know that you're going to kill me and tell me that you already told me that it's "accessing widgets from the non-gui thread leads to a crash"... ok well, I did get access to the widgets, and even got my external DLL slot to get called...
but now the thing is that I can't create a dialog from my DLL... is there a way to work around it? (I think that can manage without the dialog)
Re: DLL Injection with slots... ?!?!?
Thus far I have an impression that you are doing some random things and expect to find a combination of them that works. This is not a good approach. You should first analyze what the applicaiton you are attaching to is actually doing. Otherwise your code might be called from a completely arbitrary context and it will not be possible to control it. Use a debugger to see whether the application uses threads and find a context where it will be running the main thread and try attaching to that. Otherwise you'll end up in a situation that you are doing something from a worker thread that gets terminated at some point and you won't be able to continue. Maybe you should find a different way to achieve your goal? Is the application dynamically or statically linked?
Re: DLL Injection with slots... ?!?!?
Ok, after some time I've got some progress...
but now I have another question: (Should I open a new thread?)
I investigate the main application UI structure by going to it's children and printing out the widget name, x, y, visible etc.
BUT I have some window (A VERY important one for me) that contains a a very complex UI, but it's not a child of any of the QWidgets... A large portion of the UI is missing...
I found a QWidget with no children... can it be that this is the complex UI that I'm missing? can it be that a complex UI is some kind of external EXE running inside the QWidget?
any ideas?
Thanks
Re: DLL Injection with slots... ?!?!?
It's rather a graphics view or a custom widget that paints all its contents by itself.
Re: DLL Injection with slots... ?!?!?
great! it's a graphics view... didn't know they exist... :D
ok, now that I have the graphics view, how can I enum all the items that inherit from QGraphicsTextItem? and print out their text...
yea, I know it's a dumb question, but I have no C++ background.... and I didn't find a way to do it.
Thanks
Gil
Re: DLL Injection with slots... ?!?!?
You ask the scene for all items and then you iterate over them checking their type and so on.
Re: DLL Injection with slots... ?!?!?
yea I know.... but my C++ background is 0.
can't get it to work...
Code:
{
if (gti)
{
sendmsg("QGraphicsTextItem found");
}
}
Re: DLL Injection with slots... ?!?!?
Define "can't get it to work".
Re: DLL Injection with slots... ?!?!?
Re: DLL Injection with slots... ?!?!?
So use a debugger and fix it.