none
passing data to queueinputreport? RRS feed

  • General discussion

  • I have this problem I have asked in visual c++ I believe to be a bug with passing data to queueinputreport from the generichid code from dsf(device simulation framework) in wdk 7.1. Here's what I have but it only works in vbscript or other scripting languages and not c++:

    STDMETHODIMP CMMEmulator::sendinputreport(BYTE inputreport[5], int length)
    {
    	// TODO: Add your implementation code here
    		 _TCHAR szBuffer[100];
        _stprintf_s(szBuffer, _T("%i"), inputreport[1]);
      
    	MessageBox(NULL,L"value of second byte input report",szBuffer,NULL);
    	SAFEARRAY *test = new SAFEARRAY;
    	  VARIANT HUGEP* pDescriptorData  = NULL;
    	// Create a boundary struct to pass in when we create the SafeArray
        SAFEARRAYBOUND rgsabound[1];
        ZeroMemory(rgsabound, sizeof(rgsabound));
        rgsabound[0].lLbound = 0;
        rgsabound[0].cElements = 5;
     
        // Create as an Array of Variants becuase that is what the DSF 
        // Interface->put_DeviceSpecificDescriptor is expecting an array of Variants
    	
    	test = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
    	//FADF_STATIC+FADF_FIXEDSIZE+FADF_VARIANT+FADF_HAVEVARTYPE;
      if(  test->fFeatures == 0x892)
      {
    	  MessageBox(NULL,L"has correct safearray type",L"correct data format",NULL);
    
      }
      else
      {
         MessageBox(NULL,L"does not have the correct safearray type",L"incorrect data format",NULL);
      }
        //  test->fFeatures = 2194;
        if( test == NULL )
        {
            // if the create failed, then goto to exit
            hr = E_UNEXPECTED;
            goto Exit;
        }
        
      
    
        // Step through the SAFEARRAY and populate each variant with a Byte value
        //INT descSize2 = sizeof(inputreport);
        for( INT i = 0; i <= 4; ++i )
        {
           pDescriptorData[i].vt = VT_UI1;
    	   pDescriptorData[i].bVal = inputreport[i];
    	  
        }
    	  SafeArrayAccessData(test, (void HUGEP**)&pDescriptorData);
    	 _TCHAR szBuffer2[100];
        _stprintf_s(szBuffer2, _T("%i"), test->fFeatures);
    	MessageBox(NULL,L"safe array type",szBuffer2,NULL);
    	piSoftHidDevice1[devindex]->QueueInputReport(test,10);
    	piSoftHidDevice1[devindex]->StartProcessing();
    	piSoftHidDevice1[devindex]->StopProcessing();
    	SafeArrayUnaccessData(test);
    	return S_OK;
    	Exit:
    SafeArrayUnaccessData(test);
    return hr;
    }

    I hope someone on the wdk forums can tell me if Iam passing the data wrong or if it is an actual error in the code somewhere. I have pre-entered the report descriptors in my version of the generic hid code (also called softhidreceiver.dll) so the devices are created correctly in device simulation framework.  I sometimes get an error about memory corruption and other times it crashes with a bluescreen which disappears too fast to get any information.

    As you can see above I have tried to pass the data but I am having problems with passing a safe array of variants which includes the simulated devices input report. I have tried using variantinit, excluding HUGHP, and SafeArrayAccessData/SafeArrayUnaccessData. Does anyone have any idea what is wrong with the above code or do they think its a bug?

    If anyone has had success getting dsf to work can you please share your code?


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr

    Friday, October 25, 2013 8:09 PM