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 8329291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:43:51+00:00 2026-06-09T01:43:51+00:00

The following code yields the runtime error: Unhandled exception at 0x773315de in Window File

  • 0

The following code yields the runtime error:

Unhandled exception at 0x773315de in Window File Search.exe: 0xC0000005: Access violation.

I don’t have any idea what has caused it. Could you point out my mistake?

Here is the function that probably contain the culprit:

int fileSearcher::findFilesRecursivelly(const TCHAR* curDir,const TCHAR* fileName,bool caseSensitive,TCHAR* output)
{
    HANDLE hFoundFile;
    WIN32_FIND_DATA foundFileData;

    TCHAR nextDirBuffer[MAX_PATH]=TEXT("");

    SetCurrentDirectory(curDir);
    //Fetch inside current directory
    hFoundFile = FindFirstFileEx(fileName,FINDEX_INFO_LEVELS::FindExInfoBasic,&foundFileData ,FINDEX_SEARCH_OPS::FindExSearchNameMatch ,NULL , FIND_FIRST_EX_LARGE_FETCH);

    if(hFoundFile != INVALID_HANDLE_VALUE)
    {       
        do
        {
            nothingFound = false;

            wcscat(output,curDir);
            wcscat(output,TEXT("\\"));
            wcscat(output,foundFileData.cFileName);
            wcscat(output,TEXT("\n"));
        }   
        while(FindNextFile(hFoundFile,&foundFileData));
    }

    //Go to the subdirs
    hFoundFile = FindFirstFileEx(TEXT("*"),FINDEX_INFO_LEVELS::FindExInfoBasic,&foundFileData ,FINDEX_SEARCH_OPS::FindExSearchLimitToDirectories ,NULL , FIND_FIRST_EX_LARGE_FETCH); //This line of code was on the call stack

    if(hFoundFile != INVALID_HANDLE_VALUE)
    {
        do
        {
            wcscat(nextDirBuffer,curDir);
            wcscat(nextDirBuffer,TEXT("\\"));
            wcscat(nextDirBuffer,foundFileData.cFileName);
            findFilesRecursivelly(nextDirBuffer,fileName,caseSensitive,outputBuffer);
        }
        while(FindNextFile(hFoundFile,&foundFileData));
    } 

    return 0;

}

Less important code:

File Search.h

#ifndef UNICODE
#define UNICODE
#endif

#include <Windows.h>

namespace fileSearch
{
class fileSearcher
{
public: 
    fileSearcher();

    void getAllPaths(const TCHAR* fileName,bool caseSensitive,TCHAR* output);   
    /*Returns all matching pathes at the current local system. Format:
    [A-Z]:\[FirstPath\foo1...\fileName]
    [A-Z]:\[SecondPath\foo2...\fileName]
    [A-Z]:\[ThirdPath\foo3...\fileName]
    ...
    [A-Z]:\[FourthPath\foo4...\fileName]
    Also an asterisk sign is supported, as in regular expressions.

    This functions uses WinApi methods.
    */

    int findFilesRecursivelly(const TCHAR* curDir,const TCHAR* fileName,bool caseSensitive,TCHAR* output);
    //Searches for the file in the current and in sub directories. NOT IN PARENT!!!!!!!!!!!!!!!!!!!!! Returns true if the file is found.

private:
    static const int MAX_NUMBER_OF_FILES = 100;
    static const int MAX_OUTPUT_SIZE = 2000;

    bool nothingFound;

    TCHAR outputBuffer[MAX_OUTPUT_SIZE];
};
}

… and rest of FileSeach.cpp

#ifndef UNICODE
#define UNICODE
#endif

#include "File Search.h"

using namespace fileSearch;

fileSearcher::fileSearcher()
{
    nothingFound = true;
}

void fileSearcher::getAllPaths(const TCHAR* fileName,bool caseSensitive, TCHAR* output)
{
    TCHAR localDrives[50];
    TCHAR currentDrive;
    int voluminesChecked=0;

    TCHAR searchedVolumine[5];


    GetLogicalDriveStrings(sizeof(localDrives)/sizeof(TCHAR),localDrives);

    //For all drives:
    for(int i=0; i < sizeof(localDrives)/sizeof(TCHAR); i++)
    {       
            if(localDrives[i] >= 65 && localDrives[i] <= 90)
            {   
                currentDrive = localDrives[i];
                voluminesChecked++;
            }
            else continue;



    searchedVolumine[0] = currentDrive;
    searchedVolumine[1] = L':';
    searchedVolumine[2] = 0;



    outputBuffer[0]=0;
    findFilesRecursivelly(searchedVolumine,fileName,caseSensitive,outputBuffer);

    (nothingFound) ? wcscpy(output,L"File not found") : wcscpy(output,outputBuffer);

    }

}

EDIT

The value of curDir after some iterations is –

 +        curDir  0x003df234 "C:\.\$Recycle.Bin\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\."  const wchar_t *

but I don’t know why.

  • 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-06-09T01:43:53+00:00Added an answer on June 9, 2026 at 1:43 am

    Every non-root directory contains both itself (“.”) and its parent (“..”). You need to explicitly exclude those from the recursive search:

    if (wcscmp(foundFileData.cFileName, L".") != 0 
         && wcscmp(foundFileData.cFileName, L"..") != 0) 
    {
      wcscat(nextDirBuffer,curDir);
      wcscat(nextDirBuffer,TEXT("\\"));
      wcscat(nextDirBuffer,foundFileData.cFileName);
      findFilesRecursivelly(nextDirBuffer,fileName,caseSensitive,outputBuffer);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code yields an error error: ‘struct Foo’ is not a valid type
Since a short time my rails applications yields the following runtime error in the
The execution of the following code yields error :No overloads of ProcessPerson Matches ThreadStart.
The following code $t = 1 – (1 - 2); yields: Parse error: syntax
I'm trying to execute the following query but I receive a runtime error stating
Running the following C# code through NUnit yields Test.ControllerTest.TestSanity: Expected: `<System.DivideByZeroException>` But was: null
Following example code from the libpcap documentation yields the following code which should report
I have the following code which throws an exception (detail in code comments below).
The following code yields 15 for the offsetHeight in IE and Chrome, and in
The following code: class ApplicationController < ActionController::Base protect_from_forgery if user_signed_in? end end yields this

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.