flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] COM need help

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1618
Roman 14 Aug 2020, 09:19
My code work on Windows 7
Code:
format PE64 GUI 5.0
include 'C:\fasmw17316\include\win64a.inc'
entry start
struc GUID def
 {
   match d1-d2-d3-d4-d5, def
    \{
      .Data1 dd 0x\#d1
      .Data2 dw 0x\#d2
      .Data3 dw 0x\#d3
      .Data4 db 0x\#d4 shr 8,0x\#d4 and 0FFh
      .Data5 db 0x\#d5 shr 40,0x\#d5 shr 32 and 0FFh,0x\#d5 shr 24 and 0FFh,0x\#d5 shr 16 and 0FFh,0x\#d5 shr 8 and 0FFh,0x\#d5 and 0FFh
    \}
 }
interface               IMMDeviceEnumerator,\
                                QueryInterface,\
                                AddRef,\
                                Release,\
                                EnumAudioEndpoints,\
                                GetDefaultAudioEndpoint


interface               IMMDevice,\
                                QueryInterface,\
                                AddRef,\
                                Release,\
                                Activate,\
                                OpenPropertyStore,\
                                GetId,\
                                GetState

interface IAudioMeterInformation,\
                        QueryInterface,\
                                AddRef,\
                                Release,\
                                GetPeakValue



section '.idata' import data readable writeable
        library kernel32,'KERNEL32.DLL',\
                user32,'USER32.DLL',\
                ole32,'ole32.dll'

        import  kernel32,\
                ExitProcess,'ExitProcess'
        import  user32,\
                MessageBox,'MessageBoxA'

        import  ole32,\
                CoInitialize,'CoInitialize',\
                CoInitializeEx,'CoInitializeEx',\
                CoCreateInstance,'CoCreateInstance',\
                CoUninitialize,'CoUninitialize'

section '.data' data readable writeable 
        CLASS_MMDeviceEnumerator        GUID BCDE0395-E52F-467C-8E3D-C4579291692E
        IID_IMMDeviceEnumerator         GUID A95664D2-9614-4F35-A746-DE8DB63617E6
        IID_IAudioMeterInformation          GUID C02216F6-8C67-4B5B-9D00-D008E73E0064
                        dq 0
        pMeterInfo      dq ?
        peak            dd ?
        ee dq 40 dup (0)
        CLSCTX_ALL = 0x00000007
        CLSCTX_INPROC_SERVER = 0x1
        eConsole = 0
        eRender = 0
        
        pEnumerator     IMMDeviceEnumerator
        pDevice         IMMDevice
macro testNull chP {local l1
      cmp qword [chP],0
      jnz l1
      invoke MessageBox,0,`chP#" = NULL !",0,0
      jmp ExitToWin
l1:
      }
section '.code' code readable writeable executable
start:
        sub             rsp,8
        mov rax,rrrr
        ;invoke          CoInitialize,0
        COINIT_MULTITHREADED = 0
        invoke  CoInitializeEx, NULL, COINIT_MULTITHREADED

        invoke          CoCreateInstance,CLASS_MMDeviceEnumerator,0,\
                                        dword CLSCTX_INPROC_SERVER,IID_IMMDeviceEnumerator,\
                                        pEnumerator

        testNull        pEnumerator
        invoke MessageBox,0,"0",0,0

rrrr:
        mov dword [ee+40],1
        comcall         [pEnumerator],IMMDeviceEnumerator,GetDefaultAudioEndpoint,dword 0,dword 0 ,pDevice
        invoke MessageBox,0,"2",0,0
        testNull        pDevice
        mov             rbp,[pDevice]
        invoke MessageBox,0,"3",0,0

        comcall         rbp,IMMDevice,Activate,IID_IAudioMeterInformation,dword CLSCTX_ALL, 0,pMeterInfo
        testNull        pMeterInfo
        invoke MessageBox,0,"3",0,0
        mov             rbx,[pMeterInfo]
        comcall         rbx,IAudioMeterInformation,GetPeakValue,peak
        invoke MessageBox,0,"4",0,0
        cominvk         pDevice,Release
        cominvk         pEnumerator,Release
ExitToWin:
        invoke          CoUninitialize
        invoke          ExitProcess,0    
                                             
                                     
    


Last edited by Roman on 14 Aug 2020, 09:28; edited 1 time in total
Post 14 Aug 2020, 09:19
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 635
Location: Ukraine
Overclick 14 Aug 2020, 09:22
Seems it works?
Code:
interface               IMMDeviceEnumerator,\
                        QueryInterface,\
                        AddRef,\
                        Release,\
                        EnumAudioEndpoints,\
                        GetDefaultAudioEndpoint

interface               IMMDevice,\
                        QueryInterface,\
                        AddRef,\
                        Release,\
                        Activate,\
                        IAudioMeterInformation,\
                        GetPeakValue    


Is it correct?
Post 14 Aug 2020, 09:22
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1618
Roman 14 Aug 2020, 09:30
Code:
interface               IMMDeviceEnumerator,\
                                QueryInterface,\
                                AddRef,\
                                Release,\
                                EnumAudioEndpoints,\
                                GetDefaultAudioEndpoint


interface               IMMDevice,\
                                QueryInterface,\
                                AddRef,\
                                Release,\
                                Activate,\
                                OpenPropertyStore,\
                                GetId,\
                                GetState

interface IAudioMeterInformation,\
                        QueryInterface,\
                                AddRef,\
                                Release,\
                                GetPeakValue
    

You do mistake:
IID_IAudioMeterInformation and exist interface AudioMeterInformation
In my code i fix this.
Post 14 Aug 2020, 09:30
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 635
Location: Ukraine
Overclick 14 Aug 2020, 09:54
Thanks everyone, Progress bar shows it correctly.
The next step is to get channels quantity and get peak for each one separately...
Post 14 Aug 2020, 09:54
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.