The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on June 07, 2009, 03:39:59 AM

Title: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 03:39:59 AM


STISpRecognizer STRUCT
QueryInterface                dword ?
AddRef                        dword ?
Release                      dword ?
SetPropertyNum                dword ?
GetPropertyNum                dword ?
SetPropertyString            dword ?
GetPropertyString            dword ?
SetRecognizer                dword ?
GetRecognizer                dword ?
SetInput                      dword ?
GetInputObjectToken          dword ?
GetInputStream                dword ?
CreateRecoContext            dword ?
GetRecoProfile                dword ?
SetRecoProfile                dword ?
IsSharedInstance              dword ?
GetRecoState                  dword ?
SetRecoState                  dword ?
GetStatus                    dword ?
GetFormat                    dword ?
IsUISupported                dword ?
DisplayUI                    dword ?
EmulateRecognition            dword ?
STISpRecognizer ENDS

.data
GUID_SpSharedRecognizer GUID {03BEE4890h,04FE9h,04A37h,<08Ch,1Eh,05Eh,07Eh,012h,79h,1Ch,1Fh>}
spi STISpRecognizer <?>


.code

InitSAPI proc uses esi edi

invoke CoCreateInstance,addr GUID_SpSharedRecognizer,0,CLSCTX_ALL,0,addr spi


ret
InitSAPI endp


I got the GUID From SAPI 5.1 SDK.

EXTERN_C const CLSID CLSID_SpSharedRecognizer;

#ifdef __cplusplus

class DECLSPEC_UUID("3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F")
SpSharedRecognizer;
#endif


But the CoCreateInstance always Failed.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 05:19:59 AM
Hello,
How to proceed seem to be your question.
Search in the registry
Quote
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}\ProgID
                                           Sapi.SpSharedRecognizer.1
This say to you that you have to make a test with the CLSIDFromProgID function
Quote
ThreadingModel Both
This mean you have to take care with the initialisation method
Prefered is
Quote
invoke CoInitializeEx ,NULL, COINIT_MULTITHREADED

Title: Re: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 05:49:23 AM
Quote from: ToutEnMasm on June 07, 2009, 05:19:59 AM
Hello,
How to proceed seem to be your question.
Search in the registry
Quote
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}\ProgID
                                           Sapi.SpSharedRecognizer.1
This say to you that you have to make a test with the CLSIDFromProgID function
Quote
ThreadingModel Both
This mean you have to take care with the initialisation method
Prefered is
Quote
invoke CoInitializeEx ,NULL, COINIT_MULTITHREADED



Thats complicated. Any link for information for this?
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 06:38:22 AM

Not so complicated

;use the init function


Quote
; use of function
invoke GetInterfaceFromProgId,SADR("DExplore.AppObj.9.0"),addr IID_Help2



GetInterfaceFromProgId PROC pProgId:DWORD,pIID:DWORD
        LOCAL wszProgID[1024]:word
        LOCAL ppv:Dword,retour,pchaine         
        LOCAL clsid     :GUID
        mov retour,0

        invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,pProgId,-1,addr wszProgID,sizeof wszProgID
        invoke CLSIDFromProgID,addr wszProgID,addr clsid
        .if eax == S_OK
                invoke CoCreateInstance,addr clsid, NULL,CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER OR CLSCTX_LOCAL_SERVER,pIID,addr ppv

                .if eax == S_OK                         
                        PuPo retour,ppv
                .endif
        .endif
        mov eax,retour
        RET
GetInterfaceFromProgId endp


If it's failed  http://www.masm32.com/board/index.php?topic=10901.msg80021#msg80021

You can also look at the typelib (follow the register key)
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 07, 2009, 06:54:05 AM
old stuf.

[attachment deleted by admin]
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 07:21:59 AM
I have forgotten the most important:

VERIFY that the interface you want is in your computer.
For this use OLEVIEW or my tool "cherche".
For me,I have not this one in my computer (XP sp3).

The ernie old stuff couldn't help here.

Use the header's of the ready to use SDK RC 7,there is here a full translate of the interfaces of the sapi51 .I have tested it.
Your defined one is very bad,no prototypes and couldn't be debugged easily.

Title: Re: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 07:26:31 AM
I got this code from googling, I think it is simple,


CoInitialize(NULL);

ISpRecognizer* m_iEngine = NULL;

HRESULT hr = CoCreateInstance(CLSID_SpSharedRecognizer, NULL, CLSCTX_ALL, IID_SpSharedRecognizer, reinterpret_cast<ISpRecogniser*>(&m_iEngine));


The problem is what is the value of IID_SpSharedRecognizer, and how to get it. Your Init function only give me the CLSID but not with the IID.

[edit]
ToutEnMasm:
Okay I got it.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 07:31:50 AM

The IID_ ... is the register key of an interface.
The one you have is a CLSID who can only give you the Iunknown interface using the IID_iunknow in the GetInterfaceFromProgId function.
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 07:39:31 AM
Quote from: ToutEnMasm on June 07, 2009, 07:31:50 AM

The IID_ ... is the register key of an interface.
The one you have is a CLSID who can only give you the Iunknown interface using the IID_iunknow in the GetInterfaceFromProgId function.


IID is GUID? Sorry a bit late of thinking in here.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 07:52:25 AM

More explain seem needed.
Following what I was saying in my upper post,i have searched in the typelib
Quote
    coclass SpSharedRecognizer {
        [default] interface ISpeechRecognizer;
        interface ISpRecognizer;

Here you have the two interface supported by SpSharedRecognizer
Verify that those interfaces are present in your registry
use the IID (given by the registry)  with the function given upper.This one is the good method to connect.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 08:04:59 AM
complete soluce using the RC 7 sdk translate.
Quote
   include translate.inc
   include windows.sdk
   ;include richedit.sdk
   ;include adoctint.sdk
   include sapi51.sdk
   include macro.inc
   ;include dbdao.sdk
   ;------- librairie courantes ,identiques masm32rt
   ;ExitProcess PROTO :DWORD   
   GetInterfaceFromProgId PROTO :DWORD,:DWORD
   
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\Comctl32.lib
      includelib \masm32\lib\comdlg32.lib
      includelib \masm32\lib\shell32.lib
      includelib \masm32\lib\oleaut32.lib
      includelib \masm32\lib\ole32.lib
      ;includelib \masm32\lib\msvcrt.lib   incompatible avec certaines librairies windows,directx
   ;editmasm.ini pour l'environnement du projet
;RIEN MACRO
;   :DWORD,
;ENDM
   

   .const


   .data
ppvISpRecognizer dd 0   
ppvISpeechRecognizer dd 0
CLSID_SpSharedRecognizer GUID {03BEE4890h,04FE9h,04A37h,<08Ch,1Eh,05Eh,07Eh,012h,79h,1Ch,1Fh>}   
IID_IUnknown GUID <0H,0H,0H,<0C0H,0H,0H,0H,0H,0H,0H,046H>>
IID_ISpeechRecognizer GUID {2D5F1C0Ch,0BD75h,4B08h,<94h,78h,3Bh,11h,0FEh,0A2h,58h,6Ch>}
   .code
   
   start:
   invoke CoInitializeEx ,NULL, COINIT_MULTITHREADED   
   invoke GetInterfaceFromProgId,SADR("Sapi.SpSharedRecognizer.1"),addr IID_ISpeechRecognizer
   .if eax != 0
      mov ppvISpeechRecognizer,eax
      ISpeechRecognizer Release
   .endif
   invoke ExitProcess,0
   ;------- proc içi ------------
GetInterfaceFromProgId PROC pProgId:DWORD,pIID:DWORD
        LOCAL wszProgID[1024]:word
        LOCAL ppv:Dword,retour,pchaine         
        LOCAL clsid     :GUID
        mov retour,0

        invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,pProgId,-1,addr wszProgID,sizeof wszProgID
        invoke CLSIDFromProgID,addr wszProgID,addr clsid
        .if eax == S_OK
                invoke CoCreateInstance,addr clsid, NULL,CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER OR CLSCTX_LOCAL_SERVER,pIID,addr ppv

                .if eax == S_OK                         
                        PuPo retour,ppv
                .endif
        .endif
        mov eax,retour
        RET
GetInterfaceFromProgId endp   

Title: Re: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 08:05:26 AM
Quote from: ToutEnMasm on June 07, 2009, 07:52:25 AM

More explain seem needed.
Following what I was saying in my upper post,i have searched in the typelib
Quote
    coclass SpSharedRecognizer {
        [default] interface ISpeechRecognizer;
        interface ISpRecognizer;

Here you have the two interface supported by SpSharedRecognizer
Verify that those interfaces are present in your registry
use the IID (given by the registry)  with the function given upper.This one is the good method to connect.

Any code for doing it automatically?  :dazzled:
I used IID_Iunknown GUID <0H,0H,0H,<0C0H,0H,0H,0H,0H,0H,0H,046H>> on pIID and it connected, but retour return 0, is it okay?

[edit]
Aaaah this is what I want

IID_ISpeechRecognizer GUID {2D5F1C0Ch,0BD75h,4B08h,<94h,78h,3Bh,11h,0FEh,0A2h,58h,6Ch>}


[edit again]
USing IID_ISpeechRecognizer ppv return zero, is it normal?
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 08:15:21 AM

If the return value is 0 , it's not OK,perhaps have you not this CLSID in your registry.
MADE the verify , use regedit , open the HKEY_CLASSES_ROOT\CLSID key and with the edit menu search for 03BEE4890.It is enough like that.
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 08:20:44 AM
Oh its working, the return value is zero becase the SAPISrv is already started and Im not releasing it. Thanks. I will try to studying the documentation.
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 07, 2009, 08:28:57 AM
Quoteinclude macro.inc
what is it?
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 08:35:05 AM
 It's just a set of macros i use every time.
I must go away now.

Quote

   HIWORD MACRO ParamFen
      mov eax,ParamFen
      shr eax,16
   ENDM
   LOWORD MACRO ParamFen
      mov eax,ParamFen
      and eax,0FFFFh
   ENDM

      FUNC MACRO parameters:VARARG
        invoke parameters
        EXITM <eax>
      ENDM

      PuPo MACRO M1, M2
        push M2
        pop  M1
      ENDM

;un simple saut par dessus les datas en section code suffit
   InsTxt MACRO Name, Text:VARARG
   LOCAL lbl
      jmp lbl
      Name db Text,0
   lbl:
   ENDM

   return MACRO valeur
      mov eax,valeur
      ret
   ENDM
   
   
      ZEROLOCALES MACRO dernierelocale:REQ
         mov ecx,ebp
         lea edx,dernierelocale
         sub ecx,edx
         .if ecx != 0
            push edi
            mov edi,edx
            mov al,0
            cld
            rep stosb
            pop edi         
         .endif
      ENDM


    ; --------------------------------------------------------
    ; Crée une donnée en data,renvoie l'étiquette de la chaine
    ; La création du nom de l'étiquette est facultatif
    ; la macro vérifie la syntaxe des chaines et étiquettes
    ; ---------------------------------------------------------
      CREDATA MACRO quoted_text:REQ,NomdeChaine
      LOCAL Local_Etiquette,verif
   IFNB <NomdeChaine>         ;present
      verif SUBSTR <NomdeChaine>,1,1
            IFIDN verif,<">            ;si le premier caractere est "
         .ERR  <ETIQUETTE SUPRIMER les " >         
      ENDIF
   Local_Etiquette TEXTEQU <NomdeChaine>      ;changer le nom d'étiquette
   ENDIF
   verif SUBSTR <quoted_text>,1,1            
   IFDIF verif,<">
      .ERR  <CHAINE AJOUTER LES " >
   ENDIF
   
      .data
      Local_Etiquette db quoted_text,0
      .code
      EXITM <Local_Etiquette>
      ENDM
    ; ----------------------------------------------------
    ; Sort l' adresse de la chaine créer, SADR("chaine")
    ; -----------------------------------------------------
    ; ----------------------------------------------------
    ; Sort l' adresse de la chaine créer, SADR("chaine")
    ; -----------------------------------------------------
   ;si la chaine est "!DefaultToc",évite que "!" ne devienne un opérateur
   ;l'espace après ADDR et offset est indispensable
   SADR MACRO quoted_text:REQ,NomdeChaine
           EXITM @CatStr(<ADDR >, CREDATA(quoted_text,NomdeChaine))
      ENDM
    ; ----------------------------------------------------
    ; Sort l' offset de la chaine créer, SOFF("chaine")
    ; -----------------------------------------------------
   SOFF MACRO quoted_text:REQ,NomdeChaine
           EXITM @CatStr(<Offset >, CREDATA(quoted_text,NomdeChaine))
      ENDM   

  ; ---------------------------------------------------
  ; return an arguments specified in "num" from a macro
  ; argument list or "-1" if the number is out of range
  ; ---------------------------------------------------
    getarg MACRO num:REQ,args:VARARG
      LOCAL cnt, txt
      cnt = 0
      FOR arg, <args>
        cnt = cnt + 1
        IF cnt EQ num
          txt TEXTEQU <arg>     ;; set "txt" to content of arg num
          EXITM
        ENDIF
      ENDM
      IFNDEF txt
        txt TEXTEQU <-1>        ;; return -1 if num out of range
      ENDIF
      EXITM txt
    ENDM
   
  ; -----------------------------------------------
  ; count the number of arguments passed to a macro
  ; This is a slightly modified 1990 MASM 6.0 macro
  ; -----------------------------------------------
    argcount MACRO args:VARARG
      LOCAL cnt
      cnt = 0
      FOR item, <args>
        cnt = cnt + 1
      ENDM
      EXITM %cnt                ;; return as a number
    ENDM      
;la macro peut s'écrire plus simplement
;mais hélas,la boucle FOR ... génère un "internal error" lorsque le fichier inclus
;contient des macros,les macros argcount et getarg sont la pour y remédier
LIB  MACRO args:VARARG
   LOCAL acnt,buffer,var,boucle,buf1
   acnt = argcount(args)         ;macro argcount , nb d'arguments
   var = 1
   :boucle
   buffer equ getarg(var,args)      ;macro getarg

   buf1 CATSTR <include \masm32\include\>,buffer,<.inc>
   buf1

   buf1 CATSTR <includelib \masm32\lib\>,buffer,<.lib>
   buf1

   var = var + 1
   IF var LE acnt
   goto boucle
   ENDIF
ENDM

; macros d'écran

;HAUTEUR et LARGEUR permettent d'extraire ces dimensions d'une structure rectangle (RECT)

   ;usage    mov resultat,HAUTEUR( Rct)
   HAUTEUR MACRO Adrrect:REQ
      push ebx
      lea ebx,Adrrect
      mov     eax,(RECT ptr [ebx]).bottom                 ; y bas origine coin haut gauche 0,0
      sub     eax,(RECT ptr [ebx]).top              ; y haut   
      pop ebx
   EXITM <eax>
   ENDM
   LARGEUR MACRO Adrrect:REQ
      push ebx
      lea ebx,Adrrect
      mov     eax,(RECT ptr [ebx]).right       ; x coin droit bas  origine coin haut gauche 0,0
      sub     eax, (RECT ptr [ebx]).left      ; x coin gauche haut
      pop ebx
   EXITM <eax>
   ENDM
   comment µ
   
   FRECT   STRUCT
      min POINT <>
      max POINT <>
   FRECT ENDS
   
;la définition de la structure RECT est à jeter aux oubliettes
;dans .data     rect FRECT <>
;dans le code (pseudo code)
;   largeur = rect.max.x -rect.min.x
;        hauteur = rect.max.y - rect.min.y
;Reference de tailles pour MoveWindow et CreateWindowEx,dans l'ordre
;   rect.min.x,rect.min.y,largeur,hauteur
;Facile!? me direz-vous,essayez maintenant de faire la même chose avec RECT sans
;regarder winhelp.Je parie que vous n'y arrivez pas,ou alors vous la connaissez par coeur et ne vérifiez pas
;vos sources
;RECT est une blague de chez microsoft
   µ

;----------------------------- exceptions -------------------------------

   comment µ
   lea edx,FindeProgramme
   invoke InstalleExceptions,SADR("c:\masm32\ref\dbghelp.dll"),\
         DebutdeProgramme,edx
   .if eax == 0
      jmp Findeminus
   .endif
   mov Hdbghelp,eax
   µ

;--------------- macro pour exception ------------------------------------------------
;XP
   ;remplacer invoke par XPEXCEPT ,c'est tout
   
   XPEXCEPT MACRO parameters:VARARG
      ;ajouter dans les déclarations:    EXTERNDEF pileazertyswxc:DWORD   
      invoke AddVectoredExceptionHandler,1,HANDLER
      ;éviter de redescendre les adresses laissées en pile par la fonction,9
      push pileazertyswxc   ;préservé les handlers précédents
      mov eax,esp
      mov pileazertyswxc,eax      
      invoke parameters
      invoke RemoveVectoredExceptionHandler,HANDLER
      pop pileazertyswxc
   ENDM








   ;usage
   ;EXCEPT ("je me trouve dans macro.inc"),Nomproc,Param1,Param2.....
   ;remplace: invoke Nomproc,Param1,Param2
   ;-------- structures pour les HANDLERS ------------------------------



;--------------------- version 98 -------------------------------------------------------

   ERR_WIN STRUCT
      ERR_OLD   dd ?         ;c'est le bloc que windows s'attend a trouver   
      ERR_NEW   dd ?         ;inversé par rapport a la normale
   ERR_WIN ENDS

   
   MEM_EXCEPT   STRUCT
      err_win ERR_WIN   <>      ;position imposée,rien au dessus
      Adr_retour      dd ?      ;derrière le proc appelé
      Chaine_Explique   dd ?         
      Adr_Invoke      dd ?      
      Reg_EBP      dd ?      
      Valeur_Retour   dd ?      
   MEM_EXCEPT   ENDS


;windows 98   
   ;---------------------------------------------------------------------------
   EXCEPT   MACRO NomProc:REQ,parameters:VARARG
      LOCAL Local_Etiquette
      LOCAL localinvoke
      sub esp,sizeof MEM_EXCEPT   ;reserve de la place en pile
      mov edx,esp                        
      xor eax,eax
      mov (MEM_EXCEPT ptr [edx]).Valeur_Retour,eax   ;zero pour l'instant
      mov (MEM_EXCEPT ptr [edx]).Reg_EBP,ebp
      lea eax,localinvoke
      mov (MEM_EXCEPT ptr [edx]).Adr_Invoke,eax
      mov eax,ADRESSE NomProc
      mov (MEM_EXCEPT ptr [edx]).Chaine_Explique,eax
      lea eax,Local_Etiquette
      mov (MEM_EXCEPT ptr [edx]).Adr_retour,eax
      lea eax,HANDLER   ;la nouvelle routine d'exceptions
      mov (MEM_EXCEPT ptr [edx]).err_win.ERR_NEW,eax
      assume FS:NOTHING      ;masm par défaut affecte une structure a FS            
      push FS:[0]          ;conserve l'ancien pointeur sur ERR      ;pointeur +0
      pop  (MEM_EXCEPT ptr [edx]).err_win.ERR_OLD
      ;windows est content,il a son bloc d'adresse
      mov FS:[0],esp         ;remplacer l'ancien pointeur sur ERR par le nouveau            
      localinvoke:      ;---------------ce qui du meme coup sauvegarde esp
      invoke parameters      ;rajouter la ligne tel que
      mov edx,esp
      add edx,sizeof MEM_EXCEPT
      mov (MEM_EXCEPT ptr [edx]).Valeur_Retour,eax   
            ;tout s'est bien passer,préserve la valeur de retour
      Local_Etiquette:      ;adresse ou continuer en cas d'échec
      mov eax,(MEM_EXCEPT ptr [edx]).Valeur_Retour   ;envoyé par handler
            ;prend la valeur de retour ,modifié en cas d'exceptions
      push dword ptr (MEM_EXCEPT ptr [edx]).err_win.ERR_OLD
      pop FS:[0]             ;retablir l'ancien err quand la zone protégée est terminée
      add esp,sizeof MEM_EXCEPT       ;libere la mémoire pile   
   ENDM


   
   ADRESSE MACRO bidule:REQ
      EXITM <offset CREDATA (bidule)>
   ENDM
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 09:03:11 AM
Aw, I cant call anything.
I want to make it clear, ppv return an array of each function right? And each function address is 4 bytes am I right?
So How should I call it?

I tried this
Quote
ShutDownSAPI proc uses esi edi
   
   mov eax,sri
   call [eax].STISpRecognizer.Release
   
   ret
ShutDownSAPI endp
Where sri is the ppv from the init function, but it crashes. I think that function has no parameter.
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 07, 2009, 11:51:19 AM
Anyone know why I cannot get the object?

This is the C++ Code

g_cpRecoCtxt->CreateGrammar(GRAMMARID1, &g_cpCmdGrammar);

And here is my code

CreateGrammar proc uses esi edi
LOCAL qw:qword

lea eax,cgrm ; This is g_cpCmdGrammar
push eax
lea eax,qw  ; GRAMMARID1
mov edx,0
movd mm0,edx
movq [eax],mm0
push eax
mov esi,rcc
push esi
mov esi,[esi]
call [esi].STISpRecoContext.CreateGrammar

.if cgrm==0
invoke MessageBox,0,CADD("Error creating grammar"),0,0
.endif


; push 2
; push CSTR("coffee.xml")
; mov esi,cgrm
; push esi
; mov esi,[esi]
; call [esi].STISpRecoGrammar.LoadCmdFromFile

ret
CreateGrammar endp
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 07, 2009, 02:46:25 PM
Same methods as upper.
Typelib translated by Oleview
Quote

    coclass SpMMAudioIn {
        [default] interface ISpeechMMSysAudio;
        interface ISpEventSource;
        interface ISpEventSink;
        interface ISpObjectWithToken;
        interface ISpMMSysAudio;


    [
      odl,
      uuid(2177DB29-7F45-47D0-8554-067E91C80502),    //IID_ISpRecoGrammar
      helpstring("ISpRecoGrammar Interface"),
      restricted
    ]


    coclass SpSharedRecoContext {
        [default] interface ISpeechRecoContext;
        interface ISpRecoContext;
        [default, source] dispinterface _ISpeechRecoContextEvents;

   [
      odl,
      uuid(F740A62F-7C15-489E-8234-940A33D9272D),           //IID_ISpRecoContext
      helpstring("ISpRecoContext Interface"),
      restricted


1) verify that this interface is in your registry (if not,find a way to install it)
2) same code as upper
   ISpRecoGrammar  LoadCmdFromFile,dword,dword


The interface "ISpEventSource  CreateGrammar"  give the ppv on the ISpRecoGrammar interface
coclass = CLSID

Look at SpMMAudioIn in the registry and you have what you want
Typelib (oleview) is the only one document who give the interfaces supported by a CLSID (coclass)



Title: Re: Am I right defining the GUID?
Post by: Farabi on June 08, 2009, 02:54:47 AM
The return value of  g_cpRecoCtxt->CreateGrammar is E_INVALIDARG so I guess the interface is on my system.
The ID is a pointer to 64-bit address ID and the next parameter is a pointer to Grammar pointer.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 08, 2009, 06:47:07 AM
In this case a search for this interface in the translated typelib show that the pointer is given by "ISpRecognizer CreateRecoContext".
Try to give it threw:
Quote
    [
      uuid(41B89B6B-9399-11D2-9623-00C04F8EE628),
      helpstring("SpInprocRecognizer Class")
    ]
    coclass SpInprocRecognizer {
        [default] interface ISpeechRecognizer;
        interface ISpRecognizer;
    };

 
see also http://msdn.microsoft.com/en-us/library/ms718548(VS.85).aspx

Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 08, 2009, 06:52:57 AM
hope, you have more time to write some exmple for me.
:wink
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 08, 2009, 03:22:27 PM
On WinXp the IID is IID_SpeechRecognizer5_1 GUID {0C2B5F241h,0DAA0h,04507h,<9Eh,16h,5Ah,1Eh,0AAh,2Bh,7Ah,5Ch>} ( I downloaded OLEViewer from MS Site)
This thing is complicated is not it? I want to understand this basic first, after this done, I will jump to macro.

[edit]
Got it working on XP I guess I know why g_cpRecoCtxt->CreateGrammar(GRAMMARID1, &g_cpCmdGrammar); is not working, because Vista is using vesrsion 5.3 and XP is 5.1. XP need 3 parameter on it, ull is a double push of dword (I know it because I debug the MS example) but the vista version is unknown. This this really complicated.

Here is the code so far


STISpRecognizer STRUCT
QueryInterface                dword ?
AddRef                        dword ?
Release                      dword ?
SetPropertyNum                dword ?
GetPropertyNum                dword ?
SetPropertyString            dword ?
GetPropertyString            dword ?
SetRecognizer                dword ?
GetRecognizer                dword ?
SetInput                      dword ?
GetInputObjectToken          dword ?
GetInputStream                dword ?
CreateRecoContext            dword ?
GetRecoProfile                dword ?
SetRecoProfile                dword ?
IsSharedInstance              dword ?
GetRecoState                  dword ?
SetRecoState                  dword ?
GetStatus                    dword ?
GetFormat                    dword ?
IsUISupported                dword ?
DisplayUI                    dword ?
EmulateRecognition            dword ?
STISpRecognizer ENDS

STISpRecoContext STRUCT
QueryInterface                dword ?
AddRef                        dword ?
Release                      dword ?
SetNotifySink                dword ?
SetNotifyWindowMessage        dword ?
SetNotifyCallbackFunction    dword ?
SetNotifyCallbackInterface    dword ?
SetNotifyWin32Event          dword ?
WaitForNotifyEvent            dword ?
GetNotifyEventHandle          dword ?
SetInterest dword  ?
GetEvents                    dword ?
GetInfo                      dword ?
GetRecognizer                dword ?
CreateGrammar dword  ?
GetStatus                    dword ?
GetMaxAlternates              dword ?
SetMaxAlternates              dword ?
SetAudioOptions              dword ?
GetAudioOptions              dword ?
DeserializeResult            dword ?
Bookmark dword  ?
SetAdaptationData            dword ?
pause1                        dword ?
Resume                        dword ?
SetVoice                      dword ?
GetVoice                      dword ?
SetVoicePurgeEvent dword  ?
GetVoicePurgeEvent            dword ?
SetContextState              dword ?
GetContextState              dword ?
STISpRecoContext ENDS

STISpRecoGrammar STRUCT
QueryInterface                dword ?
AddRef                        dword ?
Release                      dword ?
ResetGrammar                  dword ?
GetRule                      dword ?
ClearRule                    dword ?
CreateNewState                dword ?
AddWordTransition            dword ?
AddRuleTransition            dword ?
AddResource                  dword ?
Commit                        dword ?
GetGrammarId                  dword ?
GetRecoContext                dword ?
LoadCmdFromFile              dword ?
LoadCmdFromObject            dword ?
LoadCmdFromResource          dword ?
LoadCmdFromMemory            dword ?
LoadCmdFromProprietaryGrammar dword ?
SetRuleState                  dword ?
SetRuleIdState                dword ?
LoadDictation                dword ?
UnloadDictation              dword ?
SetDictationState            dword ?
SetWordSequenceData          dword ?
SetTextSelection              dword ?
IsPronounceable              dword ?
SetGrammarState              dword ?
SaveCmd                      dword ?
GetGrammarState              dword ?
STISpRecoGrammar ENDS

SPPHRASEELEMENT STRUCT
ulAudioTimeOffset DWORD ?
ulAudioSizeTime DWORD ?
ulAudioStreamOffset DWORD ?
ulAudioSizeBytes DWORD ?
ulRetainedStreamOffset DWORD ?
ulRetainedSizeBytes DWORD ?
pszDisplayText DWORD ?
pszLexicalForm DWORD ?
pszPronunciation DWORD ?
bDisplayAttributes BYTE ?
RequiredConfidence BYTE ?
ActualConfidence BYTE ?
Reserved BYTE ?
SREngineConfidence DWORD ?
SPPHRASEELEMENT ENDS



SPPHRASERULE STRUCT
pszName DWORD ?
ulId DWORD ?
ulFirstElement DWORD ?
ulCountOfElements DWORD ?
pNextSibling DWORD ?
pFirstChild DWORD ?
SREngineConfidence DWORD ?
Confidence BYTE ?
SPPHRASERULE ENDS



;SPPHRASEPROPERTY STRUCT
; pszName DWORD ?
; ulId DWORD ?
; pszValue DWORD ?
; vValue VARIANT <>
; ulFirstElement DWORD ?
; ulCountOfElements DWORD ?
; pNextSibling DWORD ?
; pFirstChild DWORD ?
; SREngineConfidence DWORD ?
; Confidence BYTE ?
;SPPHRASEPROPERTY ENDS



SPPHRASEREPLACEMENT STRUCT
bDisplayAttributes BYTE ?
pszReplacementText DWORD ?
ulFirstElement DWORD ?
ulCountOfElements DWORD ?
SPPHRASEREPLACEMENT ENDS



SPSEMANTICERRORINFO STRUCT
ulLineNumber DWORD ?
pszScriptLine DWORD ?
pszSource DWORD ?
pszDescription DWORD ?
hrResultCode DWORD ?
SPSEMANTICERRORINFO ENDS



SPPHRASE_50 STRUCT
cbSize DWORD ?
LangID WORD ?
wHomophoneGroupId WORD ?
ullGrammarID QWORD ?
ftStartTime QWORD ?
ullAudioStreamPosition QWORD ?
ulAudioSizeBytes DWORD ?
ulRetainedSizeBytes DWORD ?
ulAudioSizeTime DWORD ?
Rule SPPHRASERULE <>
pProperties DWORD ?
pElements DWORD ?
cReplacements DWORD ?
pReplacements DWORD ?
SREngineID GUID <>
ulSREnginePrivateDataSize DWORD ?
pSREnginePrivateData DWORD ?
SPPHRASE_50 ENDS


SP_SPPHRASESIZE_500 equ < SPPHRASE_50>
IF 0

SPPHRASE STRUCT
cbSize DWORD ?
LangID WORD ?
wReserved WORD ?
ullGrammarID QWORD ?
ftStartTime QWORD ?
ullAudioStreamPosition QWORD ?
ulAudioSizeBytes DWORD ?
ulRetainedSizeBytes DWORD ?
ulAudioSizeTime DWORD ?
Rule SPPHRASERULE <>
pProperties DWORD ?
pElements DWORD ?
cReplacements DWORD ?
pReplacements DWORD ?
SREngineID GUID <>
ulSREnginePrivateDataSize DWORD ?
pSREnginePrivateData DWORD ?
SPPHRASE ENDS


ELSE
IFDEF SAPI_ALLOW_ENGINE_SML

SPPHRASE STRUCT
pSML DWORD ?
pSemanticErrorInfo DWORD ?
SPPHRASE ENDS


ELSE
ENDIF
ENDIF

SPSERIALIZEDPHRASE STRUCT
ulSerializedSize DWORD ?
SPSERIALIZEDPHRASE ENDS



SPRULE STRUCT
pszRuleName DWORD ?
ulRuleId DWORD ?
dwAttributes DWORD ?
SPRULE ENDS

        S_OK equ 0
        S_FALSE equ 00000001
        NOERROR equ 0
        E_NOTIMPL     equ 80004001h
        E_NOINTERFACE equ 80004002h
        E_POINTER     equ 80004003h
        E_ABORT       equ 80004004h
        E_FAIL        equ 80004005h
        E_HANDLE      equ 80070006h
        CLASS_E_NOAGGREGATION equ 80040110h
        E_OUTOFMEMORY equ 8007000Eh
        E_INVALIDARG  equ 80070057h
        E_UNEXPECTED  equ 8000FFFFh


.data
GUID_SpSharedRecognizer GUID {3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}
spi STISpRecognizer <?>
IID_SpSharedRecognizer GUID {?}
IID_Iunknown GUID <0H,0H,0H,<0C0H,0H,0H,0H,0H,0H,0H,046H>>
IID_SpeechRecognizer GUID {2D5F1C0Ch,0BD75h,4B08h,<94h,78h,3Bh,11h,0FEh,0A2h,58h,6Ch>}
IID_RecoGrammar GUID {0B6D6F79Fh,02158h,04E50h,<0B5h,0BCh,9ah,9ch,0CDh,85h,02Ah,09h>}
IID_RecoContext GUID {580AA49Dh,7E1Eh,4809h,<0B8h,0E2h,57h,0DAh,80h,61h,04h,0B8h>}

IID_SpeechRecognizer5_1 GUID {0C2B5F241h,0DAA0h,04507h,<9Eh,16h,5Ah,1Eh,0AAh,2Bh,7Ah,5Ch>}

sri dword 0
rcc dword 0
cgrm dword 0

.code

GetInterfaceFromProgId PROC pProgId:DWORD,pIID:DWORD
        LOCAL wszProgID[1024]:word
        LOCAL ppv:Dword,retour,pchaine         
        LOCAL clsid     :GUID
       
        ; Wrote by ToutEnMasm
        mov retour,0

        invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,pProgId,-1,addr wszProgID,sizeof wszProgID
        invoke CLSIDFromProgID,addr wszProgID,addr clsid
        .if eax == S_OK
                invoke CoCreateInstance,addr clsid, NULL,CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER OR CLSCTX_LOCAL_SERVER,pIID,addr ppv
                .if eax == S_OK
; invoke MessageBox,0,CADD("ppv Filled"),0,0
                        push ppv
                        pop retour
                .endif
        .endif
        mov eax,retour
        RET
GetInterfaceFromProgId endp

InitSAPI proc uses esi edi


;invoke CoCreateInstance,addr GUID_SpSharedRecognizer,0,CLSCTX_ALL,addr GUID_SpSharedRecognizer,addr spi
invoke GetInterfaceFromProgId,CADD("Sapi.SpSharedRecognizer.1"),addr IID_SpeechRecognizer5_1
.if eax==0
invoke MessageBox,0,CADD("Something was wrong"),0,0
.else
mov sri,eax
.endif

ret
InitSAPI endp

CreateRecoContact proc uses esi edi

mov rcc,0

mov esi,sri
lea eax,rcc
push eax
mov eax,sri
push eax
mov esi,[esi]
call [esi].STISpRecognizer.CreateRecoContext


.if rcc==0
invoke MessageBox,0,CADD("FAiled"),0,0
.endif

ret
CreateRecoContact endp

SetNotifyWindowMessage proc uses esi edi hWnd:dword,uMsg:UINT, wParam:WPARAM, lParam:LPARAM

push lParam
push wParam
push uMsg
push hWnd
mov esi,rcc
push esi
mov esi,[esi]
call [esi].STISpRecoContext.SetNotifyWindowMessage

ret
SetNotifyWindowMessage endp

SetInterest proc uses esi edi
LOCAL ull:qword

lea eax,ull
push eax
push eax
mov esi,rcc
push esi
mov esi,[esi]
call [esi].STISpRecoContext.SetInterest

ret
SetInterest endp

CreateGrammar proc uses esi edi
LOCAL qw:qword
LOCAL buff[256]:dword

lea eax,cgrm
push eax
lea eax,qw
mov edx,161
pxor mm0,mm0
movd mm0,edx
movq [eax],mm0
push 0
push 161
mov esi,rcc
push esi
mov esi,[esi]
call [esi].STISpRecoContext.CreateGrammar

.if cgrm==0
push eax
invoke MessageBox,0,CADD("Error creating grammar"),0,0
pop eax
xchg edx,eax
invoke dw2hex,edx,addr buff
invoke MessageBox,0,addr buff,0,0
.endif
; invoke PostQuitMessage,0
; push 2
; push CSTR("coffee.xml")
; mov esi,cgrm
; push esi
; mov esi,[esi]
; call [esi].STISpRecoGrammar.LoadCmdFromFile

ret
CreateGrammar endp

ShutDownSAPI proc uses esi edi

mov eax,sri
push eax
mov eax,[eax]
call [eax].STISpRecognizer.Release

ret
ShutDownSAPI endp


.if uMsg==WM_CREATE
invoke CoInitializeEx,0,COINIT_MULTITHREADED
.if eax!=S_OK
invoke MessageBox,0,CADD("COM Initialization error"),0,MB_OK
.else
invoke InitSAPI
.if eax!=0
invoke CreateRecoContact
invoke SetNotifyWindowMessage,hWnd,WM_USER,0,0
;invoke PostQuitMessage,0
;invoke SetInterest
invoke CreateGrammar
.endif
.endif
.endif
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 08, 2009, 03:32:40 PM
miss pressed button
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 08, 2009, 05:19:56 PM
There is a little error in your writing
Two interfaces can get a RecoContext pointer (ISpRecoContext)
it is the ISpeechRecognizer  and the ISpRecognizer
Quote
IID_ISpeechRecognizer GUID {2D5F1C0Ch,0BD75h,4B08h,<94h,78h,3Bh,11h,0FEh,0A2h,58h,6Ch>}
the one you call IID_SpeechRecognizer5_1
Quote
IID_ISpRecognizer GUID {0C2B5F241h,0DAA0h,04507h,<9Eh,16h,5Ah,1Eh,0AAh,2Bh,7Ah,5Ch>}

To work with Speech recognition

http://www.e-speaking.com/installsapi.htm



Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 08, 2009, 07:17:06 PM

Source code with the translated SDK RC 7
Don't forget to install SAPI
http://www.e-speaking.com/installsapi.htm

Quote
.NOLIST         
   .586
   .model flat, stdcall
   option casemap :none   ; case sensitive
      
   include translate.inc
   include windows.sdk
   include richedit.sdk
   include adoctint.sdk
   include sapi51.sdk
   include macro.inc
   ;include dbdao.sdk
   
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\oleaut32.lib
      includelib \masm32\lib\ole32.lib
   

   .const


   .data
ppvISpRecognizer dd 0   
ppvISpeechRecognizer dd 0
ppvISpEventSource dd 0
ppvISpRecoContext dd 0
ppvISpRecoGrammar dd 0
CLSID_SpSharedRecoContext GUID {47206204h,5ECAh,11D2h,<96h,0Fh,00h,0C0h,4Fh,8Eh,0E6h,28>}
CLSID_SpSharedRecognizer GUID {03BEE4890h,04FE9h,04A37h,<08Ch,1Eh,05Eh,07Eh,012h,79h,1Ch,1Fh>}   
IID_IUnknown GUID <0H,0H,0H,<0C0H,0H,0H,0H,0H,0H,0H,046H>>
IID_ISpeechRecognizer GUID {2D5F1C0Ch,0BD75h,4B08h,<94h,78h,3Bh,11h,0FEh,0A2h,58h,6Ch>}
IID_ISpEventSource GUID {0BE7A9CCEh,5F9Eh,11D2h,<96h,0Fh,00h,0C0h,4Fh,8Eh,0E6h,28h>}
;F740A62F
IID_ISpRecoContext GUID {0F740A62Fh,7C15h,489Eh,<82h,34h,94h,0Ah,33h,0D9h,27h,2Dh>}
IID_ISpRecognizer GUID {0C2B5F241h,0DAA0h,04507h,<9Eh,16h,5Ah,1Eh,0AAh,2Bh,7Ah,5Ch>}
     ; uuid(C2B5F241-DAA0-4507-9E16-5A1EAA2B7A5C),
ullGramId QWORD 0

   .code
   
   start:
   invoke CoInitializeEx ,NULL, COINIT_MULTITHREADED
   ;   SharedRecognizer method
   invoke GetInterfaceFromProgId,SADR("Sapi.SpSharedRecognizer.1"),addr IID_ISpeechRecognizer ;IID_ISpRecognizer
   .if eax != 0
      mov ppvISpeechRecognizer,eax   
      ISpeechRecognizer CreateRecoContext,   addr ppvISpRecoContext
      .if ppvISpRecoContext != 0
         ISpRecoContext Release
      .else
         invoke MessageBox,NULL,SADR("SAPI is not Installed"),SADR("SAPI ERROR"),MB_OK   
      .endif
      ISpeechRecognizer Release
   .endif
   ;-------------------------------------------------------------------------------
   ;------------ InprocRecognizer method ----------------------
   ;SADR("SAPI.SpMMAudioIn.1")
   invoke GetInterfaceFromProgId,SADR("Sapi.SpInprocRecognizer.1"),addr IID_ISpRecognizer
   .if eax != 0
      mov ppvISpRecognizer,eax
      ISpRecognizer CreateRecoContext,   addr ppvISpRecoContext
      .if ppvISpRecoContext != 0   
         mov dword ptr [ullGramId],1
         ISpRecoContext CreateGrammar,ullGramId,addr ppvISpRecoGrammar
         .if eax == S_OK
            invoke MessageBox,NULL,SADR("ISpRecoContext CreateGrammar"),SADR("SpInprocRecognizer"),MB_OK         
            ISpRecoGrammar Release
         .endif
         ISpRecoContext Release
      .else
         invoke MessageBox,NULL,SADR("SAPI is not Installed"),SADR("SAPI ERROR"),MB_OK            
      .endif
      ISpRecognizer Release
   .endif   
   invoke CoUninitialize
   invoke ExitProcess,0
   ;------- proc içi ------------
GetInterfaceFromProgId PROC pProgId:DWORD,pIID:DWORD
        LOCAL wszProgID[1024]:word
        LOCAL ppv:Dword,retour,pchaine         
        LOCAL clsid     :GUID
        mov retour,0

        invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,pProgId,-1,addr wszProgID,sizeof wszProgID
        invoke CLSIDFromProgID,addr wszProgID,addr clsid
        .if eax == S_OK
                invoke CoCreateInstance,addr clsid, NULL,CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER OR CLSCTX_LOCAL_SERVER,pIID,addr ppv
                .if eax == S_OK                         
                        PuPo retour,ppv
                .endif
        .endif
        mov eax,retour
        RET
GetInterfaceFromProgId endp   
   end start      
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 02:40:27 AM
Speech SDK 5.1http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en
not for Vista or Win7.
:(
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 03:42:17 AM
i need more help Assembling: SAPI.asm
sdk\sdkrc7\adoctint.sdk(15) : fatal error A1000: cannot open file : tchar.SDK
Press any key to continue . . .
File: sdk.zip
Sha1: 6b3e89a51b17ab70dd8ea65a16f6de162a9de431
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 09, 2009, 04:21:29 AM
Quote from: UtillMasm on June 09, 2009, 03:42:17 AM
i need more help Assembling: SAPI.asm
sdk\sdkrc7\adoctint.sdk(15) : fatal error A1000: cannot open file : tchar.SDK
Press any key to continue . . .
File: sdk.zip
Sha1: 6b3e89a51b17ab70dd8ea65a16f6de162a9de431


Well, I guess you need that tchar.sdk file.
Title: Re: Am I right defining the GUID?
Post by: dedndave on June 09, 2009, 04:22:48 AM
careful Farabi - you will be a terrorist, again - lol
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 04:31:23 AM
 :naughty:
no, the man is a master now.

i don't know about the 'tchar.sdk' file.
how to generate the file or where can download Newer 'sdk.zip'?
Title: Re: Am I right defining the GUID?
Post by: dedndave on June 09, 2009, 04:49:41 AM
i found tchar.h
it is an include file
C:\Program Files\Microsoft Visual Studio 9.0\VC\include
maybe you need to have an environment variable set
set include=C:\Program Files\Microsoft Visual Studio 9.0\VC\include
better to go into the control panel
system icon
advanced tab
environment variables
create new system variable
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 04:54:07 AM
9.0? Visual Studio 2003?
tchar.h is very helpful information! :U@echo off
echo Generating C Volume Structure to File...
dir c:\ /a-d/s/b>CVolumeFiles.txt
echo Finding character strings...
find.exe/i"\tchar.h" "CVolumeFiles.txt"
echo Done, ready to exit.
pause
echo Generating C Volume Structure to File...
Finding character strings...

---------- CVOLUMEFILES.TXT
c:\Cygwin\usr\include\mingw\tchar.h
c:\Program Files\Microsoft SDKs\Windows\v6.0\VC\INCLUDE\tchar.h
c:\WinDDK\6001.18001\inc\crt\tchar.h
c:\wrk\wrk-v1.2\public\sdk\inc\crt\tchar.h
Done, ready to exit.
Press any key to continue . . .

.h is not .SDK.
Title: Re: Am I right defining the GUID?
Post by: dedndave on June 09, 2009, 05:01:22 AM
the only SDK file i have is makefile.sdk
it is a makefile
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 05:58:50 AM

A little explain seem needed on the missing files in the sdk translate.
The windows SDK include header files that can be found only in the c++ express edition or better edition of the c++.
To solve this,put them in comment adding a ; in the include files.
It isn't obligatory to have them in the set of files.
In case of need just translate them with the translator and add them to the set of files of the SDK.
If i have a few minutes i put them here in a zip files.
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 06:13:06 AM
 :U
waiting for your zip! and hope you have more time be here.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 06:44:08 AM

They are Here
http://www.masm32.com/board/index.php?topic=11617.msg87347#msg87347
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 06:53:14 AM
 :U
Assembling: SAPI.asm
..\sdk\sdkrc7\crtdefs.SDK(220) : error A2005: symbol redefinition : __GOT_SECURE
_LIB__
..\sdk\sdkrc7\crtdefs.SDK(549) : error A2008: syntax error : [
..\sdk\sdkrc7\crtdefs.SDK(552) : error A2005: symbol redefinition : refcount
..\sdk\sdkrc7\crtdefs.SDK(554) : fatal error A1010: unmatched block nesting
Press any key to continue . . .
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 07:08:38 AM

put the one redefined in comment

Quote
   STRUCT   lc_category[6]
   locale DWORD ?
   wlocale DWORD ?
   refcount DWORD ?
   wrefcount DWORD ?
   ENDS

This nested structure is repeated 6
Masm don't accept this.
Put it out of the "threadlocinfo   STRUCT" like this



Quote

IFNDEF _THREADLOCALEINFO
LC_CATEGORY STRUCT   
   locale DWORD ?
   wlocale DWORD ?
   refcount DWORD ?
   wrefcount DWORD ?
LC_CATEGORY ENDS


threadlocinfo   STRUCT
   refcount DWORD ?
   lc_codepage DWORD ?
   lc_collate_cp DWORD ?
   lc_handle DWORD 6 dup (?) ;/* LCID */
   lc_id LC_ID 6 dup (<>)
   lc_category LC_CATEGORY 6 dup (<>)
   lc_clike DWORD ?
   mb_cur_max DWORD ?
   lconv_intl_refcount DWORD ?
   lconv_num_refcount DWORD ?
   lconv_mon_refcount DWORD ?
   lconv DWORD ?
   ctype1_refcount DWORD ?
   ctype1 DWORD ?
   pctype DWORD ?
   pclmap DWORD ?
   pcumap DWORD ?
   lc_time_curr DWORD ?
threadlocinfo      ENDS









Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 07:19:18 AM
 :U Assembling: SAPI.asm
..\sdk\sdkrc7\crtdefs.SDK(220) : error A2005: symbol redefinition : __GOT_SECURE
_LIB__
SAPI.asm(51) : error A2006: undefined symbol : GetInterfaceFromProgId
SAPI.asm(65) : error A2006: undefined symbol : GetInterfaceFromProgId
SAPI.asm(101) : fatal error A1010: unmatched block nesting : if-else
Press any key to continue . . .
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 07:32:38 AM

That's just a mistake cutting comments in the source I have posted,just add
Quote
   GetInterfaceFromProgId PROTO :DWORD,:DWORD

For the .if missing , look at the lines (all conditions are in the source posted).The  GetInterfaceFromProgId  used two if .Perhaps have you cut some words ?.
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 07:38:01 AM
 :U
Assembling: SAPI.asm
..\sdk\sdkrc7\crtdefs.SDK(220) : error A2005: symbol redefinition : __GOT_SECURE
_LIB__
SAPI.asm(101) : fatal error A1010: unmatched block nesting : if-else
Press any key to continue . . .

[attachment deleted by admin]
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 08:06:25 AM

You have cuted a if in the crtdefs.sdk and masm search a if at the end of the files , that is in the asm file.
here is the corrected crtdefs

[attachment deleted by admin]
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 08:10:51 AM
 :U
Assembling: SAPI.asm
..\sdk\sdkrc7\adoctint.sdk(1637) : fatal error A1010: unmatched block nesting
Press any key to continue . . .
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 08:16:15 AM
Put this include file in comment , it was for another answer in the forum.YOU DON'T NEED IT.
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 08:20:08 AM
 :U
Assembling: SAPI.asm
SAPI.obj : error LNK2001: unresolved external symbol _VarI4FromI8@12
SAPI.obj : error LNK2001: unresolved external symbol _VarI4FromUI8@12
SAPI.exe : fatal error LNK1120: 2 unresolved externals
Press any key to continue . . .
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 08:24:06 AM

      includelib \masm32\lib\oleaut32.lib

It's two names of api that are reused in interfaces functions and masm don't accept this


Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 08:34:59 AM

Not that,
There is something unsupported by masm in the name ??..!
just put in comment the prototypes ,adding just a ; (nothing else) here
Quote
F:\sdkrc7\OleAuto.sdk
308   : VarI4FromUI8 PROTO :QWORD ,:DWORD
684   : VarI4FromUI8 PROTO :QWORD ,:DWORD
Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 12:32:18 PM
 :U Assembling: SAPI.asm
LINK : warning LNK4089: all references to "gdi32.dll" discarded by /OPT:REF
Press any key to continue . . .
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 12:54:34 PM

You are ready now to make a simple of use.
using interfaces couldn't be more simple
Sample:
You want to use ISpeechPhraseRule ,create a data for the interface pointer adding ppv to the name of the interface.That is ppvISpeechPhraseRule
Get the pointer on the interface , put it in ppvISpeechPhraseRule
You can now use the interface as an api ,the name of the interface replace invoke (who is in used in the macro)
sample
ISpeechPhraseRule Release

If you don't have it,download Oleview,it is very useful to find the interfaces supported by a CLSID(coclass)


Title: Re: Am I right defining the GUID?
Post by: UtillMasm on June 09, 2009, 12:57:45 PM
 :U
ok, thanks.
Title: Re: Am I right defining the GUID?
Post by: dedndave on June 09, 2009, 01:10:12 PM
Quoteusing interfaces couldn't be more simple
that's easy for you to say - lol
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 09, 2009, 06:05:14 PM

I wasn't saying it is simple
If you find something more simple with the same grants of writing (use of prototypes and invoke), I get it.

Title: Re: Am I right defining the GUID?
Post by: Farabi on June 10, 2009, 02:05:11 AM
What is this used for? ISpRecoGrammar::LoadDictation and how do I make a topic for it?

Is this function STISpRecoGrammar.SetDictationState make my computer to start listening? How to get the word from it?
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 10, 2009, 07:26:23 AM

Seems you need now a microphone and to study the samples.
For XP it's here
http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 10, 2009, 10:24:27 AM
Quote from: ToutEnMasm on June 10, 2009, 07:26:23 AM

Seems you need now a microphone and to study the samples.
For XP it's here
http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en

The microphone is attached to my laptop.
I already had all of the SDK, just need an example, but nevermind, I will debug the example.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 10, 2009, 12:14:15 PM

In this case,the "SimpleDict" is written in c++ and seems to be not too more difficult.
I have try to compile it without success (too many errors of syntax)
But the exe work.
I will try to translate it.

Title: Re: Am I right defining the GUID?
Post by: Farabi on June 10, 2009, 12:19:51 PM
Quote from: ToutEnMasm on June 10, 2009, 12:14:15 PM

In this case,the "SimpleDict" is written in c++ and seems to be not too more difficult.
I have try to compile it without success (too many errors of syntax)
But the exe work.
I will try to translate it.



Talkback looks more simpler I guess.


I confused translating this, I think this is the last part

inline HRESULT BlockForResult(ISpRecoContext * pRecoCtxt, ISpRecoResult ** ppResult)
{
    HRESULT hr = S_OK;
CSpEvent event;

    while (SUCCEEDED(hr) &&
           SUCCEEDED(hr = event.GetFrom(pRecoCtxt)) &&
           hr == S_FALSE)
    {
        hr = pRecoCtxt->WaitForNotifyEvent(INFINITE);
    }

    *ppResult = event.RecoResult();
    if (*ppResult)
    {
        (*ppResult)->AddRef();
    }

    return hr;
}




WaitForNotifyEvent proc uses esi edi nDWMilliSecond:dword

push nDWMilliSecond
mov esi,rcc
push esi
mov esi,[esi]
call [esi].STISpRecoContext.WaitForNotifyEvent

ret
WaitForNotifyEvent endp

BlockForResult proc
LOCAL buff[256]:dword


push 0
lea eax,buff
push eax
push 1
mov eax,rcc
push eax
mov eax,[eax]
call[eax].STISpRecoContext.GetEvents

; invoke WaitForNotifyEvent,INFINITE
; .if eax==S_OK
; xchg edx,eax
; invoke dw2hex,edx,addr buff
; invoke MessageBox,0,addr buff,0,0
; .endif
;invoke MessageBox,hWnd,CADD("OKe done"),0,0

ret
BlockForResult endp


Here is a part of the event class

   IUnknown * Object() const
    {
        SPDBG_ASSERT(elParamType == SPET_LPARAM_IS_OBJECT);
        return (IUnknown*)lParam;
    }
    ISpRecoResult * RecoResult() const
    {
        SPDBG_ASSERT(eEventId == SPEI_RECOGNITION || eEventId == SPEI_FALSE_RECOGNITION || eEventId == SPEI_HYPOTHESIS);
        return (ISpRecoResult *)Object();
    }
   HRESULT GetFrom(ISpEventSource * pEventSrc)
    {
        SpClearEvent(this);
        return pEventSrc->GetEvents(1, this, NULL);
    }
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 10, 2009, 12:55:51 PM

Ok , seems also it's the correct one to translate. I have play with it a little.
Same defauts as the other,could not be compile.

Title: Re: Am I right defining the GUID?
Post by: Farabi on June 11, 2009, 01:44:41 PM
Anyone know what is this mean?

SPDBG_ASSERT(eEventId == SPEI_RECOGNITION || eEventId == SPEI_FALSE_RECOGNITION || eEventId == SPEI_HYPOTHESIS);


I used

movzx eax, SPEI_RECOGNITION or SPEI_FALSE_RECOGNITION or SPEI_HYPOTHESIS


but the value is never match.
If I used the value 520 every time I talk to my computer the computer responded and show a message box.
Title: Re: Am I right defining the GUID?
Post by: Farabi on June 11, 2009, 03:13:27 PM
Quote from: ToutEnMasm on June 10, 2009, 12:55:51 PM

Ok , seems also it's the correct one to translate. I have play with it a little.
Same defauts as the other,could not be compile.



CHeck out the bin folder. There are the exe, so you dont need to compile it to debug it.
Title: Re: Am I right defining the GUID?
Post by: ToutEnMasm on June 11, 2009, 06:28:43 PM

I am lucky this day,to compile the samples modifies the c++ project as define below
Quote
The fix is to change one of the project settings on your project. Change:
Configuration Properties -> C++ -> Language -> Treat wchar_t as Built-in
Type from Yes (/Zc:wchar_t) to No.

It's more easy like that No ?
I am working with SPEVENT structure,the one who give all the suit.
This will be finish in a few time