Home > Code > Accessing MSVBVM60 API [TUT]

Accessing MSVBVM60 API [TUT]

Im reposting this here cause Ive been asked many times for this document.

This is a small tuto Ive made to explain a basic way to add some APIs and constants to your VB.
Hope you understand the basic concept and find this at least funny if not useful.
Have Funk!

Accessing MSVBVM60 API

Categories: Code
  1. maminej
    March 1st, 2010 at 20:52 | #1

    Thanks a lot Cobein.
    I really appreciate that.

  2. maminej
    March 1st, 2010 at 21:19 | #2

    So following this GREAT tutorial instructions, one can "add" __vbaCopyBytes to VBA6.DLL and get rid of this declaration :
    Private Declare Sub CopyBytes Lib "MSVBVM60" Alias "__vbaCopyBytes" (ByVal Size As Long, Dest As Any, Source As Any)

    My question is :
    Can we do the same with DLL's other than MSVBVM60, like kernel32 or user32

    Thanks again Cobein and sorry if any of my questions appear evident to you, i am one of your beginners students :)

    • March 2nd, 2010 at 00:25 | #3

      The problem adding something from for instance "user32" is that the compiler is gonna ignore the library, is gonna work on the IDE but after compiled is gonna fail. I strongly suggest you to learn about type libraries, thats the way to go if you want to avoid the declarations in the IDE or have a standard IAT in the final exe.

      • maminej
        March 2nd, 2010 at 02:23 | #4

        Thanks for your advices Cobein

        i have some problems using your TUT with "__vbaCopyBytes" , i will prepare a document with screenshots and will uploade it, just to be clear and of course you will find some time for that
        Thank s

        • maminej
          March 2nd, 2010 at 03:46 | #5

          Edit..

          … and of course IF you can find some time for that …

          Thanks again

      • abronsius
        March 20th, 2010 at 01:47 | #6

        Hi Cobein, Can u explain more please, we have to remod the dll or compile another way ?

  3. March 2nd, 2010 at 05:25 | #7

    Hey cobein thankz for this TUT seems pretty helpful adding constants will make a good improve while im coding btw the API's seccion of the tut is better

  4. astral
    March 4th, 2010 at 15:05 | #8

    Hey nice tutorial Cobein,

    Private Declare Sub CopyBytes Lib "MSVBVM60" Alias "__vbaCopyBytes" (ByVal Size As Long, Dest As Any, Source As Any)

    In this declatarion we habe Dest as ANY and Source as ANY. Could you point me how to change parameter type to ANY in PowerVB Type Library Editor? They don't have it in Parameter Type window.

    Thanks,
    Astral.

  5. astral
    March 4th, 2010 at 15:57 | #9

    oh and, how to set Parameter Types to be ByVal (as for __vbaCopyBytes we have ByVal Size as Long..)

    Thanks again,
    Astral.

    • March 4th, 2010 at 22:10 | #10

      As Any = Void

      Byval is the default type of var, so don't worry about that, just set it as LONG/DWORD =P

  6. astral
    March 5th, 2010 at 08:47 | #11

    Thanks Karcrack,

    In a simple project VB Ide crashes unexpectedly. Same for RunPE…
    I think I'm doing something wrong:

    http://img716.imageshack.us/img716/9436/67099305….
    http://img651.imageshack.us/img651/7954/71222628….
    http://img220.imageshack.us/img220/7360/25884772….

    Project is standard RunPE modified by you Karcrack, with only difference – CopyBytes API changed to new CoByte (as on pics)

    Look at it if you'll have some spare time.

    Thanks,
    Astral.

    • March 6th, 2010 at 09:42 | #12

      Dest & Source must be same Parameter Type… [OUT] or [IN] i'm not sure, but i think is [IN]

      • abronsius
        March 20th, 2010 at 13:59 | #13

        I've put —>[in]long, [in] void *,[in] void *
        i ve also create own tlb with this function but exe don't load..

        What is the next point ? should i pass parameter to Link to take my function ?

        The compils is good but as cobein say we have to learn more, i've read the section of Type Library in the Book "Advanced…..for everyday programing" u know but i can't understand what i do wrong….

        Thank u to put me in the right way :)

        Cobein and Karcrack are just my BOSS ;)

        • March 21st, 2010 at 15:00 | #14

          How are you call CopyBytes? Paste a call…

          • abronsius
            March 21st, 2010 at 17:59 | #15

            CopyBytes Len(Pish), Pish, lpBuffer(Pidh.e_lfn + Len(Pinh) + Len(Pish) * i)

            I've also try a callAPiByName but i can't pass Pish to params….

            Thx

          • March 21st, 2010 at 21:54 | #16

            Try this:
            CopyBytes Len(Pish), byref Pish, byval varptr(lpBuffer(Pidh.e_lfn + Len(Pinh) + Len(Pish) * i))
            Or:
            CopyBytes Len(Pish), varptr(Pish.FIRST_ENTRY_OF_PISH), varptr(lpBuffer(Pidh.e_lfn + Len(Pinh) + Len(Pish) * i))

            Good luck

          • abronsius
            March 21st, 2010 at 22:07 | #17

            Oki thank u, my first test are wrong but i will continue in ur way ;)

  7. oijkn
    March 19th, 2010 at 22:18 | #18

    I'm trying to save the modified dll file but PowerVB Type Library Editor is in trial version, i can't find a full version anywhere….if someone can help me please because i need this method (avira have tagg __vbaCopyBytes). Thanks for the help and great tuto Cobein !

    • oijkn
      March 20th, 2010 at 01:04 | #19

      ok a friend have found it for me :) but now i have problem with the API, the compiled file with tlb modified is ok but when i try to run it nothing appear : what i'm doing wrong ? thanks for the help

      • Coder's Central
        March 20th, 2010 at 13:28 | #20

        Hey oijkn, i have found it as well, seems we missed each other :)

        I am having an issue with this, perhaps someone could find my error. I modify the constants of vba6.dll, and add the vbQuote constant. I click update, and then i click save (note that it is saving to the vba6.tlb file on my desktop). I then go into peexplore and i locate my original vba6.dll file, i then replace the resource with my modified (vba6.tlb file). After saving and closing pe explore i open up VB6 and go into object Browser. Under "constants", vbQuote is not there. I have tried this many times with the same result.

        Ps, i made sure that no VB6 was open while i made the changes. Any ideas?

  8. Coder's Central
    March 20th, 2010 at 19:44 | #21

    I really need help with this, for some reason, the runpe doesnt run correctly if i use the tlb. Can anyone please help me with this?

  9. DeadlyVermilion
    April 19th, 2010 at 16:49 | #22

    I still cannot get this to work with your RunPE which is, cRunPE_PTR
    Using __VbaCopyBytes.
    It just crashes the executeable file. Is there any way you could make a working runPE for it and post it up here or Email it to me please?? It would mean alot, I look up to you.

  1. No trackbacks yet.
You must be logged in to post a comment.