Results 1 to 30 of 30

Thread: [VB6] - Calling functions by pointer.

Threaded View

  1. #30
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Resolved Re: [VB6] - Calling functions by pointer.

    Quote Originally Posted by The trick View Post
    ACTUAL VERSION IN 9 POST
    Exploring the function VBA6 figured out a way to call functions the pointer.
    It's simple. Declare a function prototype (void function), where the first argument will be further transferred to the function address. Next, do a patch, so he tossed to us at the address specified in the first parameter. Thus it is possible to call functions in the standard modules, class modules, forms, API-functions (eg obtained through LoadLibrary and GetProcAddress).* One note, run the project through Ctrl + F5. And working in the IDE and compiled form.
    For "patching" the prototype I made a separate module:
    [CODE]
    ' ?????? ?????? WinApi ??????? ?? ?????????
    Public Sub Main()
    Dim hUser As Long, hGDI As Long
    Dim DC As Long

    hUser = LoadLibrary("user32")
    hGDI = LoadLibrary("gdi32")

    PatchFunc "GetDC", AddressOf GetDC
    PatchFunc "ReleaseDC", AddressOf ReleaseDC
    PatchFunc "Ellipse", AddressOf Ellipse
    If two modules have the same function, how to solve the problem of calling under IDE?
    model1.bas
    model2.bas
    "GetDC", AddressOf GetDC

    need use
    PatchFunc "model2.GetDC", AddressOf model2.

    Code:
     TipGetFunctionId hProj, StrPtr(FuncName), sId
            If sId = 0 Then MsgBox "Can't find function by name?" & FuncName: Exit Sub
    Last edited by xiaoyao; Oct 1st, 2024 at 07:30 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width