How can I call Windows API functions using emacs lisp? - windows

I want to call some Windows API functions to manipulate Windows Input Method Editor to make my Emacs an IME-aware application. How can I call Windows API functions using Emacs lisp?
Thank you!

I dont believe its possible to directly call native code from emacs; the best you'll be able to achieve is to proxy calls to the Windows API through another process, and communicate with it through IPC
Check this stackoverflow question:
load a dynamic library from elisp

I think maybe need a proxy interface, but use w32-send-sys-command can do little things,
code 61776 can send hotkey maybe worth a try

Related

windbg: Is it possible to embed Windgb engine in my own program?

I'd like to write a debugging/diagnostic tool which can call Windbg functions to examine a dump file, instead of writing a windbg extension. Is this possible and any references?
Thanks a lot.
Rather than WinDbg, you can use the Debugging API which is implemented in dbghelp.dll. It's documented on MSDN. That reference documentation is rather dry, but it should give you an idea of the capabilities of the API. For example, MiniDumpReadDumpStream is the gateway to examining dump files.
In addition to the existing answers, WinDBG is a GUI front end for the DbgEng API. You can use this API to write either WinDBG extensions or other standalone applications. The WinDBG SDK ships with samples of both, an example standalone application can be found in the \sdk\samples\dumpstk subdirectory of your WinDBG install.
For more information, I wrote an article about DbgEng to write extensions here:
http://www.osronline.com/custom.cfm?name=articlePrint.cfm&id=559
Most of that will also apply for how you write a standalone application as it mostly focuses on the programming pattern of the DbgEng interface.
here are some links that use dbgeng interfaces to make standalone executables.
a short summary of the process is to
call DebugCreate() to create a client
call QueryInterFace()
and call one of its methods
http://www.woodmann.com/forum/entry.php?252-Dbgeng-based-handles-(PART-2-)
http://www.woodmann.com/forum/entry.php?246-A-Simple-Dbgeng-Based-User-Mode-Debugger
http://www.woodmann.com/forum/entry.php?248-DbgEng-Based-Debugger-(PART2)
http://www.woodmann.com/forum/entry.php?249-DbgEng-Based-Debugger-(PART2-Contd-)
http://www.woodmann.com/forum/entry.php?250-DbgEng-based-Kernel-Debugger
http://www.woodmann.com/forum/entry.php?251-Dbgeng-based-Handles
You could make commands using powershell or to the command line version of WinDbg which is cdb and then parse the output from cdb which you interpret.
This would be similar notion to piping the output from cdb to your app.
There is post about using powershell in this manner: http://rkeithhill.wordpress.com/2006/08/14/minidump-crash-analysis-with-powershell/
It should be straightforward to pump commands to cdb and interpret the output for specific commands.
Python integrated with dbgeng:
pykd.codeplex.com
This project may be use as a demo for such integration

Would be possible for Compiz to work on Windows?

I obviously don't think it would work as it is. Its more like, does Windows internal architecture allows for some third party SW to integrate in between? From what I read about Compiz, I believe it creates its own window, and somehow mixes graphics from System X to its own. But it still has to catch events like EXIT button and so on.
Does Windows even allow this? Let 3rd program to scan for input of another window? And more, catching output of GUI and replace it?
Does Windows even allow this? Let 3rd
program to scan for input of another
window? And more, catching output of
GUI and replace it? Thanks.
It is certainly possible. See WindowBlinds for an example. Just note that Windows "officially" does not support this, applications like WindowBlinds use API hooking, subclassing etc. to perform their deeds.
Windows does not natively allow it - it has its own compositor framework built in called DWM that does much of the same internal functionality as Compiz. However, glitzy graphics that are systemwide are reserved for the OS to perform, sadly. As other people mention, doing this as a 3rd-party app is going to be really hacky and difficult.
API Hooking:
http://www.codeproject.com/KB/system/hooksys.aspx
Also, look at:
http://yodm-3d.en.uptodown.com/
A free 'Compiz' for Windows.

Can you call COM components from server side javascript?

Is it possible (using one of the server side implementations of javascript .. see http://www.nakedjavascript.com/getting-started-55) to instantiate a COM object and invoke methods on it?
There is node-win32ole (npm install win32ole).
That depends on which server-side implementation you’re using.
When using ASP/JS (or any other framework using Microsoft’s Windows Scripting engine), that’s not a problem using the ActiveXObject constructor.
When using JSDB, you can use the ActiveX constructor.
Node.js doesn’t really work on Windows, only thru Cygwin, so ActiveX probably won’t be supported.
I have no idea how easy or difficult it would be to access COM objects from SpiderMonkey, V8 or SquirrelFish directly. They have C/C++ interfaces — and are open source, so if you know your way in the language, you could probably add it.

C++ WinInet Wrapper for Windows Mobile

Environment: Win32, C++/VS2008
I'm getting into the need to make HTTP (not HTTPS) requests from the internet using a Windows Mobile phone and to save time + reinventing the wheel, wondered if anybody here might have kindly shared a simple C++ (Win32?) WinInet wrapper or similar class?
The closest I found so far using Google is on codeproject, but wondered if someone here might yet have a better implementation.
Thank you. :)
The WinInet API is the same on Windows as it is on Windows CE. And its disgustingly easy to program. Why do you need a c++ wrapper for a really simple C API before you can proceed?
If you need help with WinInet, then ask an actual question.
In the simplest case, use of WinInet would start with InternetOpen, followed by InternetOpenUrl and InternetReadFile. Making a class to wrap up access to that is really an exercise left for the reader.

Common Lisp GUI Programming With System Calls

Can anyone tell me about using (Steel Bank) Common Lisp for writing GUIs via system calls? I know there are some libraries out there but this is a language learning exercise, so I want to do it myself.
I'm developing on Kubuntu 8.10 and SBCL 1.0.18.
Thanks.
You can take a closer look at the sb-posix-package. But as the page sais "The functionality contained in the package SB-UNIX is for SBCL internal use only; its contents are likely to change from version to version."
Another Possibility - the one I would choose - is to include the C-syscall(2)-Instruction via CFFI, and then perform it.
To create a windowed GUI, you must use X11, at least to give you a Window to paint on. Therefore, you must know the X11-Specifications to create a window, and implement the Syscalls for accessing Unix Domain Sockets, or initiating shm-devices etc.
If you just want graphics on a console, you could think of using the framebuffer-device /dev/fb*. You need ioctl(2)'s and the syscalls for read(2)ing and write(2)ing to use it, but still, I think this would be a lot easier than using X11 for this (even though still a lot of work). Maybe you shoudld look at the sourcecode for libFB or something similar to see how to initialize it, etc.
Is this really what you want to do? This is a lot of work, you will learn a lot, but more about the linux system infrastructure, rather than about SBCL, I think. If you want to use Syscalls under SBCL, maybe its better to try to open TCP-Sockets only with Linux-Syscalls - alone this can take hours of frustration.
By writing GUI via system calls you mean not using any GUI toolkit such as Gtk+ or Qt? In such case, you should talk directly to the X-server via socket and implement all the X11 protocol (or use CLX) and GUI on top of it. But that is not an easisest task, because X11 is complex.
In case you decide to dig into X11, there are some links for specifications: http://www.xfree86.org/current/specindex.html
http://www.freedesktop.org/wiki/Specifications?action=show&redirect=Standards

Resources