Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4123272
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:35:25+00:00 2026-05-20T23:35:25+00:00

I have been thinking to implement the following program, just out of curiosity and

  • 0

I have been thinking to implement the following program, just out of curiosity and learning experience. I want to write a program for password protecting a folder, so you can only open the folder after entering the correct password. I know this is specific to the operation system, so let it be Windows. I guess this is only possible in C++, but if it is also possible in plain C# or Java(which I doubt), then please tell me.

Could someone point me in the right direction? Thanks in advance!

Best regards, Petar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:35:26+00:00Added an answer on May 20, 2026 at 11:35 pm

    If you want a bulletproof protection of your files, then just protecting access to the folder is not enough, you’d have to encrypt them and there’re secure containers and file system encyptions on the market.

    If it does not need to be high security, you can hook into Windows I guess. You’ll especially need to hook into the directory listing functions, like FindFirstFile, FindNextFile and OpenFile also probably (and into their derivates like FindFirstFileW) and maybe some others.

    You do that by redirecting calls to kernel32.dll to your custom functions, see a little code example below which I found on the internet:

        unsigned char Store[10];
        //redirect FindNextFileW to your custom function
        void HookAPI()
        {
            DWORD OldProtect, NewProtect = PAGE_EXECUTE_READWRITE;
            HMODULE hmod = GetModuleHandle("Kernel32.dll");
            long pa = (long)GetProcAddress(hmod,"FindNextFileW");
            long pa2 = (long)MyFindNextFile;
            long dAddr = pa2 - pa - 5;
            unsigned char *p = (unsigned char *)pa;
            unsigned char *p2 = (unsigned char *)(&dAddr);
    
            VirtualProtect((void *)pa,5,NewProtect,&OldProtect);
    
            for (int i=0;i<5;i++)
                Store[i] = p[i];
    
            p[0] = (unsigned char)0xE9;
            for (int i=0;i<4;i++)
                p[i + 1] = p2[i];
    
            VirtualProtect((void *)pa,5,OldProtect,&NewProtect);
        }
    
        void UnHookAPI()
        {
            DWORD OldProtect, NewProtect = PAGE_EXECUTE_READWRITE;
            HMODULE hmod = GetModuleHandle("Kernel32.dll");
            long pa = (long)GetProcAddress(hmod,"FindNextFileW");
            unsigned char *p = (unsigned char *)pa;
    
            VirtualProtect((void *)pa,5,NewProtect,&OldProtect);
    
            for (int i=0;i<5;i++)
                p[i] = Store[i];
    
            VirtualProtect((void *)pa,5,OldProtect,&NewProtect);
        }
    
        BOOL WINAPI MyFindNextFile(HANDLE hFindFile,LPWIN32_FIND_DATAW lpFindFileData)
        {
            UnHookAPI();
            BOOL ans = FindNextFileW(hFindFile, lpFindFileData);
    
            //your logic here, display password prompt to user e.g.
    
            HookAPI();
            return ans;
        }
    

    What you want to do can also be done with Java (JNI) or C# (pinvoke), but it’d be a real detour. I’d use something which can be compiled to native code.

    Edit:
    Aoi Karasu provided a link to a post which suggests to use a FileSystemFilterDriver, which is probably the best concept to realize the application in question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been thinking about a way solve a problem I have and I'm
I have been thinking of a way to export data from SQL to Excel.
I have been thinking of starting a site of my own for long time.
I have been thinking about the optimal way to create an XML file using
I have been thinking about a neat way of load balancing and one thing
I am looking for some input on something I have been thinking about for
I'm working on a toy game engine. I have never been thinking about coordinate
Here's something I've been thinking about: suppose you have a number, x, that can
I've been thinking about using shared pointers, and I know how to implement one
I have been reading a lot about test-driven development and decided that I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.