Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / MFC

Driver to Hide Processes and Files

, ,
Rate me:
Please Sign up or sign in to vote.
4.57/5 (145 votes)
17 Aug 2009CPOL12 min read 654.7K   28.6K   369  
In this article, we describe the driver we created to hide processes and files in a system.
// InstallForm.cpp : implementation file
//

#include "stdafx.h"
#include "GUI.h"
#include "InstallForm.h"


// InstallForm

IMPLEMENT_DYNCREATE(InstallForm, CFormView)

BEGIN_MESSAGE_MAP(InstallForm, CFormView)
	ON_BN_CLICKED(IDC_BUT_PATH_SELECT, OnBnClickedButPathSelect)
	ON_BN_CLICKED(IDC_BUT_INST, OnBnClickedButInst)
	ON_BN_CLICKED(IDC_BUT_UNINST, OnBnClickedButUninst)
	ON_BN_CLICKED(IDC_BUT_RUN, OnBnClickedButRun)
	ON_BN_CLICKED(IDC_BUT_STOP, OnBnClickedButStop)
END_MESSAGE_MAP()

InstallForm::InstallForm()
	: CFormView(InstallForm::IDD)
{
}

InstallForm::~InstallForm()
{
}

void InstallForm::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
}

void InstallForm::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();

	SetDlgItemText(IDC_EDIT_PATH,_T("C:\\DriverDev\\HideDriver.sys"));
	SetDlgItemText(IDC_EDIT_NAME,_T("HideDriver"));
	SetDlgItemText(IDC_COMBO_TYPE,_T("SERVICE_DEMAND_START"));
}

// InstallForm message handlers
void InstallForm::OnBnClickedButPathSelect()
{
	CFileDialog fl_dlg(true);
	if(fl_dlg.DoModal() != IDOK )
		return;

	CString file_path=fl_dlg.GetPathName();

	SetDlgItemText(IDC_EDIT_PATH,file_path);
	SetDlgItemText(IDC_EDIT_NAME,_T(""));
}
// Driver installation
void InstallForm::OnBnClickedButInst()
{
	CString strName,strPath,strStartType;
	DWORD startType;
	// Get input parameters
	GetDlgItemText(IDC_EDIT_PATH,strPath);
	if(strPath.GetLength() == NULL)
	{
		AfxMessageBox(_T("Path is empty"));
		return;
	}
	GetDlgItemText(IDC_EDIT_NAME,strName);
	if(strName.GetLength() == NULL)
	{
		AfxMessageBox(_T("Name is empty"));
		return;
	}
	GetDlgItemText(IDC_COMBO_TYPE,strStartType);
	if(strStartType == _T("SERVICE_AUTO_START"))
		startType = SERVICE_AUTO_START;
	else if(strStartType == _T("SERVICE_BOOT_START"))
		startType = SERVICE_BOOT_START;
	else if(strStartType == _T("SERVICE_DEMAND_START"))
		startType = SERVICE_DEMAND_START;
	else if(strStartType == _T("SERVICE_DISABLED"))
		startType = SERVICE_DISABLED;
	else if(strStartType == _T("SERVICE_SYSTEM_START"))
		startType = SERVICE_SYSTEM_START;
	else
	{
		AfxMessageBox(_T("Wrong start type"));
		return;
	}

	// Try to install driver
	BOOL res = mDrvWork.Install(strName,strPath,startType);
	if(!res) // But they can be installed early
		SetDlgItemText(IDC_STATIC_STATUS,_T("Cannot install"));
	else
		SetDlgItemText(IDC_STATIC_STATUS,_T("Installed"));
}
void InstallForm::OnBnClickedButUninst()
{
	CString strName,strPath;
	// Get input parameters
	GetDlgItemText(IDC_EDIT_PATH,strPath);
	if(strPath.GetLength() == NULL)
	{
		AfxMessageBox(_T("Path is empty"));
		return;
	}
	GetDlgItemText(IDC_EDIT_NAME,strName);
	if(strName.GetLength() == NULL)
	{
		AfxMessageBox(_T("Name is empty"));
		return;
	}

	BOOL res = mDrvWork.Remove(strName,strPath);
	if(!res) 
		SetDlgItemText(IDC_STATIC_STATUS,_T("Cannot uninstall"));
	else
		SetDlgItemText(IDC_STATIC_STATUS,_T("Uninstaled"));
}

// Driver control
void InstallForm::OnBnClickedButRun()
{
	CString strName;
	// Get input parameters
	GetDlgItemText(IDC_EDIT_NAME,strName);
	if(strName.GetLength() == NULL)
	{
		AfxMessageBox(_T("Name is empty"));
		return;
	}

	BOOL res = mDrvWork.Start(strName);
	if(!res) 
		SetDlgItemText(IDC_STATIC_STATUS,_T("Cannot start"));
	else
		SetDlgItemText(IDC_STATIC_STATUS,_T("Started"));
}

void InstallForm::OnBnClickedButStop()
{	
	CString strName;
	// Get input parameters
	GetDlgItemText(IDC_EDIT_NAME,strName);
	if(strName.GetLength() == NULL)
	{
		AfxMessageBox(_T("Name is empty"));
		return;
	}

	BOOL res = mDrvWork.Stop(strName);
	if(!res) 
		SetDlgItemText(IDC_STATIC_STATUS,_T("Cannot stop"));
	else
		SetDlgItemText(IDC_STATIC_STATUS,_T("Stoped"));
}

// InstallForm diagnostics

#ifdef _DEBUG
void InstallForm::AssertValid() const
{
	CFormView::AssertValid();
}

void InstallForm::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Apriorit Inc.
United States United States
ApriorIT is a software research and development company specializing in cybersecurity and data management technology engineering. We work for a broad range of clients from Fortune 500 technology leaders to small innovative startups building unique solutions.

As Apriorit offers integrated research&development services for the software projects in such areas as endpoint security, network security, data security, embedded Systems, and virtualization, we have strong kernel and driver development skills, huge system programming expertise, and are reals fans of research projects.

Our specialty is reverse engineering, we apply it for security testing and security-related projects.

A separate department of Apriorit works on large-scale business SaaS solutions, handling tasks from business analysis, data architecture design, and web development to performance optimization and DevOps.

Official site: https://www.apriorit.com
Clutch profile: https://clutch.co/profile/apriorit
This is a Organisation

33 members

Written By
Software Developer Codedgers Inc
Ukraine Ukraine
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Software Developer (Junior) ApriorIT
Ukraine Ukraine
Sergey Popenko.
22 years old.
The Driver Team`s software developer.
Master of the Applied Math faculty, the Dnipropetrovsk National University, Ukraine.

Comments and Discussions