Skip to content

Commit

Permalink
폴더 경로를 받아 리스트에 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
GIL committed Sep 19, 2018
1 parent 0783985 commit 36a1451
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 10 deletions.
53 changes: 47 additions & 6 deletions GilRanClient/GilRanClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
#include <fltuser.h>
#include <dontuse.h>
#include <suppress.h>

#include <list>
#include <iomanip>
#include <iostream>
#include <string>
#include <future>
#include <thread>

#include "../Common/Common.h"
#include "Utils.h"

#define CLIENT_DEFAULT_REQUEST_COUNT 4
#define CLIENT_DEFAULT_THREAD_COUNT 4
Expand All @@ -14,6 +20,7 @@
typedef struct _THREAD_CONTEXT {
HANDLE hCommunicationPort;
HANDLE hIoCompletionPort;
std::list<PWCHAR> arrFolderPath;
} THREAD_CONTEXT, *PTHREAD_CONTEXT;

typedef struct _FILTER_MESSAGE {
Expand Down Expand Up @@ -49,8 +56,6 @@ DWORD ClientWorker(
break;
}

printf("\n\n------------------------------ \nPID: %p\nVolumeName: %ws\nFileName: %ws\n", pFilterMessage->Request.ProcessID, pFilterMessage->Request.VolumeName, pFilterMessage->Request.FilePath);

PORT_RESPONSE Response;
Response.Header.Status = 0;
Response.Header.MessageId = pFilterMessage->Header.MessageId;
Expand Down Expand Up @@ -86,7 +91,8 @@ int _cdecl main(
{
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);


THREAD_CONTEXT ThreadContext;
HANDLE hCommunicationPort;
HRESULT hResult = FilterConnectCommunicationPort(
PORT_NAME,
Expand All @@ -106,7 +112,6 @@ int _cdecl main(
CLIENT_DEFAULT_THREAD_COUNT
);

THREAD_CONTEXT ThreadContext;
ThreadContext.hCommunicationPort = hCommunicationPort;
ThreadContext.hIoCompletionPort = hIoCompletionPort;

Expand Down Expand Up @@ -159,10 +164,46 @@ int _cdecl main(
}
}
}
WaitForMultipleObjectsEx(loop, hThread, TRUE, INFINITE, FALSE);

int Command = TRUE;
while (Command) {
std::wcout << std::endl;
std::wcout << "================================================================================" << std::endl;
std::wcout << "| GilRan Ransomware Solution v0.1a |" << std::endl;
std::wcout << "================================================================================" << std::endl;
std::wcout << "| [1] DMZ Folder -- SHOW |" << std::endl;
std::wcout << "| [2] DMZ Folder -- ADD |" << std::endl;
std::wcout << "| [0] Exit |" << std::endl;
std::wcout << "================================================================================" << std::endl;
std::wcout << "Select: ";

std::cin >> Command;
if (!std::cin) {
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
Command = TRUE;
}

switch (Command) {
case 1:
for (auto FolderPath : ThreadContext.arrFolderPath) {
std::wcout << FolderPath << std::endl;
}
break;
case 2:
PWCHAR Path = new WCHAR[MAX_PATH];

std::wcout << L"Input folder path to make DMZ Folder" << std::endl;
std::wcout << L">";
std::wcin >> Path;

ThreadContext.arrFolderPath.push_back(Path);
break;
}
}

CloseHandle(hCommunicationPort);
CloseHandle(hIoCompletionPort);

return S_OK;
}
10 changes: 6 additions & 4 deletions GilRanClient/GilRanClient.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="GilRanClient.cpp" />
<ClCompile Include="Utils.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Common\Common.h" />
<ClInclude Include="Utils.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{AC5C0863-C3F8-4628-94E2-4F009FB92427}</ProjectGuid>
Expand Down Expand Up @@ -127,15 +129,15 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WINAPI_PARTITION_DESKTOP=1;WINAPI_PARTITION_SYSTEM=1;WINAPI_PARTITION_APP=1;WINAPI_PARTITION_PC_APP=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -144,15 +146,15 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WINAPI_PARTITION_DESKTOP=1;WINAPI_PARTITION_SYSTEM=1;WINAPI_PARTITION_APP=1;WINAPI_PARTITION_PC_APP=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
Expand Down
6 changes: 6 additions & 0 deletions GilRanClient/GilRanClient.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
<ClCompile Include="GilRanClient.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Common\Common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
60 changes: 60 additions & 0 deletions GilRanClient/Utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// TODO: Dialog로 폴더 경로 받으려 했으나, Dialog를 열면 모든 Thread가 정지돼 실패. (SHBrowseFolder, IFileDialog)
// TODK: 문제를 해결지 못하면 문자열로 경로를 받고 실제 폴더가 있는지 확인한후 등록.
/*
#include <windows.h>
#include <shobjidl.h>
#include <shlobj_core.h>
#include <iostream>
#include "Utils.h"
PWCHAR GetFolderPath() {
IFileDialog *pIFileDialog = NULL;
CoInitialize(NULL);
CoCreateInstance(
CLSID_FileOpenDialog,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pIFileDialog)
);
if (!pIFileDialog) NULL;
pIFileDialog->SetOptions(
FOS_NOCHANGEDIR | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM |
FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_DONTADDTORECENT
);
pIFileDialog->SetTitle(
L"DMZ Folder"
);
HRESULT hResult = pIFileDialog->Show(NULL);
if (SUCCEEDED(hResult)) {
IShellItem* pIShellItem = NULL;
if (SUCCEEDED(pIFileDialog->GetResult(&pIShellItem))) {
PIDLIST_ABSOLUTE pIDListAbsolute = NULL;
SHGetIDListFromObject(pIShellItem, &pIDListAbsolute);
pIShellItem->Release();
pIFileDialog->Release();
CoUninitialize();
PWCHAR Path = new WCHAR[MAX_PATH];
if (SHGetPathFromIDList(pIDListAbsolute, Path)) {
return Path;
}
delete Path;
}
}
CoUninitialize();
pIFileDialog->Release();
return NULL;
}
*/
4 changes: 4 additions & 0 deletions GilRanClient/Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
#pragma once
PWCHAR GetFolderPath();
*/

0 comments on commit 36a1451

Please sign in to comment.