flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > libzplay.dll play OGG\MP3

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



Joined: 21 Apr 2012
Posts: 495
Any body try use in fasm or masm libzplay.dll for playing OGG\MP3 files ?
I search simple examples.
Post 22 Jan 2019, 01:02
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
I try import from libzplay.dll function CreateZPlay.
But Windows 7 crash when i Call CreateZPlay.
My program 32 bit.
Post 22 Jan 2019, 08:03
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Post your libzplay.dll program here, I'll look into it.

Sorry for the delay.
Post 10 Feb 2019, 08:41
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 570
Location: Belarus
Let me guess it’s a data alignment related problem.
Post 10 Feb 2019, 09:08
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
vivik
Oh ! Sorry. I am forget my topic.


Description:
Download
Filename: libzplay.rar
Filesize: 608.84 KB
Downloaded: 71 Time(s)

Post 17 Feb 2019, 09:25
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
in code use simple.
Code:
library libzplay,         'libzplay.dll'
import  libzplay,\
          CreateZPlay,'zplay_CreateZPlay'
    


Call CreateZPlay
Post 17 Feb 2019, 09:28
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Please post the whole fasm program. Something I can compile.

hm, http://libzplay.sourceforge.net/CSTYLEINTERFACE.html
Post 17 Feb 2019, 11:55
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Well, nothing crashed for me so far

Code:
; Example of making 32-bit PE program as raw code and data

format PE GUI
entry start

section '.text' code readable executable

  start:

        push    0
        push    _caption
        push    _message
        push    0
        call    [MessageBoxA]
        
        call    [zplay_CreateZPlay]

        push    0
        call    [ExitProcess]

section '.data' data readable writeable

  _caption db 'Win32 assembly program',0
  _message db 'Hello World!',0

section '.idata' import data readable writeable

  dd 0,0,0,RVA kernel_name,RVA kernel_table
  dd 0,0,0,RVA user_name,RVA user_table
  dd 0,0,0,RVA libzplay_name,RVA libzplay_table
  dd 0,0,0,0,0

  kernel_table:
    ExitProcess dd RVA _ExitProcess
    dd 0
  user_table:
    MessageBoxA dd RVA _MessageBoxA
    dd 0
  libzplay_table:
    zplay_CreateZPlay dd RVA _zplay_CreateZPlay
    dd 0

  kernel_name db 'KERNEL32.DLL',0
  user_name db 'USER32.DLL',0
  libzplay_name db 'libzplay.dll',0

  _ExitProcess dw 0
    db 'ExitProcess',0
  _MessageBoxA dw 0
    db 'MessageBoxA',0
  _zplay_CreateZPlay dw 0
    db 'zplay_CreateZPlay',0

section '.reloc' fixups data readable discardable       ; needed for Win32s
    


I don't really know how to import functions in fasm properly.
Post 17 Feb 2019, 12:23
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
You example work fine for me !
Interesting.


Last edited by Roman on 17 Feb 2019, 13:40; edited 1 time in total
Post 17 Feb 2019, 12:55
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
Fasm 1.73 this code crash on Call CreateZPlay
Code:
format PE GUI 4.0
entry start
include 'c:\fasm\include\Win32a.inc'

section '.data' data readable writeable

  _caption db 'Win32 assembly program',0
  _message db 'Hello World!',0
  _error db 'Error load mp3',0

   zplay dd 0
  
section '.text' code readable executable

  start:
        call    CreateZPlay
        mov     [zplay],eax
        test    eax,eax
        jnz     @f
        push    0
        push    _caption
        push    _error
        push    0
        call    [MessageBox]
@@:     
        push    0
        push    _caption
        push    _message
        push    0
        call    [MessageBox]
        push    0
        call    [ExitProcess]



section '.idata' import data readable writeable

  library kernel32,       'KERNEL32.DLL',\
          user32,         'USER32.DLL',\
          msvcrt,         'MSVCRT.DLL',\
          libzplay,       'libzplay.dll'
  include 'c:\fasm\include/vapia/kernel32.inc'
  include 'c:\fasm\include/vapia/user32.inc'
  import  libzplay,\
          CreateZPlay,'zplay_CreateZPlay' 
    
Post 17 Feb 2019, 13:38
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16734
Location: In your JS exploiting you and your system
You need brackets "call [CreateZPlay]"
Post 17 Feb 2019, 13:55
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
F..ck !
I completely out my mind Smile

I forgot Invoke and Call differ
Post 17 Feb 2019, 13:59
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 570
Location: Belarus
I really wonder what’s the purpose of avoiding invoke/cinvoke/stdcall/etc. macros. I could see some reasoning behind avoiding struct macro which is quite difficult to understand but procXX.inc macros (especially invoke/stdcall/etc.) are very simple, so the point of not using things you don’t understand doesn’t work here. So, why write tons of pushes instead of focusing on the task?
Post 17 Feb 2019, 14:18
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
Yes ! Now work and play sound !
Post 17 Feb 2019, 15:17
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
This code work fine. With exe put 1.mp3 file.
Code:
format PE GUI 4.0
entry start
include 'c:\fasm\include\Win32a.inc'
 include "c:\fasm\include\encoding\win1251.inc" ;codirovka ansi 1251
 include 'c:\fasm\include\equates\kernel32.inc'
 include 'c:\fasm\include\equates\gdi32.inc'
 include 'c:\fasm\include\equates\user32.inc'
 ;interface get from class ZPlay
interface hrum,\
          SetSettings,\
          GetSettings ,\
          GetVersion ,\
          GetError ,\
          GetErrorW,\
          GetFileFormat,\
          GetFileFormatW,\
          EnumerateWaveOut,\
          GetWaveOutInfo,\
          GetWaveOutInfoW,\
          SetWaveOutDevice,\
          OpenFile,\
          OpenFileW ,\
          AddFile ,\
          AddFileW ,\
          OpenStream  ,\
          PushDataToStream ,\
          IsStreamDataFree ,\
          GetDynamicStreamLoad ,\
          GetStreamInfo ,\
          GetStreamInfoW ,\
          Close ,\
          Play,\
          PlayLoop,\
          Seek ,\
          ReverseMode ,\
          Stop ,\
          Pause  ,\
          Resume ,\
          GetPosition,\
          SetMasterVolume ,\
          SetPlayerVolume,\
          GetMasterVolume ,\
          GetPlayerVolume,\
          GetBitrate,\
          GetStatus ,\
          MixChannels ,\
          GetVUData ,\
          SlideVolume ,\
          EnableEqualizer,\
          SetEqualizerPoints  ,\
          GetEqualizerPoints,\
          SetEqualizerParam ,\
          GetEqualizerParam  ,\
          SetEqualizerPreampGain ,\
          GetEqualizerPreampGain ,\
          SetEqualizerBandGain,\
          GetEqualizerBandGain,\
          LoadID3 ,\
          LoadID3W ,\
          LoadFileID3 ,\
          LoadFileID3W,\
          EnableEcho ,\
          SetEchoParam ,\
          GetEchoParam ,\
          SetCallbackFunc,\
          SetRate,\
          GetRate ,\
          SetPitch ,\
          GetPitch,\
          SetTempo ,\
          GetTempo ,\
          StereoCut,\
          Release ,\
          DetectBPM,\
          DetectFileBPM,\
          DetectFileBPMW ,\
          GetFFTData ,\
          DrawFFTGraphOnHDC ,\
          DrawFFTGraphOnHWND ,\
          SetFFTGraphParam ,\
          GetFFTGraphParam
section '.data' data readable writeable

  _caption    db 'Win32 assembly program',0
  _message    db 'Hello World!',0
  _error      db 'Error load mp3',0
  pName       db '1.mp3',0
  Auto        dd 850 dup (0)
  zplay       hrum

section '.text' code readable executable

  start:
        call    [CreateZPlay]
        test    eax,eax
        jz      Exit
        mov     [zplay],eax
;       player->OpenFile("test.mp3", sfAutodetect)
        cominvk zplay,OpenFile,pName,1 ;1000 = autodetect(mp3\ogg\wav)
        test    eax,eax                ;eax=1 ok
        jnz     @f
        invoke  MessageBox,0,_error,_caption,0
        jmp   Exit
@@:     cominvk zplay,GetStreamInfo,Auto
        cinvoke sprintf,Auto,"Length: %02u:%02u:%02u:%03u",\
                dword [Auto+12],dword [Auto+16],dword [Auto+20],dword [Auto+24]
        invoke  MessageBox,0,Auto,_caption,0
@@:     cominvk zplay,Play
        ;jmp  @b
        cinvoke sprintf,Auto,'%u ',eax
        invoke  MessageBox,0,Auto,_caption,0
        cominvk zplay,Release
Exit:
        invoke  ExitProcess,0



section '.idata' import data readable writeable

  library kernel32,       'KERNEL32.DLL',\
          user32,         'USER32.DLL',\
          msvcrt,         'MSVCRT.DLL',\
          libzplay,       'libzplay.dll'
  include 'c:\fasm\include/vapia/kernel32.inc'
  include 'c:\fasm\include/vapia/user32.inc'
  import msvcrt,\
         sprintf,'sprintf'
  import  libzplay,\
          CreateZPlay,'zplay_CreateZPlay'    
Post 17 Feb 2019, 15:31
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
I tried to compile the program above me, and my fasm can't find this file: fasm\include/vapia/kernel32.inc

what is this "vapia" folder? I don't have this.

I want to be able to play an mp3 file in a loop, wonder if this library is capable of that. Like, play file up to 30 seconds, then loop back to 2 seconds, and keep playing in the loop.

btw, I'm sure you can do this:

Code:
  import  libzplay,\
          CreateZPlay,'CreateZPlay'      


instead of this:

Code:
  import  libzplay,\
          CreateZPlay,'zplay_CreateZPlay'      


they both point to the same function. Didn't check it though, but my ollydbg/x64dbg said so.
Post 20 Feb 2019, 11:24
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 570
Location: Belarus
vivik wrote:
I tried to compile the program above me, and my fasm can't find this file: fasm\include/vapia/kernel32.inc

what is this "vapia" folder? I don't have this.

IIRC, MadMatt’s pack contained something like that.
Post 20 Feb 2019, 12:15
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
In fasm API.
Just write
Code:
include "fasm\include/api/kernel32.inc"
include "fasm\include/api/user32.inc"
    


In kernel32.inc file(like usual):
Code:
import kernel32,\
       AddAtomA,'AddAtomA',\
       AddAtomW,'AddAtomW',\
       AddConsoleAliasA,'AddConsoleAliasA',\
       AddConsoleAliasW,'AddConsoleAliasW',\
       AllocConsole,'AllocConsole',\
       AreFileApisANSI,'AreFileApisANSI',\    



Vivik use PlayLoop. This function more difficult then Play();
http://libzplay.sourceforge.net/libZPlayCpp__ZPlay__PlayLoop@TTimeFormat@TStreamTime__@TTimeFormat@TStreamTime__@unsigned_int@unsigned_int.html
http://libzplay.sourceforge.net/ZPLAYINTERFACE.html
Post 20 Feb 2019, 14:03
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
still doesn't compile, but now there's a different error.

Code:
format PE GUI 4.0
entry start
include 'c:\path\fasm\include\Win32a.inc'
 include 'c:\path\fasm\include\encoding\win1251.inc' ;codirovka ansi 1251
 include 'c:\path\fasm\include\equates\kernel32.inc'
 include 'c:\path\fasm\include\equates\gdi32.inc'
 include 'c:\path\fasm\include\equates\user32.inc'
 ;interface get from class ZPlay
interface hrum,\
          SetSettings,\
          GetSettings ,\
          GetVersion ,\
          GetError ,\
          GetErrorW,\
          GetFileFormat,\
          GetFileFormatW,\
          EnumerateWaveOut,\
          GetWaveOutInfo,\
          GetWaveOutInfoW,\
          SetWaveOutDevice,\
          OpenFile,\
          OpenFileW ,\
          AddFile ,\
          AddFileW ,\
          OpenStream  ,\
          PushDataToStream ,\
          IsStreamDataFree ,\
          GetDynamicStreamLoad ,\
          GetStreamInfo ,\
          GetStreamInfoW ,\
          Close ,\
          Play,\
          PlayLoop,\
          Seek ,\
          ReverseMode ,\
          Stop ,\
          Pause  ,\
          Resume ,\
          GetPosition,\
          SetMasterVolume ,\
          SetPlayerVolume,\
          GetMasterVolume ,\
          GetPlayerVolume,\
          GetBitrate,\
          GetStatus ,\
          MixChannels ,\
          GetVUData ,\
          SlideVolume ,\
          EnableEqualizer,\
          SetEqualizerPoints  ,\
          GetEqualizerPoints,\
          SetEqualizerParam ,\
          GetEqualizerParam  ,\
          SetEqualizerPreampGain ,\
          GetEqualizerPreampGain ,\
          SetEqualizerBandGain,\
          GetEqualizerBandGain,\
          LoadID3 ,\
          LoadID3W ,\
          LoadFileID3 ,\
          LoadFileID3W,\
          EnableEcho ,\
          SetEchoParam ,\
          GetEchoParam ,\
          SetCallbackFunc,\
          SetRate,\
          GetRate ,\
          SetPitch ,\
          GetPitch,\
          SetTempo ,\
          GetTempo ,\
          StereoCut,\
          Release ,\
          DetectBPM,\
          DetectFileBPM,\
          DetectFileBPMW ,\
          GetFFTData ,\
          DrawFFTGraphOnHDC ,\
          DrawFFTGraphOnHWND ,\
          SetFFTGraphParam ,\
          GetFFTGraphParam
section '.data' data readable writeable

  _caption    db 'Win32 assembly program',0
  _message    db 'Hello World!',0
  _error      db 'Error load mp3',0
  pName       db 's.wav',0
  Auto        dd 850 dup (0)
  zplay       hrum

section '.text' code readable executable

  start:
        call    [CreateZPlay]
        test    eax,eax
        jz      Exit
        mov     [zplay],eax
;       player->OpenFile("test.mp3", sfAutodetect)
        cominvk zplay,OpenFile,pName,1 ;1000 = autodetect(mp3\ogg\wav)
        test    eax,eax                ;eax=1 ok
        jnz     @f
        invoke  MessageBox,0,_error,_caption,0
        jmp   Exit
@@:     cominvk zplay,GetStreamInfo,Auto
        cinvoke sprintf,Auto,"Length: %02u:%02u:%02u:%03u",\
                dword [Auto+12],dword [Auto+16],dword [Auto+20],dword [Auto+24]
        invoke  MessageBox,0,Auto,_caption,0
@@:     cominvk zplay,Play
        ;jmp  @b
        cinvoke sprintf,Auto,'%u ',eax
        invoke  MessageBox,0,Auto,_caption,0
        cominvk zplay,Release
Exit:
        invoke  ExitProcess,0



section '.idata' import data readable writeable

  library kernel32,       'KERNEL32.DLL',\
          user32,         'USER32.DLL',\
          msvcrt,         'MSVCRT.DLL',\
          libzplay,       'libzplay.dll'
  include 'c:\path\fasm\include/api/kernel32.inc'
  include 'c:\path\fasm\include/api/user32.inc'
  import msvcrt,\
         sprintf,'sprintf'
  import  libzplay,\
          CreateZPlay,'zplay_CreateZPlay'     


Code:
Error: symbol already defined.

struct SYSTEM_INFO
  wProcessorArchitecture      dw ?
  wReserved                   dw ?
  dwPageSize                  dd ?
  lpMinimumApplicationAddress dd ?
  lpMaximumApplicationAddress dd ?
  dwActiveProcessorMask       dd ?
  dwNumberOfProcessors        dd ?
  dwProcessorType             dd ?
  dwAllocationGranularity     dd ?
  wProcessorLevel             dw ?
  wProcessorRevision          dw ?
ends   

C:\path\fasm\INCLUDE\EQUATES\KERNEL32.INC         
    
Post 20 Feb 2019, 15:50
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 495
Vivik
I compile my code fine.
I not get this error.

I use Fasm 1.73

I found SYSTEM_INFO in fasm\INCLUDE\EQUATES\Kernel64.inc but not in fasm\INCLUDE\EQUATES\Kernel32.inc


Last edited by Roman on 20 Feb 2019, 16:00; edited 1 time in total
Post 20 Feb 2019, 15:57
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2019, Tomasz Grysztar.

Powered by rwasa.