Thread: how to intercept / prevent file creation?

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    3

    how to intercept / prevent file creation?

    I was playing around with some code to receive shell change
    notifications using:

    SHChangeNotifyRegister (and others)

    however I'd like to intercept the file creation messages and
    prevent certain files from being created.

    It appears that by the time I get the message SHCNE_CREATE
    and SHCNE_UPDATEDIR, the file has already been created.

    Any ideas where to start?

    Running:

    Win2k Pro, SP 3
    Visual Studio 6 Enterprise

    Thanks,

    xeno
    Last edited by xeno; 04-29-2003 at 07:23 PM.

  2. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Wrong board?

    Sorry, this isn't an answer... but this should probably be on the Windows Board.

    And, this may be impossible without "hacking" the operating system. The operating system does not want you or your program interfering with it's operation or the operation of other programs.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    3
    ... Sorry about posting in the wrong forum

    DougDbug:

    Thanks for your reply however I slightly disagree. I wouldn't
    consider it a "hack" to prevent file types from being created. This
    is done by programs such as Virus Scanners.

    Take for instance, Norton AntiVirus. When a file is dropped on my
    hard drive with a virus in it, Norton moves the file to a quarrantine
    folder and does not allow the file to be created.


    What I am trying to do is prevent users who are not in a certain
    group from deploying Access databases on a network drive. My
    employer will allow them to create databases on their local drive
    however we do not want them deployed to the network unless
    they are built and maintained by one of us Access developers.

    Our reason for this is because the number of databases on our
    servers got out of hand (and most weren't being used) and it has
    taken us a long time to round up the "business necessary" databases
    and delete all the others.

    I would simply like to write an application that runs as a service and
    checks the path where the file is being created. If the path is any
    other than a local path, inform the user he/she may not deploy
    a database on the network.

  4. #4
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    Posts
    531

    Re: Wrong board?

    Originally posted by DougDbug
    Sorry, this isn't an answer... but this should probably be on the Windows Board.

    And, this may be impossible without "hacking" the operating system. The operating system does not want you or your program interfering with it's operation or the operation of other programs.
    What about if it is not in Windows, think about in Linux.
    [ Never code before desk work ]
    -------------------------------------:-->
    A man who fears Nothing is the man who Loves Nothing
    If you Love Nothing, what joy is there in your life.
    =------------------------------------------------------= - I may be wrong.

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Can you not put an ACL on the device or directory your legitimate db files are in and then grant access to the bona-fide developers?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I agree with adrian...this looks like more of a network privilage problem..If you did want to control the creation of files, you would probably need to intercept system services...and to do this you would need to write a driver to access the parts of windows that translate file system calls to the service calls that do all the work - tricky, version dependant & officially undocumented.

    Your better off having a chat with your network admin IMO

  7. #7
    Registered User
    Join Date
    Apr 2003
    Posts
    3
    Zahid:

    I have never used unix so I wouldn't even know where to begin.
    All our desktops are running Win2k Pro and will be upgraded to
    WinXP soon. I'm not too concerned with writing for Unix since
    this would be a local service rather than a "server side" service...
    which our servers are in fact Unix based servers...

    Adrian:

    Yes, that would work however they want to prevent .mdb deployment
    across the entire network, not just one specific folder. The company
    has offices in 4 states and they want to prevent users in Florida
    from deploying databases on the servers in New York, etc...

    They attempted to do this with the Virus software we had which
    worked (for the most part) however the users were not only
    blocked from deploying... they couldn't open any databases with
    any Macros in them without the Virus scanner "freaking" out.

    They also tried using another mechanism (not sure what) to grant
    read / execute permissions to the users however this became an
    issue because it would not allow the .ldb file to be created when
    the database was opened due to the lack of write permissions...

    Fordy:

    My network admin actually approached me on this one. He
    mentioned that the company was looking into a software
    package which will do this. He had asked if I could look into the
    possibility of writing our own to avoid the licensing costs...

    But, I don't know how to write the kind of driver you're talking
    about and honestly wouldn't want to attempt it.



    Thanks everyone for your replies though. I guess the company
    will have to dish out the cash...
    Last edited by xeno; 05-06-2003 at 02:37 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 03:28 PM