Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Implements a run-time dynamic code execution.

 

Syntax

 

Call DWord dwPointer [TO LongVariable]

 

Returns

 

Parameters

 

Name

Type

Optional

Meaning

LongVariable

Variable

Yes

A LONG or DWORD variable used to get back a value from the called dynamic code





 

Remarks

 

Restrictions

 

See also

 

Examples

 

'---------------------------------------------------------------------------

' Dynamic assembler using thinBasic CALL DWORD ... [TO ...] statement

'---------------------------------------------------------------------------

'---Reference:

'---http://developer.intel.com/design/pentiumii/manuals/243191.htm

'---------------------------------------------------------------------------

Declare Function LoadLibrary    Lib   "KERNEL32.DLL"    _

                                Alias "LoadLibraryA"    _

                                (lpLibFileName As ASCIIZAs Long

Declare Function GetProcAddress Lib   "KERNEL32.DLL"    _

                                Alias "GetProcAddress"  _

                                (ByVal hModule As DWORD, lpProcName As ASCIIZAs Long

Dim   hLib      , _               '---Used to store external Lib handle

      hFun      , _               '---Used to store a pointer to function

      psASM       As Long         '---Used for passing a pointer to dynamic assembly

 

Dim   sASM      , _               '---Dynamic assembly string

      sMessage  , _               '---MessageBox message

      sTitle      As String       '---MessageBox title

 

Dim RetVal        As Long

 

'---Load library and get handle

hLib  = LoadLibrary("User32.dll")

'---If handle was ok

If hLib Then

  '---Get function pointer

  hFun  = GetProcAddress(hLib, "MessageBoxA")

  If hFun Then

    sTitle    = "Dynamic Assembly Demo"

    sMessage  = "Hello World!"

 

    '----------------------------------------------

    ' Compose ASSEMBLE MACHINE CODE STRING

    '----------------------------------------------

    sASM = _

          CHR$(&h68) + MKL$(0)                          + _   ' 01 push 0 for style

          CHR$(&h68) + MKL$(STRPTR(sTitle))             + _   ' 06 push title address

          CHR$(&h68) + MKL$(STRPTR(sMessage))           + _   ' 11 push message address

          CHR$(&h68) + MKL$(0)                          + _   ' 16 push 0 for hWnd handle

          CHR$(&hFF) + CHR$(&h15) + MKL$(VARPTR(hFun))  + _   ' 21 call messagebox

          CHR$(&HC3)                                          ' 27 return

 

    '----------------------------------------------

    '---Get the address of the ASM string

    psASM = STRPTR(sASM)          ' address of code

    '---Fire the direct call using dynamic asm

    Call DWORD psASM To RetVal    ' make the call and get the return value

 

    '---Show return value

    MSGBOX 0, RetVal

      

  End If

End If

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software