#include <stdio.h>

#include <Windows.h>

#include <locale.h>

#include <tchar.h>

#include <atlstr.h>


int Folder_access(CString p);

int Make_file(CString path);


int main()

{

   CString root(_T("C:\\virustest\\"));

   Folder_access(root);

   return 0;

}


int Folder_access(CString p)

{

   WIN32_FIND_DATA finddata;

   HANDLE hfind;

   CString wild(_T("\\*"));


   _wsetlocale(LC_ALL, _T("korean"));


   if (PathIsDirectoryEmpty(p))

   {

      Make_file(p+"\\");

      printf("empty\n");

      return 0;

   }

   else

   {

      hfind = FindFirstFile(p + wild, &finddata);


      do

      {

         if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)

         {

            CString d(finddata.cFileName);

            if (d != _T(".") && d != _T(".."))

            {


               Make_file(p + '\\');

               Folder_access(p + '\\' + d);

               _tprintf(_T("%s\n"), finddata.cFileName);

            }

         }

      } while (FindNextFile(hfind, &finddata));


   }


   FindClose(hfind);


   return 0;

}


int Make_file(CString path)

{

   FILE *f;


   CString name(_T("hack.txt"));

   path += name;

   const char *str;

   str = (CStringA)path;


   fopen_s(&f, str, "w");

   fprintf(f, "hello!");

   fclose(f);


   return 0;

}

'Windows 개발' 카테고리의 다른 글

dll 분석  (0) 2014.09.21
(WinAPI) 문자열 함수(멀티바이트->유니코드->TCHAR)  (0) 2014.08.09
파일 처리 함수들  (0) 2013.10.28
Thread 비교, 사용법  (0) 2013.10.27
Windows7 SSDT Hooking  (0) 2013.08.23
Posted by wakira
,