GithubHelp home page GithubHelp logo

openralauncherosx's Issues

App translocation breaks external mod metadata.

macOS >= 10.12 includes a security feature that 'translocates' applications (with a list of exclusions that don't always apply to OpenRA) at runtime to run from a read-only disk image. This breaks our ModMetadata launch paths, giving transient paths that are not repeatable.

e.g.:

	LaunchPath: /private/var/folders/wm/1cb20jp50y9_ycdlqlqxhky00000gn/T/AppTranslocation/E917BB1D-A577-4BD3-89B7-A8BA65E6CEAB/d/OpenRA.app/Contents/MacOS/OpenRA

Running from the translocated location isn't a problem so long as we know the original launch path so that we can reliably relaunch the game.

http://lapcatsoftware.com/articles/detect-app-translocation.html contains a code snippet that should let us find the original path:

#include <dlfcn.h> // dlopen, dlclose

bool IsTranslocatedURL(CFURLRef currentURL, CFURLRef *originalURL)
{
	if (currentURL == NULL)
	{
		return false;
	}
	
	// #define NSAppKitVersionNumber10_11 1404
	if (floor(NSAppKitVersionNumber) <= 1404)
	{
		return false;
	}
	
	void *handle = dlopen("/System/Library/Frameworks/Security.framework/Security", RTLD_LAZY);
	if (handle == NULL)
	{
		return false;
	}
	
	bool isTranslocated = false;
	
	Boolean (*mySecTranslocateIsTranslocatedURL)(CFURLRef path, bool *isTranslocated, CFErrorRef * __nullable error);
	mySecTranslocateIsTranslocatedURL = dlsym(handle, "SecTranslocateIsTranslocatedURL");
	if (mySecTranslocateIsTranslocatedURL != NULL)
	{
		if (mySecTranslocateIsTranslocatedURL(currentURL, &isTranslocated, NULL))
		{
			if (isTranslocated)
			{
				if (originalURL != NULL)
				{
					CFURLRef __nullable (*mySecTranslocateCreateOriginalPathForURL)(CFURLRef translocatedPath, CFErrorRef * __nullable error);
					mySecTranslocateCreateOriginalPathForURL = dlsym(handle, "SecTranslocateCreateOriginalPathForURL");
					if (mySecTranslocateCreateOriginalPathForURL != NULL)
					{
						*originalURL = mySecTranslocateCreateOriginalPathForURL((CFURLRef)currentURL, NULL);
					}
					else
					{
						*originalURL = NULL;
					}
				}
			}
		}
	}
	
	dlclose(handle);
	
	return isTranslocated;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.