mfc >> File System Hook

by Srusal » Fri, 17 Mar 2006 12:14:47 GMT

Hi,

I am trying to hook the file system to get the notifications whenever
an application / process opens a file. I must be able to get the
process' information (i.e. name, path, etc).

I do know that it has to be done at the file system driver layer by
having a filter driver (Is there any other way?). But I could not get
any source code. I am posting this question here with the hope that
atleast one of you would have faced similar situation. It would be
great, if someone give me a link that points to the source.

Thanks a lot
Srusal



Similar Threads

1. File System Hook

2. ANN: Single File System v.2.30: delphi virtual single-file system

3. system hook? - CSharp/C#

4. Injecting c# built system hook dll into another process

I have been reading alot about local system hooks, and am able to
inject a c# built system hook into a thread outside of my app but
unsuccessfully, the program crashes(ie: notepad keyboard hook for
testing). I assume that you cannot inject a c# built dll into an app
other than your own appdomain? If this is the case, is the only other
option to build the LocalSystemHook base class in c++?

5. Extendind/hooking system dll's - CSharp/C#

6. System journal hooks - Macro Recorder

Hello,

I need to build the following functionality into my application and
wanted to see if the System journal hooks were the right way to
approach this problem? If not, I would appreciate any suggestions.

1) I need to be able to define fields on a screens on a variety mediums
- ie. web pages, java applications, windows app, etc. the values for
these fields will come from my database

2) Later I need to be able run the app so that it launches the screen
above and automatically populates the fields and then clicks on the
okay or submit button.

If there tools available that will make this easier to implement, I
would appreciate knowing about them as well.

Thanks

7. [?] ERROR_HOOK_NEEDS_HMOD during installing system hook - CSharp/C#

8. problem installing a system-wide hook

I am having trouble installing a system-wide hook (WH_CBT) using
SetWindowsHookEx. I have build a DLL which contains my hook procedure
and I dynamically load this DLL in my calling application, get the hook
proc address, and call SetWindowsHookEx with the thread parameter as
NULL. However, when I debug, the hook proc only gets called when
windows are created, deactivated, etc for my application, instead I
wanted the proc to be called for ANY window creation, activation, etc.
I have tried a number of things but I don't understand why I am only
able to hook events of my calling application instead of all events
from the OS. I am pasting the relevant pieces of the source code to
give an idea of what I have done. Any pointers will be deeply
appreciated. Thanks,

//DLL Part

extern "C"
{
	LRESULT HOOKPROVIDER_API __stdcall CALLBACK CBTProc(int nCode, WPARAM
wParam, LPARAM lParam);
}

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}

LRESULT HOOKPROVIDER_API __stdcall CALLBACK CBTProc(int nCode, WPARAM
wParam, LPARAM lParam)
{
    if (nCode < 0)  // do not process message
        return CallNextHookEx(0, nCode, wParam,
            lParam);
    switch (nCode)
    {
        case HCBT_ACTIVATE:
            break;
        default:
            break;
    }
	return CallNextHookEx(0, nCode, wParam,
        lParam);
}

//Calling Application

HOOKPROC hkprcSysMsg;
HMODULE  hinstDLL;
HHOOK hhookSysMsg;
hinstDLL = LoadLibrary((LPCTSTR) "D:\\My Documents\\Visual Studio
Projects\\hookprovider\\Debug\\hookprovider.dll");
hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL,(LPCSTR)5);
hhookSysMsg = SetWindowsHookEx(WH_CBT,hkprcSysMsg,hinstDLL,NULL);