Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated service.cpp for protected ImagePath #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion apps/freelan/src/windows/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "../tools.hpp"
#include "../system.hpp"
#include "../configuration_helper.hpp"
#include <tchar.h>

namespace fs = boost::filesystem;
namespace fl = freelan;
Expand Down Expand Up @@ -237,7 +238,16 @@ namespace windows
{
SCManager service_control_manager(SC_MANAGER_CREATE_SERVICE);

TCHAR total[_MAX_PATH + 3]; //on cree le buffer
TCHAR quote[3] =_T ("\""); //on cree la quote, taille 3 pour 2 chars pour \ et " plus termination

_tcscpy(total, (const wchar_t*)quote); //on colle une quote dans le buffer vide

const fs::path path = get_module_filename();
_tcscat(total, (const TCHAR*)path.string<std::basic_string<TCHAR> >().c_str()); //on colle le path (cast) dans 'total'

_tcscat(total, (const wchar_t*)quote); //on colle une quote pour fermer, le path est protege


SC_HANDLE service = ::CreateService(
service_control_manager.handle(),
Expand All @@ -247,7 +257,8 @@ namespace windows
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
path.string<std::basic_string<TCHAR> >().c_str(),
/*path.string<std::basic_string<TCHAR> >().c_str(),*/ //remplace par total
total,
NULL,
NULL,
SERVICE_DEPENDENCIES,
Expand Down