SPONSORS:






User Tag List

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Jan 2002
    Location
    Sacramento,CA
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HELP - Mem Access Violation performing SendMessage to Win32 App

    I'm attempting to write a user defined class in silk which will contain methods to query a customize GUI control (Spread Sheet control). My approach is straight forward in the since that I send user defined windows messages to this control and internally the application will return the appropriate data or at least the memory address to acquire the data. Unfortunately this approach does not seem to work when attempting to return a memory address from the application under test, that is, ACCESS VIOLATION caused.

    My understanding of Inter-Process Communication is very limited, except to say that this exhibited behavior is correct. One process (Application under test) can not access memory addresses of another process (Silk) and vice versa. However, my question is how does Silk achieve this for all other controls. For example, when Silk queries a TextField by GetText() what mechanism does it use to return the data/string.

    Moreover, I have a short term solution, that is, copy the contains of the row from the Application to the Clipboard. Another User suggested using Memory Page maps. Any advice??? Please review sample code below to see my efforts for the simple GetItemCount and the more involved GetSelText.

    Thanks in advance
    Simon McCabe

    ************************************
    Below is all the code both Application and Silk used in my current efforts.

    1] My first attempt was to write a method to return the number of rows in the spread sheet.

    [Within the Control class definition]
    // Message identifiers used by calling SendMessage()
    const WM_QAP_GETITEMCOUNT = WM_USER + 300;

    // Function prototypes in class declaration
    afx_msg long OnGetItemCount(UINT, long);

    // Message map entry from implementation file
    ON_MESSAGE(WM_QAP_GETITEMCOUNT, OnGetItemCount)

    // Implementation
    // Message handler to return the number of items
    //wParam; not used
    //lParam; out, item count
    // return; 1 (should not fail)
    long CTableView::OnGetItemCount(UINT wParam, long lParam) {
    long lItems = m_pTableData->GetNumberOfRows();
    _fmemcpy((void*)lParam, &lItems, sizeof(lItems));

    return 1L;
    }


    [Within Silk]

    [-] integer GetItemCount()
    [ ] long nCount =0
    [ ]
    [ ] SendMessage(this.GetHandle(), WM_QAP_RV_GETITEMCOUNT, 0, [out]nCount)
    [ ] return ([integer]nCount)

    Note: Remember that with Windows messages, the parameters (wparam & lparam) are forced upon you. So we are returning a value <= size of the storage (parameter) so the data can be returned directly in the parameter.

    THIS WORKS PERFECTLY .....

    2] My second attempt was to write a method to return the current cell data

    // Message identifiers used by calling SendMessage()
    const WM_QAP_GETSELDATA = WM_USER + 301;

    // Function prototypes in class declaration
    afx_msg long OnGetSelectedData(UINT, long);

    // Message map entry from implementation file
    ON_MESSAGE(WM_QAP_GETSELDATA, OnGetSelectedData)


    // Implementation

    // Message handler to return a field of the item at
    // current position
    // wParam; index for switch/case statement to
    // identify field
    // lParam; out; field string from currently selected
    // item
    // return; 0 = failed, 1 = success
    long CTableView::OnGetSelectedData(UINT wParam, long lParam)
    {
    long lRow;
    CDataRow* pRow = 0;

    if (m_pTableData->GetFirstSelectedDataRow(lRow, pRow) != 0) {
    if (pRow != 0) {
    const CDisplayRow* pDisplayRow =pRow->GetDisplay();

    if (pDisplayRow != 0) {
    const char* szBuffer = 0;

    switch (wParam) {
    case 1:
    szBuffer =pDisplayRow->GetSourceDisplay();
    break;

    case 2:
    szBuffer = pDisplayRow->GetTypeDisplay();
    break;

    // Additional cases removed for brevity
    default:
    ; // Empty buffer
    }

    if (szBuffer != 0) {
    _fmemcpy((void*)lParam, szBuffer, strlen(szBuffer) + 1);

    return 1L;
    }
    }
    }
    }
    }


    [Within Silk]

    [-] string GetSelText(integer nKey)
    [ ] string sText =""
    [ ]
    [ ] SendMessage(this.GetHandle(), WM_QAP_RV_GETSELKEY, nKey, [out]sText)
    [ ] return (sText)


    Note: In this second example the string is longer than we have storage for, so we must return an address to the data. Fortunately? The lparam is 32-bits; large enough to take a 32-bit address.

    ACCESS VIOLATION ...
    If it can walk on water, it's probably SilkTest.

  2. #2
    AJ
    AJ is offline
    Moderator AJ's Avatar
    Join Date
    Jun 1999
    Location
    San Jose, CA
    Posts
    1,691
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HELP - Mem Access Violation performing SendMessage to Win32 App

    Can you post your message again, but this time use the UBB Code headers

    example:
    [ c o d e ]
    paste your code here
    [ / c o d e ]

    But remove the spaces.

    example result:
    AJ Alhait
    BetaSoft Inc.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:49 PM.

Copyright BetaSoft Inc.