|
I haven't used Detours in a few years, but offhand I can think of a few problems with hooking Qt class methods.
The first problem is the ABI (Application Binary Interface) used by Qt. This differs from the ABI used by Windows APIs or by COM objects, and in fact can (and does) vary between compiler implementations.
The second problem is the C++ name mangling - there is no standard way of mangling names. You would have research the exported name (which might be something like QPushButton$event$QEventP$bool and might be something totally different), and do this for every function that you wish to intercept. Again, this depends on the compiler used to compile Qt.
Can you give us some idea of the problem you are trying to solve? Perhaps there is a better way to do this.
|
|
|
|
|
The functions are correctly exported
from QtGui4.dll :
bool QPushButton::event(class QEvent *)
Tools like "Auto Debug Pro" can hook them.
So it is certainly possible to hook them with Detours.
(there is no other way to do what I'm trying to do (interact with Qt pseudo-buttons, drawn by Qt with memory instructions, from its source code))
|
|
|
|
|
I stand by the points that I made in my first reply. You must either statically link with the Qt DLL (and can then extract a pointer to the method) or dynamically load the Qt DLL (and use GetProcAddress() with the mangled method name).
IIRC, the source code for Qt is available for download. An examination of the make file would give you the compiler and compiler options used, which would give you the calling convention and the mangled name for the C++ method. You may then write a class that uses the same calling conventions, and contains a method with the same signature as the method that you wish to intercept. This should get you close enough to working code that debugging would be feasible. For example:
class QT_API MyQPushButton
{
public:
bool event( void* data )
{
}
};
|
|
|
|
|
Finally, I was wrong : I found an easier way.
I just create a Qt DLL that I inject in the destination process, then I get the QWidget* from the main hWnd and I can enumerate all children from there and do what I want on any Qt pseudo-control
Thanks for answers.
|
|
|
|
|
Hi,
Would you like to show your code to me?
I have a similar problem to solve and want to refer to it!
Thank you so much!
modified 15-May-22 8:51am.
|
|
|
|
|
Is there any way to change the color (and / or style) of scrollbar controls used into an application ?
I had tried this [^]solution, but used at some control inside of a dialogbar, everything is go crazy ...
Through a manifest file, can I change some styles of an scrollbars ? If yes, how ?
Thank you.
|
|
|
|
|
There is also this article, here: "Roll Your Own Scroll Bar"[^].
I don't know if it fits your needs (and if I am stating the bleeding obvious... ).
|
|
|
|
|
Thanks, now I have to clean my monitor!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Ha! You and I both.
|
|
|
|
|
Yes, I saw that article, but there is a solution to customize the scrollbars controls (stand alone scrollbars, CScrollbar control, I mean), or, in my situation, the grid control has it's own scrollbars ... I don't know how to customize the control scrollbars ... if I well understanding ...
Later edit: Yes, I could use your solution, but for that I should hide the grid control scrollbars, put these ones, and sincronize the grid and the scrollbar control ... but I guess on this road, I'll meet another problems ... and I think it the longest road ...
modified 15-Jan-15 2:25am.
|
|
|
|
|
I am writing a membership program in C++ and MFC (Yes I know that is old hat these days!) and I want it to be able to send HTML emails with attachments and use BCC list.
My initial attempt uses MAPI functions. This has two problems :
1) If the application is built as a UNICODE application, but the MAPI client is MBCS (or visa versa) then the MAPI calls fail.
2) Not all mail clients are MAPI compliant. Outlook is, but Outlook Express and various shareware mail clients are not. Also a lot of people use cloud based systems.
What method can I use to send emails that will work with most (if not all) Windows systems?
|
|
|
|
|
If you're interested in spending money, I can recommend the email component from http://www.chilkatsoft.com[^] .
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Thank you for stating the bleeding obvious. I have already done that. It comes up with a list of articles (277 of them) with those words in them. It does not come up with a recommendation of which of the many methods is the most flexible; which one overcomes the 32/64 bit problem; what the pros and cons of each method are. The Code Project search engine, whilst very good at finding words in articles, is ill equipped to give recommendations. I have already tried one of the articles (Using extended MAPI) and found problems with it. Rather than trying the other 276 articles in turn, I thought I would seek advice on the matter from the friendly people at Code Project. I find that asking humans these sorts of questions yields better results. Well most of the time anyway. Occasionally you get someone who has had a bad day and feels the need to take it out on someone else. If you don't know the answer to my question or you don't understand the question then don't be shy. Let me know and I will try to explain myself in more simpler terms for you.
|
|
|
|
|
At which point in your original question did you make mention of the fact that you had in fact done some degree of research, particularly that you had reviewed CP's articles?
If you don't state what you've done, how can you expect someone not to suggest the very same thing?
Furthermore, you make mention that you realize MFC is old hat, which is irrelevant, yet make no mention of research, only of the failings of your initial attempt.
Frankly, your reply post is one I consider rather rude and I'd be surprised to learn I was alone in thinking like this. I hope the rest of your day improved/s.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
enhzflep wrote: reply post is one I consider rather rude That's bleeding obvious!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Touché!
|
|
|
|
|
enhzflep wrote: If you don't state what you've done, how can you expect someone not to suggest the very same thing? I disagree. In addition to everything else, we're also supposed to be mind readers and know what the OP wants.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Of course, I'd forgotten about the famed CPMRU - I think I needed to order more batteries, it's been sitting on the shelf collecting dust for a while and doesn't function at present.
|
|
|
|
|
You are welcome.
And sorry if I have no interest in your 'simpler terms'.
|
|
|
|
|
I'm not really familiar with the stuff you're using, and I haven't used C++ for a few years, but from what I remember any functions in the Windows API that changed between character types depending on precomiler definitions had other similarly named functions.
I remember the function to show a message box was called MessageBox(), and internally it mapped to either MessageBoxA() or MessageBoxW() depending on precompiler definitions.
Maybe you'll find something similar with your function for sending the mail?
Then depending on how speedy you need it to run you could write some code to attempt the other version of the function if the first try failed, or if you need it faster try to detect what the MAPI client needed you to use and have some kinda fancy interface, function pointer, etc to convert your text and send it using the right format.
Alternatively, you could try using .Net from C++ to use all of the email junk built into that - though I'm kinda assuming you're avoiding needing to install the entire .Net framework alongside your application.
|
|
|
|
|
You should investigate SMTP (Simple Mail Transfer Protocol), which is the most common one in use. I am not aware of any MFC classes that support it, but it should be easy enough to find out.
|
|
|
|
|
Use this class[^]
- Michael Haephrati מיכאל האפרתי
|
|
|
|
|
Many thanks. I'll give it a try.
|
|
|
|
|
I'm studying MMS Protocol in order to develop the program connecting to FM Radio broadcast of which the url scheme is mms://domain_name/sub_name(directory name?) such as mms://wmc1.liquidviewer.net/WEEI
I can obtain the ip address of mms url above, but i don't know the meaning of sub_name. it's important when i write tcp socket code.
The socket function usually takes ip address and port number.
The MMS protocol's port number is used with 1755.
If i have ip address and port number, i can write code as below.
-------------------------------------------------------------
const int MMF_PROTOCOL = 1755;
char sServerIP[] = "127.0.0.1";
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
ErrorHandling("WSAStartup() error!");
hSocket=socket(PF_INET, SOCK_STREAM, 0);
if(hSocket == INVALID_SOCKET)
ErrorHandling("socket() error");
memset(&servAddr, 0, sizeof(servAddr));
servAddr.sin_family=AF_INET;
servAddr.sin_addr.s_addr=inet_addr(sServerIP);
servAddr.sin_port=htons(MMF_PROTOCOL);
if(connect(hSocket, (struct sockaddr*)&servAddr, sizeof(servAddr))==SOCKET_ERROR)
ErrorHandling("connect() error!");
while(1)
{
send(hSocket, message, strlen(message), 0);
...
}
-------------------------------------------------------------
However, i don't know how to connect that mms url owing to the sub_name(directory?).
if mms url is mms://111.222.333.444, i can try to connect server with socket because in that case i know ip address and port number(MMS Protocol's port number, 1755).
But, with mms://111.222.333.444/sub_name(directory?), i can't connect due to sub_name.
I want to take account of sub_name, then do my purpose.
Do you know anybody about this problem?
|
|
|
|