Author Topic: bind  (Read 1101 times)

0 Members and 1 Guest are viewing this topic.

José Roca

  • Guest
bind
« on: October 04, 2018, 05:42:57 PM »
bind a list of procedures from a Dynamic Link Library (DLL)
 
USE: for low level (without protoype) calls to DLL functions. the first name is the one used in the program. The second is the name used in the DLL. 

'          sys Kernel32
kernel32=LoadLibrary "kernel32.dll"


RESULT:
"the first column of keywords is recognised as procedure calls."

Which column?

A prototype may be attached to any of these keywords later.
 
How?


Charles Pegge

  • Guest
Re: bind
« Reply #1 on: October 05, 2018, 12:00:59 AM »
This an example of binding. A full Messagebox prototype is then attached.

Code: [Select]
  sys kernel32=LoadLibrary `kernel32.dll`
  sys user32=LoadLibrary `user32.dll`
  sys GDI32=LoadLibrary `GDI32.dll`

  bind kernel32
  (
    GetCommandLine  GetCommandLineA   ; @0
    GetModuleHandle GetModuleHandleA  ; @4
    ExitProcess     ExitProcess       ; @4
  )

  bind user32
  (
    LoadIcon         LoadIconA         ; @8
    LoadCursor       LoadCursorA       ; @8
    RegisterClass    RegisterClassA    ; @4
    MessageBox       MessageBoxA       ; @4
    CreateWindowEx   CreateWindowExA   ; @48
    ShowWindow       ShowWindow        ; @8
    UpdateWindow     UpdateWindow      ; @4
    GetMessage       GetMessageA       ; @16
    TranslateMessage TranslateMessage  ; @4
    DispatchMessage  DispatchMessageA  ; @4
    PostQuitMessage  PostQuitMessage   ; @4
    BeginPaint       BeginPaint        ; @8
    EndPaint         EndPaint          ; @8
    GetClientRect    GetClientRect     ; @8 
    DrawText         DrawTextA         ; @20
    PostMessage      PostMessageA      ; @16
    DefWindowProc    DefWindowProcA    ; @16
  )


  bind GDI32
  (
    GetStockObject   GetStockObject    ; @4
  )

declare MessageBox(sys hWnd, char* lpText, char* lpCaption,   
   dword uType) as int at @MessageBox

MessageBox 0,"Hello World", "binding",0

José Roca

  • Guest
Re: bind
« Reply #2 on: October 05, 2018, 08:12:10 AM »
Very interesting, thanks.

José Roca

  • Guest
Re: bind
« Reply #3 on: October 05, 2018, 08:35:27 AM »
Apparently, this does the same:

Code: [Select]
extern lib "user32.dll"
! MessageBox "MessageBoxA"
end extern

declare MessageBox(sys hWnd, char* lpText, char* lpCaption,   
   dword uType) as int at @MessageBox

MessageBox 0,"Hello World", "binding",0

But it seems that with "!" you can also specify the function prototype:

Code: [Select]
extern lib "user32.dll"
! MessageBox "MessageBoxA"(sys hWnd, char* lpText, char* lpCaption, dword uType) as int
end extern

MessageBox 0,"Hello World", "binding",0

Does "!" accept more variations?