MacOS App proc_listpids() fails, but works on other program - macos

I am new to MacOS and especially its lower level stuff, I built a CLI program to inject a dylib into a vulnrable process. It works fine, but I wanted to make a GUI program to do this, but now on my call to
proc_listallpids(NULL, 0);
the return value is always 0. Looking into some source code I found:
if ((error = proc_security_policy(PROC_NULL, PROC_INFO_CALL_LISTPIDS, type, NO_CHECK_SAME_USER)))
return (error);
But I was not able to find the source code for this function to find out why it fails(assuming this is the reason it does fail)
Is proc_listallpids() not allowed to be called from Apps? If so is there a way I can still make a GUI program but use this function? I was kind of thinking this might be to do with restrictions for the appstore but I wouldn't want my program on the appstore
Also I was wondering if there is a better site to go for topics like this.

The answer was App Sandbox, not sure if this is worth keeping around or not. I turned it off in the project settings and the function works now

Related

Problems with deploying a GTK Application

I am currently testing the GTK Application that I built on windows using the MSYS2 64bit shell.
For the program to be able to run outside of the shell, I packed all the required DLLs with it as well as the following:
FOLDER\lib\gdk-pixbuf-2.0\2.10.0\loaders\\*
FOLDER\lib\gdk-pixbuf-2.0\2.10.0\loaders.cache
FOLDER\share\glib-2.0\schemas\gschemas.compiled
FOLDER\share\icons\Adwaita\\*
FOLDER\share\icons\hicolor\\*
The good news is: It works :) And it also works flawlessly on another PC that doesnt have GTK/Msys2/whatever installed.
The bad news is: On yet another PC (I have tested it on 2 other Systems other than my developing System so far, one one of them it works flawlessly), the program itself works, but the GUI is not rendered sharply (texts are blurry).
Do you guys have any idea on what could be the reason for that? I'm guessing it could be one of the following:
The affected system could have some general display problems that have nothing to do with my app.
The gschemas.compiled file does not suit the affected system. In that case I would probably have to create that file dynamically, but I have no idea how to do this.
I am missing some file from GTK or Glib that would solve the problem.
I am thankful for any help :) Compiling/Deploying a GTK App for Windows has proven to be a pain in the ***, but since (almost) everything works now, I feel like its not much that I am missing unless I have overseen something critical.
Regards,
tagelicht
Given the way you created your package, my bet is that you are missing some components, making the drawing code use some fallback routines, hence the "sharp" drawing.
Try to run the application in command line on the machine where your have the problem, to see if there are some unusual warnings you don't have when running it on your machine.
See also my answer on how to distribute a GTK+ application on Windows.

Mac OS X App fails to execute completion handler in release build but works in debug build

I know this is rather vague but does anyone have any pointers as to why a completion handler does not get run in the release build but does run in the debug build.
I have not idea where to begin trying to solve this other than changing the code to not use a completion handler.
Any pointers would be welcome.
App is written in Swift and built for OS X 10.10
UPDATE
I just modified the code to send a NSNotification rather than run the completion handler and now things work fine. I still have the completion handler code in but its not being called.
We can't read minds. Can't help you if you don't show us the real code.
BUT. It it possible that you've come across a compiler bug. I've had a similar problem, where the Swift compiler would generate incorrect code in optimized (Release) build — but the same thing would work fine in Debug. (rdar://18906781) I've also heard of other production apps written in Swift that simply do not work correctly in optimized builds (and so are shipped unoptimized).
Try reworking the code to achieve the same thing with different code — maybe you'll work around the bug.
If you have the time, I encourage you to try narrowing the bug as much as possible to make a test case and reporting it on http://bugreport.apple.com.

VNC: Translate Qt KeyEvent to usable X11/RFB keysym

Background: I am currently in the process of creating a simple VNC viewer embedded in a QWidget for use on Windows. For this, I compiled the Qt-only VNC version of KRDC (remote desktop viewer for KDE) as well as its dependency libvncclient on windows. The problem which arose now however lies in the way krdc sends key events over vnc: it simply sends the value of QKeyEvent::nativeVirtualKey(), which on X11 is conveniently already a valid RFB keysym. On Windows however, this is not the case.
Now, to solve this problem, I think the best (and ultimately also portable) way is to translate Qt's QKeyEvent::key() and ::modifier() data back to valid X11/RFB keysyms. This seems somewhat complex though given that I need to pick different keysyms depending on modifier state (XK_a vs XK_A, I've only considered shift so far) as well. Looking into how X11 -> Qt translation is done in Qt's source code didn't really help either.
Might there already be a library or code snippet out there which accomplishes this? Or should I just attempt to write my own (incomplete) translation routine? If so, what would be the best way to go about this and also, are there other caveats related to X11 I should be aware of?
Well, seems like I'm actually blind; there was a reference in krdc's code, right below the e->nativeVirtualKey() statement, referencing another project's class where they encountered the exact same problem as me:
// hmm, either Win32-platform or too old Qt so we have to handle and
// translate Qt-key-codes to X-keycodes
I didn't test their solution but it seems solid. As I only discovered this now, I have already written a small routine myself which should work ok for most latin keyboards (but will probably break if the Qt team changes any of the Qt::Key values), if anyone is interested in it: link

Finding instances of sdk usage outside the deployment target

I'm trying to build an automated test to check that methods called outside of the current deployment target are handled correctly. Here's a concrete example:
My app is set to use the Mac OS X 10.8 sdk and the deployment target is set to 10.6.
I often use the setTimingFunciton: method. It was introduced in 10.7.
[[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
In most cases I correctly bounded this method call with a check to ensure the method exists or that the OS was the correct version or later. But I missed one. And it's in a rarely executed code path, so even beta testing didn't notice it. It only came back to bite me much later.
I'd like to build an automated way to test for things like this that can be deployed on an integration server or other such scripted regression test. It seemed like something there must be a way to check for automatically.
Recompiling with the 10.6 sdk unfortunately results in many errors, most due to "modern obj-c". These, of course, are not errors when using the 10.8 sdk. Being careful, I can pick through the errors and find the method calls -- but that's overly complicated and manual.
Does anyone know of a way to statically check these sorts of things that doesn't involve a human picking through hundreds of lines of false-errors?
P.S. I've read this: How to check if not available methods are used if deployment target < base sdk?
Which recommends another manual flow for digging through them. The problem is, the human method failed me. I missed one. I'd like something a bit more certain.
I've used the technique from this answer and it has worked great. Totally automatic and it doesn't miss anything.
Here is an idea. undef and redefine the availability macros so they contain something that Clang will object to but will otherwise not affect program flow. Run Clang.

MacRuby: How to write an app/script that generates native Mac apps?

So I'm basically trying to recreate what this app: Fluid, already does. I want to write a Ruby script, or MacRuby app that accepts a few parameters and can generate a simple native app.
Since their code is not open-sourced, I can't see how they do it. And I don't know how I would begin to accomplish something like this.
Also, I would like this script to be run on Windows (not that the user could install the generated app, but so the app could be distributed to Mac users).
How could I do something like this?
Solution:
Here is a project that does exactly the same thing that I'm trying to do. It takes an app bundle and does some string replacing on some files in the bundle. I'm going to use it as an example to imitate.
https://github.com/maccman/macgap-rb
MacRuby can already create native app bundles on OS X (it's a compiler as well as an interpreter), so in a sense there's no question to be answered here. If you want to write an app in MacRuby or Objective-C for OS X, the experience is essentially the same (though, of course, MacRuby has different command line flags for generating the final result, in this case the -deploy flag to MacRuby vs some linker invocation for ObjC). That said, nothing you write in MacRuby will run natively in Windows. Depending on the complexity of the app you have in mind, you may have to go to some cross-platform solution (like Unity) for that.
Check out Prism. It's not Ruby, but it does exactly what you describe and is open-source. One thing you'll to do is embed a web browser into a window, so look for libraries that do that. I'm assuming you'll use Cocoa for GUI since you're using MacRuby. In the end, the simplest way would be just have a window with web browser in it.

Resources