|
In the C/C++ code below debugptr comes up as null however when I go into Disassembly the value return in register rax from __imp_Cwnd::FromHandle is correct as I place an eyecatcher "Debug" in CprogDebug and when I go to look at that memory address I can see that literal in the memory
more so when I got to rsi + 118h the value of the rax register is there
When I do a quickwatch in VS on Debugptr its NULL
BTW I do a get an exception utilizing debugptr as a pointer
133: debugptr = (CprogDebug *)temptr->GetOwner();
00007FF635B24727 48 8B 88 98 00 00 00 mov rcx,qword ptr [rax+98h]
00007FF635B2472E 48 85 C9 test rcx,rcx
00007FF635B24731 75 0D jne CMypercolate::process_sdump+60h (07FF635B24740h)
00007FF635B24733 48 8B 48 40 mov rcx,qword ptr [rax+40h]
00007FF635B24737 FF 15 A3 AC 00 00 call qword ptr [__imp_GetParent (07FF635B2F3E0h)]
00007FF635B2473D 48 8B C8 mov rcx,rax
00007FF635B24740 FF 15 BA B8 00 00 call qword ptr [__imp_CWnd::FromHandle (07FF635B30000h)]
00007FF635B24746 48 89 86 18 01 00 00 mov qword ptr [rsi+118h],rax
|
|
|
|
|
The source and assembly do not appear to match.
|
|
|
|
|
Wow you are good I’ll do it again but I was still at a breakpoint when I copied the text while was tracing and verifying the output I’m in bed as it’s 2:37 in the morning so I’ll do it again tommorow or in the morning
|
|
|
|
|
ForNow wrote: Wow you are good Not at all. It's just that every so often I actually read a question carefully.
|
|
|
|
|
I re-built its the the code at 5:52 est I just tested it did a disassembly it the same disassembly I posted it strange because the value returned from Cwnd::FromHandle has a valid return in rax I check rsi + 118 h and that value has the rax register also nore rsi + 118h = FA2C48D158 however I do quick watch on &debugptr and that value is null the value of &debugptr is 7FFd34e61810 which is strange shouldn't rsi + 118h == &debugptr ???
thanks
|
|
|
|
|
Sorry I must be missing something . I do not see the connection between Cwnd::FromHandle and debugptr = (CprogDebug *)temptr->GetOwner(); .
|
|
|
|
|
First let just say what I am trying to accomplish I have CProgDebug object of Cwnd type I am trying to save all the info in that Object I have two modal dialogboxes which gather info that I need so when I create these two Modal Dialog Boxes one after the other I create them with pParent being = to the Created Dialog the documentation says in that Case if pParent is not equal to NULL the pParent Cwnd will be the Parent or Owner maybe I should try debugptr = temptr->GetParent(); and see what Happens I think your logic is right though
Thanks
|
|
|
|
|
this is what documentation states Quote: Points to the parent or owner window object (of type CWnd
I just stepped thru my constructer of both modal dialog boxes in my quick watch I had this->m_WndOwner (from Cwnd) and this->m_pParent (from Cdialog) I had passed a valid Cwnd
after in Disassembly mode I executed Cdialog:Cdialog this->m_pParent is Null while this->m_pParent has a value in fact the pointer to the pParent I pass as I can see the eyecatcher
|
|
|
|
|
I have never used GetOwner , but there seem to be some caveats about its usage at CWnd::GetOwner[^]. You also need to be sure that temptr is pointing at the object you think it is.
|
|
|
|
|
Richard as you noted the assembly didn't match the source It lead me to insert #pragma optimize("",off) and #pragma optimize ('',on) around the function the call to __imp CWnd::FromHandle disappeard and debugptr had the right value
Thanks
|
|
|
|
|
Hi all of you. Is there any solution that my application (an SDI MFC app) to know the moment when an new process is loaded into memory ?
|
|
|
|
|
|
I have listed all processes from an PC, with CreateToolhelp32Snapshot, but I don't know after some while another new processes are loaded ...
|
|
|
|
|
|
I have a modeless dialog from which I display to two modal dialog boxes one after the other
I would like to save all the information I get from the two in the modeless dialog
So my plan was when creating the modal dialog box pass the Cwnd pointer using the this pointer
Well the first one seems to work by this I mean make breakpoint
abendialog = new RTMDialog(mylparam,this);
at the creation of the object and then at the contructor
RTMDialog::RTMDialog(LPARAM mylparam, CWnd* pParent)
: CDialog(IDD_DIALOG9, pParent)
at this pParent has valid pointer
In this dialog I create a second modal dialog
void RTMDialog::Percolate()
{
CMypercolate DOPREC(this);
DOPREC.DoModal();
}
here too the this pointer is valid however when I get to this constructer
pParent is null
CMypercolate::CMypercolate(CWnd* pParent )
: CDialog(IIDD_MYPERCOLATE, pParent)
{
|
|
|
|
|
Hardly surprising the question you need to ask yourself as a learning exercise
What is difference between instantiating an object using new vs. without
AKA there is a difference between these two things
abendialog = new RTMDialog(mylparam,this);
CMypercolate DOPREC(this);
The hint is where is the object put in the two different cases?
Hmmm your into your mutitasking so what is wrong with this which is the same thing
void SomeCreateCall (void){
char[256] data;
CreateThread(NULL, 0, SomeThreadFunction, (LPVOID)&data, 0, NULL);
}
The variable data above is obviously valid to pass so whats the problem and whats the fix?
In vino veritas
modified 23-Feb-18 2:52am.
|
|
|
|
|
The stack data or local data disappears once the functions exists
Thank so much
|
|
|
|
|
Correct pretty sure same thing is going to happen with your code, I wouldn't hold the dialog on the stack on a modeless dialog.
It's pretty dangerous to do, hold it as local data in the first dialog or on the heap same as you would on a multitask code
In vino veritas
|
|
|
|
|
Hello,
I wanted to communicate from one app (exe) to another app (exe) so I implemented COM interface in first application.
There are only .idl and some auto generated files (xxx.h & xxx.c) in first app but I dont know how to use this interface in another application.
Please guide.
|
|
|
|
|
|
Thanks for link.
Actually I am aware about the usage of COM but now problem is something different.
How to use COM interface defined in my first application which is an executable. It does not produce any dll or lib.
I need to give some reference to my second application to access same COM interface.
|
|
|
|
|
If you read those articles they explain how to link a COM client to the server.
|
|
|
|
|
Thanks,
Actually I got it. In my case it is .tlb file which I need to use to instantiate interface.
Now one more problem came
COCreateInstance() is returning REGDB_E_CLASSNOTREG Class not registered.
Do I need to register tlb file like a com dll?
If yes then how can do so?
|
|
|
|
|
Fedrer wrote: Do I need to register tlb file like a com dll?
You cannot register a TLB file.
However you have to register the COM component (that is the DLL ).
|
|
|
|
|
I am working with an ARM microcontroller and I'm programming in normal C programming language. I have a big array of struct, but a lot of the struct elements are unused and I would like to turn the array into an optimized struct/linked list instead. What would CLEAVER_MACRO_OR_PERHAPS_FUNCTION be in this case?
struct mySmallStruct1_s {
void* ptrToNextElement;
int myArray[1];
};
struct mySmallStruct2_s {
void* ptrToNextElement;
int myArray[2];
};
struct mySmallStruct3_s {
void* ptrToNextElement;
int myArray[3];
};
struct myBigStruct_s {
struct mySmallStruct1_s mySmallStruct1;
struct mySmallStruct2_s mySmallStruct2;
struct mySmallStruct3_s mySmallStruct3;
};
// This compiles fine, but I want something more reader-friendly
struct myBigStruct_s myBigStruct = {
{(void*)&myBigStruct.mySmallStruct2, {0}},
{(void*)&myBigStruct.mySmallStruct3, {0, 0}},
{(void*)0, {0, 0, 0}}
};
// What should CLEAVER_MACRO_OR_PERHAPS_FUNCTION be to make this compile?
struct myBigStruct_s myBigStruct2 = {
{CLEAVER_MACRO_OR_PERHAPS_FUNCTION(2), {0}},
{CLEAVER_MACRO_OR_PERHAPS_FUNCTION(3), {0, 0}},
{NULL, {0, 0, 0}}
};
|
|
|
|