flat assembler
Message board for the users of flat assembler.

Index > Windows > How to use fasm in vb6?

Author
Thread Post new topic Reply to topic
sylwek32



Joined: 27 Apr 2006
Posts: 339
sylwek32 23 Nov 2006, 18:55
Hello,
how to "include" fasm programs in vb6?

I want to use both fasm and vb6 in my program
and make 2 language at the same time programming.
for example for some jumps..

Can you help me?

PS:
I invite you to my new website
http://www.oscon.info
Post 23 Nov 2006, 18:55
View user's profile Send private message Reply with quote
Evgeny



Joined: 16 Jan 2006
Posts: 11
Evgeny 24 Nov 2006, 03:45
Put your function into memory and use something like CallWindowProc to call it.
Real example (stdcall int CRC32(data, length, void, void) compiled function placed into resource with id="CRC32", type="CODE"):
Code:
Private Declare Function FunctionCall Lib "user32" Alias "CallWindowProcA" (ByVal lpCode As Long, ByVal S0 As String, ByVal L0 As Long, ByVal S1 As String, ByVal L1 As Long) As Long

Public Function ResCall(ResId As String, S0 As String, L0 As Long, S1 As String, L1 As Long) As Long
  Dim Code() As Byte
  Code = LoadResData(ResId, "CODE")
  ResCall = FunctionCall(StrPtr(Code), S0, L0, S1, L1)
End Function

Sub Main()
  Dim Data As String: Data = "Test"
  'Arguments 3 and 4 don't used.
  MsgBox(Hex(ResCall("CRC32", Data, Len(Data), vbNullString, 0)))
End Sub
    
Post 24 Nov 2006, 03:45
View user's profile Send private message Reply with quote
sylwek32



Joined: 27 Apr 2006
Posts: 339
sylwek32 24 Nov 2006, 16:08
Hello!
Thanks for that.
And whats the fasm code which belongs to it?
Post 24 Nov 2006, 16:08
View user's profile Send private message Reply with quote
Filter



Joined: 08 Oct 2006
Posts: 67
Filter 25 Nov 2006, 02:20
sylwek32 wrote:
Hello!
Thanks for that.
And whats the fasm code which belongs to it?


Actually it looks like a demonstration of calling a dll from VB. Put your fasm code in a dll and then call it using the given method.

In the example he calls a function "CallWindowProcA" in user32.dll.
Post 25 Nov 2006, 02:20
View user's profile Send private message Reply with quote
Evgeny



Joined: 16 Jan 2006
Posts: 11
Evgeny 25 Nov 2006, 07:51
ASM code for VB code above (compile it and place into resources of VB project, set type="CODE" and id="CRC32").
Code:
        format  binary
        use32
;------------------------------------------------------------------------------;
; stdcall int CRC32(data,length,void,void).                                    ;
;------------------------------------------------------------------------------;
CRC32: ;Code by Matrix.
        push    ebp
        mov     ebp,esp
        push    ebx esi edi
        mov     esi,[ebp+0x08]          ;CRC32.data.
        mov     edi,[ebp+0x0c]          ;CRC32.length.
        xor     ecx,ecx
        dec     ecx
        mov     edx,ecx
    .next_byte:
        xor     eax,eax
        xor     ebx,ebx
        lods    byte[esi]
        xor     al,cl
        mov     cl,ch
        mov     ch,dl
        mov     dl,dh
        mov     dh,0x08
    .next_bit:
        shr     bx,0x01
        rcr     ax,0x01
        jnc     .skip_bit
        xor     ax,0x8320
        xor     bx,0xedb8
    .skip_bit:
        dec     dh
        jnz     .next_bit
        xor     ecx,eax
        xor     edx,ebx
        dec     edi
        jnz     .next_byte
        not     edx
        not     ecx
        mov     eax,edx
        rol     eax,0x10
        mov     ax,cx
        pop     edi esi ebx ebp
        ret     0x10
    
Post 25 Nov 2006, 07:51
View user's profile Send private message Reply with quote
Raedwulf



Joined: 13 Jul 2005
Posts: 375
Location: United Kingdom
Raedwulf 25 Nov 2006, 14:53
You can write assembly inline straight into VB6 using this add-in. You need to install the main package then get the updates of individual packages.
The project is very-little developed these days, but the developers (me included) will still help you if you need help ^^.
Libor added FASM support some time ago, but I never tested it out myself. Note: The asm WILL NOT work in IDE... but will work perfectly compiled natively.

http://sourceforge.net/projects/thundervb/
Post 25 Nov 2006, 14:53
View user's profile Send private message MSN Messenger Reply with quote
DustWolf



Joined: 26 Jan 2006
Posts: 373
Location: Ljubljana, Slovenia
DustWolf 25 Nov 2006, 16:46
Or you can do it like me... write the FASM code into a DLL and then use the DLL proc in your VB6 program like you would any other API.
Post 25 Nov 2006, 16:46
View user's profile Send private message Reply with quote
Evgeny



Joined: 16 Jan 2006
Posts: 11
Evgeny 25 Nov 2006, 18:05
Raedwulf, thank you. Didn't know about that.
ps. Is there an english translation of http://www.freewebs.com/hardcorevb/?
Post 25 Nov 2006, 18:05
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 26 Nov 2006, 19:58
http://www.activevb.de/tipps/tipkat/kat16.html

This site helped me the learn how to do it, never managed to make it work with fasm by myself but that was a long time ago Laughing Also taught me some more german Cool

HTH
Post 26 Nov 2006, 19:58
View user's profile Send private message Reply with quote
Raedwulf



Joined: 13 Jul 2005
Posts: 375
Location: United Kingdom
Raedwulf 01 Dec 2006, 20:14
HardcoreVB?
Is this what you are looking for?

vb.mvps.org/hardcore/

Thats the main official page for it i think Smile.
Post 01 Dec 2006, 20:14
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.