|
Hello,
Get_paremeter_class() was intended to be a function returning a string. In this case the plan was to have the string returned to target beginning with the fifth character in target. If target started with contents "abcdefghi" and the function returned "XYZ" then target would contain "abcdXYZhi"
I am pretty sure this will not work.
What character/string types do you recommend? I read that CString is a Microsoft creation so I think I would prefer something else. The code builds many strings with wprintf_s(...).
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
bkelly13 wrote: In this case the plan was to have the string returned to target beginning with the fifth character in target. If target started with contents "abcdefghi" and the function returned "XYZ" then target would contain "abcdXYZhi" I am pretty sure this will not work.
Could you please elaborate (detailing exactly what are the inputs and what should be the output)?
I didn't get you.
bkelly13 wrote: I read that CString is a Microsoft creation so I think I would prefer something else. The underlying operative system is a Microsoft creation too.
CString is just fine. You could also use, if you like, std::wstring .
|
|
|
|
|
Run into a coder who for whatever and unknown reason posted in this "style":
....
return A+B;
return A+B;
}
and duplicated few other lines of code also.
Obviously the second "return" won't ever be executed ( unless used after "if" for example ).
My question is - does the "optimizer" do anything with subsequent and identical lines of code assuming the first line does not modify anything?
Just asking, and yes , I did ask the originator, but he was too busy "fixing" his illogical code elsewhere and did not seems interested in such trivial matters.
Cheers Vaclav
|
|
|
|
|
|
Any half decent compiler would optimize out the second statement as it serves no purpose.
|
|
|
|
|
True. Anyway any decent compiler would actively refuse to compile such a code.
|
|
|
|
|
VS2013 (actually the compiler) compiles it fine.
|
|
|
|
|
Doesn't find it outrageous?
|
|
|
|
|
VC6-VC10 produce unreachable code warnings (C4702) /W4, but much to my surprise not at /W3.
|
|
|
|
|
You might try it with your favorite compiler.
|
|
|
|
|
Vaclav_Sal wrote: does the "optimizer" do anything with subsequent and identical lines of code
Why does it matter?
Code itself requires very little space in pretty much all modern applications perhaps only excluding very small (device itself is small) embedded processing apps.
And since the line can never execute, regardless of anything like a normal language, that means the space that the code actually takes up is the only part that is relevant in any normal 'optimization' discussion.
|
|
|
|
|
"Why does it matter?"
Why do you bother to reply if you cannot stay on subject and really answer the question?
To everybody else:
Observed on C++ code written for Arduino "toy" controller.
"They" use some version of cpp compiler, sorry do not know exactly which one.
It changes ( version ) often.
I agree that such code should not compile on limited resources "embedded" hardware, as pointed out. But the compiler does not know that, right?
There may be an option in compiler setup,but I have not search for it.
Maybe when I get my messy code fixed I'll check it.
Thanks
Cheers Vaclav
|
|
|
|
|
Vaclav_Sal wrote: I agree that such code should not compile on limited resources "embedded" hardware, as pointed out. But the compiler does not know that, right? Well it should; 'general' compilers have an option to tell them the target hardware. Without such an option how can they know what code to generate? I am still not sure what this question is really about, do you have an actual problem that needs resolving?
|
|
|
|
|
Vaclav_Sal wrote: "Why does it matter?" Why do you bother to reply if you cannot stay on subject and really answer the question
You said "optimization".
Focusing on 'micro' optimization is meaningless.
Focusing on business optimization is very relevant and thus the context of my response. So yes it is on subject in less you meant something else when you said "optimization".
Vaclav_Sal wrote: But the compiler does not know that, right?
When one is targeting specific 'small' embedded spaces the following is probably always relevant (I only say probably because I am not familiar with every possible small device.)
- The entire application must take into account the embedded space.
- I doubt seriously that the cross compiler would not be specific to the device and perhaps even specific to the version of the device (certainly true is all of the limited cases I have worked with.)
- Cross compilers can often have language limitations. For example (quite a bit in the past) a C cross compiler that I used did not support floating point numbers in any form.
|
|
|
|
|
"They" use some version of cpp compiler, sorry do not know exactly which one.
Seems likely it'd be a GCC, or nowadays maybe even LLVM. Have a look at command line options -W4 or -Wall. One of the two options (or very similar) would probably tell you "Silly user, now you gone and made a mess out of stuff again!".
|
|
|
|
|
Hello,
with Detours, one can hook any api call.
In the sample "wrotei.cpp", COM interfaces can be hooked :
"
CreateStreamOnHGlobal(NULL, TRUE, &pStream);
//...
RealIStreamWrite = pStream->lpVtbl->Write;
//...
"
But is it possible to hook QT ?
Because in QT source code, there is no interfaces, just classes
for example, could it be possible to hook QPushButton::event() ? :
bool QPushButton::event(QEvent *e)
{
// code
return QAbstractButton::event(e);
}
Thanks.
|
|
|
|
|
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.
|
|
|
|