It appears that cygwin doesn't support user context switching (supported by ucontext.h).
Given I need to developed a user-context switching application under cygwin, is there any solution for this?
You can probably write your own implementation, wrapping around the Fiber API. http://msdn.microsoft.com/en-us/library/ms682661(VS.85).aspx
In C++ you could try the Context from Boost, it has a similar interface.
Related
I am currently doing some research on techniques about hooking mobile applications and came across some frameworks like Xposed (Android), Frida (Android and iOS) and Cycript (iOS).
The documentation about Xposed and Frida is fairly good explaining how exactly they are doing it. Xposed states to manipulate the binary starting the Zygote process and loading an additional JAR file that assists in hooking the methods. Frida documentation explains that it uses ptrace (in Linux environments) to attach to a process, allocating and populating a bootstrapper that loads a thread to launch a .so file containing the frida agent, in a nutshell, if I understood it correctly.
I couldn't find useful documentation about the strategy that Cycript pursues. I know that it is built on top of Cydia Substrate that does the actual hooking. I couldn't find details about how exactly Substrate accomplishes this either.
I further understand that on iOS the objective-c runtime enables runtime manipulation as it is runtime-oriented.
Does anybody know how exactly Cycript / Cydia Substrate works to hook/inject into applications?
Thanks in advance.
It figured out that is apparently working by adding the DYLD_INSERT_LIBRARIES into the program's launchd manifest and thereby every time the application is started it loads the malicious payload by loading the dynamic library.
Still, are there other techniques how to perform runtime hooking / manipulations on Android and iOS?
I have recently developed a google chrome extension that uses an NPAPI plugin made using the FireBreath framework. I just now found out that google will shortly discontinue these types of plugins and eventually ban all existing extensions that use them. So, I would like to eventually move to the NaCl / PPAPI architecture, but I am not sure if this architecture can even support what I am currently doing in the NPAPI plugin.
In my current NPAPI plugin I am supporting OSX and Windows. On the OSX version, the plugin executes the system() function which executes a small 1 line applescript. It looks like this:
osascript -e 'tell app ...
On the windows version, it executes functions in a COM library. Both versions end up doing the same exact thing. Another option I have is executing a python script, if I were to go this route, I would most likely want to embed python in the native component.
Is any of this possible anymore with NaCl / PPAPI?
The ability to run arbitrary system() function or execute arbitrary functions from a COM library is #1 reason for NPAPI deprecation. Ditto for execution of a python script (you can execute python script in NaCl, of course - but it'll not be able to call system() function or a COM library either).
It's not news: as was noted in the Chrome Comic book on the day of Chromium release NPAPI plugins are unrestricted and that it's a big problem: http://www.google.com/googlebooks/chrome/small_30.html
It was obvious even back then that this situation can only be tolerated for so long. Plugins were tolerated for five years because some important things were unimplemenatble without them but now it's time to kill plugins and make sure nothing in browser can access OS directly.
If you want to implement some functionality which can not be implemented in browser currently because there are no appropriate API the right way is to ask about it on chromium-dev and add this API to Chromium (and perhaps other browsers, too). For example access to COM ports (not libraries) was added recently (see http://developer.chrome.com/apps/app_hardware.html).
Since you are already using an extension, you may want to look at Native Messaging as a replacement for your use of NPAPI.
If you don't need an interaction between browser and the application, you can use external protocol support. You need to register protocol in the registry on Windows. I don't know how external protocols work on OSX. When user clicks external protocol link, Chrome shows a dialog which allows user to launch the application.
Are there any auto compiling scripts like the ones used at ideone.com and codepad.org available?
(preferably open source, and which execute the code in a safe environment.)
I don't think that they have special "autocompiling scripts". They could just be using normal compilers under a virtual machine for safety.
Or they could have developed something custom (Like Google app engine)
Update:
Apparently they are using normal compiler packages by Gentoo.
Why not to use Ideone API?
Are there any libraries for connecting as a client via Remote Desktop Protocol (RDP) in Linux? The language used is secondary to the issue of existence. Any mainstream language would do (e.g. C++, Perl, Java, Ruby, PHP, Python), and even less popular ones like OCaml or Scheme.
Is there any option available other than taking the rdesktop source and hacking a library out of that?
There is a set of cross-platform open source RDP libraries available in FreeRDP project. They are written in C and under Apache Licence 2.0. See http://www.freerdp.com
Typing rdp into my Mandriva Software Managment tool revealed libxrdp which is a library that xrdp depends on but I don't know the details so it may not be what you want.
The project website is xrdp.sourceforge.net.
You can look at these implementations:
FreeRDP (Apache License) - mostly C.
FreeRDP C# bindings
FreeRDP-WebConnect for HTML5 stuff
rdesktop (GPLv2) - mostly C.
rdpy (GPLv3) - python but bitmap stuff is written in C (borrowing code from rdesktop)
properJavaRDP (GPL) - java
Non portable implementations:
Terminals (MS-CL) - visual studio project.
And the reference documents:
http://msdn.microsoft.com/en-us/library/cc240445.aspx
http://msdn.microsoft.com/en-us/library/cc240452.aspx (message flows / connection sequence)
rdesktop is going to be your best option. The code is quite clean and I don't think making a library would be a huge deal.
Another option if you prefer Java is the ProperJavaRDP Client http://properjavardp.sourceforge.net/ . It's nearly a strait port of rdesktop.
Sorry, but a quick strace and nm of rdesktop reveal nothing beyond X, crypto, and compression libs.
rdesktop does allow embedding into other windows, how does it not serve your purpose?
See the -X option in help
You could embed rdesktop in a window of your own per J-16 SDIZ's suggestion and then send X.org events to that window programmatically. A similar route would be to install a VNC server on the Windows machine and run a VNC client on the Linux machine. That way you can also programmatically send X.org events to the VNC client.
This is what browsershots.org uses to programmatically control various web browsers in a cross-platform way through Python. Have a look at the gui directory if the browsershots.org client source code
I've gotten xrdp to work with RHEL on EC2: xrdp.org
Is there any UI library that can be to build both a text user interface (ncurses) and graphical user interface (GTK? QT?) from the same source?
I know that debconf can be used with various frontends, I would like to build something similar but programmable.
The library that powers YaST independence to do ncurses, gtk and qt with one codebase provides what you are looking for, and it is not tied to YaST itself.
Actually libyui only requires the standard C++ library and phtreads (IIRC). The UI plugins require of course the respective libraries (Qt, ncurses). YaST uses libyui via a set of YCP bindings that export a YCP like API on top of libyui.
The library is a bit lowlevel (one layer below an event loop), my colleage Klaus Kämpf wrote about using it some time ago in his blog, including binding to scripting languages it using swig.
The only part that is SUSE specific is the packaging, so you would need to package it yourself. Stackoverflow did not allow me to link more than once. The code of the library is linked from Klaus blog. Replace libyui for "qt" and "ncurses" for the plugin's code.
Also google for "YaST Independence From YCP" to find a blog entry from Andreas Jäger on the subject.
you could write your program to uses ncurses, and then use PDCurses to convert it to an X11 application - as the readme advertise.
I know it because I've used it as portable curses, though I've never tested its X11 capabilities
Not exactly a library but you could consider writing a web app that degrades well to Lynx
The GoboLinux guys have created their own toolkit for python called AbsTK, they use it for their installer, which actually works really good. I have never used the toolkit myself, but the apps built with it seems solid.
There's Cursed GTK, but it seems a bit dated. I found some references to a port of Qt to ncurses called Qt Console, but it seems to have disappeared.
By using a library that targets both the text-mode and GUI environments, you have a big risk of getting stuck with the worst of both worlds.
You will be better off structuring your code using the MVC pattern, and providing separate views and controllers for each platform you target. Pushing all the logic down to the model classes has several other benefits:
The code will be easier to test because you are forced to keep the user interface out of the actual domain logic.
Your program can have user interfaces that have very little in common, e.g. a web UI, or an UI driven by speech.
You can run the program easily with no UI at all (i.e. script it) by accessing the model classes directly in the same way that the controller classes do.
I think what's used for configuring the linux kernel when compiling is dialog/cdialog/xdialog. But it's been a while since I've compiled a kernel, so my memory may be off. The most promising link I can find is this one for Xdialog.
Maybe tcl/tk would provide what you want http://www.tcl.tk/
Here's the page on interfacing with curses. There is a claim there of integration with ncurses.
http://www2.tcl.tk/2372