Announcement

Collapse
No announcement yet.

MemoryEx ASM function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MemoryEx ASM function

    I'm trying to achieve the following:

    Code:
    Callback = function(arg1,arg2,arg3,arg4)
     return 0 
    end
    
    --[[
    
     -- ASM
     
     -- Function that a pointer can be obtained that will call Lua 'Callback' function.
     -- Receives 4 args and passes them to Lua function.
     -- Returns what 'Callback' returns.
     
    ]]
    but don't really know if it's possible, the point is to get a function pointer for use with an external dll but the function calls a Lua function so Lua can be used instead of ASM.

  • #2
    The arguments are:

    LPVOID
    INT
    UNIT
    LPVOID

    Comment


    • #3
      It is possible, but it's incredibly difficult to call a Lua function from one of the ASM blocks. I've done it from an LH ASM segment once, but it involved seeking for the lua functions in memory (lua_push, lua_call etc) and it was quite the hassle.

      What are you trying to do inside the callback function? You might be able to do that from within ASM as well.
      Bas Groothedde
      Imagine Programming :: Blog

      AMS8 Plugins
      IMXLH Compiler

      Comment


      • #4
        I'm not really sure what I'm going to do inside the function as its the behaviour callback function for that dll I emailed you about, given the possibilities for the callback appear endless I was just hoping to have the AMS library's and MemoryEx functions along with Lua available.


        APM has a __DLL.NewCallback function so Im going to try making a plugin that I could then over right the Lua function name and see how things work.

        Comment


        • #5
          I don't know if this can help you, it's an alien module callback example (included when you download luaforwindows):

          PHP Code:
          -- using Alien to find out what the caption title of SciTE is,
          -- and 
          iterating over all top-level windows.
          -- 
          Ensure that SciTE is running first!
          require 
          'alien'
          local user alien.load 'user32.dll'

          -- these are the API calls neededNote two NB things:
          -- (
          1functions dealing with text ending with 'A' are for ASCII
          -- (2need to specify abi to get proper __stdcall
          user
          .FindWindowA:types {"string","string",abi="stdcall"}
          user.GetWindowTextA:types {"int","string","int",abi="stdcall"}

          find  user.FindWindowA
          gettext 
          user.GetWindowTextA

          -- find the handle of the SciTE window using its class name
          hwnd 
          find("SciTEWindow",nil)

          -- and 
          grab the text of that window (will be the caption)
          -- 
          create a buffer and it will be filled!
          buf alien.buffer(128)
          gettext(hwnd,buf,128)
          print(
          buf:tostring())

          -- 
          Iterating over all top-level windows.
          -- 
          againnote the abi for both EnumWindows and the callbackEnumWindows is
          -- expecting an _integer_ back from the callbackwhere 1 means 'true' means
          -- 'continue going'
          function each_hwnd (hwnd,p)
              print(
          hwnd)
              return 
          1
          end

          each_hwnd_callback 
          alien.callback(each_hwnd,{"int","pointer",abi="stdcall"})

          user.EnumWindows:types {"callback","pointer",abi="stdcall"}

          user.EnumWindows(each_hwnd_callback,nil

          Comment

          Working...
          X