How to serialize an function? - ios

There is a way to serialize/deserialize a function inside an obj-c application?
I the near future i need to change the function's implementation without update my executable.
I know there isn't a way to serialize a function pointer / nsoperation / block so i'm looking for an alternative way...maybe can i include a python interpreter inside my app and download a script from websever?

Per the SDK licence agreement, you're not permitted to download any code whatsoever — it's a thin-end-of-the-wedge issue versus Apple's desire to vet all applications.
In technical terms, you'd need to include Python or LUA or something like that. JavaScript is included but accessible only through a very awkward process of interaction with web views.

Related

How to run Noise reduction filter from plug-in?

I want to write a plug-in, that besides other things, apply Enhance/Noise reduction filter. But I found out that there is no similar procedure in the browser. And even no documentation for this filter, which is strange.
So, does anybody knows how to call Noise reduction filter from a plugin? And why some of the filters not documented and not present in procedures?
As its icon indicates, this is a GEGL operation, and unfortunately these have currently no API for scripts.
To be more complete, and as far as I can tell:
No new API has been added for the new GEGL tools
However, for compatibility:
Functions that had an existing non-GEGL implementation have been converted to use the equivalent GEGL tool (for instance deinterlace and blur-gauss still are called plug-in-something in the API but you won't find them listed in pluginrc)
Some plugins that are no longer shown in the UI still have the plugin code to make them callable by legacy scripts (plug-in-sharpen for instance)

Giving or changing the implementation of method at runtime in iOS

Recently i caught with the a thought of changing the implementation of method after deployment
When i googled about objective c runtime and all, came to know about method swizzling methodExchangeImplementations etc.
I know that it could be possible by https://rollout.io/
But my thought is how to do Hot Patching by myself for simple things.
my idea is injecting the code using webservice call.
Webservice should give a replacement for particular method.
That string has to be converted to executable code
What i want to know is ...
How to inject the code in existing method of enterprise application.
For ex:
Consider this method in objective c
-(void)fetchTheResult{
// some code lines
}
After deployment i would like to change the method implementation to
-(void)fetchTheresult{
NSLog(#"test log");
//some Code lines
//some more lines
}
Please guide me the way to achieve this
This is a big question and you've some research to do to figure out an answer. Here as some things you can look into:
First you've referenced Rollout, you could follow the same idea and send your update as JavaScript. You'll need to study how to call JavaScript, swizzle methods, and probably dynamically add methods - more on that in a moment.
An alternative you can investigate is dynamic library loading - you can open, and call code in, a library which your app loads at runtime. So you could look at sending your update as a library. You'll still need to do method swizzling and probably dynamically add methods...
As well as method swizzling you may find you need to dynamically add methods - e.g. so you have something to swap the existing implementation to. A good place to find out how to do that is Mike Ash's writings on KVO - go DuckDuckGo (or Google)
HTH
It is not as easy as you think, at least in Objective C and other similar compiled languages. This kind of runtime changes to the code is only possible in interpreted languages like Javascript.
The basic problem is, the apps are not allowed to change the executable files themselves. The apps on iOS and Android run in a sandboxed environment, and thus have access to limited disk locations only.
Also, after compiling the code, the code does not know where the part of code is converted and stored in machine language. You have to understand the basics of compilers to understand this. There are heavy optimisations happening to your code during this process.

iOS - Operating text input as code

Is it possible to have input from a UITextField operated as code? for instance, I have a text field and button. The user enters some code (for instance NSLog(#"hello world")) then presses the button. Whatever the user inputted is treated as code and is operated as though part of the usual .m file.
So, is this possible?
(Edit: A little bit like Python's input command, where input can be treated as code
If you need any more information just ask, though I think that should cover it.
Technically speaking: yes, it's possible. But it's far from easy.
So what you want is: entering some Objective-C code and make it run, from within the app. What is needed for this is:
An Objective-C compiler embedded in the app;
And the permission of the OS/kernel to run the resulting code.
The solution to problem #1 may be embedding the Clang/LLVM compiler suite in your app (but it's huge, several tens of megabytes). However, 1. be prepared for not being able to port it to iOS (it is hard to port a functional cross-toolchain, especially with the brainless build system of LLVM and Clang), 2. and the generated code won't be codesigned anyway, so it won't run in an official environment, it would only run on jailbroken devices.
If you want to provide some kind of interactive programming feature to the user, you better try embedding a small scripting language such as Lua into your app instead.
Short and practical answer, no.
Python is an interpreted language, objective-c needs to be compiled first in order to run and you don't have a compiler available inside an app. Even if you had a compiler, that code wouldn't be able to run (it's not signed) and you would probably be breaking lots of appstore rules.

How to get the property list and values of a control within a third-party Delphi application?

I'd like to get information about a third party application's controls such as a list of its properties and their values: something like RTTI information but for a third-party Delphi application.
I see that this is possible. For example TestComplete has the ObjectSpy window which can give many useful information about the control, including RTTI information. How can this be done ?
Edit: To explain why I'm investigating this issue... I'm a registered user of TestComplete/TestExecute and I do like... most of it. I can get over the minor things but the one major problem for me is their license verification system which requires me to have a physical computer (not a virtual machine) always on just for the sake of running a license server so that TestExecute can run at night. As I have basic testing needs (compare screenshots and check basic Delphi component's properties) I wondered how hard it would be to make my own private very simple "TestExecute-like" application.
To go further, I suggest you these relevant resources found here on SO
Writing a very basic debugger (The accepted answer along with its comment thread are all valuable).
Is it possible to access memory from an application to another ? How? (Excerpt from the accepted answer: It is possible. Just use the Windows API functions WriteProcessMemory/ReadProcessMemory. Pass in the handle of the process and the pointer to the data).
Search the memory of another process (The excellent accepted answer also forwards to another valuable resource delphi-code-coverage by Christer Fahlgren and Nick Ring).
StackWalk of other process in delphi? (Check Barry Kelly's answer !!!, the same for the one from the AsmProfiler author !!!).
I strongly suggest you to port to Delphi this c++ project entitled Get Process Info with NtQueryInformationProcess: A hands on experience on using ReadProcessMemory to access the CommandLine used to launch another process.
Last Edit:
NtQuerySystemInformation Delphi Example.
RRUZ's answer to Delphi - get what files are opened by an application as suggested by LU RD.
When we want to take another application which is compiled with debug information and get stuff out of it at runtime, what we are dealing with is the problem of "how to write my own custom debugger/profiler/automated-test kernel".
TestComplete and other AutomatedQA programs contain a Debugger and Profiler Kernel which can start up, run and remotely control apps, and parse their Debug information in several formats, including the TurboDebugger TD32 information attached to these executables. Their profiling kernel also can see each object as it is created, and can iterate the RTTI-like debug information to determine that an object that was created is of a particular class type, and then see what properties exist in that object.
Now, TestComplete adds on top of the AQTime-level of stuff, the ability to introspect Window handles, and intuit from Window Handles, the Delphi class Names that are behind it. However, it's much easier for you (or me) to write a program which can tell you that the mouse is over a window handle that belongs to a TPanel, than to know which version of Delphi created that particular executable, what version of TPanel that is, then, and what properties it would contain, and to read those values back from a running program, which requires that you implement your own "debugger engine". I am not aware of any open source applications that you could even use to get a start writing your own debugger, and you certainly can't use the ones that are inside AQTime/TestComplete, or the one inside Delphi itself, in your own apps.
I could not write you a sample program to do this, but even if I could, it would require a lot of third-party library support. To see the window classes for a window handle which your mouse is over, look for how to implement something like the MS Spy++ utility.
An easy case is if your mouse is mousing over a window inside your own application. For that, see this about.com link, which simply uses RTTI.

Is it possible to make system calls on iOS?

Is it possible to make a system call, such as executing ls -la, and use the result in your app?
Usually when someone says system call they mean calling into the kernel through one of the defined entry points. While its technically possible on iPhone, you are always better of going through the libSystem shims because the call interface is probably not stable (it isn't on Mac OS X for instance). I doubt Apple would like it if you did that, but I suspect no one as really thought about it much and they are unlikely to notice.
I don't think that is what you mean though. I think you want to use ISO/IEC 9899:1990 (C90) C libraray function "system". The answer to that is no, you can't.
Sadly syscall.h under iOS is a private api. While you can use it in private applications Apple will not allow you to use the syscall() API for App Store submissions unfortunately.

Resources