Jump to content

Search the Community

Showing results for tags 'mobile broadband'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 1 result

  1. Hello. I try to register event handler for for IMbnPinManagerEvents interface. All goes well, but when event triggered i have in params strange data. For example in OnGetPinStateComplete in $iRequestID i expect same id, but getting 0 all the time, in $pPinInfo i expect pointer to the structure, but when i fills the structure on this pointer, i have incorrect data in results, and so on... This is a very specific API and work only whith usb modems, so if you do not have a modem, example does not work, but I hope that the skilled person will be able to find and show where the error in the code. I hope for your help. Thanks. https://msdn.microsoft.com/en-us/library/windows/desktop/dd323268(v=vs.85).aspx #include <WinAPI.au3> #include 'SafeArray.au3' #Region Const Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}" Global Const $sIID_IMbnPinManager = '{DCBBBAB6-2005-4BBB-AAEE-338E368AF6FA}' Global Const $dtag_IMbnPinManager = _ 'GetPinList hresult();' & _ 'GetPin hresult();' & _ 'GetPinState hresult(ulong*);' ; /* [out] */ __RPC__out ULONG *requestID Global Const $sIID_IMbnPinManagerEvents = '{DCBBBAB6-2006-4BBB-AAEE-338E368AF6FA}' Global Const $dtag_IMbnPinManagerEvents = _ 'OnPinListAvailable hresult();' & _ 'OnGetPinStateComplete hresult(' & _ 'ptr;' & _ ; /* [in] */ __RPC__in_opt IMbnPinManager *pinManager 'struct;' & _ ; /* [in] */ MBN_PIN_INFO pinInfo 'ulong;' & _ ; /* [in] */ ULONG requestID 'hresult;)' ; /* [in] */ HRESULT status Global Const $tRIID_IMbnPinManagerEvents = _WinAPI_GUIDFromString($sIID_IMbnPinManagerEvents) Global Const $sIID_IConnectionPointContainer = '{B196B284-BAB4-101A-B69C-00AA00341D07}' Global Const $dtag_IConnectionPointContainer = _ 'EnumConnectionPoints hresult();' & _ 'FindConnectionPoint hresult(clsid;ptr*;);'; /* [in] */ __RPC__in REFIID riid | /* [out] */ __RPC__deref_out_opt IConnectionPoint **ppCP Global Const $sIID_IConnectionPoint = '{B196B286-BAB4-101A-B69C-00AA00341D07}' Global Const $dtag_IConnectionPoint = _ 'GetConnectionInterface hresult();' & _ 'GetConnectionPointContainer hresult();' & _ 'Advise hresult(ptr;dword*;);' & _ ; /* [in] */ __RPC__in_opt IUnknown *pUnkSink, /* [out] */ __RPC__out DWORD *pdwCookie 'Unadvise hresult(dword);' & _ 'EnumConnections hresult();' Global Const $CLSID_MbnInterfaceManager = '{BDFEE05B-4418-11DD-90ED-001C257CCFF1}' ;MbnInterfaceManager Global Const $sIID_IMbnInterfaceManager = '{DCBBBAB6-201B-4BBB-AAEE-338E368AF6FA}' Global Const $dtag_IMbnInterfaceManager = _ 'GetInterface hresult();' & _ 'GetInterfaces hresult(ptr*);' ; /* [retval][ref][out] */ __RPC__deref_out_opt SAFEARRAY * *mbnInterfaces #EndRegion Const ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd430416(v=vs.85).aspx Local $oMbnInterfaceManager = ObjCreateInterface($CLSID_MbnInterfaceManager, $sIID_IMbnInterfaceManager, $dtag_IMbnInterfaceManager) If @error Then Exit -@ScriptLineNumber ;https://msdn.microsoft.com/en-us/library/windows/desktop/dd430421%28v=vs.85%29.aspx Local $p_mbnInterfaces $oMbnInterfaceManager.GetInterfaces($p_mbnInterfaces) If @error Or Not $p_mbnInterfaces Then Exit -@ScriptLineNumber Local $iBound SafeArrayGetUBound($p_mbnInterfaces, $iBound) If @error Or $iBound < 0 Then Exit -@ScriptLineNumber ;Get first Local $p_mbnInterface, $iIndex = 0 SafeArrayGetElement($p_mbnInterfaces, $iIndex, $p_mbnInterface) If @error Or Not $p_mbnInterface Then Exit -@ScriptLineNumber ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323117(v=vs.85).aspx Local $oIMbnPinManager = ObjCreateInterface($p_mbnInterface, $sIID_IMbnPinManager, $dtag_IMbnPinManager) If @error Then Exit -@ScriptLineNumber ;Prepare Events ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323118(v=vs.85).aspx ;~ 1) Get an IConnectionPointContainer interface by calling QueryInterface on an IMbnInterfaceManager object. ;~ 2) Call FindConnectionPoint on the returned interface and pass IID_IMbnPinManagerEvents to riid. ;~ 3) Call Advise on the returned connection point and pass a pointer to an IUnknown interface on an object that implements IMbnPinManagerEvents to pUnk. ;1 STEP Local $oIConnectionPointContainer = ObjCreateInterface($CLSID_MbnInterfaceManager, $sIID_IConnectionPointContainer, $dtag_IConnectionPointContainer) If @error Then Exit -@ScriptLineNumber ;2 STEP Local $p_IConnectionPoint $oIConnectionPointContainer.FindConnectionPoint($tRIID_IMbnPinManagerEvents, $p_IConnectionPoint) If @error Or Not $p_IConnectionPoint Then Exit -@ScriptLineNumber Local $oIConnectionPoint = ObjCreateInterface($p_IConnectionPoint, $sIID_IConnectionPoint, $dtag_IConnectionPoint) If @error Then Exit -@ScriptLineNumber ;3 STEP ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119%28v=vs.85%29.aspx Local $tIMbnPinManagerEvents Local $oIMbnPinManagerEvents = ObjectFromTag("oIMbnPinManagerEvents_", $dtag_IMbnPinManagerEvents, $tIMbnPinManagerEvents) If @error Then Exit -@ScriptLineNumber Local $p_IUnknown = $oIMbnPinManagerEvents() ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/ms678815(v=vs.85).aspx Local $pdwCookie $oIConnectionPoint.Advise($p_IUnknown, $pdwCookie) If @error Or Not $pdwCookie Then ConsoleWrite('! Connection was not successfully established' & @CRLF) Exit -@ScriptLineNumber EndIf ;~ 4 STEP ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323117%28v=vs.85%29.aspx ;Call GetPinState and wait events Local $iRequestID $oIMbnPinManager.GetPinState($iRequestID) If @error Or Not $iRequestID Then Exit -@ScriptLineNumber ConsoleWrite('> Wait events for request: ' & $iRequestID & @CRLF) AdlibRegister('_exit', 5000) While 1 Sleep(250) WEnd ;Console Output ;~ QueryInterface {0000013D-0000-0000-C000-000000000046} ;IClientSecurity ;~ QueryInterface {0000001B-0000-0000-C000-000000000046} ;? ;~ QueryInterface {00000003-0000-0000-C000-000000000046} ;IMarshal ;~ > Wait events for request: 152 ;~ QueryInterface {0000001B-0000-0000-C000-000000000046} ;? ;~ QueryInterface {00000018-0000-0000-C000-000000000046} ;IStdMarshalInfo ;~ QueryInterface {00000019-0000-0000-C000-000000000046} ;IExternalConnection ;~ QueryInterface {4C1E39E1-E3E3-4296-AA86-EC938D896E92} ;? ;~ QueryInterface {1C733A30-2A1C-11CE-ADE5-00AA0044773D} ;ICallFactory ;~ + OnGetPinStateComplete event ;Event fired ;~ > $pIMbnPinManager: 0x00BB9684 ;WHY THE SAME? ;~ > $pPinInfo: 0x00BB9684 ;WHY THE SAME? ;~ > $iRequestID: 0 ;0 ? ;~ > $iStatus: 3 ;3 ? ;~ > pinState: 12208352 ;bla ;~ > pinType: 1 ;bla ;~ > attemptsRemaining: 12194924 ;bla Exit Func _exit() AdlibUnRegister('_exit') $oIConnectionPoint.Unadvise($pdwCookie) Exit EndFunc ;==>_exit Func oIMbnPinManagerEvents_OnGetPinStateComplete($pSelf, $pIMbnPinManager, $pPinInfo, $iRequestID, $iStatus) ; Ret: long Par: ptr;struct;ulong;long ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119%28v=vs.85%29.aspx ConsoleWrite('+ OnGetPinStateComplete event' & @CRLF) ConsoleWrite('> $pIMbnPinManager: ' & $pIMbnPinManager & @CRLF) ConsoleWrite('> $pPinInfo: ' & $pPinInfo & @CRLF) ConsoleWrite('> $iRequestID: ' & $iRequestID & @CRLF) ConsoleWrite('> $iStatus: ' & $iStatus & @CRLF) ;Ok. Now create a MBN_PIN_INFO struct ;~ https://msdn.microsoft.com/en-us/library/windows/desktop/dd323226(v=vs.85).aspx Local Static $tagMBN_PIN_INFO = 'struct;dword pinState;dword pinType;ulong attemptsRemaining;endstruct' Local $tMBN_PIN_INFO = DllStructCreate($tagMBN_PIN_INFO, $pPinInfo) If Not @error Then ConsoleWrite('> pinState: ' & DllStructGetData($tMBN_PIN_INFO, 'pinState') & @CRLF) ConsoleWrite('> pinType: ' & DllStructGetData($tMBN_PIN_INFO, 'pinType') & @CRLF) ConsoleWrite('> attemptsRemaining: ' & DllStructGetData($tMBN_PIN_INFO, 'attemptsRemaining') & @CRLF) EndIf Return $S_OK EndFunc ;==>oIMbnPinManagerEvents_OnGetPinStateComplete Func oIMbnPinManagerEvents_OnPinListAvailable($pSelf) ; Ret: long Return $S_OK EndFunc ;==>oIMbnPinManagerEvents_OnPinListAvailable Func oIMbnPinManagerEvents_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr Local $sIID = StringFromGUID($pRIID) If $sIID = $sIID_IUnknown Then DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf) Return $S_OK ElseIf $sIID = $sIID_IMbnPinManagerEvents Then DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf) Return $S_OK Else ConsoleWrite('QueryInterface ' & $sIID & @CRLF) Return $E_NOINTERFACE EndIf EndFunc ;==>oIMbnPinManagerEvents_QueryInterface Func oIMbnPinManagerEvents_AddRef($pSelf) ; Ret: dword Return 1 EndFunc ;==>oIMbnPinManagerEvents_AddRef Func oIMbnPinManagerEvents_Release($pSelf) ; Ret: dword Return 1 EndFunc ;==>oIMbnPinManagerEvents_Release Func StringFromGUID($pGUID) Local $aResult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $pGUID, "wstr", "", "int", 40) If @error Then Return SetError(@error, @extended, "") Return SetExtended($aResult[0], $aResult[2]) EndFunc ;==>StringFromGUID Func ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $fPrint = False, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ; last param is IID_IUnknown by default If $bIsUnknown = Default Then $bIsUnknown = True Local $sInterface = $tagInterface ; copy interface description Local $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _ "AddRef dword();" & _ "Release dword();" ; Adding IUnknown methods If $bIsUnknown Then $tagInterface = $tagIUnknown & $tagInterface ; Below line is really simple even though it looks super complex. It's just written weird to fit in one line, not to steal your attention Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($tagInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr"), @LF, 3) Local $iUbound = UBound($aMethods) Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback ; Allocation $tInterface = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[" & $iUbound & "];int_ptr Callbacks[" & $iUbound & "];ulong_ptr Slots[16]") ; 16 pointer sized elements more to create space for possible private props If @error Then Return SetError(1, 0, 0) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] $sTagPart = $aSplit[1] $sMethod = $sFunctionPrefix & $sNamePart If $fPrint Then Local $iPar = StringInStr($sTagPart, ";", 2), $t If $iPar Then $t = "Ret: " & StringLeft($sTagPart, $iPar - 1) & " " & _ "Par: " & StringRight($sTagPart, StringLen($sTagPart) - $iPar) Else $t = "Ret: " & $sTagPart EndIf Local $s = "Func " & $sMethod & _ "( $pSelf ) ; " & $t & @CRLF & _ "EndFunc" & @CRLF ConsoleWrite($s) EndIf $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringReplace($sTagPart, $sRet, "", 1) $sParams = "ptr" & $sParams $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) If @error Then ConsoleWrite('! ' & @error & ' ' & $sMethod & @CRLF & @CRLF) EndIf DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle Next DllStructSetData($tInterface, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tInterface, "Size", $iUbound) ; number of interface methods DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), $sIID, $sInterface, $bIsUnknown) ; pointer that's wrapped into object EndFunc ;==>ObjectFromTag
×
×
  • Create New...