Skip to content

Commit

Permalink
Merge branch 'Hell'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hell committed Apr 15, 2018
2 parents fe6648a + ffec3d8 commit d14c312
Show file tree
Hide file tree
Showing 11 changed files with 497 additions and 87 deletions.
4 changes: 0 additions & 4 deletions 驱动工具/ControlWorkerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ wxThread::ExitCode CControlWorkerThread::Entry()
case INSTALL:
if (sc.InstallService() != TRUE)
{
//strNotify.Format(wxT("错误代码:%lu,%s"), sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
swprintf_s(buff, L"错误代码:%lu,%s", sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
strNotify = buff;
}
Expand All @@ -43,7 +42,6 @@ wxThread::ExitCode CControlWorkerThread::Entry()
case START:
if (sc.RunService() != TRUE)
{
//strNotify.Format(wxT("错误代码:%lu,%s"), sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
swprintf_s(buff, L"错误代码:%lu,%s", sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
strNotify = buff;
}
Expand All @@ -56,7 +54,6 @@ wxThread::ExitCode CControlWorkerThread::Entry()
case STOP:
if (sc.StopService() != TRUE)
{
//strNotify.Format(wxT("错误代码:%lu,%s"), sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
swprintf_s(buff, L"错误代码:%lu,%s", sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
strNotify = buff;
}
Expand All @@ -69,7 +66,6 @@ wxThread::ExitCode CControlWorkerThread::Entry()
case UNINSTALL:
if (sc.UnInstallService() != TRUE)
{
//strNotify.Format(wxT("错误代码:%lu,%s"), sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
swprintf_s(buff, L"错误代码:%lu,%s", sc.GetErrorCode(), sc.GetErrorStr(sc.GetErrorCode()));
strNotify = buff;
}
Expand Down
91 changes: 22 additions & 69 deletions 驱动工具/DriverToolFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ wxBEGIN_EVENT_TABLE(CDriverToolFrame, wxFrame)
EVT_BUTTON(ID_BTN_UNINSTALL, CDriverToolFrame::OnUnInstall)
EVT_THREAD(THREAD_SERVER_CONTROL_COMPLETE, CDriverToolFrame::OnServiceControlComplete)
EVT_CHECKBOX(ID_CHK_WINDOWTOP, CDriverToolFrame::OnWindowTop)
//EVT_BUTTON(ID_BTN_MORE, CDriverToolFrame::OnShowExtendFrame)
EVT_DROP_FILES(CDriverToolFrame::OnDropFile)
//EVT_MOVE(OnWindowMove)
EVT_COLLAPSIBLEPANE_CHANGED(ID_COLLAPSIBLEPANE, OnCollapsiblePaneExpand)

//ExtPandFirst
Expand Down Expand Up @@ -83,6 +81,7 @@ wxBEGIN_EVENT_TABLE(CDriverToolFrame, wxFrame)

//Second Panel
EVT_TEXT(ID_EDTSHOWIOCTL, OnIoctlCodeChange)
EVT_TEXT(ID_EDTSHOWMNEMONIC, OnIoctlMnemonicChange)
EVT_SPIN(ID_SPIL_DEVICETYPE, OnSpinClick)
EVT_SPIN(ID_SPIL_FUNCTION, OnSpinClick)
EVT_SPIN(ID_SPIL_METHOD, OnSpinClick)
Expand All @@ -99,7 +98,7 @@ std::map<wxString, wxString> g_GUIDMap;
SetIcon(wxICON(icon));
CreateStatusBar();
SetStatusText(wxT("欢迎使用"));
//m_pPanel = new wxPanel(this, wxID_ANY);

this->SetBackgroundColour(wxColor(255, 255, 255));
this->DragAcceptFiles(true);

Expand Down Expand Up @@ -154,11 +153,7 @@ std::map<wxString, wxString> g_GUIDMap;

m_pOtherBoxSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("进度条"));

//m_pBtnMore = new wxButton(this, ID_BTN_MORE, wxT("更多"));
//m_pOtherBoxSizer->Add(m_pBtnMore, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);

m_pGauge = new wxGauge(this, ID_GAUGE, 100);
//m_pGauge->Pulse();
m_pOtherBoxSizer->Add(m_pGauge, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5);

//Extend Panel
Expand All @@ -171,9 +166,6 @@ std::map<wxString, wxString> g_GUIDMap;

InitCollapsiblePane();

//m_pExtendFrame = new CExtendedFrame(this, ID_EXTEND_FRAME, wxT("更多"));
//m_pExtendFrame->Show(false);

this->SetSizer(m_pMainBoxSizer);
m_pMainBoxSizer->SetMinSize(wxSize(600, 300));
m_pMainBoxSizer->SetSizeHints(this);
Expand Down Expand Up @@ -201,12 +193,6 @@ void CDriverToolFrame::OnSelectFile(wxCommandEvent & event)

wxString szPath = fileDialog.GetPath();
m_pEdtDriverPath->SetLabelText(szPath);

//CServiceControl sc;

//wxWidgets 没办法自由发消息,因此全部改为异步调用
//m_pExtendFrame->SetServiceName(wxString(sc.FindServiceName(szPath.c_str())));
//m_pExtendFrame->CallAfter(&CExtendedFrame::OnUpdateInfo);
} while (0);
}

Expand Down Expand Up @@ -477,23 +463,9 @@ void CDriverToolFrame::OnFilterDriverNotify(wxCommandEvent & event)
{
szItem = p;
serviceArray.Add(szItem);
/*
if (!_tcsicmp(m_szServiceName.c_str(), p))
{
bFind = true;
break;
}
*/
p += szItem.Length() + 1;
}

/*
if (bFind == false)
{
//没找到,本来就没有
break;
}
*/
auto iter = serviceArray.begin();
for (; iter != serviceArray.end();)
{
Expand All @@ -519,20 +491,7 @@ void CDriverToolFrame::OnFilterDriverNotify(wxCommandEvent & event)
p += 1;
length += 1;
}
//memcpy(p, p + _tcslen(p) + 1, dwRetSize - (p + _tcslen(p) + 1 - szDriverList));
/*
p = szDriverList;
while (*p != 0)
{
if (!_tcsicmp(m_szServiceName.c_str(), p))
{
bFind = true;
break;
}

p += _tcslen(p) + 1;
}
*/
ulRet = RegSetValueEx(hMainKey, TEXT("UpperFilters"), 0, REG_MULTI_SZ, (CONST BYTE*)szDriverList, length * sizeof(TCHAR));
if (ulRet != ERROR_SUCCESS)
{
Expand All @@ -559,21 +518,6 @@ void CDriverToolFrame::OnFilterDriverNotify(wxCommandEvent & event)
}
}

/*
void CDriverToolFrame::OnShowExtendFrame(wxCommandEvent & event)
{
wxRect rect = this->GetRect();
wxPoint point;
point.x = rect.GetRight();
point.y = rect.GetTop();
m_pExtendFrame->Move(point);
m_pExtendFrame->Show(true);
m_pExtendFrame->CallAfter(&CExtendedFrame::OnUpdateInfo);
}
*/

void CDriverToolFrame::DisableAllButton()
{
if (m_pBtnInstall != NULL)
Expand Down Expand Up @@ -642,9 +586,6 @@ void CDriverToolFrame::OnDropFile(wxDropFilesEvent & event)
if (event.GetNumberOfFiles() > 0)
{
m_pEdtDriverPath->SetLabelText(event.GetFiles()[0]);
//CServiceControl sc;
//m_pExtendFrame->SetServiceName(wxString(sc.FindServiceName(event.GetFiles()[0].c_str())));
//m_pExtendFrame->CallAfter(&CExtendedFrame::OnUpdateInfo);
}


Expand Down Expand Up @@ -759,6 +700,19 @@ void CDriverToolFrame::OnIoctlCodeChange(wxCommandEvent & event)
UpdateIoctlInfo(ioctlInfo);
}

void CDriverToolFrame::OnIoctlMnemonicChange(wxCommandEvent & event)
{
static wxString strLastData = wxT("");
wxString strtemp;
strtemp = m_pEdtMnemonic->GetValue();
if (strLastData != strtemp)
{
strLastData = strtemp;
m_pIoctlControl->MnemonicSet(strtemp);
}

}

void CDriverToolFrame::OnSpinClick(wxSpinEvent & event)
{
wxObject* pObject = event.GetEventObject();
Expand Down Expand Up @@ -861,7 +815,6 @@ void CDriverToolFrame::InitCollapsiblePane()
m_vecSizerPointArray.push_back(pSizer);

m_pStaticIoctlNumber = new wxStaticText(m_pExtSecondPanel, wxID_ANY, wxT("Ioctl Code:"));
//m_pStaticIoctlNumber->SetMinSize(wxSize(50, 0));
pSizer->Add(m_pStaticIoctlNumber, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);

m_pEdtShowIoctlCode = new wxTextCtrl(m_pExtSecondPanel, ID_EDTSHOWIOCTL);
Expand Down Expand Up @@ -916,7 +869,8 @@ void CDriverToolFrame::InitCollapsiblePane()
m_pSpinFunction->SetRange(0, 0xFFF);
m_pFlexGridSizer->Add(m_pSpinFunction, wxSizerFlags(0).CenterVertical());

//


m_vecSizerPointArray.push_back(pSizer);

m_pStaticMethod = new wxStaticText(m_pExtSecondPanel, wxID_ANY, wxT("Method:"));
Expand All @@ -929,9 +883,6 @@ void CDriverToolFrame::InitCollapsiblePane()
m_pSpinMethod->SetRange(0, 3);
m_pFlexGridSizer->Add(m_pSpinMethod, wxSizerFlags().CenterVertical());

//m_pIoctlSetailsSizer->Add(m_pFlexGridSizer, 1, wxALIGN_CENTRE_VERTICAL | wxALL, 2);
//m_pIoctlSetailsSizer->Add(pSizer, 0, wxGROW | wxALL, 0);

//
m_pStaticAccess = new wxStaticText(m_pExtSecondPanel, wxID_ANY, wxT("Access:"));
m_pFlexGridSizer->Add(m_pStaticAccess, wxSizerFlags().CenterVertical());
Expand All @@ -945,6 +896,7 @@ void CDriverToolFrame::InitCollapsiblePane()

m_pIoctlSetailsSizer->Add(m_pFlexGridSizer, 0, wxGROW | wxALL, 0);
m_pExtBoxSize2->Add(m_pIoctlSetailsSizer, 0, wxGROW | wxALL, 5);

//Layout
m_pIoctlLayout = new wxStaticBoxSizer(wxVERTICAL, m_pExtSecondPanel, wxT("I/O Control Code Layout"));

Expand All @@ -962,7 +914,8 @@ void CDriverToolFrame::InitCollapsiblePane()

//初始化Ioctl助记符
m_pIoctlControl = new CIoctlEdtControl(m_pEdtShowIoctlCode, m_pEdtMnemonic, m_pEdtDeviceType, m_pEdtFunction, m_pEdtMethod, m_pEdtAccess, m_pEdtIoctlLayout);
//m_pEdtShowIoctlCode->SetLabelText(wxT("000B0000"));
m_pEdtShowIoctlCode->SetLabelText(wxT("000B0000"));

wxString strTemp;
strTemp = wxString::Format(wxT("Recognizes %lu mnemonics"), m_pIoctlControl->GetMnemonicNumber());
m_pStaticNumberOfIoctl->SetLabelText(strTemp);
Expand Down Expand Up @@ -1079,8 +1032,8 @@ void CDriverToolFrame::UpdateDriverInfo()
auto iter = g_GUIDMap.cbegin();
for (int index = 0; iter != g_GUIDMap.cend(); ++iter, ++index)
{
keyPath = TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\") + iter->second;//{ca3e7ab9-b4c3-4ae6-8251-579ef933890f}
//keyPath = TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\{ca3e7ab9-b4c3-4ae6-8251-579ef933890f}");
keyPath = TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\") + iter->second;

ulRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyPath.c_str(), 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hMainKey);
if (ulRet != ERROR_SUCCESS)
{
Expand Down
5 changes: 2 additions & 3 deletions 驱动工具/DriverToolFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ enum
ID_BTN_MORE,
ID_GAUGE,
ID_EXTEND_FRAME,
//CollapsiblePane
ID_COLLAPSIBLEPANE,
ID_NOTEBOOK,
ID_RADIOBOX_PAGE1,
ID_RADIOBEGIN,
ID_RADIOEND = ID_RADIOBEGIN + 50,
ID_EDTSHOWIOCTL,
ID_EDTSHOWMNEMONIC,//m_pEdtMnemonic
ID_EDTSHOWMNEMONIC,
ID_SPIL_DEVICETYPE,
ID_SPIL_FUNCTION,
ID_SPIL_METHOD,
Expand Down Expand Up @@ -154,7 +153,6 @@ class CDriverToolFrame :
void OnUnInstall(wxCommandEvent &event);
void OnWindowTop(wxCommandEvent &event);
void OnWindowMove(wxMoveEvent &event);
//void OnShowExtendFrame(wxCommandEvent &event);
void OnStartChange(wxCommandEvent & event);
void OnFilterDriverNotify(wxCommandEvent & event);

Expand All @@ -165,6 +163,7 @@ class CDriverToolFrame :
void OnCollapsiblePaneExpand(wxCollapsiblePaneEvent& event);

void OnIoctlCodeChange(wxCommandEvent& event);
void OnIoctlMnemonicChange(wxCommandEvent& event);
void OnSpinClick(wxSpinEvent& event);
private:
void InitCollapsiblePane();
Expand Down
39 changes: 39 additions & 0 deletions 驱动工具/HidDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once
//
// Macro for defining HID ioctls
//
#define HID_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_NEITHER, FILE_ANY_ACCESS)
#define HID_BUFFER_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HID_IN_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define HID_OUT_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_OUT_DIRECT, FILE_ANY_ACCESS)

#define HID_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_NEITHER, FILE_ANY_ACCESS)
#define HID_BUFFER_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HID_IN_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define HID_OUT_CTL_CODE(id) CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_HID_GET_DRIVER_CONFIG HID_BUFFER_CTL_CODE(100)
#define IOCTL_HID_SET_DRIVER_CONFIG HID_BUFFER_CTL_CODE(101)
#define IOCTL_HID_GET_POLL_FREQUENCY_MSEC HID_BUFFER_CTL_CODE(102)
#define IOCTL_HID_SET_POLL_FREQUENCY_MSEC HID_BUFFER_CTL_CODE(103)
#define IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS HID_BUFFER_CTL_CODE(104)
#define IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS HID_BUFFER_CTL_CODE(105)
#define IOCTL_HID_GET_COLLECTION_INFORMATION HID_BUFFER_CTL_CODE(106)
#define IOCTL_HID_ENABLE_WAKE_ON_SX HID_BUFFER_CTL_CODE(107)
#define IOCTL_HID_SET_S0_IDLE_TIMEOUT HID_BUFFER_CTL_CODE(108)
#define IOCTL_HID_GET_COLLECTION_DESCRIPTOR HID_CTL_CODE(100)
#define IOCTL_HID_FLUSH_QUEUE HID_CTL_CODE(101)
#define IOCTL_HID_SET_FEATURE HID_IN_CTL_CODE(100)
#define IOCTL_HID_SET_OUTPUT_REPORT HID_IN_CTL_CODE(101)
#define IOCTL_HID_GET_FEATURE HID_OUT_CTL_CODE(100)
#define IOCTL_GET_PHYSICAL_DESCRIPTOR HID_OUT_CTL_CODE(102)
#define IOCTL_HID_GET_HARDWARE_ID HID_OUT_CTL_CODE(103)
#define IOCTL_HID_GET_INPUT_REPORT HID_OUT_CTL_CODE(104)
#define IOCTL_HID_GET_OUTPUT_REPORT HID_OUT_CTL_CODE(105)
#define IOCTL_HID_GET_MANUFACTURER_STRING HID_OUT_CTL_CODE(110)
#define IOCTL_HID_GET_PRODUCT_STRING HID_OUT_CTL_CODE(111)
#define IOCTL_HID_GET_SERIALNUMBER_STRING HID_OUT_CTL_CODE(112)
#define IOCTL_HID_GET_INDEXED_STRING HID_OUT_CTL_CODE(120)
#define IOCTL_HID_GET_MS_GENRE_DESCRIPTOR HID_OUT_CTL_CODE(121)
#define IOCTL_HID_ENABLE_SECURE_READ HID_CTL_CODE(130)
#define IOCTL_HID_DISABLE_SECURE_READ HID_CTL_CODE(131)
#define IOCTL_HID_DEVICERESET_NOTIFICATION HID_CTL_CODE(140)
Loading

0 comments on commit d14c312

Please sign in to comment.