It's not safe in the general case to make any assumptions about the location of applications like that. Most well-built Mac OS X applications are self-contained and can be moved almost anywhere, and users do this all the time.
If you are interested in applications, you might want to use a higher-level API in user space to watch for app launches and then pass that information down to your kext. That would give you an opportunity to bind information to the application so that your kext could deal sensibly with the case where the user has moved the application from one location to another.
= Mike
On Jan 12, 2011, at 12:49 AM, searockcliff wrote:
I want to check the process full path(if exist), if the path is in a specified folder like /Applications/, then I will do some work related it.
At 2011-01-12 16:45:06,"Michael Smith" <email@hidden> wrote:
Some processes are created as the result of executing binaries. Others are not. The path you've highlighted here is not always correct even if the process was created as a result of executing a binary, and the path is only valid in the context of the process that caused it to be executed.
What do you plan to do with the path string in a kext? Operations using path names are generally strongly discouraged from kernel context.
= Mike
On Jan 12, 2011, at 12:24 AM, searockcliff wrote:
I want to get the directory location of the process file.
For example, in user space, the TextEdit, the pid is 234
localhost:~ macuser$ ps -p 234
PID TTY TIME CMD
234 ?? 0:00.19 /Applications/TextEdit.app/Contents/MacOS/TextEdit -psn_0_94231
I want to get this "/Applications/TextEdit.app/Contents/MacOS/TextEdit" in kext.
At 2011-01-12 15:54:33,"Michael Smith" <
email@hidden> wrote:
On Jan 11, 2011, at 6:15 PM, searockcliff wrote:
Hello,
I have a process ID, I need to get the full path of the process in kext.
I know there are methods in user space application, like sysctl.
Are there also functions to achieve this in kext?
Processes don't have paths.
What are you trying to do?
= Mike
--
Excellence in any department can be attained only by the labor of a lifetime; it is not to be purchased at a lesser price -- Samuel Johnson
--
Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile -- Hippocrates
--
Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile -- Hippocrates