Jump to content
Inververs

[solved] Help with event notifications for IMbnPinManagerEvents interface

Recommended Posts

Inververs

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

 

 

Edited by Inververs
solved

Share this post


Link to post
Share on other sites
LarsJ

After a quick look at the code, I can see a little mistake. "struct" in definition of IMbnPinManagerEvents interface must be "struct*":

; Replace
'struct;' & _                           ; /* [in] */ MBN_PIN_INFO   pinInfo
; with
'struct*;' & _                           ; /* [in] */ MBN_PIN_INFO   pinInfo

You can try to correct this for a start.

Share this post


Link to post
Share on other sites
Inververs

If change to struct*, than i get this in OnGetPinStateComplete event:

+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x00933D44
> $pPinInfo: 0x00000000
> $iRequestID: 0
> $iStatus: 3

$pPinInfo became null.

So It did not help

Share this post


Link to post
Share on other sites
LarsJ

What does $iStatus = 3 mean? Since $iStatus <> 0 the operation failed, and that's probably the reason why $pPinInfo and $iRequestID are not set.

As you have managed to create all the interface objects, there seems not to be any obvious errors.

Do you know if this code works? Do you have some C++ code to verify that the code works. If the C++ code works, it's usually possible to get the AutoIt code to work too. On the other hand. If it's not possible to get the C++ code to work, then it's also not possible to have the AutoIt code to work.

Share this post


Link to post
Share on other sites
Danyfirex

When you create the callback in the parameters you do this.  ptr;ptr;struct;ulong;long. Don't use struct, use ptr instead.

dllcallbackregister remarks says: Uses all DllCall() types except "struct". for that reason you get $pIMbnPinManager same as $pPinInfo. So if you use  ptr;ptr;ptr;ulong;long you should get correct pointer to MBN_PIN_INFO structure.

 

Saludos

 

Edited by Danyfirex
write more

Share this post


Link to post
Share on other sites
Inververs

Honestly, i have no idea what is the status 3
If msdn on this page said, https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119(v=vs.85).aspx
that status  can expect one of the following values:
S_OK
HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)
E_MBN_SIM_NOT_INSERTED
E_MBN_BAD_SIM

in sdk i can find this constants
E_MBN_SIM_NOT_INSERTED           _HRESULT_TYPEDEF_(0x8054820AL)
E_MBN_BAD_SIM                    _HRESULT_TYPEDEF_(0x80548202L)

but what 3 meen, i dont know.
I am inclined to believe that callback is not working properly.

No working code in C++. I'm trying to make it from scratch, using only the information from the site
But, i have working command in netsh which is able to determine the status of the pin,
and I can not say it uses an this API, or something else.

netsh mbn show pin interface=*
result is:
    Тип ПИН-кода           : Pin1
    Состояние ПИН-кода          : Ввод
    Количество оставшихся попыток: 3
    
What can be translated as:
    Type PIN: Pin1
    Status PIN: Input
    The number of remaining attempts: 3
    
This is very similar to the data that are located in the structure MBN_PIN_INFO

typedef struct MBN_PIN_INFO {
  MBN_PIN_STATE pinState;
  MBN_PIN_TYPE  pinType;
  ULONG         attemptsRemaining;
} MBN_PIN_INFO;

, but as you can see, the access to which I can not get.

Edited by Inververs

Share this post


Link to post
Share on other sites
Danyfirex

¿did you read? what I wrote...

Share this post


Link to post
Share on other sites
Inververs

Danyfirex, so read, did not have time to answer, I'm sorry.

I change to this

Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager
        'ptr;' & _                              ; /* [in] */ MBN_PIN_INFO   pinInfo
        'ulong;' & _                            ; /* [in] */ ULONG          requestID
        'hresult;)' ;                             /* [in] */ HRESULT        status

but it still does not work

Share this post


Link to post
Share on other sites
Inververs
Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager
        'ptr;' & _                              ; /* [in] */ MBN_PIN_INFO   pinInfo
        'ulong;' & _                            ; /* [in] */ ULONG          requestID
        'long;)' ;                              /* [in] */ HRESULT      status

It does not work to

Share this post


Link to post
Share on other sites
Danyfirex

why you use 5 parameters in oIMbnPinManagerEvents_OnGetPinStateComplete($pSelf, $pIMbnPinManager, $pPinInfo, $iRequestID, $iStatus).? it just say 4 as far I see.

Share this post


Link to post
Share on other sites
Inververs

someone wrote that

methods for objects created with ObjectFromTag allways have $pSelf as first parameter

Share this post


Link to post
Share on other sites
LarsJ

ObjectFromTag is a function coded by trancexx. There are several versions of this function. It is important to use the latest. But as far as I can see, it is the latest version.

Share this post


Link to post
Share on other sites
Danyfirex

I did not know it.  making that I said. You till got $pIMbnPinManager: 0x00BB9684     $pPinInfo: 0x00BB9684 ?

 

Saludos

 

Share this post


Link to post
Share on other sites
Inververs
Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager
        'ptr;' & _                              ; /* [in] */ MBN_PIN_INFO   pinInfo
        'ulong;' & _                            ; /* [in] */ ULONG          requestID
        'long;)' ;                              ; /* [in] */ HRESULT        status

> Wait events for request: 250

This when device pin1 require:
+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x0076A0AC
> $pPinInfo: 0x00000001
> $iRequestID: 2
> $iStatus: 3

Then when device unblocked(pin entered)

> Wait events for request: 251

+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x00B2D09C
> $pPinInfo: 0x00000000
> $iRequestID: 0
> $iStatus: 3

Share this post


Link to post
Share on other sites
Inververs

These events do not work as expected.
If you take other functions, then everything is OK
This code provides:
> Pin format: MBN_PIN_FORMAT_NUMERIC
> Pin type: MBN_PIN_TYPE_PIN1
> $oIMbnPin.get_PinLengthMin 4
> $oIMbnPin.get_PinLengthMax 8

 

Local Const $MBN_PIN_TYPE_CUSTOM = 0x1, $MBN_PIN_TYPE_PIN1 = 0x2
Local $p_IMbnPin

$oIMbnPinManager.GetPin($MBN_PIN_TYPE_PIN1, $p_IMbnPin)

Local $oIMbnPin = ObjCreateInterface($p_IMbnPin, $sIID_IMbnPin, $dtag_IMbnPin)
If @error Then Exit -@ScriptLineNumber

Local $iPinFormat
$oIMbnPin.get_PinFormat($iPinFormat)

Switch $iPinFormat
    Case 0x0
        ConsoleWrite('> Pin format: ' & 'MBN_PIN_FORMAT_NONE' & @CRLF)
    Case 0x1
        ConsoleWrite('> Pin format: ' & 'MBN_PIN_FORMAT_NUMERIC' & @CRLF)
    Case 0x2
        ConsoleWrite('> Pin format: ' & 'MBN_PIN_FORMAT_ALPHANUMERIC' & @CRLF)
EndSwitch

Local $iPinType
$oIMbnPin.get_PinType($iPinType)
ConsoleWrite('> Pin type: ')
Switch $iPinType
    Case 0x00
        ConsoleWrite('MBN_PIN_TYPE_NONE' & @CRLF)
    Case 0x1
        ConsoleWrite('MBN_PIN_TYPE_CUSTOM' & @CRLF)
    Case 0x2
        ConsoleWrite('MBN_PIN_TYPE_PIN1' & @CRLF)
    Case 0x3
        ConsoleWrite('MBN_PIN_TYPE_PIN2' & @CRLF)
    Case 0x4
        ConsoleWrite('MBN_PIN_TYPE_DEVICE_SIM_PIN' & @CRLF)
    Case 0x5
        ConsoleWrite('MBN_PIN_TYPE_DEVICE_FIRST_SIM_PIN' & @CRLF)
    Case 0x6
        ConsoleWrite('MBN_PIN_TYPE_NETWORK_PIN' & @CRLF)
    Case 0x7
        ConsoleWrite('MBN_PIN_TYPE_NETWORK_SUBSET_PIN' & @CRLF)
    Case 0x8
        ConsoleWrite('MBN_PIN_TYPE_SVC_PROVIDER_PIN' & @CRLF)
    Case 0x9
        ConsoleWrite('MBN_PIN_TYPE_CORPORATE_PIN' & @CRLF)
    Case 0xA
        ConsoleWrite('MBN_PIN_TYPE_SUBSIDY_LOCK' & @CRLF)
EndSwitch

Local $iPinLengthMin, $iPinLengthMax
$oIMbnPin.get_PinLengthMin($iPinLengthMin)
$oIMbnPin.get_PinLengthMax($iPinLengthMax)

ConsoleWrite('> $oIMbnPin.get_PinLengthMin ' & $iPinLengthMin & @CRLF)
ConsoleWrite('> $oIMbnPin.get_PinLengthMax ' & $iPinLengthMax & @CRLF)

 

Share this post


Link to post
Share on other sites
Inververs

ObjectFromTag is a function coded by trancexx. There are several versions of this function. It is important to use the latest. But as far as I can see, it is the latest version.

yes, correct. and she said this phrase.

Share this post


Link to post
Share on other sites
Inververs

funnily,  1 2 3 in the parameters

Share this post


Link to post
Share on other sites
trancexx

Wait, that's exactly what netsh shows. Right?

Then maybe try it like this:

Global Const $dtag_IMbnPinManagerEvents = _
        'OnPinListAvailable hresult();' & _
        'OnGetPinStateComplete hresult(' & _
        'ptr;' & _                              ; /* [in] */ __RPC__in_opt  IMbnPinManager *pinManager

        'int;int;ulong;' & _                           ; /* [in] */ MBN_PIN_INFO   pinInfo

        'ulong;' & _                            ; /* [in] */ ULONG          requestID

        'hresult;)' ;                             /* [in] */ HRESULT        status
        
;...

Func oIMbnPinManagerEvents_OnGetPinStateComplete($pSelf, $pIMbnPinManager, $pinState, $pinType, $attemptsRemaining, $iRequestID, $iStatus)
;~  https://msdn.microsoft.com/en-us/library/windows/desktop/dd323119%28v=vs.85%29.aspx

    ConsoleWrite('+ OnGetPinStateComplete event' & @CRLF)

    ConsoleWrite('> $pIMbnPinManager: ' & $pIMbnPinManager & @CRLF)

    ConsoleWrite('> $pinState: ' & $pinState & @CRLF)
    ConsoleWrite('> $pinType: ' & $pinType & @CRLF)
    ConsoleWrite('> $attemptsRemaining: ' & $attemptsRemaining & @CRLF)

    ConsoleWrite('> $iRequestID: ' & $iRequestID & @CRLF)
    ConsoleWrite('> $iStatus: ' & $iStatus & @CRLF)

    Return $S_OK
EndFunc

 

  • Like 3

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Inververs

ingenious, it works!

Pin entered:

> Wait events for request: 274

+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x00A2CBEC
> $pinState: 0
> $pinType: 0
> $attemptsRemaining: 3
> $iRequestID: 274
> $iStatus: 0

Pin required:

> Wait events for request: 275
+ OnGetPinStateComplete event
> $pIMbnPinManager: 0x0099AC74
> $pinState: 1
> $pinType: 2
> $attemptsRemaining: 3
> $iRequestID: 275
> $iStatus: 0

trancexx, thanks a lot!

As I understand it, the structure should be expand in dtag...?

 

 

 

Share this post


Link to post
Share on other sites
Danyfirex

MSDN play us a joke. nowhere says pointer to  MBN_PIN_INFO just add the parameter as nested way. another Great one Trancexx. 

 

@Inververs could you pass SafeArray.au3. I would like to play a little with your code.

 

Saludos

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • rcmaehl
      By rcmaehl
      Hi all, 

      Recently my work swapped from Cisco CTIOS to Finesse. This completely threw me off as I had been automating the Win32 application and I had never done IUIAutomation before. As such I've been messing around with the API and will be adding code as I figure it out. While I do have Supervisor access, I will likely not be adding functions for those features yet.
      Currently Available Functions:

      Changelog:

      Changes I'm Thinking About
       
      Download:
       
       
    • Iznogoud
      By Iznogoud
      Hi,
      I was wondering if someone can help me to create an AutoIT script which can create a ticket in a TopDesk environment.
      The API is wel documented, but i have not enough knowlegde at this moment to get this up from the ground. If someone could help me or if i could hire / pay someone to help me with this, that would be great.
      Information about the API can be found here: https://developers.topdesk.com/
      Is there a place where i maybe can hire AutoIT professionals to help me with this?
      On freelancer.com is an option, but there are alot of people responding which doesn't know a thing about AutoIT.
    • Ascer
      By Ascer
      1. Description.
      oAuth 2.0 is security system implemented by Google a few years ago. You are able to connect into your Google accounts and manage documents. In this UDF i show you how to pass first authorization process., this allow you to automate most of functions using API interface. 2. Requirements.
      Google account. oAuth.au3 Download 3. Possibilities
      ;============================================================================================================ ; Date: 2018-02-10, 14:21 ; ; Description: UDF for authorize your app with oAuth 2.0 Google. ; ; Function(s): ; oAuth2GetAuthorizationCode() -> Get Code for "grant". ; oAuth2GetAccessToken() -> Get "access_token" and "refresh_token" first time. ; oAuth2RefreshAccessToken() -> Get current "access_token" using "refresh_token". ; ; Author(s): Ascer ;============================================================================================================ 4. Enable your Google API.
          4.1. Video Tutorial not mine!
       YouTube     4.2 Screenshots from authorization process (Polish language) 
      Go to https://console.developers.google.com/apis/dashboard and accept current rules.  

       
      Next create an new project  

       
      Enter name of you new project and click Create  

       
      Google will working now, please wait until finish. Next go to enable your API interface, we make if for Google  

       
      Take "Gmail" in search input and after click in found result.  

       
      Click Enable interface, Google will working now.  

       
      Create your login credentials  

       
      Select Windows Interface (combobox), User credentials (radio) and click button what is need bla bla  

       
      Type name of a new client id for oAuth 2.0 and click Create a new Client ID.  

       
      Next configure screen aplication, type some name and click Next. Google will working now.  

       
      Last step on this website is download source with your credentials in *Json format.  

       
      Now you received a file named client_id.json, it's how it look in Sublime Text:  

       
      5. Coding.
      Now we need to call a some function to get access code.  
      #include <oAuth.au3> Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sRedirectUri = "http://localhost" oAuth2GetAuthorizationCode($sClientId, $sRedirectUri)  
      Function will execute default browser for ask you to permission.  

       
      Next Google ask you to permission for access to your personal details by application Autoit   

       
      Now you can thing is something wrong but all is ok, you need to copy all after  code= . It your access code.  

       
      Let's now ask Google about our Access Token and Refresh Token  
      #include <oAuth.au3> Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sClientSecret = "cWalvFr3WxiE6cjUkdmKEPo8" Local $sAuthorizationCode = "4/AAAPXJOZ-Tz0s6mrx7JbV6nthXSfcxaszFh_aH0azVqHkSHkfiwE8uamcabn4eMbEWg1eAuUw7AU0PQ0XeWUFRo#" Local $sRedirectUri = "http://localhost" Local $aRet = oAuth2GetAccessToken($sClientId, $sClientSecret, $sAuthorizationCode, $sRedirectUri) If Ubound($aRet) <> 4 then ConsoleWrite("+++ Something wrong with reading ResponseText." & @CRLF) Exit EndIf ConsoleWrite("Successfully received data from Google." & @CRLF) ConsoleWrite("access_token: " & $aRet[0] & @CRLF) ConsoleWrite("expires_in: " & $aRet[1] & @CRLF) ConsoleWrite("refresh_token: " & $aRet[2] & @CRLF) ConsoleWrite("token_type: " & $aRet[3] & @CRLF)  
      Important! When you received error 400 and output says: Invalid grant it means that your previous generated access_code lost validity and you need to generate new calling previus code. When everything is fine you should received a 4 informations about your: access_token, expires_in, refresh_token and token_type. Access_Token time is a little short so you need to know fuction possible to refresh it (tell Google that he should generate a new Token for you)  
      #include <oAuth.au3> Local $sRefreshToken = "1/ba8JpW7TjQH3-UI1BvPaXhSf-oTQ4BmZAbBfhcKgKfY" Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sClientSecret = "cWalvFr3WxiE6cjUkdmKEPo8" Local $sRedirectUri = "http://localhost" Local $aRet = oAuth2RefreshAccessToken($sRefreshToken, $sClientId, $sClientSecret) If Ubound($aRet) <> 3 then ConsoleWrite("+++ Something wrong with reading ResponseText." & @CRLF) Exit EndIf ConsoleWrite("Successfully received data from Google." & @CRLF) ConsoleWrite("access_token: " & $aRet[0] & @CRLF) ConsoleWrite("expires_in: " & $aRet[1] & @CRLF) ConsoleWrite("token_type: " & $aRet[2] & @CRLF)  
      6. Finish words
      If you followed all this above steps im sure that you received all informations required for coding your Google API (Gmail, Dropbox, YouTube, Calender etc. See next thread: [UDF] Gmail API - Email automation with AutoIt!
    • Ascer
      By Ascer
      1. Description.
      Automate communication with Gmail API using oAuth 2.0 security. 2. Requirements.
      Google Gmail account. Finished Authorization process. Look here 3. Possibilities.
      ;======================================================================================================================== ; Date: 2018-02-12, 11:46 ; ; Bug Fixs: 2018-02-17, 7:31 -> Fixed problems with adding items to array and minor bugs. ; ; Description: UDF for using Gmail API interface. This UDF requires oAuth.au3 and Gmail account. ; ; Function(s): ; gmailUsersGetProfile() -> Information about your account. ; gmailUsersLabelsList() -> Get all available labels ids. ex. "INBOX", "UNREAD" ; gmailUsersLabelsGet() -> Get information about specific label id. ; gmailUsersMessagesBatchDelete() -> Delete many messages emails by id. ; gmailUsersMessagesBatchModify() -> Set status for many messages ex. "INBOX", "UNREAD" ; gmailUsersMessagesDelete() -> Totaly delete email from ur account. ; gmailUsersMessagesGet() -> Get all information about specific email. ; gmailUsersMessagesList() -> Get list of last ~100 emails. ; gmailUsersMessagesModify() -> Modify single message. ; gmailUsersMessagesTrash() -> Put email in trash. ; gmailUsersMessagesUntrash() -> Restore email from trash. ; gmailUsersMessagesSend() -> Send email to single or group recipients. ; gmailUsersMessagesAttachmentsGet() -> Download attachment by id. ; ; Author(s): Ascer ;======================================================================================================================== 4. Downloads.
      oAuth.au3 Gmail API.au3 5. Examples.
      Sending emails
    • islandspapand
      By islandspapand
      Hi All
      i am currently trying to add a function to my project that can send SMS, i have gone with Twilio for the sms service that use a REST API.
      I have never worked with an API before, and could use some help.
      I can get my function working with using cURL.exe and copy past command from the website with the following code. And thats great unfortunately i am have issue with character like æøå when sending a SMS appears like a box or ?. this does not happen if i do it from the website so it looks like a Unicode issue in curl.exe.
      I have done some searching on the forum and understand that i should be able to implement this curl command with the WinHTTP UDF from @trancexx so i don't need a third part exe and it might fix my charater issue.
      Unfortunately i really don't understand how i am to change curl commands to the WinHTTP and i was hoping some good maybe give me an example i could learn from.
      Thanks in advanced
      i have removed the AuthToken number from the script.
      _SendSMS("00000000","SomeOne","SMS body info") Func _SendSMS($SendTo,$SendFrom,$Msgtxt) $AccountSID = "ACbb765b3180d5938229eff8b8f63ed1bc" $AuthToken = "Auth Token number" $Data = '"https://api.twilio.com/2010-04-01/Accounts/'&$AccountSID&'/Messages.json"'& _ '-X POST \ --data-urlencode "To=+45'&$SendTo&'" \ --data-urlencode "From='&$SendFrom&'" \ --data-urlencode "Body='&$Msgtxt&'" \ -u '&$AccountSID&':'&$AuthToken&'' ShellExecute(@ScriptDir&"\curl.exe","-k "&$Data) ;~ curl 'https://api.twilio.com/2010-04-01/Accounts/ACbb765b3180d5938229eff8b8f63ed1bc/Messages.json' -X POST \ ;~ --data-urlencode 'To=+4500000000' \ ;~ --data-urlencode 'From=Reception' \ ;~ --data-urlencode 'Body=Test Body' \ ;~ -u ACbb765b3180d5938229eff8b8f63ed1bc:[AuthToken] EndFunc  
       
×