javac++winapiservicentfs-mft

Is it possible to query a privileged windows service from a user mode java application?


Background

I am working on an application where I need to query for all the files available on my harddisk using java. As performance is a major requirement, I have written a native application which accesses the windows Master File Table ($MBT) for all the valid file entries.

I am planning to modify the native as a windows service (running with admin privileges.. needed for accessing MFT) and then use my user mode java application to contact it via some IPC technique (specifically shared memory or named pipe or sockets... need to evaluate).

The target application is windows specific and java is used for text processing (I know python/perl are good at it but haven't used them for long time).

Questions

Now my question are -

  1. Whether it is possible to query a privileged windows service from a limited user level application?
  2. If not what could be the workaround to achieve this?
  3. I think sockets could be the possible IPC mechanism as other two would fail with Access Denied. Am I correct in assuming that?
  4. Is converting the native code to JNI/DLL and then using is correct over what I am planning? But in that case I have to start my java app with admin privilege by having a custom manifest file.

Platform

  1. Windows 7 Enterprise
  2. Visual Studio 2012 (for native $MFT access)
  3. JDK build 1.7.0_25-b17

Thanks


Solution

    1. You can query a privileged service, application if it provides a way of do it. (i.e. socket, pipe etc..)
    2. You can use socket a TCP/UDP Socket for this. You must make sure your firewall blocks this port to outside the machine.
    3. The easiest & loosely coupled way is Socket. The performance depends on the amount of data you transfer.
    4. Monitoring Hard disk files is an Admin task. So its not a bad thing to run this java app with admin privileges. but if you allow normal users to run this app by externally setting admin privileges, Its not a good practice.