How can I use a Lua DLL call function to send the message EM_REDO to the User32 dynamic link library, using the SendMessageA function? I have actually checked the Microsoft site and studied the parameters and any further information required, which I have applied, but I still don't get how to implement this in Lua. I actually think the problem is how to define the message EM_REDO with a constant value. I believe an attempt to get this working will help most programmers coding in Lua, since user32.dll in Windows comes with many functions.
You may want to check winapi module for Lua, both because it may already handle what you need and because you can see how this is all done under the hood. As far as I remember, it supports both SendMessage and PostMessage calls.
Related
I have an old set of DLLs developed in late 90s with Visual C++ of that time and an application which uses them. Is there any way to know what functions (and their signatures, e.g. arguments and value types) are called from these DLLs.
There's a more general question. Is there a way to monitor all DLL calls which are made by any process in the system?
The only precise way to see what functions are used from a DLL is to debug the application that use the DLL and inspect the stack before each call.
If you want something more generic you can log every LoadLibrary and GetProcAddres API call but it is a daunting task.
You can also run an API monitor software like this one from Rohitab: APImonitor
I want to know if I can directly read or write values in the current process in a Visual Basic 2005 Windows application.
Like *(DWORD*)(0x123456) = 1; in C++ will write the value 1 at the address 0x123456.
So anyway to do the same in VB using only built in functions and not using ReadProcessMemory and WriteProcessMemory?
If you are really sure you need to do this you should look into the Marshal Class, specifically Marshal.WriteByte.
But I am pretty sure Marshal makes heavy use of Win32 API functions so it's questionable if it's really "built in".
I am currently using vba and have found a couple of handy pieces of code on the internet.
However some of these pieces of code use functions from DLL's e.g(user32).
The code works fine but it frustrates me that I have no means of discovering such functionality myself except for stumbling upon code on the internet.
I basically want to know if there is a way of obtaining descriptions of what exactly a specific DLL function does and what the input parameters represent or can this only be done by looking at the DLL's in their original language?
Not in VBA as fas as I know, but pinvoke site can help a lot.
Chek how well explained is LogonUser for example. Easy to adapt VB.NET to VBA with all that info I think.
These functions are part of the native Win32 API.
They're all quite well documented on MSDN, Microsoft's SDK documentation for Windows programmers.
For example, you might see the GetParent function called, which returns a handle to the specified window's parent or owner. The documentation for that function is here.
Note how the documentation tells you what the function does, how it is prototyped in a C-style language, what each of its parameters are and what they mean, and what its return value is and what it means. Very comprehensive; guaranteed to answer almost all of your questions. You should definitely read the "Remarks" section for any function which you are unfamiliar. There are a lot of important caveats to the Win32 API—it's a very powerful, but very old C API. There are a lot of arbitrary limitations that the programmers were forced to work around, and now because of backwards compatibility, we've been saddled with those workarounds for generations. The very bottom also tells you what DLL file you need to specify in order to call that function. For example, GetParent is found in user32.dll.
In just about every case that I've tried (and I've gone searching for lots of docs), you can type the name of the function into Google and the appropriate MSDN page will be the first result.
I'm having trouble with the SerialPort function intermittently crashing while data logging for several days. It's been a hard problem to debug and I would like to try Zach Saw's fix which he talks about here and provides code for in C#
My question is, to do this, do I need to rewrite the entire use of the Serial Port in my code?
If I use the System.IO.Ports.SerialPort module, is there a way to just do a DLLImport of SetCommState to set fAbortOnError to false, or do I need to abandon the SerialPort module entirely and write everything using the kernel32.dll?
I'm pretty sure in this case you could import his project into your solution, and it should run just fine. Since VB and C# are both CLR languages, they both compile down to the same intermediate language.
Check out this page
http://support.microsoft.com/kb/823179
It's got the proper declarations for SetCommState, with some example code. Zach's fix is to basically open the com port as a file first, call setcommstate, then use the serial io functions in .net. I haven't tried it but his post sounds like you shouldn't have to do much at all to your code.
Having tested about 15 different solutions to the various problems with serial ports in .NET, I settled on using CommStudio. It's been rock solid ever since.
You can get CommStudio Express (their free version) here: http://www.componentsource.com/products/commstudio/downloads.html?rv=42917
I'm wondering if anyone has any tips for integrating Lua and VB6. I am running a small Online RPG that would be awesome to add some scripting to.
Well, it is doable. I once did it for Lua 5.0.2 but I can't find the files. Among the options you have, you can:
Wrap Lua in a COM dll exposing the Lua API, so in VB you can add a reference to it.
Build your custom Lua version, using the __stdcall calling convention, so you can use Declare in VB to import the needed Lua functions. Writing a Type Library will ease a lot the integration with VB (mainly, it will do the conversion from C strings to VB strings for you).
Build a wrapper DLL, that replicates Lua's interface but using __stdcall, adding the functions that are defined with macros, etc.
I remember that using a custom built Lua, I could register VB functions (defined in modules) into Lua and call them from a script. I don't recall if I ever got it to call member functions.
I hope this can get you started.
Use LuaInterface. It's a .NET Library that allows you to use lua. However it doesnt come with docs in and of itself, look at this for some helpful guides.
Basically, you add the DLL to your project and reference it/add using satements, then create a new Lua object. From there, you can access it like an array to extract variables, and there are methods to call lua functions and manipulate tables.