News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Am I right defining the GUID?

Started by Farabi, June 07, 2009, 03:39:59 AM

Previous topic - Next topic

ToutEnMasm

 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

Farabi

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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

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
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm

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)




Farabi

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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm

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


UtillMasm

hope, you have more time to write some exmple for me.
:wink

Farabi

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
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm

#24
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




ToutEnMasm


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      

UtillMasm

Speech SDK 5.1http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en
not for Vista or Win7.
:(

UtillMasm

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

Farabi

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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

dedndave

careful Farabi - you will be a terrorist, again - lol