Selectively disable Process features - wpf

I've been trying to create a WPF application which will be a proactive filter trying to limit user activity. I've controlled mouse and keyboard through Win32 API. Now another requirement is to let the user open every other application/file through the WPF one.
I don't want to disable the user's clicking ability while he's inside a process. I've tried to disable file access but with no luck.
I have control over the user while launching a new process but what if he opens a file within the process?
Can I just disable 'New' and 'Open' options or the complete file menu in any other process like Microsoft Word?

You can try this. But the problem is, that this just tells what files are currently being accessed by the given process. So you can maybe kill the process in that moment:D Or warn the user. But as far as i know, you cannot create a semi-layer between another process and his system requests (like is the file [read/write] access request).
EDIT: Maybe there is another option. If these restricted files are known to you, and there is just small amount of them... then you can just lock them for your process and disable access to them for every other processes.

Related

Embedding CEF3 with existing application

I have a running WIN32 application. There a window in this application where I want to show web content using CEF3. But, I am facing problems and the entire window becomes white without showing any web page content. So I have the following questions:
Is it possible to use CEF3 with existing message loop in application? I dont want to call the CEF message loop, it may impact other things in my application.
Is it absolutely necessary to use a message window as in the sample application? I am not able to understand its objective.
When CEF3 launches multiple processes, how does it show in the task manager? If my application name is A.exe, does it show A.exe multiple times in task manager?
Any help is much appreciated.
For windows users there is possible to use multi threaded message loop (CefSettings). It is allow maintain browser windows via own message loop. But there is good practice use single threaded message loop, - you can call CefDoMessageLoopWork periodiacally on idle or some additional events. It is possible even with existing message loop.
I'm not sure what you mean.
CefSettings.BrowserSubprocessPath specifies which executable will be used for child processes. While you are integrating it in other process, looks like it is one possible solution and in task manager you will see processes as you named it.
About the question number 2:
every windows application has its own "main window" and wndProc that receives all the messages sent by his children.
And the sample win32 cefclient shows how to integrate cef message loop inside the application's message loop.
And if you don't handle and dispatch cef messages in proper way the browser window becomes white.

How can I allow only administrators to shutdown a program in windows

I dont know if this has to do with how the program is programmed or how it is set up or how it is started.
But I created a program in WPF and I would like to make sure that none of he regular users on the computer shut it down.
The regular users need to be able to interact with it but they should not be able to close it.
The correct approach would be to run the application as a service with permissions set by the administrator to not let the user manipulate the service. Otherwise you will run into trouble with user-initiated shutdown and with preventing the application from being terminated.
If it is the case that the OP wants to prevent visibility of the OS, creating a terminal like experience. The best way to do this is to create a shell replacement.
Then the user wouldn't see the OS as windows directly.

Wait for file to be unlocked - Windows

I'm writing a TFTP server program for university, which needs exclusive access to the files it opens for reading. Thus it can be configured that if a file is locked by another process that it waits for the file to become unlocked.
Is there any way on Win32 to wait for a file become unlocked without creating a handle for it first?
The reason I ask, is that if another process calls CreateFile() with a dwShareMode that is incompatible to the one my process uses, I won't even be able to get a file handle to use for waiting on the lock using LockFileEx().
Thanks for your help in advance!
If you take a look at the Stack Overflow questions What Win32 API can be used to find the process that has a given file open? and SYSTEM_HANDLE_INFORMATION structure, you will find links to code that can be used to enumerate processes and all open handles of each running process. This information can be used to obtain a HANDLE to the process that has the file open as well as its HANDLE for the file. You would then use DuplicateHandle() to create a copy of the file HANDLE, but in the TFTP process' handle table. The duplicated HANDLE could then be used by the TFTP process with LockFileEx().
This solution relies on an internal function, NtQuerySystemInformation(), and an undocumented system information class value that can be used to enumerate open handles. Note that this feature of NtQuerySystemInformation() "may be altered or unavailable in future versions of Windows". You might want to use an SEH handler to guard against access violations were that to happen.
As tools from MS like OH and Process Explorer do it, it is definitely possible to get all the handles opened by a process. From there to wait on what you'd like the road is still long, but it is a beginning :)
If you have no success with the Win32 API, one place to look at is for sure the NT Native API http://en.wikipedia.org/wiki/Native_API
You can start from here http://msdn.microsoft.com/en-us/library/windows/desktop/ms724509%28v=vs.85%29.aspx and see if it works with the SystemProcessInformation flag.
Look also here for a start http://nsylvain.blogspot.com/2007/09/how-list-all-open-handles.html
The native API is poorly documented, but you can find resources online (like here http://www.osronline.com/article.cfm?id=91)
As a disclaimer, I should add that the Native API is somehow "internal", and therefore subject to change on future versions. Some functions, however, are exposed also publicly in the DDK, at kernel level, so the likelihood of these functions to change is low.
Good luck!

Launch MS Access from Winforms

I'm trying to figure out how to launch a specific page/form in an Access project from a winforms app. Basically I'm trying to link the two applications via hyperlink or button or whatever (clicking on a button from a winforms form should take the user to that specific form in the access project). Is this possible?
You can launch MSAccess using Process Class
and
Open a Page/Form in MSAccess using Command-Line switches in Microsoft Access
to achieve your task you need to Create Macros in MSAccess to Open the specified page/form depend on your needs. you can call the Macro by specifying some parameters. here you need to use /Excl to open the database exclusively and /X to run the Macro.
a sample workaround is here
Process access = new Process();
access.StartInfo.FileName = "msaccess.exe";
access.StartInfo.Arguments = #"e:\test.mdb /Excl /X Macro1";
access.Start();
hope this helps

Checkpointing and restarting X11 applications

I want to checkpoint and restart X11 applications. I am using the BLCR (Berkeley Lab Checkpoint/Restart (BLCR)) tool.
BLCR is not able (without modifications) to reinitiate the connection to the X-Server. I used an interposition library to log all Xlib function calls with their parameters to a text file.
Now I want to be able to re-use this logged function call.
Is there a better way than to save them to a text file and parsing/interpreting them during the restart procedure?
The application which is checkpointed should redo the calls which were logged, but this seems to be not as easy as it has sounded first.
I've not tested this, but I think you might be able to solve this one by spawning an xmove child process and making sure this gets stored in the checkpoints. Your application would talk to xmove instead of the XServer directly and every time you restore from checkpoint you would "move" to the current xserver again.

Resources