Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Strange Debugging results

Strange Debugging results

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiodebuggingperformance
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • F ForNow

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The source and assembly do not appear to match.

      F 1 Reply Last reply
      0
      • L Lost User

        The source and assembly do not appear to match.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • F ForNow

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          ForNow wrote:

          Wow you are good

          Not at all. It's just that every so often I actually read a question carefully.

          F 1 Reply Last reply
          0
          • L Lost User

            ForNow wrote:

            Wow you are good

            Not at all. It's just that every so often I actually read a question carefully.

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            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

            L 1 Reply Last reply
            0
            • F ForNow

              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

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Sorry I must be missing something . I do not see the connection between Cwnd::FromHandle and debugptr = (CprogDebug *)temptr->GetOwner();.

              F 1 Reply Last reply
              0
              • L Lost User

                Sorry I must be missing something . I do not see the connection between Cwnd::FromHandle and debugptr = (CprogDebug *)temptr->GetOwner();.

                F Offline
                F Offline
                ForNow
                wrote on last edited by
                #7

                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

                F 1 Reply Last reply
                0
                • F ForNow

                  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

                  F Offline
                  F Offline
                  ForNow
                  wrote on last edited by
                  #8

                  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

                  L 1 Reply Last reply
                  0
                  • F ForNow

                    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

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    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.

                    F 1 Reply Last reply
                    0
                    • L Lost User

                      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.

                      F Offline
                      F Offline
                      ForNow
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups