Show Content of app file after unzipping the iPA, and opening exec shows my local path - ios

I've developed an application and I need to remove my computer local path from the generated iPA file.
I did the following:
unzipping iPA file.
click on show package content.
open exec(appname.exec) file with text editor.
Now I can see some binary stuff, and strings with my computer local path (with my mac name).
I have to remove these paths from the exec file, due to security issues. How can I do so?

As Accessing Files and Directories says:
Although you can open any file and read its contents as a stream of bytes, doing so is not always the right choice. OS X and iOS provide built-in support that makes opening many types of standard file formats (such as text files, images, sounds, and property lists) much easier. For these standard file formats, you should use the higher-level options for reading and writing the file contents. Table 2-1 lists the common file types supported by the system along with information about how you access them.
You have many ways to save your data:
Specifying the Path to a File or Directory
Locating Items in Your App Bundle
Locating Items in the Standard Directories
Locating Files Using Bookmarks
You have chosen to Specifying the Path to a File or Directory,as #Droppy says
Firstly it will break the code signature and secondly it's time consuming and error prone.
You'd better choose to Locating Items in the Standard Directories
Here is why you should choose the way:
Locating Items in the Standard Directories
When you need to locate a file in one of the standard directories, use the system frameworks to locate the directory first and then use the resulting URL to build a path to the file. The Foundation framework includes several options for locating the standard system directories. By using these methods, the paths will be correct whether your app is sandboxed or not:
The URLsForDirectory:inDomains: method of the NSFileManager class returns a directory’s location packaged in an NSURL object. The directory to search for is an NSSearchPathDirectory constant. These constants provide URLs for the user’s home directory, as well as most of the standard directories.
The NSSearchPathForDirectoriesInDomains function behaves like the URLsForDirectory:inDomains: method but returns the directory’s location as a string-based path. You should use the URLsForDirectory:inDomains: method instead.
The NSHomeDirectory function returns the path to either the user’s or app’s home directory. (Which home directory is returned depends on the platform and whether the app is in a sandbox.) When an app is sandboxed the home directory points to the app’s sandbox, otherwise it points to the User’s home directory on the file system. If constructing a file to a subdirectory of a user’s home directory, you should instead consider using the URLsForDirectory:inDomains: method instead.
You can use the URL or path-based string you receive from the preceding routines to build new objects with the locations of the files you want. Both the NSURL and NSString classes provide path-related methods for adding and removing path components and making changes to the path in general. Listing 2-1 shows an example that searches for the standard Application Support directory and creates a new URL for a directory containing the app’s data files.

You cannot do it this way. Firstly it will break the code signature and secondly it's time consuming and error prone.
The correct approach is to not use the complete path in your code and instead use methods like NSSearchPathForDirectoriesInDomains to get the Documents folder, or whatever directory you want to use.

Related

How to prevent local msmpi installation from loading system wide msmpi.dll

I'm writing a console app for windows that sets up an environment and launches (popen) various hpc-apps using msmpi mpiexec.exe.
I have an msmpi installation installed locally to the application I'm writing. All works fine and parallel processing is OK.
However, as soon as I happen to have a system installation of msmpi as well (as installed by e.g. msmpisetup.exe), my applications stubbornly loads the Windows/system32/msmpi.dll instead of the msmpi.dll that I point at using PATH. Since the system msmpi.dll is of a different version, my apps does not run.
The PATH env.var. is set within my app, and it is apparently inherited correctly by the child processes, including mpiexec.
The only remedy I've found is to either (1) Rename system32/msmpi.dll or (2) place a copy of "my" msmpi.dll into every folder in which I have a parallel executable. Both remedies are... not nice.
How can I prevent my apps from selecting the system32/msmpi.dll and use the instance that's in the PATH instead??
Thank you for any advice.
N
The standard DLL search order in Windows is documented to be
The directory from which the application loaded.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The current directory.
The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
If you want your application to check a specific location first before using the system locations, you can call SetDllDirectory in the parent application before letting it execute other binaries that require a particular DLL.

Firefox Addon SDK - How to get a list of files in a directory, and get a file

I am using the SDK to build a Firefox addon. In the addon options, the user can specify a directory of images for my addon to use (these will be added to a webpage).
I cannot figure out how to obtain a list of the files in the directory the user specified (Note that I know how to get this directory using simple-prefs). I also need to know how to get a specific file.
The file I get will be sent to a contentScriptFile to add to a webpage (as a background-image) using pageMod, via worker.port.emit(...).
So my question: How do I obtain a list of files in a directory, and how to get one of those files to send to a contentScriptFile?
I have found out how to do it, using the Low-Level API io/file
After you require() it using var fileIO = require("sdk/io/file"); you can do the following:
List files and directories in a directory using fileIO.list(path), where path is the path to the directory
Read a file using fileIO.read(path), this returns a string with the contents of the file

NULL when using fopen with xcode

I am trying to initialize a multidimensional array from a file using C for a iPhone 4inch app but I can't open up the file using fopen.
Whenever I try this I get a NULL:
FILE *f;
f=fopen("/level1.rez", "r");
if (f == NULL)
{
printf("Error Reading File\n");
//exit (0);
}
I am not sure how to open files using C.
I tried this already:
I printed out the current working directory using getcwd but all I got was "/" and when I attached that to the file name I still got NULL.
I read that if you go to product > scheme > edit scheme then options you can change the current working directory but I don't see that option.
Also I read that you can use absolute paths like: /users/name/desktop/program
but I am new to iOS development so I don't know if that is a good idea.
So how do I get fopen to work?
You CAN specify absolute paths in iOS, but the path in your example is probably used in Mac OS, which is laid out a little differently. You can specify paths to fopen() as you say, but there is more work to finding out what the first part of that path really is.
The iOS puts all AppStore apps into folders with randomly generated sandbox directory names. It is basically the the hexadecimal string of a GUID. So you need to use methods from iOS frameworks to get the first part of the path (or URL) to your file.
If the file is part of the app bundle so it can ship with the app, then you will need to use NSBundle methods to find the path to the file.
If the file is generated or downloaded after the app starts up on the device, then you need to use NSFileManager methods to determine the path to the directory of the file. (Typically the Documents directory. You can build a directory structure of your choice within the sandbox.)

How to add settings and make then be built into an existing exe file in Delphi

lets say that I have a program, that is modifying registry in Windows. User can chose what keys will be changed. After this he will click "generate" to create new exe file which will do its job depending on user choices.
How can I achieve that "exe generating" by clicking generate?
First you need to have two EXEs. One is your main app, and the second is the app that changes the registry. Now you have to append some data to get a copy of your secondary app using your main app and append the data that specifies what keys to change.
One way is to use resources. Use your main app to append required data as resources to your target exe (The compiled to-be-generated exe).
Your target exe file should check and load data resource from its own executable file and retrieve the required data.
You might find these links useful:
How to attach a resource file to an existing executable file?
And how to retrieve the resource in your target exe:
http://delphi.about.com/od/objectpascalide/a/embed_resources_2.htm

How to pass parameter to exe downloaded from web?

I have .Net desktop app which users can download from my website. I want to customize this app to per user basis.
Is there way to modify exe before downloading, just to change few strings with appropriate for the users downloading ?
Or it is possible to pass command line parameters to this exe via URL ?
The .exe file needs to be customized for it to behave differently for certain downloads.
Skip below to find the solution I found tolerable.
Add section to the .EXE file – Not ideal.
The .exe file has sections one after the other. You could add a section with your data in it, which the executable would then read. This requires you to modify (have access to) the source code of the executable for it to do anything meaningful with the data. Also getting familiar with the .exe file format and modifying it on the web server side as well al playing with it in the program's source code is somewhat tedious.
Change resources section of the .EXE file – Not ideal.
A dedicated "resources" section exists in the executable. You could add custom strings or blob of data to it. Same cons as the first one.
Overwrite data in the .EXE at a fixed position – Passable.
Have the executable read data from itself from a fixed position in the file, which is overwritten with the customization data when serving the .exe file. Requires modifying the executable's source code.
Append data to the .EXE – Passable.
Append data to the executable. Again, reading it and doing anything special with it requires the executable itself doing so.
☑ Wrap the .EXE in another .EXE and append your data to it – Tolerable.
Create a program to which the original executable and the custom data will be appended to. When this custom program is then executed, it will extract the embedded executable and launch it with the custom data as it arguments.
This kind of a bundle-executable is also easy to produce on most server-side (scripting) languages. When the download is requested, the server sends the wrapper-exe, the original exe, the customized data and of course some statically-sized data fields denoting the sizes of both of those data blocks so it can extract them.
Cons: Requires such a wrapper program to be created, unless someone already has.
Related links:
1. Best practices to let my web users download custom .exe from my site using PHP
2. Modifying executable upon download (Like Ninite)
If the application is ClickOnce deployed, passing URL parameters is an option in the ClickOnce options dialog. However, I have not yet used this feature.
EDIT
You might want to change some user settings in your configuration depending on the user that actually runs the application. You could also make sure this is done only once per user by adding an appropriate SettingsNeedUpdate setting you set to true after the initial initialization.
Example:
Add new setting "Option1", "Option2" and "SettingsNeedUpdate" which are user settings. In Main you could add something like:
...
try
{
if (Properties.Settings.Default.SettingsNeedUpdate)
{
Properties.Settings.Default.Option1 = ...;
Properties.Settings.Default.Option2 = ...;
Properties.Settings.Default.SettingsNeedUpdate = false;
Properties.Settings.Default.Save();
}
}
catch (Exception exp)
{
...
}
...
You could write a library which can modify an assembly resources (here string table).
This library could benefit from reflection.
When a user asks for your file, asp.net page could customize the exe (using your library) and send it to client.
Not like that, No.
You could however automatically zip (on your server) your exe with a custom app.config file for each user.
Update
Point your download location to a custom HttpHandler that zips together your exe (using http://www.sharpdevelop.net/OpenSource/SharpZipLib/) with a generated (for the current user) application configuration file ( http://generally.wordpress.com/2007/09/27/using-appconfig-for-user-defined-runtime-parameters/).
The user then unzips the two files (MyApp.exe & MyApp.exe.config) to any location and run MyApp.exe.
This method does not work if you have an installer.

Resources