diff --git a/Register/RegisterManager/RegisterManager.sln b/Register/RegisterManager/RegisterManager.sln new file mode 100644 index 0000000..74adbfc --- /dev/null +++ b/Register/RegisterManager/RegisterManager.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegisterManager", "RegisterManager\RegisterManager.vcxproj", "{118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Debug|Win32.ActiveCfg = Debug|Win32 + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Debug|Win32.Build.0 = Debug|Win32 + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Debug|x64.ActiveCfg = Debug|x64 + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Debug|x64.Build.0 = Debug|x64 + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Release|Win32.ActiveCfg = Release|Win32 + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Release|Win32.Build.0 = Release|Win32 + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Release|x64.ActiveCfg = Release|x64 + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Register/RegisterManager/RegisterManager.suo b/Register/RegisterManager/RegisterManager.suo new file mode 100644 index 0000000..b7a4f01 Binary files /dev/null and b/Register/RegisterManager/RegisterManager.suo differ diff --git a/Register/RegisterManager/RegisterManager/KeyDlg.cpp b/Register/RegisterManager/RegisterManager/KeyDlg.cpp new file mode 100644 index 0000000..0ee46cf --- /dev/null +++ b/Register/RegisterManager/RegisterManager/KeyDlg.cpp @@ -0,0 +1,72 @@ +// KeyDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "RegisterManager.h" +#include "KeyDlg.h" +#include "afxdialogex.h" + + +// CKeyDlg Ի + +IMPLEMENT_DYNAMIC(CKeyDlg, CDialog) + +CKeyDlg::CKeyDlg(CWnd* pParent /*=NULL*/) + : CDialog(CKeyDlg::IDD, pParent) + , m_strKeyNameStatic(_T("")) + , m_strKeyNameEdit(_T("")) +{ + +} + +CKeyDlg::~CKeyDlg() +{ +} + +void CKeyDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Text(pDX, IDC_KEY_NAME, m_strKeyNameStatic); + DDX_Text(pDX, IDC_EDIT, m_strKeyNameEdit); +} + + +BEGIN_MESSAGE_MAP(CKeyDlg, CDialog) +END_MESSAGE_MAP() + + +// CKeyDlg Ϣ + + +BOOL CKeyDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + switch (m_nDlgType) + { + case enumRenameKey: + SetWindowText(L""); + m_strKeyNameStatic = L"¼"; + break; + + case enumRenameValue: + SetWindowText(L"ֵ"); + m_strKeyNameStatic = L"¼ֵ"; + break; + + case enumCreateKey: + SetWindowText(L"¼"); + m_strKeyNameStatic = L"¼"; + break; + + case enumSetValueKey: + SetWindowText(L"ֵ"); + m_strKeyNameStatic = L"¼ֵ"; + break; + } + + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} diff --git a/Register/RegisterManager/RegisterManager/KeyDlg.h b/Register/RegisterManager/RegisterManager/KeyDlg.h new file mode 100644 index 0000000..389113d --- /dev/null +++ b/Register/RegisterManager/RegisterManager/KeyDlg.h @@ -0,0 +1,36 @@ +#pragma once + + +// CKeyDlg Ի + + +typedef enum DLG_TYPE +{ + enumRenameKey, + enumCreateKey, + enumSetValueKey, + enumRenameValue, +}; +class CKeyDlg : public CDialog +{ + DECLARE_DYNAMIC(CKeyDlg) + +public: + CKeyDlg(CWnd* pParent = NULL); // ׼캯 + virtual ~CKeyDlg(); + + DLG_TYPE m_nDlgType; + + +// Ի + enum { IDD = IDD_KEY_DIALOG }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() +public: + CString m_strKeyNameStatic; + CString m_strKeyNameEdit; + virtual BOOL OnInitDialog(); +}; diff --git a/Register/RegisterManager/RegisterManager/ReadMe.txt b/Register/RegisterManager/RegisterManager/ReadMe.txt new file mode 100644 index 0000000..71228b8 --- /dev/null +++ b/Register/RegisterManager/RegisterManager/ReadMe.txt @@ -0,0 +1,77 @@ +================================================================================ +MICROSOFT : RegisterManager Ŀ +=============================================================================== + +ӦóΪ RegisterManager Ӧó򡣴Ӧó򲻽ʾ Microsoft Ļʹ÷ΪдӦó㡣 + +ļҪ RegisterManager Ӧóÿļݡ + +RegisterManager.vcxproj +ʹӦóɵ VC++ ĿĿļ +ɸļ Visual C++ İ汾ϢԼйʹӦóѡƽ̨úĿܵϢ + +RegisterManager.vcxproj.filters + ʹáӦó򵼡ɵ VC++ Ŀɸѡļ + йĿļɸѡ֮ĹϢ IDE УֹͨضڵԷʽʾչļ磬.cppļ롰Դļɸѡ + +RegisterManager.h +ӦóҪͷļĿضͷļ( Resource.h) CRegisterManagerApp Ӧóࡣ + +RegisterManager.cpp +ǰӦó CRegisterManagerApp ҪӦóԴļ + +RegisterManager.rc +dzʹõ Microsoft Windows Դб RES Ŀ¼д洢ͼꡢλͼ͹ꡣļֱ Microsoft Visual C++ нб༭ĿԴλ 2052 С + +res\RegisterManager.ico +ӦóͼͼļͼҪԴļ RegisterManager.rc С + +res\RegisterManager.rc2 +ļ Microsoft Visual C++ нб༭ԴӦýԴ༭༭ԴڴļС + + +///////////////////////////////////////////////////////////////////////////// + +Ӧó򵼴һԻ: + +RegisterManagerDlg.hRegisterManagerDlg.cpp - Ի +Щļ CRegisterManagerDlg ࡣඨӦóԻΪöԻģλ RegisterManager.rc Уļ Microsoft Visual C++ нб༭ + + +///////////////////////////////////////////////////////////////////////////// + +: + +ActiveX ؼ +Ӧóʹ ActiveX ؼ֧֡ + +ӡӡԤ֧ +Ӧóͨ MFC CView еijԱڴӡӡúʹӡԤĴ롣 + +///////////////////////////////////////////////////////////////////////////// + +׼ļ: + +StdAfx.hStdAfx.cpp +ЩļΪ RegisterManager.pch Ԥͷ (PCH) ļΪ StdAfx.obj Ԥļ + +Resource.h +DZ׼ͷļµԴ ID +Microsoft Visual C++ ȡ´ļ + +RegisterManager.manifest + Ӧó嵥ļ Windows XP Ӧó + ض汾г򼯵ԡسʹô + Ϣӳ򼯻ʵij򼯻 + Ӧó˽ϢӦó嵥Ϊ·ַΪ + Ӧóִļװͬļеⲿ .manifest ļ + ҲԴʽڸÿִļС +///////////////////////////////////////////////////////////////////////////// + +ע: + +ӦóʹáTODO:ָʾӦӻԶԴ벿֡ + +Ӧóڹ DLL ʹ MFCҪ·Щ MFC DLLӦóõϵͳĵǰòͬҪ·ӦıػԴ MFC100XXX.DLLйĸϢμ MSDN ĵй Redistributing Visual C++ applications (· Visual C++ Ӧó)½ڡ + +///////////////////////////////////////////////////////////////////////////// diff --git a/Register/RegisterManager/RegisterManager/RegFindDlg.cpp b/Register/RegisterManager/RegisterManager/RegFindDlg.cpp new file mode 100644 index 0000000..848881e --- /dev/null +++ b/Register/RegisterManager/RegisterManager/RegFindDlg.cpp @@ -0,0 +1,721 @@ +// RegFindDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "RegisterManager.h" +#include "RegFindDlg.h" +#include "afxdialogex.h" +#include "RegisterManagerDlg.h" + +// CRegFindDlg Ի + +IMPLEMENT_DYNAMIC(CRegFindDlg, CDialog) + +#define WM_SEARCH_FINISH WM_USER + 105 +#define WM_UPDATE_UI WM_USER + 106 + + +extern CWnd* g_Father; + +DWORD WINAPI SearchRegistryProc(PVOID lPParam) +{ + if (lPParam) + { + CRegFindDlg *Dlg = (CRegFindDlg*)lPParam; + Dlg->SearchRegistry(); + } + + return 0; +} + +CRegFindDlg::CRegFindDlg(CWnd* pParent /*=NULL*/) + : CDialog(CRegFindDlg::IDD, pParent) + , m_strSearchInKey(_T("")) + , m_nRadio(0) + , m_strFindWhat(_T("")) + , m_bKeys(TRUE) + , m_bMachCase(FALSE) + , m_bMachWholeString(FALSE) + , m_bData(TRUE) + , m_bValues(TRUE) + , m_strSearchResult(_T("")) +{ + m_strFindWhatUpper = L""; + m_nCnt = 0; + m_bStop = FALSE; + m_hThread = NULL; + +} + +CRegFindDlg::~CRegFindDlg() +{ +} + +void CRegFindDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_LIST, m_List); + DDX_Text(pDX, IDC_EDIT, m_strSearchInKey); + DDX_Radio(pDX, IDC_RADIO_SEARCH_IN, m_nRadio); + DDX_Text(pDX, IDC_EDIT_FIND_WHAT, m_strFindWhat); + DDX_Check(pDX, IDC_CHECK_KEY, m_bKeys); + DDX_Check(pDX, IDC_CHECK_MACH_CASE, m_bMachCase); + DDX_Check(pDX, IDC_CHECK_MACH_WHOLE_STRING, m_bMachWholeString); + DDX_Check(pDX, IDC_CHECK_DATA, m_bData); + DDX_Check(pDX, IDC_CHECK_VALUES, m_bValues); + DDX_Text(pDX, IDC_STATIC_FIND_RESULT, m_strSearchResult); + DDX_Control(pDX, IDC_ANIMATE, m_ctlAnimate); +} + + +BEGIN_MESSAGE_MAP(CRegFindDlg, CDialog) + + ON_BN_CLICKED(IDC_BUTTON_START, &CRegFindDlg::OnBnClickedButtonStart) + ON_MESSAGE(WM_UPDATE_UI, &CRegFindDlg::UpdateUI) + ON_BN_CLICKED(IDC_BUTTON_STOP, &CRegFindDlg::OnBnClickedButtonStop) + ON_WM_CLOSE() + ON_NOTIFY(NM_DBLCLK, IDC_LIST, &CRegFindDlg::OnNMDblclkList) +END_MESSAGE_MAP() + + +// CRegFindDlg Ϣ +LRESULT CRegFindDlg::UpdateUI(WPARAM, LPARAM) +{ + UpdateData(FALSE); + return 0; +} + +BOOL CRegFindDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + m_ctlAnimate.Open(IDR_AVI);//AVIļ + m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT); + m_List.InsertColumn(0,L"", LVCFMT_LEFT, 300); + m_List.InsertColumn(1,L"ֵ", LVCFMT_LEFT, 80); + m_List.InsertColumn(2,L"", LVCFMT_LEFT, 120); + + + m_strSearchInKey.IsEmpty() ? m_nRadio = 1 : m_nRadio = 0; //עؼ + GetDlgItem(IDC_EDIT)->EnableWindow(!m_nRadio); + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} + + + + + +void CRegFindDlg::OnBnClickedButtonStart() +{ + UpdateData(TRUE); + m_List.DeleteAllItems(); + + // жǷѾд + if (m_strFindWhat.IsEmpty()) + { + MessageBox(L"",L"Shine", MB_OK | MB_ICONWARNING); + return; + } + + // ijֵвѯ + if (m_nRadio == 0) + { + // жǷд + if (m_strSearchInKey.IsEmpty()) + { + MessageBox(L"ҷΧ", L"Shine", MB_OK | MB_ICONWARNING); + return; + } + + // жϸǷ + HKEY hKey = GetRootKey(m_strSearchInKey); + if (!hKey) + { + MessageBox(L"",L"Shine", MB_OK | MB_ICONERROR); + return; + } + + // жܷ򿪸ü + CString strSubKey; + if (m_strSearchInKey.Find('\\') != -1) + { + strSubKey = m_strSearchInKey.Right(m_strSearchInKey.GetLength() - m_strSearchInKey.Find('\\') - 1); + } + HKEY hKeyTemp = NULL; + LONG ulRet = RegOpenKeyEx(hKey, strSubKey, 0, KEY_READ, &hKeyTemp); + + if (ERROR_SUCCESS != ulRet) + { + MessageBox(L"ܴ򿪸üֵ", L"Shine", MB_OK | MB_ICONERROR); + return; + } + + RegCloseKey(hKeyTemp); + } + + // һݴдĸIJ,ҺԴСд,Ϳʹ + m_strFindWhatUpper = m_strFindWhat; + m_strFindWhatUpper.MakeUpper(); + + // ͨǰļ飬ʼ + InitControl(FALSE); //ؼ + + if (m_hThread) + { + CloseHandle(m_hThread); + m_hThread = NULL; + } + DWORD dwTid = 0; + m_hThread = CreateThread(NULL, 0, SearchRegistryProc, this, 0, &dwTid); +} + + + +HKEY CRegFindDlg::GetRootKey(CString strKey) +{ + HKEY hRet = NULL; + + if (strKey.IsEmpty()) + { + return hRet; + } + + CString strKeyRoot; + if (strKey.Find('\\') != -1) + { + strKeyRoot = strKey.Left(strKey.Find('\\')); + } + else + { + strKeyRoot = strKey; + } + + if (!strKeyRoot.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + hRet = HKEY_CLASSES_ROOT; + } + else if (!strKeyRoot.CompareNoCase(L"HKEY_CURRENT_USER")) + { + hRet = HKEY_CURRENT_USER; + } + else if (!strKeyRoot.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + hRet = HKEY_LOCAL_MACHINE; + } + else if (!strKeyRoot.CompareNoCase(L"HKEY_USERS")) + { + hRet = HKEY_USERS; + } + else if (!strKeyRoot.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + hRet = HKEY_CURRENT_CONFIG; + } + + return hRet; +} + + +VOID CRegFindDlg::SearchRegistry() +{ + m_bStop = FALSE; + m_nCnt = 0; + m_strSearchResult = L"ڲѯ"; + SendMessage(WM_UPDATE_UI); + + + + // ָ + if (m_nRadio == 0) + { + HKEY hKey = GetRootKey(m_strSearchInKey); + CString strSubKey; + if (m_strSearchInKey.Find('\\') != -1) + { + strSubKey = m_strSearchInKey.Right(m_strSearchInKey.GetLength() - m_strSearchInKey.Find('\\') - 1); + } + + EnumKeys(hKey, strSubKey); + } + + // ע + else + { + m_ctlAnimate.Play(0,-1,-1);//Ŷ + EnumKeys(HKEY_CLASSES_ROOT, NULL); + EnumKeys(HKEY_CURRENT_USER, NULL); + EnumKeys(HKEY_LOCAL_MACHINE, NULL); + EnumKeys(HKEY_USERS, NULL); + EnumKeys(HKEY_CURRENT_CONFIG, NULL); + m_ctlAnimate.Stop();//ֹͣ + + } + + InitControl(TRUE); + m_strSearchResult.Format(L"ѯ%dƥ", m_nCnt); + + SendMessage(WM_UPDATE_UI); + +// SendMessage(WM_SEARCH_FINISH); +} + + + +void CRegFindDlg::EnumKeys(HKEY hRoot, CString strSubKey) +{ + if (!hRoot) + { + return; + } + + strSubKey.TrimLeft('\\'); + HKEY hKeyTemp = NULL; + LONG nRet = RegOpenKeyEx(hRoot, strSubKey, 0, KEY_READ, &hKeyTemp); + if (nRet != ERROR_SUCCESS) + { + return; + } + + DWORD dwSubKeys = 0, dwSubValues = 0; + LONG ulRet = ::RegQueryInfoKey(hKeyTemp, NULL, NULL, NULL, &dwSubKeys, NULL, NULL, &dwSubValues, NULL, NULL, NULL, NULL); + if (ulRet != ERROR_SUCCESS) + { + RegCloseKey(hKeyTemp); + return; + } + + // CheckBox + if (m_bKeys) + { + for (DWORD dwIndex = 0; !m_bStop && dwIndex < dwSubKeys; dwIndex++) + { + DWORD dwLen = 1024; + TCHAR szSubName[1024]; + memset(szSubName, 0, 1024 * sizeof(TCHAR)); + + ulRet = RegEnumKey(hKeyTemp, dwIndex, szSubName, dwLen); + if (ulRet == ERROR_SUCCESS) + { + CString strSubName = CString(szSubName); + + // ִСд & ƥȫַ + if (m_bMachCase && m_bMachWholeString) + { + if (!strSubName.Compare(m_strFindWhat)) + { + InsertKeys(hRoot, strSubKey, strSubName); + } + } + + // ִСд,Dzȫƥ + else if (m_bMachCase && !m_bMachWholeString) + { + if (-1 != strSubName.Find(m_strFindWhat)) + { + InsertKeys(hRoot, strSubKey, strSubName); + } + } + + // ִСд & ȫƥ + else if (!m_bMachCase && m_bMachWholeString) + { + if (!strSubName.CompareNoCase(m_strFindWhat)) + { + InsertKeys(hRoot, strSubKey, strSubName); + } + } + + // ִСд & ȫƥ + else if (!m_bMachCase && !m_bMachWholeString) + { + CString szTemp = strSubName; + szTemp.MakeUpper(); + + if (szTemp.Find(m_strFindWhatUpper) != -1) + { + InsertKeys(hRoot, strSubKey, strSubName); + } + } + + // ݹö + EnumKeys(hRoot, strSubKey + L"\\" + szSubName); + } + } + } + + // ֵݶҪ,ôֱӷ + if (!m_bData && !m_bValues) + { + RegCloseKey(hKeyTemp); + return; + } + + // öֵ + for (DWORD dwIndex = 0; !m_bStop && dwIndex < dwSubValues; dwIndex++) + { + DWORD dwLen = 1024; + TCHAR szSubName[1024]; + memset(szSubName, 0, 1024 * sizeof(TCHAR)); + + DWORD dwType = 0, dwDataLen = 0x2000; + BYTE Data[0x2000] = {0}; + ulRet = RegEnumValue(hKeyTemp, dwIndex, szSubName, &dwLen, NULL, &dwType, Data, &dwDataLen); + if (ulRet == ERROR_SUCCESS) + { + // öֵѡ + if (m_bValues) + { + CString strSubName = CString(szSubName); + + // ִСд & ƥȫַ + if (m_bMachCase && m_bMachWholeString) + { + if (!strSubName.Compare(m_strFindWhat)) + { + InsertVlaues(hRoot, strSubKey, strSubName); + } + } + + // ִСд,Dzȫƥ + else if (m_bMachCase && !m_bMachWholeString) + { + if (-1 != strSubName.Find(m_strFindWhat)) + { + InsertVlaues(hRoot, strSubKey, strSubName); + } + } + + // ִСд & ȫƥ + else if (!m_bMachCase && m_bMachWholeString) + { + if (!strSubName.CompareNoCase(m_strFindWhat)) + { + InsertVlaues(hRoot, strSubKey, strSubName); + } + } + + // ִСд & ȫƥ + else if (!m_bMachCase && !m_bMachWholeString) + { + CString szTemp = strSubName; + szTemp.MakeUpper(); + + if (szTemp.Find(m_strFindWhatUpper) != -1) + { + InsertVlaues(hRoot, strSubKey, strSubName); + } + } + } + + // öݱѡ + if (m_bData) + { + InsertData(hRoot, strSubKey, szSubName, dwType, Data, dwDataLen); + } + } + } + + RegCloseKey(hKeyTemp); +} + + + +void CRegFindDlg::InsertKeys(HKEY hRoot, CString strSubKey, CString strSubSubKey) +{ + if (!hRoot) + { + return; + } + + CString strKeyPath = GetRootKeyString(hRoot); + strKeyPath += L"\\" + strSubKey + L"\\" + strSubSubKey; + int nItem = m_List.InsertItem(m_List.GetItemCount(), strKeyPath); + m_List.SetItemText(nItem, 1, L""); + m_List.SetItemText(nItem, 2, L""); + m_nCnt++; +} + + +void CRegFindDlg::InsertVlaues(HKEY hRoot, CString strSubKey, CString strValue) +{ + if (!hRoot || strValue.IsEmpty()) + { + return; + } + + CString strKeyPath = GetRootKeyString(hRoot); + strKeyPath += L"\\" + strSubKey; + int nItem = m_List.InsertItem(m_List.GetItemCount(), strKeyPath); + m_List.SetItemText(nItem, 1, strValue); + m_List.SetItemText(nItem, 2, L""); + m_nCnt++; +} + + + +void CRegFindDlg::InsertData(HKEY hRoot, CString strSubKey, CString strValue, DWORD dwType, PBYTE Data, DWORD dwDataLen) +{ + if (!hRoot || !Data || dwDataLen <= 0) + { + return; + } + + CString strRet, strCmp; + switch (dwType) + { + case REG_SZ: + case REG_EXPAND_SZ: + strCmp = strRet = (WCHAR*)Data; + break; + + case REG_DWORD: + { + strCmp.Format(L"%ld", *(PULONG)Data); + if (m_strFindWhat.GetLength() == strCmp.GetLength()) + { + BOOL bNumber = TRUE; + for (int i = 0; i < m_strFindWhat.GetLength(); i++) + { + WCHAR ch = m_strFindWhat.GetAt(i); + if (ch < '0' || ch > '9') + { + bNumber = FALSE; + break; + } + } + + if (bNumber && *(PULONG)Data == _wtoi(m_strFindWhat)) + { + strRet.Format(L"0x%08X (%d)", *(PULONG)Data, *(PULONG)Data); + } + else + { + return; + } + } + else + { + return; + } + } + break; + + case REG_DWORD_BIG_ENDIAN: + { + BYTE Value[4] = {0}; + Value[0] = *((PBYTE)Data + 3); + Value[1] = *((PBYTE)Data + 2); + Value[2] = *((PBYTE)Data + 1); + Value[3] = *((PBYTE)Data + 0); + strCmp.Format(L"%ld", *(PULONG)Value); + strRet.Format(L"0x%08X (%ld)", *(PULONG)Value, *(PULONG)Value); + } + break; + case REG_QWORD: + { + strCmp.Format(L"%ld", *(PQWORD)Data); + if (m_strFindWhat.GetLength() == strCmp.GetLength()) + { + BOOL bNumber = TRUE; + for (int i = 0; i < m_strFindWhat.GetLength(); i++) + { + WCHAR ch = m_strFindWhat.GetAt(i); + if (ch < '0' || ch > '9') + { + bNumber = FALSE; + break; + } + } + + if (bNumber && *(PQWORD)Data == _wtoi(m_strFindWhat)) + { + strRet.Format(L"0x%08X (%ld)", *(PQWORD)Data, *(PQWORD)Data); + } + else + { + return; + } + } + else + { + return; + } + } + break; + case REG_MULTI_SZ: + { + DWORD len = 0; + while (wcslen((WCHAR*)Data + len)) + { + strRet += ((WCHAR*)Data + len); + strRet += L" "; + len += wcslen((WCHAR*)Data + len) + 1; + } + + strCmp = strRet; + } + break; + + default: + return; + } + + if (strCmp.IsEmpty()) + { + return; + } + + CString strSubName = strCmp; + BOOL bInsert = FALSE; + + // ִСд & ƥȫַ + if (m_bMachCase && m_bMachWholeString) + { + if (!strSubName.Compare(m_strFindWhat)) + { + bInsert = TRUE; + } + } + + // ִСд,Dzȫƥ + else if (m_bMachCase && !m_bMachWholeString) + { + if (-1 != strSubName.Find(m_strFindWhat)) + { + bInsert = TRUE; + } + } + + // ִСд & ȫƥ + else if (!m_bMachCase && m_bMachWholeString) + { + if (!strSubName.CompareNoCase(m_strFindWhat)) + { + bInsert = TRUE; + } + } + + // ִСд & ȫƥ + else if (!m_bMachCase && !m_bMachWholeString) + { + CString strTemp = strSubName; + strTemp.MakeUpper(); + + if (strTemp.Find(m_strFindWhatUpper) != -1) + { + bInsert = TRUE; + } + } + + if (bInsert) + { + CString strKeyPath = GetRootKeyString(hRoot); + strKeyPath += L"\\" + strSubKey; + int nItem = m_List.InsertItem(m_List.GetItemCount(), strKeyPath); + m_List.SetItemText(nItem, 1, strValue); + m_List.SetItemText(nItem, 2, strRet); + m_nCnt++; + } +} + + + +CString CRegFindDlg::GetRootKeyString(HKEY hRoot) +{ + CString strRet; + if (!hRoot) + { + return strRet; + } + + if (hRoot == HKEY_CLASSES_ROOT) + { + strRet = L"HKEY_CLASSES_ROOT"; + } + else if (hRoot == HKEY_CURRENT_USER) + { + strRet = L"HKEY_CURRENT_USER"; + } + else if (hRoot == HKEY_LOCAL_MACHINE) + { + strRet = L"HKEY_LOCAL_MACHINE"; + } + else if (hRoot == HKEY_USERS) + { + strRet = L"HKEY_USERS"; + } + else if (hRoot == HKEY_CURRENT_CONFIG) + { + strRet = L"HKEY_CURRENT_CONFIG"; + } + + return strRet; +} + +void CRegFindDlg::OnBnClickedButtonStop() +{ + m_bStop = TRUE; + InitControl(TRUE); +} + + + +void CRegFindDlg::InitControl(BOOL bOk) +{ + GetDlgItem(IDC_CHECK_KEY)->EnableWindow(bOk); + GetDlgItem(IDC_CHECK_VALUES)->EnableWindow(bOk); + GetDlgItem(IDC_CHECK_DATA)->EnableWindow(bOk); + GetDlgItem(IDC_CHECK_MACH_CASE)->EnableWindow(bOk); + GetDlgItem(IDC_CHECK_MACH_WHOLE_STRING)->EnableWindow(bOk); + GetDlgItem(IDC_RADIO_SEARCH_IN)->EnableWindow(bOk); + GetDlgItem(IDC_RADIO_SEARCH_ALL)->EnableWindow(bOk); + GetDlgItem(IDC_BUTTON_START)->EnableWindow(bOk); + GetDlgItem(IDC_EDIT_FIND_WHAT)->EnableWindow(bOk); + GetDlgItem(IDC_EDIT)->EnableWindow(bOk); + GetDlgItem(IDC_EDIT_FIND_WHAT)->EnableWindow(bOk); + GetDlgItem(IDC_BUTTON_STOP)->EnableWindow(!bOk); +} + +void CRegFindDlg::OnClose() +{ + m_bStop = TRUE; + if (m_hThread) + { + if (WaitForSingleObject(m_hThread, 500) != WAIT_OBJECT_0) + { + TerminateThread(m_hThread, 0); + } + + CloseHandle(m_hThread); + m_hThread = NULL; + } + + + CDialog::OnClose(); + + delete this; +} + + + +void CRegFindDlg::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult) +{ + int nItem = m_List.GetSelectionMark(); + if (nItem != -1) + { + CString strKey = m_List.GetItemText(nItem, 0); + CString strValue = m_List.GetItemText(nItem, 1); + + JmpToRegistry(strKey, strValue); + } + *pResult = 0; +} + + +void CRegFindDlg::JmpToRegistry(CString strKey, CString strData) +{ + if (!strKey.IsEmpty() && g_Father) + { + + ((CRegisterManagerDlg*)g_Father)->JmpToReg(strKey, strData); + } +} \ No newline at end of file diff --git a/Register/RegisterManager/RegisterManager/RegFindDlg.h b/Register/RegisterManager/RegisterManager/RegFindDlg.h new file mode 100644 index 0000000..303ad38 --- /dev/null +++ b/Register/RegisterManager/RegisterManager/RegFindDlg.h @@ -0,0 +1,53 @@ +#pragma once +#include "afxcmn.h" + + +// CRegFindDlg Ի + +class CRegFindDlg : public CDialog +{ + DECLARE_DYNAMIC(CRegFindDlg) + +public: + CRegFindDlg(CWnd* pParent = NULL); // ׼캯 + virtual ~CRegFindDlg(); + HKEY CRegFindDlg::GetRootKey(CString strKey); + VOID CRegFindDlg::SearchRegistry(); + void CRegFindDlg::EnumKeys(HKEY hRoot, CString strSubKey); + void CRegFindDlg::InsertKeys(HKEY hRoot, CString strSubKey, CString strSubSubKey); + CString CRegFindDlg::GetRootKeyString(HKEY hRoot); + void CRegFindDlg::InsertVlaues(HKEY hRoot, CString strSubKey, CString strValue); + void CRegFindDlg::InsertData(HKEY hRoot, CString strSubKey, CString strValue, DWORD dwType, PBYTE Data, DWORD dwDataLen); + void CRegFindDlg::InitControl(BOOL bOk); + void CRegFindDlg::JmpToRegistry(CString strKey, CString strData); +// Ի + enum { IDD = IDD_FIND_REG_DIALOG }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + DECLARE_MESSAGE_MAP() +public: + CListCtrl m_List; + virtual BOOL OnInitDialog(); + CString m_strSearchInKey; + int m_nRadio; + afx_msg void OnBnClickedRadioSearchIn(); + afx_msg void OnBnClickedButtonStart(); + afx_msg LRESULT UpdateUI(WPARAM,LPARAM); + CString m_strFindWhat; + CString m_strFindWhatUpper; // д + BOOL m_bStop; + HANDLE m_hThread; + BOOL m_bKeys; + BOOL m_bMachCase; + BOOL m_bMachWholeString; + BOOL m_bData; + BOOL m_bValues; + ULONG m_nCnt; //¼ҵĸ + CString m_strSearchResult; + CAnimateCtrl m_ctlAnimate; + afx_msg void OnBnClickedButtonStop(); + afx_msg void OnClose(); + afx_msg void OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult); +}; diff --git a/Register/RegisterManager/RegisterManager/RegHexEditDlg.cpp b/Register/RegisterManager/RegisterManager/RegHexEditDlg.cpp new file mode 100644 index 0000000..8155664 --- /dev/null +++ b/Register/RegisterManager/RegisterManager/RegHexEditDlg.cpp @@ -0,0 +1,135 @@ +// RegHexEditDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "RegisterManager.h" +#include "RegHexEditDlg.h" +#include "afxdialogex.h" + + +// CRegHexEditDlg Ի + +IMPLEMENT_DYNAMIC(CRegHexEditDlg, CDialog) + +CRegHexEditDlg::CRegHexEditDlg(CWnd* pParent /*=NULL*/) + : CDialog(CRegHexEditDlg::IDD, pParent) + , m_strValueNameEdit(_T("")) + , m_strHex(_T("")) +{ + +} + +CRegHexEditDlg::~CRegHexEditDlg() +{ +} + +void CRegHexEditDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_HEXEDIT, m_HexEdit); + DDX_Text(pDX, IDC_EDIT_VALUE_NAME, m_strValueNameEdit); + DDX_Text(pDX, IDC_HEXEDIT, m_strHex); +} + + +BEGIN_MESSAGE_MAP(CRegHexEditDlg, CDialog) + ON_BN_CLICKED(IDOK, &CRegHexEditDlg::OnBnClickedOk) +END_MESSAGE_MAP() + + +// CRegHexEditDlg Ϣ + + +BOOL CRegHexEditDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + + SetWindowText(L"Ʊ༭"); + + ULONG i = 0; + CString strShowData; + for (i=0;i + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {118E09E5-83B5-4DC6-A3ED-70F0F1BFE66C} + RegisterManager + MFCProj + + + + Application + true + Unicode + Static + + + Application + true + Unicode + Static + + + Application + false + true + Unicode + Dynamic + + + Application + false + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + + + Windows + true + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + + + Windows + true + AsInvoker + + + false + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + false + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Register/RegisterManager/RegisterManager/RegisterManager.vcxproj.filters b/Register/RegisterManager/RegisterManager/RegisterManager.vcxproj.filters new file mode 100644 index 0000000..a57635f --- /dev/null +++ b/Register/RegisterManager/RegisterManager/RegisterManager.vcxproj.filters @@ -0,0 +1,115 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git a/Register/RegisterManager/RegisterManager/RegisterManager.vcxproj.user b/Register/RegisterManager/RegisterManager/RegisterManager.vcxproj.user new file mode 100644 index 0000000..ace9a86 --- /dev/null +++ b/Register/RegisterManager/RegisterManager/RegisterManager.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Register/RegisterManager/RegisterManager/RegisterManagerDlg.cpp b/Register/RegisterManager/RegisterManager/RegisterManagerDlg.cpp new file mode 100644 index 0000000..8154a62 --- /dev/null +++ b/Register/RegisterManager/RegisterManager/RegisterManagerDlg.cpp @@ -0,0 +1,3399 @@ + +// RegisterManagerDlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "RegisterManager.h" +#include "RegisterManagerDlg.h" +#include "afxdialogex.h" +#include "KeyDlg.h" +#include "RegFindDlg.h" +#include "RegModifyDlg.h" +#include "RegHexEditDlg.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Ӧó򡰹ڡ˵ CAboutDlg Ի +HANDLE g_hDevice = NULL; +CWnd* g_Father = NULL; + +HANDLE +OpenDevice(LPCTSTR lpDevicePath) +{ + HANDLE hDevice = CreateFile(lpDevicePath, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hDevice == INVALID_HANDLE_VALUE) + { + + } + + return hDevice; + +} + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// Ի + enum { IDD = IDD_ABOUTBOX }; + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + +// ʵ +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// CRegisterManagerDlg Ի + + + + +CRegisterManagerDlg::CRegisterManagerDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(CRegisterManagerDlg::IDD, pParent) + , m_strComboText(_T("")) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + + m_wzhKeyCurrentUser = NULL; + m_RegPathList.clear(); + m_bmRefresh.LoadBitmap(IDB_REFRESH); //ͼ + m_bmDelete.LoadBitmap(IDB_DELETE); + m_bmCopy.LoadBitmap(IDB_COPY); + m_bmExport.LoadBitmap(IDB_EXPORT); + m_bmLookfor.LoadBitmap(IDB_LOOKFOR); + + m_FindRegDlg = NULL; +} + +CRegisterManagerDlg::~CRegisterManagerDlg() +{ + if (m_wzhKeyCurrentUser) + { + free(m_wzhKeyCurrentUser); + m_wzhKeyCurrentUser = NULL; + } + + m_RegPathList.clear(); +} + +void CRegisterManagerDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_TREE, m_Tree); + DDX_Control(pDX, IDC_LIST, m_List); + DDX_Control(pDX, IDC_COMBO, m_ComboBox); + DDX_CBString(pDX, IDC_COMBO, m_strComboText); +} + +BEGIN_MESSAGE_MAP(CRegisterManagerDlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_NOTIFY(TVN_ITEMEXPANDING, IDC_TREE, &CRegisterManagerDlg::OnTvnItemexpandingTree) + ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, &CRegisterManagerDlg::OnTvnSelchangedTree) + ON_BN_CLICKED(IDC_GOTO, &CRegisterManagerDlg::OnBnClickedGoto) + ON_CBN_DROPDOWN(IDC_COMBO, &CRegisterManagerDlg::OnCbnDropdownCombo) + ON_COMMAND(ID_REG_REFRESH, &CRegisterManagerDlg::OnRegRefresh) + ON_NOTIFY(NM_RCLICK, IDC_TREE, &CRegisterManagerDlg::OnNMRClickTree) + ON_COMMAND(ID_REG_NEW_KEY, &CRegisterManagerDlg::OnRegNewKey) + ON_COMMAND(ID_STRING_VALUE, &CRegisterManagerDlg::OnStringValue) + ON_COMMAND(ID_BINARY_VALUE, &CRegisterManagerDlg::OnBinaryValue) + ON_COMMAND(ID_DWORD_VALUE, &CRegisterManagerDlg::OnDwordValue) + ON_COMMAND(ID_MUI_STRING_VALUE, &CRegisterManagerDlg::OnMuiStringValue) + ON_COMMAND(ID_EXPAND_STRING_VALUE, &CRegisterManagerDlg::OnExpandStringValue) + ON_COMMAND(ID_REG_DELETE, &CRegisterManagerDlg::OnRegDelete) + ON_COMMAND(ID_REG_RENAME, &CRegisterManagerDlg::OnRegRename) + ON_COMMAND(ID_QWORD_VALUE, &CRegisterManagerDlg::OnQwordValue) + ON_COMMAND(ID_REG_COPY_KEY_NAME, &CRegisterManagerDlg::OnRegCopyKeyName) + ON_COMMAND(ID_REG_COPY_FULL_KEY_NAME, &CRegisterManagerDlg::OnRegCopyFullKeyName) + ON_COMMAND(ID_REG_ADD_TO_QUICK_ADDRESS, &CRegisterManagerDlg::OnRegAddToQuickAddress) + ON_COMMAND(ID_REG_INPORT, &CRegisterManagerDlg::OnRegInport) + ON_COMMAND(ID_REG_EXPORT, &CRegisterManagerDlg::OnRegExport) + ON_COMMAND(ID_REG_LOOK_FOR, &CRegisterManagerDlg::OnRegLookFor) + ON_NOTIFY(NM_RCLICK, IDC_LIST, &CRegisterManagerDlg::OnNMRClickList) + ON_COMMAND(ID_REG_LIST_REFRESH, &CRegisterManagerDlg::OnRegListRefresh) + ON_COMMAND(ID_REG_LIST_MODIFY, &CRegisterManagerDlg::OnRegListModify) + ON_COMMAND(ID_REG_LIST_DELETE, &CRegisterManagerDlg::OnRegListDelete) + ON_COMMAND(ID_REG_LIST_RENAME, &CRegisterManagerDlg::OnRegListRename) + ON_COMMAND(ID_REG_LIST_COPY_VALUE, &CRegisterManagerDlg::OnRegListCopyValue) + ON_COMMAND(ID_REG_LIST_COPY_VALUE_DATA, &CRegisterManagerDlg::OnRegListCopyValueData) +END_MESSAGE_MAP() + + +// CRegisterManagerDlg Ϣ + +BOOL CRegisterManagerDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // ...˵ӵϵͳ˵С + + // IDM_ABOUTBOX ϵͳΧڡ + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != NULL) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // ô˶ԻͼꡣӦóڲǶԻʱܽԶ + // ִд˲ + SetIcon(m_hIcon, TRUE); // ôͼ + SetIcon(m_hIcon, FALSE); // Сͼ + + // TODO: ڴӶijʼ + + + + g_Father = this; + + + InitControlTree(); //ʼؼ + + + //ʼListؼ + HICON hIcon[10]; + hIcon[0] = AfxGetApp()->LoadIcon (IDI_REG_SZ); + hIcon[1] = AfxGetApp()->LoadIcon (IDI_DWORD); + m_ImageList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 2, 2); + for(int n = 0; n < 2; n++) + { + m_ImageList.Add(hIcon[n]); + m_List.SetImageList(&m_ImageList, LVSIL_SMALL); + } + + m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT); + m_List.InsertColumn(0, L"", LVCFMT_LEFT, 200); + m_List.InsertColumn(1, L"", LVCFMT_LEFT, 130); + m_List.InsertColumn(2, L"", LVCFMT_LEFT, 590); + + InitRegistry(); + InitRegPathList(); //Combo ϵĿٶλ + return TRUE; // ǽõؼ򷵻 TRUE +} + +void CRegisterManagerDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// ԻСťҪĴ +// Ƹͼꡣʹĵ/ͼģ͵ MFC Ӧó +// ⽫ɿԶɡ + +void CRegisterManagerDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // ڻƵ豸 + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // ʹͼڹо + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // ͼ + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialogEx::OnPaint(); + } +} + +//û϶Сʱϵͳô˺ȡù +//ʾ +HCURSOR CRegisterManagerDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + + + + +BOOL CRegisterManagerDlg::InitControlTree() +{ + + //IconԴ + int iCount = 3; + HICON hIcon[4]; + hIcon[0] = AfxGetApp()->LoadIcon (IDI_COMPUTER); + hIcon[1] = AfxGetApp()->LoadIcon (IDI_CLOSE_DIRECTORY); + hIcon[2] = AfxGetApp()->LoadIcon (IDI_OPEN_DIRECTORY); + + + //ͼƬ + m_TreeImageList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 2, 2); + for(int n = 0; n < iCount; n++) + { + m_TreeImageList.Add(hIcon[n]); + m_Tree.SetImageList(&m_TreeImageList, LVSIL_NORMAL); + } + + DWORD dwStyle = GetWindowLong(m_Tree.m_hWnd, GWL_STYLE); + dwStyle |= TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT; + ::SetWindowLong (m_Tree.m_hWnd, GWL_STYLE, dwStyle); + + HTREEITEM Computer = m_Tree.InsertItem(L"ҵĵ", 0, 0); + HTREEITEM hTreeItem0 = m_Tree.InsertItem(L"HKEY_CLASSES_ROOT", 1, 2, Computer, TVI_LAST); + HTREEITEM hTreeItem1 = m_Tree.InsertItem(L"HKEY_CURRENT_USER", 1, 2, Computer, TVI_LAST); + HTREEITEM hTreeItem2 = m_Tree.InsertItem(L"HKEY_LOCAL_MACHINE", 1, 2, Computer, TVI_LAST); + HTREEITEM hTreeItem3 = m_Tree.InsertItem(L"HKEY_USERS", 1, 2, Computer, TVI_LAST); + HTREEITEM hTreeItem4 = m_Tree.InsertItem(L"HKEY_CURRENT_CONFIG", 1, 2, Computer, TVI_LAST); + + m_Tree.Expand(Computer, TVE_EXPAND); + + return TRUE; +} + + +VOID CRegisterManagerDlg::InitRegistry() +{ + + + m_List.DeleteAllItems(); + m_strComboText = L""; + UpdateData( FALSE ); + + HTREEITEM hRootItem = m_Tree.GetRootItem(); + + if (hRootItem != NULL) + { + HTREEITEM hChild = m_Tree.GetChildItem(hRootItem); + while(hChild != NULL) + { + m_Tree.Expand(hChild, TVE_COLLAPSE); + + CString strKey = m_Tree.GetItemText(hChild); + + if (!strKey.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + EnumSubKeys(CLASSES_ROOT, hChild, TRUE); + } + else if (!strKey.CompareNoCase(L"HKEY_CURRENT_USER")) + { + EnumCurrentUserSubKeys(hChild); //Ƚ + } + else if (!strKey.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + EnumSubKeys(LOCAL_MACHINE, hChild); + } + else if (!strKey.CompareNoCase(L"HKEY_USERS")) + { + EnumSubKeys(USERS, hChild); + } + else if (!strKey.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + EnumSubKeys(CURRENT_CONFIGL, hChild, TRUE); + } + else + { + break; + } + + hChild = m_Tree.GetNextSiblingItem(hChild); + } + } + + m_Tree.Invalidate(TRUE); +} + + + +VOID CRegisterManagerDlg::EnumSubKeys(CString strKey, HTREEITEM hItem, BOOL bSubSubKey/* = FALSE */) +{ + if ( !strKey.IsEmpty() && hItem != NULL ) + { + DeleteSubTree(hItem); //οЧ + + UNICODE_STRING uniKey; + + if (InitUnicodeString(&uniKey, strKey.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey,KEY_ALL_ACCESS, &oa)) + { + /* WCHAR wzBuffer[256] = {0}; + wsprintf(wzBuffer,L"0x%p",hKey); + ::MessageBox(NULL,wzBuffer,L"Data",MB_OK);*/ + + for (ULONG i = 0;;i++) + { + ULONG nRetLen = 0; + BOOL bRet = EnumerateKey(hKey,i,KeyBasicInformation,NULL,0,&nRetLen); + + if (!bRet && GetLastError() == ERROR_NO_MORE_ITEMS) + { + break; + } + else if (!bRet && GetLastError() == ERROR_INSUFFICIENT_BUFFER) // STATUS_BUFFER_TOO_SMALL + { + + + //MessageBox(L"1",L"1"); + PKEY_BASIC_INFORMATION Buffer = (PKEY_BASIC_INFORMATION)malloc(nRetLen + 0x100); + if (Buffer) + { + memset(Buffer, 0, nRetLen + 0x100); + bRet = EnumerateKey(hKey, i, KeyBasicInformation,Buffer, nRetLen + 0x100, &nRetLen); + + if (bRet) + { + m_Tree.InsertItem(Buffer->Name, 1, 2, hItem, TVI_LAST); + } + + free(Buffer); + + // öôֻҪһͿˣ + // ΪǰѾһ+ˣҪΪٶŻ + if (bRet && bSubSubKey) + { + break; + } + } + } + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + } +} + + +VOID CRegisterManagerDlg::DeleteSubTree(HTREEITEM hTreeItem) +{ + if(hTreeItem == NULL) + { + return; + } + + if(m_Tree.ItemHasChildren(hTreeItem)) + { + HTREEITEM hNext, hChild = m_Tree.GetChildItem(hTreeItem); + while(hChild != NULL) + { + hNext = m_Tree.GetNextSiblingItem(hChild); + m_Tree.DeleteItem(hChild); + hChild = hNext; + } + } +} + + + +BOOL CRegisterManagerDlg::InitUnicodeString(PUNICODE_STRING uniString, WCHAR *wzString) +{ + BOOL bRet = FALSE; + if (!wzString) + { + uniString->Buffer = NULL; + uniString->Length = 0; + uniString->MaximumLength = 2; + bRet = TRUE; + } + else + { + ULONG nLen = wcslen(wzString); + if (uniString && nLen > 0) + { + PWCHAR Buffer = (PWCHAR)malloc((nLen + 1) * sizeof(WCHAR)); + if (Buffer) + { + memset(Buffer, 0, (nLen + 1) * sizeof(WCHAR)); + wcscpy_s(Buffer, nLen + 1, wzString); + uniString->Buffer = Buffer; + uniString->Length = (USHORT)(nLen * sizeof(WCHAR)); + uniString->MaximumLength = (USHORT)((nLen + 1) * sizeof(WCHAR)); + bRet = TRUE; + } + } + } + + return bRet; +} +VOID CRegisterManagerDlg::FreeUnicodeString(UNICODE_STRING *uniString) +{ + if (uniString && uniString->Buffer && uniString->Length > 0) + { + uniString->Length = 0; + uniString->MaximumLength = 0; + free(uniString->Buffer); + uniString->Buffer = NULL; + } +} + +BOOL CRegisterManagerDlg::OpenKey(OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ) +{ + + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + + struct{ + ACCESS_MASK DesiredAccess; + POBJECT_ATTRIBUTES ObjectAttributes; + }Open; + + + + memset(&Open, 0, sizeof(Open)); + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + Open.DesiredAccess = DesiredAccess; + Open.ObjectAttributes = ObjectAttributes; + + + dwRet = DeviceIoControl(g_hDevice,CTL_OPEN_KEY, + &Open, + sizeof(Open), + KeyHandle, + sizeof(KeyHandle), + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; +} + + + +BOOL CRegisterManagerDlg::EnumerateKey(IN HANDLE KeyHandle, + IN ULONG ulIndex, + IN ULONG ulKeyInformationClass, + OUT PVOID KeyInformation, + IN ULONG ulLength, + OUT PULONG ResultLength + ) +{ + + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + + struct{ + HANDLE hKey; + ULONG Index; + ULONG InformationClass; + ULONG Length; + }Enum; + + + memset(&Enum, 0, sizeof(Enum)); + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + + Enum.hKey = KeyHandle; + Enum.Index = ulIndex; + Enum.InformationClass = ulKeyInformationClass; + Enum.Length = ulLength; + + + typedef struct _ENUM_VALUE_ + { + PULONG RetLength; + PVOID ValueInfor; + }ENUM_VALUE, *PENUM_VALUE; + + + ENUM_VALUE EnumValue; + memset(&EnumValue, 0, sizeof(ENUM_VALUE)); + EnumValue.RetLength = ResultLength; + EnumValue.ValueInfor = KeyInformation; + + dwRet = DeviceIoControl(g_hDevice,CTL_ENUM_KEY, + &Enum, + sizeof(Enum), + &EnumValue, + sizeof(ENUM_VALUE), + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; +} + + +void CRegisterManagerDlg::EnumCurrentUserSubKeys(HTREEITEM hChild) +{ + DeleteSubTree(hChild); + + if (!m_wzhKeyCurrentUser) + { + m_wzhKeyCurrentUser = (WCHAR*)malloc(1024 * sizeof(WCHAR)); + if (m_wzhKeyCurrentUser) + { + memset(m_wzhKeyCurrentUser, 0, 1024 * sizeof(WCHAR)); + + if (!GetCurrentUserKeyPath(m_wzhKeyCurrentUser)) + { + wcscpy_s(m_wzhKeyCurrentUser, 1024, L"\\Registry\\User\\.Default"); + } + } + } + + if (m_wzhKeyCurrentUser && wcslen(m_wzhKeyCurrentUser) > 0) + { + EnumSubKeys(m_wzhKeyCurrentUser, hChild, TRUE); + } +} + + + +BOOL CRegisterManagerDlg::GetCurrentUserKeyPath(OUT WCHAR *wzCurrentUserPath) +{ + if (!wzCurrentUserPath) + { + return FALSE; + } + + HANDLE hToken; + UCHAR szBuffer[256] = {0}; + PSID_AND_ATTRIBUTES SidBuffer; + ULONG Length; + BOOL Status = FALSE; + + Status = OpenThreadToken(GetCurrentThread(), + TOKEN_QUERY, + TRUE, + &hToken); + + if (!Status) + { + Status = OpenProcessToken(GetCurrentProcess(), + TOKEN_QUERY, + &hToken); + + if (!Status) + { + return Status; + } + } + + SidBuffer = (PSID_AND_ATTRIBUTES)szBuffer; + Status = GetTokenInformation(hToken, + TokenUser, + (PVOID)SidBuffer, + sizeof(szBuffer), + &Length); + + CloseHandle(hToken); + if (!Status) + { + return Status; + } + + LPTSTR StringSid; + Status = ConvertSidToStringSid(SidBuffer[0].Sid, &StringSid); + if (!Status) return Status; + + WCHAR wzUser[] = L"\\Registry\\User\\"; + + Length = wcslen(StringSid) * sizeof(WCHAR) + sizeof(wzUser); + + WCHAR *wzPath = (WCHAR *)malloc(Length); + if (!wzPath) + { + LocalFree((HLOCAL)StringSid); + return FALSE; + } + + memset(wzPath, 0, Length); + wcscpy_s(wzPath, Length / sizeof(WCHAR),wzUser); + wcscat_s(wzPath, Length / sizeof(WCHAR), StringSid); + + LocalFree((HLOCAL)StringSid); + + wcscpy_s(wzCurrentUserPath, 1024, wzPath); + free(wzPath); + + return TRUE; +} + +void CRegisterManagerDlg::OnTvnItemexpandingTree(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMTREEVIEW pNMTreeView = reinterpret_cast(pNMHDR); + // TODO: ڴӿؼ֪ͨ + HTREEITEM hItem = pNMTreeView->itemNew.hItem; + BOOL nRet = FALSE; + if (!nRet) + { + // ۵״̬ʱŲӽڵ + if(!(TVIS_EXPANDED & m_Tree.GetItemState(hItem, TVIS_EXPANDED)) && + m_Tree.GetRootItem() != hItem && + hItem != NULL) + { + DeleteSubTree(hItem); + + HTREEITEM hItemTemp = hItem; + CString strKeyPath, strKeyPathTemp; + while (1) + { + CString strText = m_Tree.GetItemText(hItemTemp); + + if (!strText.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strKeyPath = CLASSES_ROOT; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strKeyPath = m_wzhKeyCurrentUser; + break; + } + else if (!strText.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strKeyPath = LOCAL_MACHINE; + break; + } + else if (!strText.CompareNoCase(L"HKEY_USERS")) + { + strKeyPath = USERS; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strKeyPath = CURRENT_CONFIGL; + break; + } + else + { + strKeyPathTemp = strText + L"\\" + strKeyPathTemp; + } + + hItemTemp = m_Tree.GetParentItem(hItemTemp); + } + + strKeyPath = strKeyPath + L"\\" + strKeyPathTemp; + EnumSubKeys(strKeyPath, hItem); + EnumSubSubKeys(strKeyPath, hItem); + } + } + + + *pResult = 0; +} + + +void CRegisterManagerDlg::EnumSubSubKeys(CString strKey, HTREEITEM hItem) +{ + if (!strKey.IsEmpty() && hItem != NULL) + { + HTREEITEM hChild = m_Tree.GetChildItem(hItem); + while(hChild != NULL) + { + CString strKeyPath = strKey + L"\\" + m_Tree.GetItemText(hChild); + EnumSubKeys(strKeyPath, hChild, TRUE); // bSubSubKey Ϊtrue,Żöٶ + hChild = m_Tree.GetNextSiblingItem(hChild); + } + } +} + + +void CRegisterManagerDlg::OnTvnSelchangedTree(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMTREEVIEW pNMTreeView = reinterpret_cast(pNMHDR); + + + + HTREEITEM hItem = pNMTreeView->itemNew.hItem; + CString strKeyShowPath; + + if(m_Tree.GetRootItem() != hItem && + hItem != NULL) + { + BOOL nRet = FALSE; + if (!nRet) + { + HTREEITEM hItemTemp = hItem; + CString strKeyPath, strKeyPathTemp; + while (1) + { + CString strText = m_Tree.GetItemText(hItemTemp); + + if (!strText.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strKeyPath = CLASSES_ROOT; + strKeyShowPath = L"HKEY_CLASSES_ROOT"; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strText = m_wzhKeyCurrentUser; + strKeyShowPath = L"HKEY_CURRENT_USER"; + break; + } + else if (!strText.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strKeyPath = LOCAL_MACHINE; + strKeyShowPath = L"HKEY_LOCAL_MACHINE"; + break; + } + else if (!strText.CompareNoCase(L"HKEY_USERS")) + { + strKeyPath = USERS; + strKeyShowPath = L"HKEY_USERS"; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strKeyPath = CURRENT_CONFIGL; + strKeyShowPath = L"HKEY_CURRENT_CONFIG"; + break; + } + else + { + strKeyPathTemp = strText + L"\\" + strKeyPathTemp; + } + + hItemTemp = m_Tree.GetParentItem(hItemTemp); + } + + strKeyPath = strKeyPath + L"\\" + strKeyPathTemp; + strKeyShowPath = strKeyShowPath + L"\\" + strKeyPathTemp; + EnumValues(strKeyPath); //List ؼʾ + } + } + + strKeyShowPath.TrimRight('\\'); + m_strComboText = strKeyShowPath; + UpdateData(FALSE); + + *pResult = 0; +} + + + +void CRegisterManagerDlg::EnumValues(CString strKey) +{ + if (strKey.IsEmpty()) + { + return; + } + + UNICODE_STRING uniKey; + + if (InitUnicodeString(&uniKey, strKey.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + m_List.DeleteAllItems(); + BOOL bDefault = FALSE; + + for (ULONG i = 0; ; i++) + { + ULONG nRetLen = 0; + BOOL bRet = EnumerateValueKey(hKey,i,KeyValueFullInformation,NULL,0,&nRetLen); + if (!bRet && GetLastError() == ERROR_NO_MORE_ITEMS) + { + //û + break; + } + else if (!bRet && GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + PKEY_VALUE_FULL_INFORMATION Buffer = (PKEY_VALUE_FULL_INFORMATION)malloc(nRetLen + 0x100); + if (Buffer) + { + memset(Buffer, 0, nRetLen + 0x100); + bRet = EnumerateValueKey(hKey, i, KeyValueFullInformation, Buffer, nRetLen + 0x100, &nRetLen); + + if (bRet) + { + CString strName, strType, strData; + WCHAR wzTempName[1024] = {0}; + + strType = GetKeyType(Buffer->Type); + strData = GetKeyData(Buffer->Type, (WCHAR*)((PBYTE)Buffer + Buffer->DataOffset), Buffer->DataLength); + + // NameLengthΪ0 + if (Buffer->NameLength == 0) + { + strName = L"Ĭ"; + bDefault = TRUE; + } + else + { + wcsncpy_s(wzTempName, 1024, Buffer->Name, Buffer->NameLength / sizeof(WCHAR)); + strName = wzTempName; + } + + int nImage = 1; + if (Buffer->Type == REG_SZ || + Buffer->Type == REG_EXPAND_SZ || + Buffer->Type == REG_MULTI_SZ) + { + nImage = 0; + } + + int n = m_List.InsertItem(m_List.GetItemCount(),strName, nImage); + + if (strType == L"REG_QWORD") + { + Sleep(1); + } + m_List.SetItemText(n, 1, strType); + m_List.SetItemText(n, 2, strData); + + if (Buffer->NameLength == 0) + { + m_List.SetItemData(n, 1); + } + } + + free(Buffer); + } + } + } + + // һĬϵļΪ + if (!bDefault) + { + int n = m_List.InsertItem(0,L"Ĭ", 0); + m_List.SetItemText(n, 1, L"REG_SZ"); + m_List.SetItemText(n, 2, L"ֵδ"); + + m_List.SetItemData(n, 1); + } + + CloseHandle(hKey); + } + + + FreeUnicodeString(&uniKey); + } +} + + +BOOL CRegisterManagerDlg::EnumerateValueKey(IN HANDLE KeyHandle, + IN ULONG ulIndex, + IN ULONG ulKeyValueInformationClass, + OUT PVOID KeyValueInformation, + IN ULONG ulLength, + OUT PULONG ulResultLength + ) +{ + + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + + struct{ + HANDLE hKey; + ULONG Index; + ULONG InformationClass; + ULONG Length; + }Enum; + + + memset(&Enum, 0, sizeof(Enum)); + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + + Enum.hKey = KeyHandle; + Enum.Index = ulIndex; + Enum.InformationClass = ulKeyValueInformationClass; + Enum.Length = ulLength; + + typedef struct _ENUM_VALUE_ + { + PULONG RetLength; + PVOID ValueInfor; + }ENUM_VALUE, *PENUM_VALUE; + + + ENUM_VALUE EnumValue; + memset(&EnumValue, 0, sizeof(ENUM_VALUE)); + EnumValue.RetLength = ulResultLength; + EnumValue.ValueInfor = KeyValueInformation; + + dwRet = DeviceIoControl(g_hDevice,CTL_ENUM_KEY_VALUE, + &Enum, + sizeof(Enum), + &EnumValue, + sizeof(ENUM_VALUE), + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; + +} + + + + +CString CRegisterManagerDlg::GetKeyType(ULONG ulType) +{ + CString strRet; + + switch (ulType) + { + case REG_NONE: + strRet = L"REG_NONE"; + break; + + case REG_SZ: + strRet = L"REG_SZ"; + break; + + case REG_EXPAND_SZ: + strRet = L"REG_EXPAND_SZ"; + break; + + case REG_BINARY: + strRet = L"REG_BINARY"; + break; + + case REG_DWORD: + strRet = L"REG_DWORD"; + break; + + case REG_DWORD_BIG_ENDIAN: + strRet = L"REG_DWORD_BIG_ENDIAN"; + break; + + case REG_LINK: + strRet = L"REG_LINK"; + break; + + case REG_MULTI_SZ: + strRet = L"REG_MULTI_SZ"; + break; + + case REG_RESOURCE_LIST: + strRet = L"REG_RESOURCE_LIST"; + break; + + case REG_FULL_RESOURCE_DESCRIPTOR: + strRet = L"REG_FULL_RESOURCE_DESCRIPTOR"; + break; + + case REG_RESOURCE_REQUIREMENTS_LIST: + strRet = L"REG_RESOURCE_REQUIREMENTS_LIST"; + break; + + case REG_QWORD: + strRet = L"REG_QWORD"; + break; + + default: + strRet = L"Unknow"; + } + + return strRet; +} + +CString CRegisterManagerDlg::GetKeyData(ULONG ulType, WCHAR* wzData, ULONG ulDataLength) +{ + CString strRet; + + if (!ulDataLength) + { + return strRet; + } + + switch (ulType) + { + case REG_SZ: + case REG_EXPAND_SZ: + strRet = wzData; + break; + + case REG_LINK: + case REG_NONE: + case REG_RESOURCE_REQUIREMENTS_LIST: + case REG_FULL_RESOURCE_DESCRIPTOR: + case REG_RESOURCE_LIST: + case REG_BINARY: + { + for (ULONG i = 0; i RegPathList; + GetAllRegPath(RegPathList); + m_nComboBoxCnt = 0; + + for (list ::iterator ir = RegPathList.begin(); + ir != RegPathList.end(); + ir++) + { + m_ComboBox.InsertString(m_nComboBoxCnt, *ir); + m_nComboBoxCnt++; + } +} + + + +void CRegisterManagerDlg::GetAllRegPath(std::list &RegPathList) +{ + RegPathList.clear(); + + for (std::list ::iterator itor = m_RegPathList.begin(); + itor != m_RegPathList.end(); + itor++) + { + RegPathList.push_back(*itor); + } +} + + +void CRegisterManagerDlg::InitRegPathList() +{ + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellExecuteHooks"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\IPSec\\Policy\\Local"); + m_RegPathList.push_back(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace"); +} + +void CRegisterManagerDlg::OnBnClickedGoto() +{ + UpdateData(TRUE); + m_ComboBox.ResetContent(); + m_ComboBox.SetWindowText(m_strComboText); + + + if (m_strComboText.IsEmpty()) + { + return; + } + + + CString strKeyPath = ComboString2KeyPath(); + if (strKeyPath.IsEmpty()) + { + return; + } + + CString strHead = m_strComboText.Left(m_strComboText.Find(L"\\")); + if (strHead.IsEmpty()) + { + strHead = m_strComboText; + } + + if (strHead.IsEmpty()) + { + return; + } + + HTREEITEM hRootItem = m_Tree.GetRootItem(); + if (hRootItem == NULL) + { + + return; + } + + HTREEITEM hChild = m_Tree.GetChildItem(hRootItem); + CString strRoot; + + WCHAR wzhKeyRoot[] = L"HKEY_CLASSES_ROOT"; + WCHAR wzhKCR[] = L"HKCR"; + + WCHAR wzhKeyCurrentUser[] = L"HKEY_CURRENT_USER"; + WCHAR wzhKCU[] = L"HKCU"; + + WCHAR wzhKeyLocalMachine[] = L"HKEY_LOCAL_MACHINE"; + WCHAR wzhKLM[] = L"HKLM"; + + WCHAR wzhKeyUsers[] = L"HKEY_USERS"; + WCHAR wzhKU[] = L"HKU";; + + WCHAR wzhKeyCurrentConfig[] = L"HKEY_CURRENT_CONFIG"; + WCHAR wzhKCC[] = L"HKCC";; + + while(hChild != NULL) + { + CString strKey = m_Tree.GetItemText(hChild); + + if ((!strHead.CompareNoCase(wzhKeyRoot) || !strHead.CompareNoCase(wzhKCR)) && + !strKey.CompareNoCase(wzhKeyRoot)) + { + strRoot = CLASSES_ROOT; + break; + } + else if ((!strHead.CompareNoCase(wzhKeyCurrentUser) || !strHead.CompareNoCase(wzhKCU)) && + !strKey.CompareNoCase(wzhKeyCurrentUser)) + { + strRoot = m_wzhKeyCurrentUser; + break; + } + else if ((!strHead.CompareNoCase(wzhKeyLocalMachine) || !strHead.CompareNoCase(wzhKLM)) && + !strKey.CompareNoCase(wzhKeyLocalMachine)) + { + strRoot = LOCAL_MACHINE; + break; + } + else if ((!strHead.CompareNoCase(wzhKeyUsers) || !strHead.CompareNoCase(wzhKU)) && + !strKey.CompareNoCase(wzhKeyUsers)) + { + strRoot = USERS; + break; + } + else if ((!strHead.CompareNoCase(wzhKeyCurrentConfig) || !strHead.CompareNoCase(wzhKCC)) && + !strKey.CompareNoCase(wzhKeyCurrentConfig)) + { + strRoot = CURRENT_CONFIGL; + break; + } + + hChild = m_Tree.GetNextSiblingItem(hChild); + } + + if (hChild == NULL || strRoot.IsEmpty()) + { + return; + } + + // չθHKEY_LOCAL_MACHINEHKEY_USERS + m_Tree.Expand(hChild, TVE_COLLAPSE); + EnumSubKeys(strRoot, hChild); + m_Tree.Expand(hChild, TVE_EXPAND); + + if (m_strComboText.Find(L"\\") != -1) + { + CString strKeyEnd = strKeyPath.GetBuffer() + strRoot.GetLength(); + strKeyPath.ReleaseBuffer(); + + if (strKeyEnd.IsEmpty()) + { + + return; + } + + strKeyEnd.TrimLeft('\\'); + + if (strKeyEnd.IsEmpty()) + { + + return; + } + + CString strTemp; + BOOL bQuiet = FALSE; + + do + { + strTemp = strKeyEnd.Left(strKeyEnd.Find('\\')); + + if (strTemp.IsEmpty()) + { + strTemp = strKeyEnd; + bQuiet = TRUE; + } + + hChild = GetTreeSubItemByName(hChild, strTemp); + if (hChild == NULL) + { + CString strMsgBox; + + strMsgBox = L""; + strMsgBox += L" \'" + m_strComboText + L"\'"; + MessageBox(strMsgBox, L"Registry", MB_OK | MB_ICONINFORMATION); + break; + } + + strRoot += L"\\" + strTemp; + + if (bQuiet) + { + EnumValues(strRoot); + m_Tree.Expand(hChild, TVE_EXPAND); + m_Tree.Select(hChild, TVGN_FIRSTVISIBLE); + m_Tree.SelectItem(hChild); + m_Tree.SetItemState(hChild, TVIS_DROPHILITED | TVIS_BOLD, TVIS_DROPHILITED | TVIS_BOLD); + //m_hChild = hChild; + } + else + { + EnumSubKeys(strRoot, hChild); + m_Tree.Expand(hChild, TVE_EXPAND); + } + + strKeyEnd = strKeyEnd.Right(strKeyEnd.GetLength() - strKeyEnd.Find('\\') - 1); + + } while (!bQuiet); + } +} + + + + +CString CRegisterManagerDlg::ComboString2KeyPath() +{ + CString strHead = m_strComboText.Left(m_strComboText.Find('\\')); + CString strRight = m_strComboText.Right(m_strComboText.GetLength() - m_strComboText.Find('\\')); + CString strKeyPath; + + if (strHead.IsEmpty()) + { + strHead = strRight; + strRight.Empty(); + } + + WCHAR wzhKeyRoot[] = L"HKEY_CLASSES_ROOT"; + WCHAR wzhKCR[] = L"HKCR"; + + WCHAR wzhKeyCurrentUser[] = L"HKEY_CURRENT_USER"; + WCHAR wzhKCU[] = L"HKCU"; + + WCHAR wzhKeyLocalMachine[] = L"HKEY_LOCAL_MACHINE"; + WCHAR wzhKLM[] = L"HKLM"; + + WCHAR wzhKeyUsers[] = L"HKEY_USERS"; + WCHAR wzhKU[] = L"HKU";; + + WCHAR wzhKeyCurrentConfig[] = L"HKEY_CURRENT_CONFIG"; + WCHAR wzhKCC[] = L"HKCC";; + + if (!strHead.CompareNoCase(wzhKeyRoot) || !strHead.CompareNoCase(wzhKCR)) + { + strKeyPath = CLASSES_ROOT; + } + else if (!strHead.CompareNoCase(wzhKeyCurrentUser) || !strHead.CompareNoCase(wzhKCU)) + { + strKeyPath = m_wzhKeyCurrentUser; + } + else if (!strHead.CompareNoCase(wzhKeyLocalMachine) || !strHead.CompareNoCase(wzhKLM)) + { + strKeyPath = LOCAL_MACHINE; + } + else if (!strHead.CompareNoCase(wzhKeyUsers) || !strHead.CompareNoCase(wzhKU)) + { + strKeyPath = USERS; + } + else if (!strHead.CompareNoCase(wzhKeyCurrentConfig) || !strHead.CompareNoCase(wzhKCC)) + { + strKeyPath = CURRENT_CONFIGL; + } + + strKeyPath += strRight; + strKeyPath.TrimRight('\\'); + + return strKeyPath; +} + + + +HTREEITEM CRegisterManagerDlg::GetTreeSubItemByName(HTREEITEM hPatentItem, CString strName) +{ + HTREEITEM hChild = m_Tree.GetChildItem(hPatentItem); + HTREEITEM hRetItem = NULL; + + while(hChild != NULL) + { + CString strKey = m_Tree.GetItemText(hChild); + + if (!strKey.CompareNoCase(strName)) + { + hRetItem = hChild; + break; + } + else if (!strKey.CompareNoCase(strName)) + { + hRetItem = hChild; + break; + } + else if (!strKey.CompareNoCase(strName)) + { + hRetItem = hChild; + break; + } + else if (!strKey.CompareNoCase(strName)) + { + hRetItem = hChild; + break; + } + else if (!strKey.CompareNoCase(strName)) + { + hRetItem = hChild; + break; + } + + hChild = m_Tree.GetNextSiblingItem(hChild); + } + + return hRetItem; +} + + +BOOL CRegisterManagerDlg::PreTranslateMessage(MSG* pMsg) +{ + if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) return TRUE; + + if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) + { + OnBnClickedGoto(); + return TRUE; + } + + + return CDialogEx::PreTranslateMessage(pMsg); +} + + + +void CRegisterManagerDlg::OnNMRClickTree(NMHDR *pNMHDR, LRESULT *pResult) +{ + + CPoint Point; + + GetCursorPos(&Point); + m_Tree.ScreenToClient(&Point); + + m_RightClickTreeItem = m_Tree.HitTest(Point, NULL); + CString strItemText; + + if ( m_RightClickTreeItem != NULL ) + { + strItemText = m_Tree.GetItemText(m_RightClickTreeItem); + m_Tree.SelectItem(m_RightClickTreeItem); + } + + + if (m_RightClickTreeItem == NULL || + !strItemText.CompareNoCase(L"ҵĵ")) + { + + } + + else + { + + CMenu ExMenu; + ExMenu.CreatePopupMenu(); + ExMenu.AppendMenu(MF_STRING, ID_STRING_VALUE,L"ֵַ"); + ExMenu.AppendMenu(MF_STRING, ID_BINARY_VALUE,L"ֵ"); + ExMenu.AppendMenu(MF_STRING, ID_DWORD_VALUE, L"DWORDֵ"); + ExMenu.AppendMenu(MF_STRING, ID_QWORD_VALUE, L"QWORDֵ"); + ExMenu.AppendMenu(MF_STRING, ID_MUI_STRING_VALUE,L"ֵַ"); + ExMenu.AppendMenu(MF_STRING, ID_EXPAND_STRING_VALUE,L"ֵַ"); + + + + CMenu Menu; + Menu.CreatePopupMenu(); + Menu.AppendMenu(MF_STRING, ID_REG_REFRESH,L"ˢ"); + Menu.AppendMenu(MF_SEPARATOR); + Menu.AppendMenu(MF_STRING, ID_REG_LOOK_FOR,L""); + Menu.AppendMenu(MF_SEPARATOR); + Menu.AppendMenu(MF_STRING, ID_REG_NEW_KEY,L"½"); + Menu.AppendMenu(MF_POPUP, (UINT)ExMenu.m_hMenu,L"½ֵ"); + Menu.AppendMenu(MF_SEPARATOR); + Menu.AppendMenu(MF_STRING, ID_REG_DELETE,L"ɾ"); + Menu.AppendMenu(MF_STRING, ID_REG_RENAME, L""); + + Menu.AppendMenu(MF_SEPARATOR); + Menu.AppendMenu(MF_STRING, ID_REG_INPORT,L""); + Menu.AppendMenu(MF_STRING, ID_REG_EXPORT,L""); + Menu.AppendMenu(MF_SEPARATOR); + + Menu.AppendMenu(MF_STRING, ID_REG_COPY_KEY_NAME,L""); + Menu.AppendMenu(MF_STRING, ID_REG_COPY_FULL_KEY_NAME,L"·"); + Menu.AppendMenu(MF_SEPARATOR); + Menu.AppendMenu(MF_STRING, ID_REG_ADD_TO_QUICK_ADDRESS,L"ӵٶλ"); + Menu.AppendMenu(MF_SEPARATOR); + int x = GetSystemMetrics(SM_CXMENUCHECK); + int y = GetSystemMetrics(SM_CYMENUCHECK); + + + if (x >= 15 && y >= 15) + { + Menu.SetMenuItemBitmaps(ID_REG_REFRESH, MF_BYCOMMAND, &m_bmRefresh, &m_bmRefresh); + Menu.SetMenuItemBitmaps(ID_REG_LOOK_FOR, MF_BYCOMMAND, &m_bmLookfor, &m_bmLookfor); + Menu.SetMenuItemBitmaps(ID_REG_DELETE, MF_BYCOMMAND, &m_bmDelete, &m_bmDelete); + + Menu.SetMenuItemBitmaps(ID_REG_COPY_KEY_NAME, MF_BYCOMMAND, &m_bmCopy, &m_bmCopy); + Menu.SetMenuItemBitmaps(ID_REG_COPY_FULL_KEY_NAME, MF_BYCOMMAND, &m_bmCopy, &m_bmCopy); + + + Menu.SetMenuItemBitmaps(ID_REG_INPORT, MF_BYCOMMAND, &m_bmExport, &m_bmExport); + Menu.SetMenuItemBitmaps(ID_REG_EXPORT, MF_BYCOMMAND, &m_bmExport, &m_bmExport); + } + + + if (!strItemText.CompareNoCase(L"HKEY_CLASSES_ROOT") || + !strItemText.CompareNoCase(L"HKEY_CURRENT_USER") || + !strItemText.CompareNoCase(L"HKEY_LOCAL_MACHINE") || + !strItemText.CompareNoCase(L"HKEY_USERS") || + !strItemText.CompareNoCase(L"HKEY_CURRENT_CONFIG") ) + { + Menu.EnableMenuItem(ID_REG_DELETE, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + Menu.EnableMenuItem(ID_REG_RENAME, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + } + + CPoint Point; + GetCursorPos(&Point); + Menu.TrackPopupMenu(TPM_RIGHTBUTTON, Point.x, Point.y, this); + Menu.DestroyMenu(); + ExMenu.DestroyMenu(); + } + + + + *pResult = 0; +} + + +void CRegisterManagerDlg::OnRegRefresh() +{ + CString strItemText; + + if ( m_RightClickTreeItem != NULL ) + { + strItemText = m_Tree.GetItemText(m_RightClickTreeItem); + } + + // computerôֱӳʼע + if (m_RightClickTreeItem == NULL || + !strItemText.CompareNoCase(L"ҵĵ")) + { + InitRegistry(); + } + else + { + // Ǵ״̬ˢ + if(m_RightClickTreeItem != NULL && + (TVIS_EXPANDED & m_Tree.GetItemState(m_RightClickTreeItem, TVIS_EXPANDED))) + { + m_Tree.Expand(m_RightClickTreeItem, TVE_COLLAPSE); + DeleteSubTree(m_RightClickTreeItem); + + HTREEITEM hItemTemp = m_RightClickTreeItem; + CString strKeyPath, strKeyPathTemp; + + while (1) + { + CString strText = m_Tree.GetItemText(hItemTemp); + + if (!strText.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strKeyPath = CLASSES_ROOT; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strKeyPath = m_wzhKeyCurrentUser; + break; + } + else if (!strText.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strKeyPath = LOCAL_MACHINE; + break; + } + else if (!strText.CompareNoCase(L"HKEY_USERS")) + { + strKeyPath = USERS; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strKeyPath = CURRENT_CONFIGL; + break; + } + else + { + strKeyPathTemp = strText + L"\\" + strKeyPathTemp; + } + + hItemTemp = m_Tree.GetParentItem(hItemTemp); + } + + strKeyPath = strKeyPath + L"\\" + strKeyPathTemp; + EnumSubKeys(strKeyPath, m_RightClickTreeItem); + EnumSubSubKeys(strKeyPath, m_RightClickTreeItem); + + m_Tree.Expand(m_RightClickTreeItem, TVE_EXPAND); + } + } +} + + + + + +void CRegisterManagerDlg::OnRegNewKey() +{ + CString strKeyPath = String2KeyPath(); + if (strKeyPath.IsEmpty()) + { + return; + } + + CKeyDlg CreateKeyDlg; //Dlg ½ ԶһDlgType + CString strNewKey; + + CreateKeyDlg.m_nDlgType = enumCreateKey; + if (CreateKeyDlg.DoModal() == IDOK) + { + strNewKey = CreateKeyDlg.m_strKeyNameEdit; + } + + if (strNewKey.IsEmpty()) + { + return; + } + + CString strKeyPathTemp = strKeyPath + L"\\"; + strKeyPathTemp += strNewKey; + + UNICODE_STRING uniKey; + if (InitUnicodeString(&uniKey, strKeyPathTemp.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + ULONG Disposition = 0; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (CreateKey(&hKey, KEY_ALL_ACCESS, &oa, 0, NULL, 0, &Disposition)) + { + if (Disposition == REG_OPENED_EXISTING_KEY) + { + MessageBox(L"üѾ",L"Shine", MB_ICONERROR | MB_OK); + } + else + { + + HTREEITEM hItem = m_Tree.GetSelectedItem(); + m_Tree.InsertItem(strNewKey, 1, 2, hItem, TVI_LAST); + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } +} + + + + +CString CRegisterManagerDlg::String2KeyPath() +{ + CString strHead = m_strComboText.Left(m_strComboText.Find('\\')); + CString strRight = m_strComboText.Right(m_strComboText.GetLength() - m_strComboText.Find('\\')); + CString strKeyPath; + + if (strHead.IsEmpty()) + { + strHead = strRight; + strRight.Empty(); + } + + if (!strHead.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strKeyPath = CLASSES_ROOT; + } + else if (!strHead.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strKeyPath = m_wzhKeyCurrentUser; + } + else if (!strHead.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strKeyPath = LOCAL_MACHINE; + } + else if (!strHead.CompareNoCase(L"HKEY_USERS")) + { + strKeyPath = USERS; + } + else if (!strHead.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strKeyPath = CURRENT_CONFIGL; + } + + strKeyPath += strRight; + + return strKeyPath; +} + + + +BOOL CRegisterManagerDlg::CreateKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG ulTitleIndex, + IN PUNICODE_STRING uniClass, + IN ULONG ulCreateOptions, + OUT PULONG Disposition + ) + +{ + + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + + struct{ + ACCESS_MASK DesiredAccess; + POBJECT_ATTRIBUTES ObjectAttributes; + }Create; + + memset(&Create, 0, sizeof(Create)); + Create.DesiredAccess = DesiredAccess; + Create.ObjectAttributes = ObjectAttributes; + + + + typedef struct _CREATE_VALUE_ + { + PHANDLE KeyHandle; + PULONG Disposition; + }CREATE_VALUE, *PCREATE_VALUE; + + + CREATE_VALUE CreateValue; + memset(&CreateValue, 0, sizeof(CREATE_VALUE)); + + + CreateValue.KeyHandle = KeyHandle; + CreateValue.Disposition = Disposition; + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + + + dwRet = DeviceIoControl(g_hDevice,CTL_CREATE_KEY, + &Create, + sizeof(Create), + &CreateValue, + sizeof(CREATE_VALUE), + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; +} + + +void CRegisterManagerDlg::OnStringValue() +{ + SetValueKey(REG_SZ,NULL,0); +} + + + + +void CRegisterManagerDlg::SetValueKey(ULONG ulType, PVOID Data, ULONG ulDataSize) +{ + CString strKeyPath = String2KeyPath(); + if (strKeyPath.IsEmpty()) + { + return; + } + + CKeyDlg SetValueKeyDlg; + CString strValue; + + SetValueKeyDlg.m_nDlgType = enumSetValueKey; + if (SetValueKeyDlg.DoModal() == IDOK) + { + strValue = SetValueKeyDlg.m_strKeyNameEdit; + } + + if (strValue.IsEmpty()) + { + return; + } + + UNICODE_STRING uniKey; + if (InitUnicodeString(&uniKey, strKeyPath.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + UNICODE_STRING uniValue; + + if (InitUnicodeString(&uniValue, strValue.GetBuffer())) + { + SetValueKey(hKey, &uniValue, 0, ulType, Data, ulDataSize); + FreeUnicodeString(&uniValue); + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + + OnRegListRefresh(); //ˢControlList +} + + + + +BOOL CRegisterManagerDlg::SetValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniValueName, + IN ULONG ulTitleIndex, + IN ULONG ulType, + IN PVOID Data, + IN ULONG ulDataSize + ) +{ + + + + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + + struct{ + HANDLE hKey; + PUNICODE_STRING ValueName; + ULONG Type; + PVOID Data; + ULONG DataSize; + }Set; + + memset(&Set, 0, sizeof(Set)); + + Set.hKey = KeyHandle; + Set.ValueName = uniValueName; + Set.Type = ulType; + Set.Data = Data; + Set.DataSize = ulDataSize; + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + + + dwRet = DeviceIoControl(g_hDevice,CTL_SET_KEY_VALUE, + &Set, + sizeof(Set), + NULL,0, + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; +} + + + +void CRegisterManagerDlg::OnRegListRefresh() +{ + CString strKeyPath = String2KeyPath(); + EnumValues(strKeyPath); +} + +void CRegisterManagerDlg::OnBinaryValue() +{ + SetValueKey(REG_BINARY,NULL,0); +} + + +void CRegisterManagerDlg::OnDwordValue() +{ + DWORD dwValue = 0; + SetValueKey(REG_DWORD,&dwValue,sizeof(DWORD)); +} + + +void CRegisterManagerDlg::OnQwordValue() +{ + QWORD dwValue = 0; + SetValueKey(REG_QWORD,&dwValue,sizeof(QWORD)); +} + +void CRegisterManagerDlg::OnMuiStringValue() +{ + SetValueKey(REG_MULTI_SZ,NULL,0); +} + + +void CRegisterManagerDlg::OnExpandStringValue() +{ + SetValueKey(REG_EXPAND_SZ,NULL,0); +} + + + +void CRegisterManagerDlg::OnRegDelete() +{ + if (m_RightClickTreeItem != NULL) + { + if (MessageBox(L"ȷɾ",L"Shine", MB_YESNO | MB_ICONQUESTION) != IDYES) + { + return; + } + + HTREEITEM hItemTemp = m_RightClickTreeItem; + CString strKeyPath, strKeyPathTemp; + + while (1) + { + CString strText = m_Tree.GetItemText(hItemTemp); + + if (!strText.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strKeyPath = CLASSES_ROOT; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strKeyPath = m_wzhKeyCurrentUser; + break; + } + else if (!strText.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strKeyPath = LOCAL_MACHINE; + break; + } + else if (!strText.CompareNoCase(L"HKEY_USERS")) + { + strKeyPath = USERS; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strKeyPath = CURRENT_CONFIGL; + break; + } + else + { + strKeyPathTemp = strText + L"\\" + strKeyPathTemp; + } + + hItemTemp = m_Tree.GetParentItem(hItemTemp); + } + + strKeyPath = strKeyPath + L"\\" + strKeyPathTemp; + strKeyPath.TrimRight('\\'); + + m_Tree.Expand(m_RightClickTreeItem, TVE_COLLAPSE); + DeleteKeyAndSubKeys(strKeyPath); + UpdateKey(strKeyPath, m_RightClickTreeItem); //ˢTreeؼ + } +} + + + +void CRegisterManagerDlg::DeleteKeyAndSubKeys(CString strKey) +{ + if (strKey.IsEmpty()) + { + return; + } + + UNICODE_STRING uniKey; + BOOL bQuit = FALSE; + if (InitUnicodeString(&uniKey, strKey.GetBuffer())) + { + strKey.ReleaseBuffer(); + + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + ULONG i = 0; + while (1) + { + if (bQuit) + { + break; + } + + ULONG ulRetLen = 0; + BOOL bRet = EnumerateKey(hKey, i, KeyBasicInformation, NULL, 0, &ulRetLen); + if (!bRet && GetLastError() == ERROR_NO_MORE_ITEMS) // STATUS_NO_MORE_ENTRIES + { + if (!DeleteKey(hKey) ) + { + + bQuit = TRUE; + } + + break; + } + else if (!bRet && GetLastError() == ERROR_INSUFFICIENT_BUFFER) // STATUS_BUFFER_TOO_SMALL + { + PKEY_BASIC_INFORMATION Buffer = (PKEY_BASIC_INFORMATION)malloc(ulRetLen + 100); + + if (Buffer) + { + memset(Buffer, 0, ulRetLen + 100); + bRet = EnumerateKey(hKey, i, KeyBasicInformation, Buffer, ulRetLen + 100, &ulRetLen); + + if (bRet && Buffer->NameLength) + { + WCHAR wzName[1024] = {0}; + wcsncpy_s(wzName, 1024, Buffer->Name, Buffer->NameLength / sizeof(WCHAR)); + CString strKeyTemp = strKey + L"\\" + wzName; + DeleteKeyAndSubKeys(strKeyTemp); + } + else + { + break; + } + + free(Buffer); + } + } + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } +} + + +BOOL CRegisterManagerDlg::DeleteKey(IN HANDLE KeyHandle) +{ + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + struct + { + HANDLE hKey; + }Delete; + + memset(&Delete, 0, sizeof(Delete)); + Delete.hKey = KeyHandle; + + + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + + + dwRet = DeviceIoControl(g_hDevice,CTL_DELETE_KEY, + &Delete, + sizeof(Delete), + NULL,0, + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; +} + + + +void CRegisterManagerDlg::UpdateKey(CString strKey, HTREEITEM hItem) +{ + if ( !strKey.IsEmpty() && hItem != NULL ) + { + DeleteSubTree(hItem); + + UNICODE_STRING uniKey; + + if (InitUnicodeString(&uniKey, strKey.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + for (ULONG i = 0; ; i++) + { + ULONG ulRetLen = 0; + BOOL bRet = EnumerateKey(hKey, i, KeyBasicInformation, NULL, 0, &ulRetLen); + + if (!bRet && GetLastError() == ERROR_NO_MORE_ITEMS) + { + break; + } + else if (!bRet && GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + PKEY_BASIC_INFORMATION Buffer = (PKEY_BASIC_INFORMATION)malloc(ulRetLen + 0x100); + if (Buffer) + { + memset(Buffer, 0, ulRetLen + 0x100); + bRet = EnumerateKey(hKey, i, KeyBasicInformation, Buffer, ulRetLen + 0x100, &ulRetLen); + + if (bRet) + { + m_Tree.InsertItem(Buffer->Name, 1, 2, hItem, TVI_LAST); + } + + free(Buffer); + } + } + } + + CloseHandle(hKey); + } + else + { + m_Tree.DeleteItem(hItem); + } + + FreeUnicodeString(&uniKey); + } + } +} + +void CRegisterManagerDlg::OnRegRename() +{ + CString strKeyPath = String2KeyPath(); + if (strKeyPath.IsEmpty()) + { + return; + } + + CString strKeyName = m_Tree.GetItemText(m_RightClickTreeItem); + CKeyDlg RenameKeyDlg; + RenameKeyDlg.m_nDlgType = enumRenameKey; + RenameKeyDlg.m_strKeyNameEdit = strKeyName; + if (RenameKeyDlg.DoModal() == IDOK) + { + CString strNewKeyName = RenameKeyDlg.m_strKeyNameEdit; + if (strNewKeyName.CompareNoCase(strKeyName)) //ֲ + { + UNICODE_STRING uniKey; + if (strNewKeyName.GetBuffer()!=NULL) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + HTREEITEM hItemTemp = m_RightClickTreeItem; + CString strKeyPath, strKeyPathTemp; + while (1) + { + CString strText = m_Tree.GetItemText(hItemTemp); + + if (!strText.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strKeyPath = CLASSES_ROOT; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strKeyPath = m_wzhKeyCurrentUser; + break; + } + else if (!strText.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strKeyPath = LOCAL_MACHINE; + break; + } + else if (!strText.CompareNoCase(L"HKEY_USERS")) + { + strKeyPath = USERS; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strKeyPath = CURRENT_CONFIGL; + break; + } + else + { + strKeyPathTemp = strText + L"\\" + strKeyPathTemp; + } + + hItemTemp = m_Tree.GetParentItem(hItemTemp); + } + + strKeyPath = strKeyPath + L"\\" + strKeyPathTemp; + + InitUnicodeString(&uniKey, strKeyPath.GetBuffer()); + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + UNICODE_STRING uniNewKey; + if (InitUnicodeString(&uniNewKey,strNewKeyName.GetBuffer())) + { + if (RenameKey(hKey, &uniNewKey)) + { + m_Tree.SetItemText(m_RightClickTreeItem, strNewKeyName); //ؼ޸ijµ + + + //ComboBox + CString strTemp = m_strComboText.Left(m_strComboText.ReverseFind('\\')); + + strTemp+=L"\\"; + + strTemp+=strNewKeyName; + + + m_ComboBox.SetWindowText(strTemp); + + + } + + FreeUnicodeString(&uniNewKey); + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + } + } +} + + +BOOL CRegisterManagerDlg::RenameKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniNewName + ) +{ + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + + struct + { + HANDLE hKey; + PUNICODE_STRING uniNewName; + }Rename; + + memset(&Rename, 0, sizeof(Rename)); + + Rename.hKey = KeyHandle; + Rename.uniNewName = uniNewName; + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + + + dwRet = DeviceIoControl(g_hDevice,CTL_RENAME_KEY, + &Rename, + sizeof(Rename), + NULL,0, + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; +} + + + +void CRegisterManagerDlg::OnRegCopyKeyName() +{ + UpdateData(TRUE); + CString strKeyName = m_strComboText.Right(m_strComboText.GetLength() - m_strComboText.ReverseFind('\\') - 1); + if (strKeyName.IsEmpty()) + { + strKeyName = m_strComboText; + } + + SetStringToClipboard(strKeyName); +} + + +void CRegisterManagerDlg::OnRegCopyFullKeyName() +{ + UpdateData(TRUE); + SetStringToClipboard(m_strComboText); +} + + + +BOOL CRegisterManagerDlg::SetStringToClipboard(CString strImageName) +{ + if (strImageName.IsEmpty()) + { + return TRUE; + } + + BOOL bRet = FALSE; + + if( OpenClipboard() ) + { + HGLOBAL hClipBuffer = 0; + WCHAR* wzBuffer = NULL; + + EmptyClipboard(); + hClipBuffer = LocalAlloc(GMEM_ZEROINIT, (strImageName.GetLength() + 1) * sizeof(WCHAR)); + if (hClipBuffer) + { + wzBuffer = (WCHAR*)GlobalLock(hClipBuffer); + if (wzBuffer) + { + wcsncpy_s(wzBuffer, strImageName.GetLength() + 1, strImageName.GetBuffer(), strImageName.GetLength()); + strImageName.ReleaseBuffer(); + SetClipboardData(CF_UNICODETEXT, hClipBuffer); + GlobalUnlock(hClipBuffer); + + bRet = TRUE; + } + } + + CloseClipboard(); + } + + return bRet; +} + + +void CRegisterManagerDlg::OnRegAddToQuickAddress() +{ + UpdateData(TRUE); + if (!m_strComboText.IsEmpty()) + { + m_RegPathList.push_back(m_strComboText); + m_nComboBoxCnt++; + + UpdateData(FALSE); + } +} + + +void CRegisterManagerDlg::OnRegInport() +{ + CFileDialog FileDlg(TRUE); + FileDlg.m_ofn.lpstrTitle = L"Open Register File"; + FileDlg.m_ofn.lpstrFilter = L"Registration Files(*.reg)\0*.reg\0\0"; + + if (IDOK == FileDlg.DoModal()) + { + CString strPath = FileDlg.GetPathName(); + ShellImportRegister(strPath); + + MessageBox(L"ɹ",L"Shine", MB_OK | MB_ICONINFORMATION); + + OnRegRefresh(); + } +} + + +VOID CRegisterManagerDlg::ShellImportRegister( + LPCTSTR ImportFile) //עļ +{ + CString strItem(ImportFile); + CString strParameters; + strParameters = L"/s \"" + strItem + L"\""; + ShellExecute(NULL, L"open", L"regedit.exe", + strParameters, NULL, SW_HIDE); + +} + +void CRegisterManagerDlg::OnRegExport() +{ + CString strItemText; + + if ( m_RightClickTreeItem != NULL ) + { + strItemText = m_Tree.GetItemText(m_RightClickTreeItem); + + if (strItemText.CompareNoCase(L"ҵĵ")) + { + HTREEITEM hItemTemp = m_RightClickTreeItem; + CString strKeyPath, strKeyPathTemp; + + while (1) + { + CString strText = m_Tree.GetItemText(hItemTemp); + + if (!strText.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strKeyPath = L"HKEY_CLASSES_ROOT"; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strKeyPath = m_wzhKeyCurrentUser; + break; + } + else if (!strText.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strKeyPath = L"HKEY_LOCAL_MACHINE"; + break; + } + else if (!strText.CompareNoCase(L"HKEY_USERS")) + { + strKeyPath = L"HKEY_USERS"; + break; + } + else if (!strText.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strKeyPath = L"HKEY_CURRENT_CONFIG"; + break; + } + else + { + strKeyPathTemp = strText + L"\\" + strKeyPathTemp; + } + + hItemTemp = m_Tree.GetParentItem(hItemTemp); + } + + strKeyPath = strKeyPath + L"\\" + strKeyPathTemp; + strKeyPath.TrimRight('\\'); + + CString strFileName = strKeyPath.Right(strKeyPath.GetLength() - strKeyPath.ReverseFind(L'\\') - 1); + CFileDialog FileDlg( FALSE, 0, strFileName, 0, L"Register Files (*.reg)|*.reg;|All Files (*.*)|*.*||", 0 ); + if (IDOK == FileDlg.DoModal()) + { + CString strFilePath = FileDlg.GetFileName(); + CString strExtern = strFilePath.Right(4); + + + + if (strExtern.CompareNoCase(L".reg")) + { + strFilePath += L".reg"; + } + + if ( !PathFileExists(strFilePath) || + (PathFileExists(strFilePath) && + MessageBox(L"ļѾ",L"Shine", MB_YESNO | MB_ICONQUESTION) == IDYES && + DeleteFile(strFilePath))) + { + ShellExportRegister(strKeyPath, strFilePath); + + MessageBox(L"ɹ",L"Shine", MB_OK | MB_ICONINFORMATION); + } + } + } + } +} + + +VOID CRegisterManagerDlg::ShellExportRegister( + CString strItem, + CString strFileName) +{ + CString strParameters = L"/e \"" + strFileName + L"\" \"" + strItem + L"\""; + ShellExecute(0, L"open", L"regedit.exe", strParameters, NULL, SW_SHOWNORMAL); +} + + +void CRegisterManagerDlg::OnRegLookFor() +{ + m_FindRegDlg = new CRegFindDlg(); + m_FindRegDlg->m_strSearchInKey = m_strComboText; + m_FindRegDlg->Create(IDD_FIND_REG_DIALOG); + m_FindRegDlg->ShowWindow(SW_SHOWNORMAL); +} + + + +void CRegisterManagerDlg::JmpToReg(CString strKey, CString strData) +{ + if (strKey.IsEmpty()) + { + return; + } + + JmpToRegCommon(strKey, strData); +} + + +void CRegisterManagerDlg::JmpToRegCommon(CString strKey, CString strData) +{ + HTREEITEM hRootItem = m_Tree.GetRootItem(); + if (hRootItem == NULL) + { + return; + } + + HTREEITEM hChild = m_Tree.GetChildItem(hRootItem); + CString strRoot; + + while(hChild != NULL) + { + CString strKeyTemp = m_Tree.GetItemText(hChild); + + if (!_wcsnicmp(strKey.GetBuffer(), L"HKEY_CLASSES_ROOT", wcslen(L"HKEY_CLASSES_ROOT")) && + !strKeyTemp.CompareNoCase(L"HKEY_CLASSES_ROOT")) + { + strRoot = CLASSES_ROOT; + break; + } + else if (!_wcsnicmp(strKey.GetBuffer(), L"HKEY_CURRENT_USER", wcslen(L"HKEY_CURRENT_USER")) && + !strKeyTemp.CompareNoCase(L"HKEY_CURRENT_USER")) + { + strRoot = m_wzhKeyCurrentUser; + break; + } + else if (!_wcsnicmp(strKey.GetBuffer(), L"HKEY_LOCAL_MACHINE", wcslen(L"HKEY_LOCAL_MACHINE")) && + !strKeyTemp.CompareNoCase(L"HKEY_LOCAL_MACHINE")) + { + strRoot = LOCAL_MACHINE; + break; + } + else if (!_wcsnicmp(strKey.GetBuffer(), L"HKEY_USERS", wcslen(L"HKEY_USERS")) && + !strKeyTemp.CompareNoCase(L"HKEY_USERS")) + { + strRoot = USERS; + break; + } + else if (!_wcsnicmp(strKey.GetBuffer(), L"HKEY_CURRENT_CONFIG", wcslen(L"HKEY_CURRENT_CONFIG")) && + !strKeyTemp.CompareNoCase(L"HKEY_CURRENT_CONFIG")) + { + strRoot = CURRENT_CONFIGL; + break; + } + + hChild = m_Tree.GetNextSiblingItem(hChild); + } + + if (hChild == NULL || strRoot.IsEmpty()) + { + return; + } + + m_Tree.Expand(hChild, TVE_COLLAPSE); + EnumSubKeys(strRoot, hChild); + m_Tree.Expand(hChild, TVE_EXPAND); + + if (strKey.Find(L"\\") != -1) + { + CString strKeyEnd = strKey.Right(strKey.GetLength() - strKey.Find('\\') - 1); + + if (strKeyEnd.IsEmpty()) + { + return; + } + + strKeyEnd.TrimLeft('\\'); + + if (strKeyEnd.IsEmpty()) + { + return; + } + + CString strTemp; + BOOL bQuiet = FALSE; + + do + { + strTemp = strKeyEnd.Left(strKeyEnd.Find('\\')); + + if (strTemp.IsEmpty()) + { + strTemp = strKeyEnd; + bQuiet = TRUE; + } + + hChild = GetTreeSubItemByName(hChild, strTemp); + if (hChild == NULL) + { + CString strMsgBox; + + strMsgBox = L""; + strMsgBox += L" \'" + strKey + L"\'"; + MessageBox(strMsgBox, L"Shine", MB_OK | MB_ICONINFORMATION); + break; + } + + strRoot += L"\\" + strTemp; + + if (bQuiet) + { + EnumValues(strRoot); + m_Tree.Expand(hChild, TVE_EXPAND); + m_Tree.Select(hChild, TVGN_FIRSTVISIBLE); + m_Tree.SelectItem(hChild); + m_Tree.SetItemState(hChild, TVIS_DROPHILITED | TVIS_BOLD, TVIS_DROPHILITED | TVIS_BOLD); + + if (!strData.IsEmpty()) + { + DWORD dwCnt = m_List.GetItemCount(); + for (DWORD i = 0; i < dwCnt; i++) + { + if (!(m_List.GetItemText(i, 0)).CompareNoCase(strData)) + { + m_List.EnsureVisible(i, false); + m_List.SetItemState(i, LVIS_FOCUSED | LVIS_SELECTED,LVIS_FOCUSED | LVIS_SELECTED); + m_List.SetFocus(); + break; + } + } + } + + break; + } + else + { + EnumSubKeys(strRoot, hChild); + m_Tree.Expand(hChild, TVE_EXPAND); + } + + strKeyEnd = strKeyEnd.Right(strKeyEnd.GetLength() - strKeyEnd.Find('\\') - 1); + + } while (!bQuiet); + } +} + +void CRegisterManagerDlg::OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast(pNMHDR); + + if (!m_strComboText.IsEmpty()) + { + + + CMenu Menu; + Menu.CreatePopupMenu(); + Menu.AppendMenu(MF_STRING, ID_REG_LIST_REFRESH,L"ˢ"); + + Menu.AppendMenu(MF_SEPARATOR); + Menu.AppendMenu(MF_STRING, ID_REG_LIST_MODIFY,L"޸"); + Menu.AppendMenu(MF_STRING, ID_REG_LIST_DELETE, L"ɾ"); + Menu.AppendMenu(MF_STRING, ID_REG_LIST_RENAME, L""); + Menu.AppendMenu(MF_SEPARATOR); + Menu.AppendMenu(MF_STRING, ID_REG_LIST_COPY_VALUE, L"ֵ"); + Menu.AppendMenu(MF_STRING, ID_REG_LIST_COPY_VALUE_DATA,L"ֵ"); + + Menu.AppendMenu(MF_SEPARATOR); + + + int x = GetSystemMetrics(SM_CXMENUCHECK); + int y = GetSystemMetrics(SM_CYMENUCHECK); + if (x >= 15 && y >= 15) + { + Menu.SetMenuItemBitmaps(ID_REG_LIST_REFRESH, MF_BYCOMMAND, &m_bmRefresh, &m_bmRefresh); + Menu.SetMenuItemBitmaps(ID_REG_LIST_DELETE, MF_BYCOMMAND, &m_bmDelete, &m_bmDelete); + Menu.SetMenuItemBitmaps(ID_REG_LIST_COPY_VALUE, MF_BYCOMMAND, &m_bmCopy, &m_bmCopy); + Menu.SetMenuItemBitmaps(ID_REG_LIST_COPY_VALUE_DATA, MF_BYCOMMAND, &m_bmCopy, &m_bmCopy); + } + + if (m_List.GetSelectedCount() == 0) + { + Menu.EnableMenuItem(ID_REG_LIST_MODIFY, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + Menu.EnableMenuItem(ID_REG_LIST_DELETE, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + Menu.EnableMenuItem(ID_REG_LIST_RENAME, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + Menu.EnableMenuItem(ID_REG_LIST_COPY_VALUE, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + Menu.EnableMenuItem(ID_REG_LIST_COPY_VALUE_DATA, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + } + else if (m_List.GetSelectedCount() == 1) + { + int nItem = m_List.GetSelectionMark(); + if (nItem != -1) + { + if (m_List.GetItemData(nItem)) + { + Menu.EnableMenuItem(ID_REG_LIST_RENAME, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + + if (!(m_List.GetItemText(nItem, 2)).CompareNoCase(L"(ֵδ)")) + { + Menu.EnableMenuItem(ID_REG_LIST_DELETE, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED); + } + } + } + } + + CPoint Point; + GetCursorPos(&Point); + Menu.TrackPopupMenu(TPM_RIGHTBUTTON, Point.x, Point.y, this); + Menu.DestroyMenu(); + + } + + *pResult = 0; +} + + +void CRegisterManagerDlg::OnRegListModify() +{ + int nItem = m_List.GetSelectionMark(); + if (nItem != -1) + { + CString strType = m_List.GetItemText(nItem, 1); + + if (strType.Find(L"SZ") != -1) + { + CString strValue = m_List.GetItemText(nItem, 0); + CString strData = m_List.GetItemText(nItem, 2); + + if (m_List.GetItemData(nItem) && !strData.CompareNoCase(L"(ֵδ)")) + { + strData = L""; + } + + CRegModifyDlg RegModifyDlg; + RegModifyDlg.m_strValueDataEdit = strData; + RegModifyDlg.m_strValueNameEdit = strValue; + + if (RegModifyDlg.DoModal() == IDOK) + { + CString strDataNew = RegModifyDlg.m_strValueDataEdit; + if (m_List.GetItemData(nItem)) + { + strValue = L""; + } + + ModifyValue(strValue,GetValueType(m_List.GetItemText(nItem, 1)),strDataNew.GetBuffer(), strDataNew.GetLength() * sizeof(WCHAR)); + OnRegListRefresh(); + } + } + else if (!strType.CompareNoCase(L"REG_DWORD")) + { + CString strValue = m_List.GetItemText(nItem, 0); + CString strData = m_List.GetItemText(nItem, 2); + + CString strShowData; + strShowData.Format(L"%ld", HexStringToLong(strData)); + + CRegModifyDlg RegModifyDlg; + RegModifyDlg.m_strValueDataEdit = strShowData; + RegModifyDlg.m_strValueNameEdit = strValue; + + if (RegModifyDlg.DoModal() == IDOK) + { + CString strDataNew = RegModifyDlg.m_strValueDataEdit; + DWORD dwData = 0; + + + + swscanf_s(strDataNew.GetBuffer(0), L"%x", &dwData); + + + + ModifyValue(strValue, GetValueType(m_List.GetItemText(nItem, 1)), &dwData, sizeof(DWORD)); + OnRegListRefresh(); + } + } + + else if (!strType.CompareNoCase(L"REG_QWORD")) + { + CString strValue = m_List.GetItemText(nItem, 0); + CString strData = m_List.GetItemText(nItem, 2); + + CString strShowData; + strShowData.Format(L"%ld", HexStringToLong(strData)); + + CRegModifyDlg RegModifyDlg; + RegModifyDlg.m_strValueDataEdit = strShowData; + RegModifyDlg.m_strValueNameEdit = strValue; + + if (RegModifyDlg.DoModal() == IDOK) + { + CString strDataNew = RegModifyDlg.m_strValueDataEdit; + LONGLONG dwData = 0; + + + + swscanf_s(strDataNew.GetBuffer(0), L"%p", &dwData); + + + + ModifyValue(strValue, GetValueType(m_List.GetItemText(nItem, 1)), &dwData, sizeof(LONGLONG)); + OnRegListRefresh(); + } + } + + + + else if (!strType.CompareNoCase(L"REG_BINARY") || + !strType.CompareNoCase(L"REG_RESOURCE_REQUIREMENTS_LIST") || + !strType.CompareNoCase(L"REG_FULL_RESOURCE_DESCRIPTOR") || + !strType.CompareNoCase(L"REG_RESOURCE_LIST")) + { + CString strValue = m_List.GetItemText(nItem, 0); + CString strData = m_List.GetItemText(nItem, 2); + ULONG ulLen = strData.GetLength() + strData.GetLength() % 2 + 10; + PBYTE Data = (PBYTE)malloc(ulLen); + ULONG ulDataLen = 0; + + if (Data) + { + memset(Data, 0, ulLen); + int n = strData.Find(' '); + while (n != -1) + { + swscanf_s(strData, L"%2x", &Data[ulDataLen++]); + strData = strData.Right(strData.GetLength() - n - 1); + n = strData.Find(' '); + } + + CRegHexEditDlg EditDlg; + EditDlg.m_Data = Data; + EditDlg.m_DataLen = ulDataLen; + EditDlg.m_strValueNameEdit = strValue; + + if (EditDlg.DoModal() == IDOK) + { + PBYTE RetData = EditDlg.m_RetData; + ULONG RetLen = EditDlg.m_RetLen; + if (RetData && RetLen) + { + ModifyValue(strValue, GetValueType(m_List.GetItemText(nItem, 1)),RetData, RetLen); + OnRegListRefresh(); + } + + if (RetData) + { + free(RetData); + } + } + + if (Data) + { + free(Data); + Data = NULL; + } + } + } + } +} + +ULONG CRegisterManagerDlg::GetValueType(CString strType) +{ + ULONG ulRet = 0; + if (strType.IsEmpty()) + { + return 0; + } + + if (!strType.CompareNoCase(L"REG_NONE")) + { + ulRet = REG_NONE; + } + else if (!strType.CompareNoCase(L"REG_SZ")) + { + ulRet = REG_SZ; + } + else if (!strType.CompareNoCase(L"REG_EXPAND_SZ")) + { + ulRet = REG_EXPAND_SZ; + } + else if (!strType.CompareNoCase(L"REG_BINARY")) + { + ulRet = REG_BINARY; + } + else if (!strType.CompareNoCase(L"REG_DWORD")) + { + ulRet = REG_DWORD; + } + else if (!strType.CompareNoCase(L"REG_DWORD_BIG_ENDIAN")) + { + ulRet = REG_DWORD_BIG_ENDIAN; + } + else if (!strType.CompareNoCase(L"REG_LINK")) + { + ulRet = REG_LINK; + } + else if (!strType.CompareNoCase(L"REG_MULTI_SZ")) + { + ulRet = REG_MULTI_SZ; + } + else if (!strType.CompareNoCase(L"REG_RESOURCE_LIST")) + { + ulRet = REG_RESOURCE_LIST; + } + else if (!strType.CompareNoCase(L"REG_FULL_RESOURCE_DESCRIPTOR")) + { + ulRet = REG_FULL_RESOURCE_DESCRIPTOR; + } + else if (!strType.CompareNoCase(L"REG_RESOURCE_REQUIREMENTS_LIST")) + { + ulRet = REG_RESOURCE_REQUIREMENTS_LIST; + } + else if (!strType.CompareNoCase(L"REG_QWORD")) + { + ulRet = REG_QWORD; + } + else if (!strType.CompareNoCase(L"Unknow")) + { + ulRet = 0; + } + + return ulRet; +} + + + +void CRegisterManagerDlg::ModifyValue(CString strValue, ULONG ulType, PVOID Data, ULONG ulDataSize) +{ + CString strKeyPath = String2KeyPath(); + + if (!strKeyPath.IsEmpty()) + { + UNICODE_STRING uniKey; + if (InitUnicodeString(&uniKey, strKeyPath.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + if (strValue.IsEmpty()) + { + UNICODE_STRING uniValue; + uniValue.Buffer = NULL; + uniValue.Length = 0; + uniValue.MaximumLength = 2; + + if (SetValueKey(hKey, &uniValue, 0, ulType,Data, ulDataSize)) + { + + } + } + else + { + UNICODE_STRING uniValue; + if (InitUnicodeString(&uniValue, strValue.GetBuffer())) + { + SetValueKey(hKey, &uniValue, 0, ulType, Data, ulDataSize); + FreeUnicodeString(&uniValue); + } + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + } +} + + +void CRegisterManagerDlg::OnRegListDelete() +{ + int nItem = m_List.GetSelectionMark(); + if (nItem != -1) + { + CString strValue = m_List.GetItemText(nItem, 0); + CString strKeyPath = String2KeyPath(); + + if (!strKeyPath.IsEmpty()) + { + if (MessageBox(L"ȷɾ",L"Shine", MB_ICONQUESTION | MB_YESNO) != IDYES) + { + return; + } + + UNICODE_STRING uniKey; + BOOL bOk = FALSE; + if (InitUnicodeString(&uniKey, strKeyPath.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + UNICODE_STRING uniValue; + + if (m_List.GetItemData(nItem)) + { + uniValue.Buffer = NULL; + uniValue.Length = 0; + uniValue.MaximumLength = 2; + + bOk = DeleteValueKey(hKey, &uniValue); + } + else + { + if (InitUnicodeString(&uniValue, strValue.GetBuffer())) + { + bOk = DeleteValueKey(hKey, &uniValue); + FreeUnicodeString(&uniValue); + + } + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + + if (bOk) + { + OnRegListRefresh(); + } + } + } +} + +ULONG CRegisterManagerDlg::HexStringToLong(CString strHex) +{ + ULONG ulRet = 0; + + if (!strHex.IsEmpty()) + { + swscanf_s(strHex.GetBuffer(wcslen(L"0x")), L"%x", &ulRet); + strHex.ReleaseBuffer(wcslen(L"0x")); + } + + return ulRet; +} + + +BOOL CRegisterManagerDlg::DeleteValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniValueName + ) +{ + DWORD dwReturnSize = 0; + DWORD dwRet = 0; + + + struct + { + HANDLE hKey; + PUNICODE_STRING uniValueName; + }DeleteValueKey; + + + memset(&DeleteValueKey, 0, sizeof(DeleteValueKey)); + + DeleteValueKey.hKey = KeyHandle; + DeleteValueKey.uniValueName = uniValueName; + + g_hDevice = OpenDevice(L"\\\\.\\RegisterManagerLink"); + + + if (g_hDevice==(HANDLE)-1) + { + return FALSE; + } + + + + dwRet = DeviceIoControl(g_hDevice,CTL_DELETE_KEY_VALUE, + &DeleteValueKey, + sizeof(DeleteValueKey), + NULL,0, + &dwReturnSize, + NULL); + + + if (dwRet==0) + { + + CloseHandle(g_hDevice); + return FALSE; + } + + CloseHandle(g_hDevice); + + return TRUE; +} + + +void CRegisterManagerDlg::OnRegListRename() +{ + CString strKeyPath = String2KeyPath(); + if (strKeyPath.IsEmpty()) + { + return; + } + + int nItem = m_List.GetSelectionMark(); + if (nItem != -1) + { + CKeyDlg RenameValueDlg; + RenameValueDlg.m_nDlgType = enumRenameValue; + CString strValueNameOld = m_List.GetItemText(nItem, 0); + RenameValueDlg.m_strKeyNameEdit = strValueNameOld; + CString strNewValueName; + if (RenameValueDlg.DoModal() == IDOK) + { + strNewValueName = RenameValueDlg.m_strKeyNameEdit; + } + + if (strNewValueName.IsEmpty()) + { + return; + } + + if (strNewValueName.CompareNoCase(strValueNameOld)) + { + //ԭȼֵĸ + PKEY_VALUE_FULL_INFORMATION ValueInfor = (PKEY_VALUE_FULL_INFORMATION)GetValueInfo(strKeyPath, strValueNameOld); + if (ValueInfor) + { + //ؽһµ + CreateValueKey(strNewValueName, ValueInfor->Type, + (PVOID)((PBYTE)ValueInfor + ValueInfor->DataOffset), ValueInfor->DataLength); + + // ɾɵļֵ + UNICODE_STRING uniKey; + if (InitUnicodeString(&uniKey, strKeyPath.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + UNICODE_STRING uniValue; + + if (InitUnicodeString(&uniValue, strValueNameOld.GetBuffer())) + { + DeleteValueKey(hKey, &uniValue); + FreeUnicodeString(&uniValue); + m_List.DeleteItem(nItem); + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + + // ͷԴ + free(ValueInfor); + ValueInfor = NULL; + } + } + } +} + + + +PVOID CRegisterManagerDlg::GetValueInfo(CString strKey, CString strValue) +{ + PVOID Ret = NULL; + + if (strKey.IsEmpty() || strValue.IsEmpty()) + { + return NULL; + } + + UNICODE_STRING uniKey; + + if (InitUnicodeString(&uniKey,strKey.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + for (ULONG i = 0; ; i++) + { + ULONG ulRetLen = 0; + BOOL bRet = EnumerateValueKey(hKey, i, KeyValueFullInformation, NULL, 0, &ulRetLen); + if (!bRet && GetLastError() == ERROR_NO_MORE_ITEMS) + { + break; + } + else if (!bRet && GetLastError() == ERROR_INSUFFICIENT_BUFFER) // STATUS_BUFFER_TOO_SMALL + { + PKEY_VALUE_FULL_INFORMATION Buffer = (PKEY_VALUE_FULL_INFORMATION)malloc(ulRetLen + 0x100); + if (Buffer) + { + memset(Buffer, 0, ulRetLen + 0x100); + bRet = EnumerateValueKey(hKey, i, KeyValueFullInformation, Buffer, ulRetLen + 0x100, &ulRetLen); + + if (bRet) + { + WCHAR wzTempName[1024] = {0}; + wcsncpy_s(wzTempName, 1024, Buffer->Name,Buffer->NameLength / sizeof(WCHAR)); + + if (!strValue.CompareNoCase(wzTempName)) + { + Ret = (PVOID)Buffer; + break; + } + } + + free(Buffer); + } + } + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + + return Ret; +} + + + + +void CRegisterManagerDlg::CreateValueKey(CString strValue, ULONG ulType, PVOID Data, ULONG ulDataSize) +{ + CString strKeyPath = String2KeyPath(); + if (strKeyPath.IsEmpty() || strValue.IsEmpty()) + { + return; + } + + UNICODE_STRING uniKey; + if (InitUnicodeString(&uniKey, strKeyPath.GetBuffer())) + { + HANDLE hKey; + OBJECT_ATTRIBUTES oa; + + InitializeObjectAttributes(&oa, &uniKey, OBJ_CASE_INSENSITIVE, 0, NULL); + + if (OpenKey(&hKey, KEY_ALL_ACCESS, &oa)) + { + UNICODE_STRING uniValue; + + if (InitUnicodeString(&uniValue, strValue.GetBuffer())) + { + SetValueKey(hKey, &uniValue, 0, ulType, Data, ulDataSize); + FreeUnicodeString(&uniValue); + } + + CloseHandle(hKey); + } + + FreeUnicodeString(&uniKey); + } + + OnRegListRefresh(); +} + + +void CRegisterManagerDlg::OnRegListCopyValue() +{ + int nItem = m_List.GetSelectionMark(); + if (nItem != -1) + { + CString strValue = m_List.GetItemText(nItem, 0); + SetStringToClipboard(strValue); + } +} + + +void CRegisterManagerDlg::OnRegListCopyValueData() +{ + int nItem = m_List.GetSelectionMark(); + if (nItem != -1) + { + CString strData = m_List.GetItemText(nItem, 2); + SetStringToClipboard(strData); + } +} diff --git a/Register/RegisterManager/RegisterManager/RegisterManagerDlg.h b/Register/RegisterManager/RegisterManager/RegisterManagerDlg.h new file mode 100644 index 0000000..99911d5 --- /dev/null +++ b/Register/RegisterManager/RegisterManager/RegisterManagerDlg.h @@ -0,0 +1,276 @@ + +// RegisterManagerDlg.h : ͷļ +// + +#pragma once +#include "afxcmn.h" +#include "afxwin.h" +#include +#include +#include +#include "RegFindDlg.h" +using namespace std; +typedef struct _KEY_BASIC_INFORMATION { + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG NameLength; + WCHAR Name[1]; +} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION; + + +typedef enum _KEY_INFORMATION_CLASS { + KeyBasicInformation, + KeyNodeInformation, + KeyFullInformation, + KeyNameInformation, + KeyCachedInformation, + KeyFlagsInformation, + KeyVirtualizationInformation, + KeyHandleTagsInformation, + MaxKeyInfoClass +} KEY_INFORMATION_CLASS; + +typedef struct _KEY_VALUE_FULL_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG DataOffset; + ULONG DataLength; + ULONG NameLength; + WCHAR Name[1]; +} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; + +typedef enum _KEY_VALUE_INFORMATION_CLASS { + KeyValueBasicInformation, + KeyValueFullInformation, + KeyValuePartialInformation, + KeyValueFullInformationAlign64, + KeyValuePartialInformationAlign64, + MaxKeyValueInfoClass +} KEY_VALUE_INFORMATION_CLASS; + + +#define CLASSES_ROOT L"\\Registry\\Machine\\SOFTWARE\\Classes" +#define LOCAL_MACHINE L"\\Registry\\Machine" +#define USERS L"\\Registry\\User" +#define CURRENT_CONFIGL L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current" + + + +#define CTL_CREATE_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x833,METHOD_NEITHER,FILE_ANY_ACCESS) + +#define CTL_OPEN_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x830,METHOD_NEITHER,FILE_ANY_ACCESS) + +#define CTL_ENUM_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x831,METHOD_NEITHER,FILE_ANY_ACCESS) + +#define CTL_ENUM_KEY_VALUE \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x832,METHOD_NEITHER,FILE_ANY_ACCESS) + +#define CTL_SET_KEY_VALUE \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x834,METHOD_NEITHER,FILE_ANY_ACCESS) + + +#define CTL_DELETE_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x835,METHOD_NEITHER,FILE_ANY_ACCESS) + +#define CTL_RENAME_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x836,METHOD_NEITHER,FILE_ANY_ACCESS) + + +#define CTL_DELETE_KEY_VALUE \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x837,METHOD_NEITHER,FILE_ANY_ACCESS) + +#define OBJ_CASE_INSENSITIVE 0x00000040L +#define InitializeObjectAttributes( p, n, a, r, s ) { \ + (p)->Length = sizeof(OBJECT_ATTRIBUTES); \ + (p)->RootDirectory = r; \ + (p)->Attributes = a; \ + (p)->ObjectName = n; \ + (p)->SecurityDescriptor = s; \ + (p)->SecurityQualityOfService = NULL; \ +} + +typedef struct _UNICODE_STRING { + USHORT Length; + USHORT MaximumLength; + PWSTR Buffer; +}UNICODE_STRING, *PUNICODE_STRING; + + +typedef struct _OBJECT_ATTRIBUTES { + ULONG Length; + HANDLE RootDirectory; + PUNICODE_STRING ObjectName; + ULONG Attributes; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; +}OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; + + +// CRegisterManagerDlg Ի +class CRegisterManagerDlg : public CDialogEx +{ +// +public: + CRegisterManagerDlg(CWnd* pParent = NULL); // ׼캯 + CRegisterManagerDlg::~CRegisterManagerDlg(); + BOOL InitControlTree(); + VOID InitRegistry(); + VOID EnumSubKeys(CString strKey, HTREEITEM hItem, BOOL bSubSubKey = FALSE); + VOID DeleteSubTree(HTREEITEM hTreeItem); + VOID CRegisterManagerDlg::FreeUnicodeString(UNICODE_STRING *uniString); + BOOL InitUnicodeString(PUNICODE_STRING uniString, WCHAR *wzString); + BOOL CRegisterManagerDlg::OpenKey(OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + BOOL CRegisterManagerDlg::EnumerateKey(IN HANDLE KeyHandle, + IN ULONG ulIndex, + IN ULONG ulKeyInformationClass, + OUT PVOID KeyInformation, + IN ULONG ulLength, + OUT PULONG ResultLength + ); + void CRegisterManagerDlg::EnumCurrentUserSubKeys(HTREEITEM hChild); + BOOL CRegisterManagerDlg::GetCurrentUserKeyPath(OUT WCHAR *wzCurrentUserPath); + void CRegisterManagerDlg::EnumSubSubKeys(CString strKey, HTREEITEM hItem); + void CRegisterManagerDlg::EnumValues(CString strKey); + + BOOL CRegisterManagerDlg::EnumerateValueKey(IN HANDLE KeyHandle, + IN ULONG ulIndex, + IN ULONG ulKeyValueInformationClass, + OUT PVOID KeyValueInformation, + IN ULONG ulLength, + OUT PULONG ulResultLength + ); + CString CRegisterManagerDlg::GetKeyType(ULONG ulType); + CString CRegisterManagerDlg::GetKeyData(ULONG ulType, WCHAR* wzData, ULONG ulDataLength); + + + VOID CRegisterManagerDlg::InitializeComboBox(); + void CRegisterManagerDlg::GetAllRegPath(std::list &RegPathList); + void CRegisterManagerDlg::InitRegPathList(); + CString CRegisterManagerDlg::ComboString2KeyPath(); + HTREEITEM CRegisterManagerDlg::GetTreeSubItemByName(HTREEITEM hPatentItem, CString strName); + CString CRegisterManagerDlg::String2KeyPath(); + + BOOL CRegisterManagerDlg::CreateKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG ulTitleIndex, + IN PUNICODE_STRING uniClass, + IN ULONG ulCreateOptions, + OUT PULONG Disposition + ); + + void CRegisterManagerDlg::SetValueKey(ULONG ulType, PVOID Data, ULONG ulDataSize); + + BOOL CRegisterManagerDlg::SetValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniValueName, + IN ULONG ulTitleIndex, + IN ULONG ulType, + IN PVOID Data, + IN ULONG ulDataSize + ); + + + void CRegisterManagerDlg::DeleteKeyAndSubKeys(CString strKey); + BOOL CRegisterManagerDlg::DeleteKey(IN HANDLE KeyHandle); + void CRegisterManagerDlg::UpdateKey(CString strKey, HTREEITEM hItem); + + + BOOL CRegisterManagerDlg::RenameKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniNewName + ); + BOOL SetStringToClipboard(CString strImageName); + VOID CRegisterManagerDlg::ShellImportRegister( + LPCTSTR ImportFile) ; + + VOID CRegisterManagerDlg::ShellExportRegister( + CString strItem, + CString strFileName); + + + void CRegisterManagerDlg::JmpToReg(CString strKey, CString strData); + void CRegisterManagerDlg::JmpToRegCommon(CString strKey, CString strData); + + BOOL CRegisterManagerDlg::DeleteValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniValueName + ); + + + PVOID CRegisterManagerDlg::GetValueInfo(CString strKey, CString strValue); + void CRegisterManagerDlg::CreateValueKey(CString strValue, ULONG ulType, PVOID Data, ULONG ulDataSize); + ULONG CRegisterManagerDlg::GetValueType(CString strType); + void CRegisterManagerDlg::ModifyValue(CString strValue, ULONG ulType, PVOID Data, ULONG ulDataSize); + ULONG CRegisterManagerDlg::HexStringToLong(CString strHex); + // Ի + enum { IDD = IDD_REGISTERMANAGER_DIALOG }; + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + +// ʵ +protected: + HICON m_hIcon; + + // ɵϢӳ亯 + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +public: + CTreeCtrl m_Tree; + CImageList m_TreeImageList; + CListCtrl m_List; + CImageList m_ImageList; + CComboBox m_ComboBox; + CString m_strComboText; + WCHAR* m_wzhKeyCurrentUser; //Ǵ洢Current_User ֵ עҪͷڴ + std::list m_RegPathList; // עĿٶλ + ULONG m_nComboBoxCnt; // ٶλ + HTREEITEM m_RightClickTreeItem; // ؼϵҼѡ + CBitmap m_bmRefresh; + CBitmap m_bmDelete; + CBitmap m_bmCopy; + CBitmap m_bmExport; + CBitmap m_bmLookfor; + CRegFindDlg *m_FindRegDlg; //Dlg + afx_msg void OnTvnItemexpandingTree(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnTvnSelchangedTree(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnBnClickedGoto(); + afx_msg void OnCbnDropdownCombo(); + virtual BOOL PreTranslateMessage(MSG* pMsg); + afx_msg void OnRegRefresh(); + afx_msg void OnNMRClickTree(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnRegNewKey(); + afx_msg void OnStringValue(); + afx_msg void OnBinaryValue(); + afx_msg void OnDwordValue(); + afx_msg void OnMuiStringValue(); + afx_msg void OnExpandStringValue(); + afx_msg void OnRegDelete(); + afx_msg void OnRegRename(); + afx_msg void OnQwordValue(); + afx_msg void OnRegCopyKeyName(); + afx_msg void OnRegCopyFullKeyName(); + afx_msg void OnRegAddToQuickAddress(); + afx_msg void OnRegInport(); + afx_msg void OnRegExport(); + afx_msg void OnRegLookFor(); + afx_msg void OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnRegListRefresh(); + afx_msg void OnRegListModify(); + afx_msg void OnRegListDelete(); + afx_msg void OnRegListRename(); + afx_msg void OnRegListCopyValue(); + afx_msg void OnRegListCopyValueData(); +}; diff --git a/Register/RegisterManager/RegisterManager/res/Bmp/Copy.bmp b/Register/RegisterManager/RegisterManager/res/Bmp/Copy.bmp new file mode 100644 index 0000000..a8890f3 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Bmp/Copy.bmp differ diff --git a/Register/RegisterManager/RegisterManager/res/Bmp/Delete.bmp b/Register/RegisterManager/RegisterManager/res/Bmp/Delete.bmp new file mode 100644 index 0000000..d75916f Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Bmp/Delete.bmp differ diff --git a/Register/RegisterManager/RegisterManager/res/Bmp/Export.bmp b/Register/RegisterManager/RegisterManager/res/Bmp/Export.bmp new file mode 100644 index 0000000..40d97cd Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Bmp/Export.bmp differ diff --git a/Register/RegisterManager/RegisterManager/res/Bmp/Lookfor.bmp b/Register/RegisterManager/RegisterManager/res/Bmp/Lookfor.bmp new file mode 100644 index 0000000..a16e281 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Bmp/Lookfor.bmp differ diff --git a/Register/RegisterManager/RegisterManager/res/Bmp/Refresh.bmp b/Register/RegisterManager/RegisterManager/res/Bmp/Refresh.bmp new file mode 100644 index 0000000..7108e16 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Bmp/Refresh.bmp differ diff --git a/Register/RegisterManager/RegisterManager/res/Check.avi b/Register/RegisterManager/RegisterManager/res/Check.avi new file mode 100644 index 0000000..89efdb4 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Check.avi differ diff --git a/Register/RegisterManager/RegisterManager/res/Icon/CloseDir.ico b/Register/RegisterManager/RegisterManager/res/Icon/CloseDir.ico new file mode 100644 index 0000000..4e7af0b Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Icon/CloseDir.ico differ diff --git a/Register/RegisterManager/RegisterManager/res/Icon/Computer.ico b/Register/RegisterManager/RegisterManager/res/Icon/Computer.ico new file mode 100644 index 0000000..b77a05b Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Icon/Computer.ico differ diff --git a/Register/RegisterManager/RegisterManager/res/Icon/OpenDir.ico b/Register/RegisterManager/RegisterManager/res/Icon/OpenDir.ico new file mode 100644 index 0000000..10750ef Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Icon/OpenDir.ico differ diff --git a/Register/RegisterManager/RegisterManager/res/Icon/REG_DWORD.ico b/Register/RegisterManager/RegisterManager/res/Icon/REG_DWORD.ico new file mode 100644 index 0000000..1402294 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Icon/REG_DWORD.ico differ diff --git a/Register/RegisterManager/RegisterManager/res/Icon/REG_SZ.ico b/Register/RegisterManager/RegisterManager/res/Icon/REG_SZ.ico new file mode 100644 index 0000000..e6afa49 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Icon/REG_SZ.ico differ diff --git a/Register/RegisterManager/RegisterManager/res/RegisterManager.ico b/Register/RegisterManager/RegisterManager/res/RegisterManager.ico new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/RegisterManager.ico differ diff --git a/Register/RegisterManager/RegisterManager/res/RegisterManager.rc2 b/Register/RegisterManager/RegisterManager/res/RegisterManager.rc2 new file mode 100644 index 0000000..a20b104 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/RegisterManager.rc2 differ diff --git a/Register/RegisterManager/RegisterManager/res/Search.avi b/Register/RegisterManager/RegisterManager/res/Search.avi new file mode 100644 index 0000000..093df22 Binary files /dev/null and b/Register/RegisterManager/RegisterManager/res/Search.avi differ diff --git a/Register/RegisterManager/RegisterManager/resource.h b/Register/RegisterManager/RegisterManager/resource.h new file mode 100644 index 0000000..a52695f Binary files /dev/null and b/Register/RegisterManager/RegisterManager/resource.h differ diff --git a/Register/RegisterManager/RegisterManager/stdafx.cpp b/Register/RegisterManager/RegisterManager/stdafx.cpp new file mode 100644 index 0000000..ac728ac --- /dev/null +++ b/Register/RegisterManager/RegisterManager/stdafx.cpp @@ -0,0 +1,8 @@ + +// stdafx.cpp : ֻ׼ļԴļ +// RegisterManager.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + + diff --git a/Register/RegisterManager/RegisterManager/stdafx.h b/Register/RegisterManager/RegisterManager/stdafx.h new file mode 100644 index 0000000..fac7631 --- /dev/null +++ b/Register/RegisterManager/RegisterManager/stdafx.h @@ -0,0 +1,58 @@ + +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ + +#pragma once + +#ifndef _SECURE_ATL +#define _SECURE_ATL 1 +#endif + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷųʹõ +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +// ر MFC ijЩɷĺԵľϢ +#define _AFX_ALL_WARNINGS + +#include // MFC ͱ׼ +#include // MFC չ + + +#include // MFC Զ + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // Ϳؼ MFC ֧ + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git a/Register/RegisterManager/RegisterManager/targetver.h b/Register/RegisterManager/RegisterManager/targetver.h new file mode 100644 index 0000000..0afac5b --- /dev/null +++ b/Register/RegisterManager/RegisterManager/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h ߰汾Ŀ Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Register/RegisterManagerDrv/RegisterManagerDrv.c b/Register/RegisterManagerDrv/RegisterManagerDrv.c new file mode 100644 index 0000000..b323f5e --- /dev/null +++ b/Register/RegisterManagerDrv/RegisterManagerDrv.c @@ -0,0 +1,1098 @@ +#include "RegisterManagerDrv.h" + +PDRIVER_OBJECT g_DriverObject = NULL; +WIN_VERSION WinVersion = WINDOWS_UNKNOW; +ULONG_PTR SYSTEM_ADDRESS_START = 0; +ULONG_PTR PreviousModeOffsetOf_KTHREAD = 0; +ULONG_PTR IndexOffset = 0; +pfnNtEnumerateValueKey NtEnumerateValueKeyAddress = NULL; +pfnNtOpenKey NtOpenKeyAddress = NULL; +pfnNtEnumerateKey NtEnumerateKeyAddress = NULL; +pfnNtCreateKey NtCreateKeyAddress = NULL; +pfnNtSetValueKey NtSetValueKeyAddress = NULL; +pfnNtDeleteKey NtDeleteKeyAddress = NULL; +pfnNtRenameKey NtRenameKeyAddress = NULL; +pfnNtDeleteValueKey NtDeleteValueKeyAddress = NULL; +ULONG_PTR SSDTDescriptor = 0; +ULONG_PTR ulIndex = 0; +ULONG_PTR SSDTFuncAddress = 0; + + +HANDLE hRoot = NULL; +NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING RegisterPath) +{ + PDEVICE_OBJECT DeviceObject; + NTSTATUS Status; + ULONG i; + + UNICODE_STRING uniDeviceName; + UNICODE_STRING uniLinkName; + + RtlInitUnicodeString(&uniDeviceName,DEVICE_NAME); + RtlInitUnicodeString(&uniLinkName,LINK_NAME); + + //豸; + Status = IoCreateDevice(DriverObject,0,&uniDeviceName,FILE_DEVICE_UNKNOWN,0,FALSE,&DeviceObject); + if (!NT_SUCCESS(Status)) + { + return Status; + } + + //; + Status = IoCreateSymbolicLink(&uniLinkName,&uniDeviceName); + + for (i = 0; iMajorFunction[i] = DefaultDispatch; + } + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ControlDispatch; + DriverObject->DriverUnload = UnloadDriver; + +#ifdef WIN64 +/* __asm + { + xchg rax,rbx + } +*/ DbgPrint("X64: RegisterManager IS RUNNING!!!\n"); +#else +/* __asm + { + xor eax,eax + } +*/ DbgPrint("X86: RegisterManager IS RUNNING!!!\n"); +#endif + + + g_DriverObject = DriverObject; + WinVersion = GetWindowsVersion(); + SetGolbalMember(); + return STATUS_SUCCESS; +} + + + +NTSTATUS ControlDispatch(PDEVICE_OBJECT DeviceObject,PIRP Irp) +{ + + NTSTATUS Status = STATUS_SUCCESS; + PIO_STACK_LOCATION IrpSp; + PVOID InputBuffer = NULL; + PVOID OutputBuffer = NULL; + ULONG_PTR InputSize = 0; + ULONG_PTR OutputSize = 0; + ULONG_PTR IoControlCode = 0; + PETHREAD EThread = NULL; + CHAR PreMode = 0; + IrpSp = IoGetCurrentIrpStackLocation(Irp); + + IrpSp = IoGetCurrentIrpStackLocation(Irp); + InputBuffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; + OutputBuffer = Irp->UserBuffer; + InputSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength; + OutputSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength; + + IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode; + + + switch(IoControlCode) + { + + case CTL_OPEN_KEY: + { + + + DbgPrint("Ӧò¼"); + + + Status = RegOpenKey(InputBuffer,OutputBuffer); + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + + break; + + } + + case CTL_ENUM_KEY: + { + + + Status = RegEnumerateKey(InputBuffer,OutputBuffer); + + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + + + break; + } + + case CTL_ENUM_KEY_VALUE: + { + + Status = RegEnumerateValueKey(InputBuffer,OutputBuffer); + + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + break; + } + + case CTL_CREATE_KEY: + { + + Status = RegCreateKey(InputBuffer,OutputBuffer); + + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + break; + } + + case CTL_SET_KEY_VALUE: + { + + Status = RegSetValueKey(InputBuffer,OutputBuffer); + + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + break; + } + + case CTL_DELETE_KEY: + { + + Status = RegDeleteKey(InputBuffer,OutputBuffer); + + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + break; + } + + case CTL_RENAME_KEY: + { + + Status = RegRenameKey(InputBuffer,OutputBuffer); + + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + break; + } + + + case CTL_DELETE_KEY_VALUE: + { + + Status = RegDeleteValueKey(InputBuffer,OutputBuffer); + + + if (NT_SUCCESS(Status)) + { + Irp->IoStatus.Information = OutputSize; + Irp->IoStatus.Status = Status; + } + + else + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + } + + break; + } + default: + { + + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + Irp->IoStatus.Information = 0; + + + + break; + } + } + + + IoCompleteRequest(Irp,IO_NO_INCREMENT); + + return Status; +} + +NTSTATUS RegOpenKey(PVOID InBuffer,PVOID OutBuffer) +{ + POPEN Open = (POPEN)InBuffer; + ACCESS_MASK Mask = Open->DesiredAccess; + POBJECT_ATTRIBUTES oa = Open->ObjectAttributes; + PHANDLE KeyHandle = (PHANDLE)OutBuffer; + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + __try + { + ProbeForRead(oa,sizeof(OBJECT_ATTRIBUTES),1); + Status = KernelOpenKey(KeyHandle,Mask,oa); + + + } + __except(1) + { + Status = STATUS_UNSUCCESSFUL; + } + + return Status; +} + + + +NTSTATUS KernelOpenKey(OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ) + +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + PETHREAD EThread = NULL; + CHAR PreMode = 0; + + if (!KeyHandle || + !ObjectAttributes) + { + return Status; + } + + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread); + Status = NtOpenKeyAddress(KeyHandle, DesiredAccess, ObjectAttributes); + RecoverPreMode(EThread, PreMode); + + + return Status; +} + + + + +NTSTATUS RegEnumerateKey(PVOID InBuffer,PVOID OutBuffer) +{ + PENUM Enum = (PENUM)InBuffer; + HANDLE KeyHandle = Enum->hKey; + ULONG Index = Enum->Index; + KEY_INFORMATION_CLASS KeyInformationClass = Enum->InformationClass; + ULONG Length = Enum->Length; + PENUM_VALUE EnumValue = (PENUM_VALUE)OutBuffer; + ULONG ulReturn = 0; + return KernelEnumerateKey(KeyHandle, Index, KeyInformationClass,EnumValue->ValueInfor,Length,EnumValue->RetLength); +} + + + +NTSTATUS KernelEnumerateKey(IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_INFORMATION_CLASS KeyInformationClass, + OUT PVOID KeyInformation, + IN ULONG Length, + OUT PULONG ResultLength + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + PETHREAD EThread = NULL; + CHAR PreMode = 0; + + if (!KeyHandle) + { + return Status; + } + + + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread);; + Status = NtEnumerateKeyAddress(KeyHandle, Index, KeyInformationClass, KeyInformation, Length, ResultLength); + RecoverPreMode(EThread, PreMode); + if (Status == STATUS_BUFFER_TOO_SMALL) + { + DbgPrint("STATUS_BUFFER_TOO_SMALL\r\n"); + } + else if (STATUS_NO_MORE_ENTRIES == Status) + { + DbgPrint("STATUS_NO_MORE_ENTRIES\r\n"); + } + + else if (Status==STATUS_ACCESS_VIOLATION) + { + DbgPrint("STATUS_ACCESS_VIOLATION %d\r\n",RtlNtStatusToDosError(Status)); + } + + return Status; +} + + + + +NTSTATUS RegEnumerateValueKey(PVOID InBuffer,PVOID OutBuffer) +{ + PENUM Enum = (PENUM)InBuffer; + HANDLE KeyHandle = Enum->hKey; + ULONG Index = Enum->Index; + KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass = Enum->InformationClass; + ULONG Length = Enum->Length; + PENUM_VALUE EnumValue = (PENUM_VALUE)OutBuffer; + + return KernelEnumerateValueKey(KeyHandle, Index, KeyValueInformationClass, EnumValue->ValueInfor, Length, EnumValue->RetLength); +} + + +NTSTATUS KernelEnumerateValueKey(IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + OUT PVOID KeyValueInformation, + IN ULONG Length, + OUT PULONG ResultLength + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + PETHREAD EThread = NULL; + CHAR PreMode = 0; + + + if (!KeyHandle) + { + return Status; + } + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread); + + Status = NtEnumerateValueKeyAddress(KeyHandle, Index, KeyValueInformationClass, KeyValueInformation, Length, ResultLength); + + if (Status == STATUS_BUFFER_TOO_SMALL) + { + DbgPrint("STATUS_BUFFER_TOO_SMALL\r\n"); + } + else if (STATUS_NO_MORE_ENTRIES == Status) + { + DbgPrint("STATUS_NO_MORE_ENTRIES\r\n"); + } + + else if (Status==STATUS_ACCESS_VIOLATION) + { + DbgPrint("STATUS_ACCESS_VIOLATION %d\r\n",RtlNtStatusToDosError(Status)); + } + + RecoverPreMode(EThread, PreMode); + return Status; +} + + +NTSTATUS RegCreateKey(PVOID InBuffer,PVOID OutBuffer) +{ + PCREATE Create = (PCREATE)InBuffer; + ACCESS_MASK DesiredAccess = Create->DesiredAccess; + POBJECT_ATTRIBUTES oa = Create->ObjectAttributes; + + PCREATE_VALUE CreateValue = (PCREATE_VALUE)OutBuffer; + PHANDLE KeyHandle = CreateValue->KeyHandle; + PULONG Disposition = CreateValue->Disposition; + return KernelCreateKey(KeyHandle, DesiredAccess, oa, 0, NULL, REG_OPTION_NON_VOLATILE, Disposition); +} + + + +NTSTATUS + KernelCreateKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL + ) +{ + + PETHREAD EThread = NULL; + CHAR PreMode = 0; + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + if (!KeyHandle) + { + return Status; + } + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread); + + Status = NtCreateKeyAddress(KeyHandle, DesiredAccess, ObjectAttributes, TitleIndex, Class, CreateOptions, Disposition); + + RecoverPreMode(EThread, PreMode); + return Status; +} + + +NTSTATUS RegSetValueKey(PVOID InBuffer,PVOID OutBuffer) +{ + PSET_KEY_VALUE SetKeyValue = (PSET_KEY_VALUE)InBuffer; + HANDLE KeyHandle = SetKeyValue->hKey; + PUNICODE_STRING uniValueName = (PUNICODE_STRING)(SetKeyValue->ValueName); + ULONG Type = SetKeyValue->Type; + PVOID Data = SetKeyValue->Data; + ULONG DataSize = SetKeyValue->DataSize; + return KernelSetValueKey(KeyHandle, uniValueName, 0, Type, Data, DataSize); +} + +NTSTATUS + KernelSetValueKey(IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex OPTIONAL, + IN ULONG Type, + IN PVOID Data, + IN ULONG DataSize + ) +{ + + PETHREAD EThread = NULL; + CHAR PreMode = 0; + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + if (!KeyHandle) + { + return Status; + } + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread); + + Status = NtSetValueKeyAddress(KeyHandle, ValueName, TitleIndex, Type, Data, DataSize); + + RecoverPreMode(EThread, PreMode); + return Status; +} + +NTSTATUS RegDeleteKey(PVOID InBuffer,PVOID OutBuffer) +{ + PDELETE Delete = (PDELETE)InBuffer; + HANDLE KeyHandle = Delete->hKey; + + return KernelDeleteKey(KeyHandle); +} + + + +NTSTATUS + KernelDeleteKey( + IN HANDLE KeyHandle + ) +{ + + PETHREAD EThread = NULL; + CHAR PreMode = 0; + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + if (!KeyHandle) + { + return Status; + } + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread); + + Status = NtDeleteKeyAddress(KeyHandle); + + RecoverPreMode(EThread, PreMode); + return Status; +} + + +NTSTATUS RegRenameKey(PVOID InBuffer,PVOID OutBuffer) +{ + PRENAME Rename = (PRENAME)InBuffer; + HANDLE KeyHandle = Rename->hKey; + PUNICODE_STRING uniNewName = (PUNICODE_STRING)(Rename->uniNewName); + + + return KernelRenameKey(KeyHandle, uniNewName); +} + + + + +NTSTATUS KernelRenameKey(IN HANDLE KeyHandle, IN PUNICODE_STRING uniNewName) +{ + + PETHREAD EThread = NULL; + CHAR PreMode = 0; + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + if (!KeyHandle) + { + return Status; + } + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread); + + Status = NtRenameKeyAddress(KeyHandle, uniNewName); + + RecoverPreMode(EThread, PreMode); + return Status; +} + + +NTSTATUS RegDeleteValueKey(PVOID InBuffer,PVOID OutBuffer) +{ + PDELETE_KEY_VALUE DeleteKeyValue = (PDELETE_KEY_VALUE)InBuffer; + HANDLE KeyHandle = DeleteKeyValue->hKey; + PUNICODE_STRING uniValueName = (PUNICODE_STRING)(DeleteKeyValue->uniValueName); + + + return KernelDeleteValueKey(KeyHandle, uniValueName); +} + + +NTSTATUS + KernelDeleteValueKey(IN HANDLE KeyHandle, + IN PUNICODE_STRING uniValueName + ) +{ + + PETHREAD EThread = NULL; + CHAR PreMode = 0; + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + if (!KeyHandle) + { + return Status; + } + + EThread = PsGetCurrentThread(); + PreMode = ChangePreMode(EThread); + + Status = NtDeleteValueKeyAddress(KeyHandle,uniValueName); + + RecoverPreMode(EThread, PreMode); + return Status; +} + + +NTSTATUS DefaultDispatch(PDEVICE_OBJECT DeviceObject,PIRP Irp) +{ + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp,IO_NO_INCREMENT); + + return STATUS_SUCCESS; +} + +VOID UnloadDriver(PDRIVER_OBJECT DriverObject) +{ + UNICODE_STRING uniLinkName; + PDEVICE_OBJECT NextObject = NULL; + PDEVICE_OBJECT CurrentObject = NULL; + RtlInitUnicodeString(&uniLinkName,LINK_NAME); + + IoDeleteSymbolicLink(&uniLinkName); + CurrentObject = DriverObject->DeviceObject; + while (CurrentObject != NULL) + { + + NextObject = CurrentObject->NextDevice; + IoDeleteDevice(CurrentObject); + CurrentObject = NextObject; + } + +#ifdef WIN64 + DbgPrint("X64: RegisterManager IS STOPPED!!!\n"); +#else + DbgPrint("X86: RegisterManager IS STOPPED!!!\n"); +#endif + + return; +} + + +CHAR ChangePreMode(PETHREAD EThread) +{ + + CHAR PreMode = *(PCHAR)((ULONG_PTR)EThread + PreviousModeOffsetOf_KTHREAD); + *(PCHAR)((ULONG_PTR)EThread + PreviousModeOffsetOf_KTHREAD) = KernelMode; + return PreMode; +} + +VOID RecoverPreMode(PETHREAD EThread, CHAR PreMode) +{ + + *(PCHAR)((ULONG_PTR)EThread + PreviousModeOffsetOf_KTHREAD) = PreMode; +} + + + +WIN_VERSION GetWindowsVersion() +{ + RTL_OSVERSIONINFOEXW osverInfo = {sizeof(osverInfo)}; + pfnRtlGetVersion RtlGetVersion = NULL; + WIN_VERSION WinVersion; + WCHAR wzRtlGetVersion[] = L"RtlGetVersion"; + + RtlGetVersion = GetFunctionAddressByName(wzRtlGetVersion); + if (RtlGetVersion) + { + RtlGetVersion((PRTL_OSVERSIONINFOW)&osverInfo); + } + else + { + PsGetVersion(&osverInfo.dwMajorVersion, &osverInfo.dwMinorVersion, &osverInfo.dwBuildNumber, NULL); + } + + DbgPrint("Build Number: %d\r\n", osverInfo.dwBuildNumber); + + if (osverInfo.dwMajorVersion == 5 && osverInfo.dwMinorVersion == 1) + { + DbgPrint("WINDOWS_XP\r\n"); + WinVersion = WINDOWS_XP; + } + else if (osverInfo.dwMajorVersion == 6 && osverInfo.dwMinorVersion == 1) + { + DbgPrint("WINDOWS 7\r\n"); + WinVersion = WINDOWS_7; + } + else if (osverInfo.dwMajorVersion == 6 && + osverInfo.dwMinorVersion == 2 && + osverInfo.dwBuildNumber == 9200) + { + DbgPrint("WINDOWS 8\r\n"); + WinVersion = WINDOWS_8; + } + else if (osverInfo.dwMajorVersion == 6 && + osverInfo.dwMinorVersion == 3 && + osverInfo.dwBuildNumber == 9600) + { + DbgPrint("WINDOWS 8.1\r\n"); + WinVersion = WINDOWS_8_1; + } + else + { + DbgPrint("WINDOWS_UNKNOW\r\n"); + WinVersion = WINDOWS_UNKNOW; + } + + return WinVersion; +} +VOID SetGolbalMember() +{ + switch(WinVersion) + { + case WINDOWS_XP: + { + SYSTEM_ADDRESS_START = 0x80000000; + + + PreviousModeOffsetOf_KTHREAD = 0x140; + IndexOffset = 1; + SSDTDescriptor = (ULONG_PTR)GetFunctionAddressByName(L"KeServiceDescriptorTable"); + //NtQueryObjectĵַ + ulIndex = GetSSDTApiFunIndex("NtOpenKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtOpenKeyAddress = (pfnNtOpenKey)SSDTFuncAddress; + + + ulIndex = GetSSDTApiFunIndex("NtEnumerateKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtEnumerateKeyAddress = (pfnNtEnumerateKey)SSDTFuncAddress; + + + ulIndex = GetSSDTApiFunIndex("NtEnumerateValueKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtEnumerateValueKeyAddress = (pfnNtEnumerateValueKey)SSDTFuncAddress; + + + ulIndex = GetSSDTApiFunIndex("NtCreateKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtCreateKeyAddress = (pfnNtCreateKey)SSDTFuncAddress; + + + + ulIndex = GetSSDTApiFunIndex("NtSetValueKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtSetValueKeyAddress = (pfnNtSetValueKey)SSDTFuncAddress; + + + ulIndex = GetSSDTApiFunIndex("NtDeleteKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtDeleteKeyAddress = (pfnNtDeleteKey)SSDTFuncAddress; + + + ulIndex = GetSSDTApiFunIndex("NtRenameKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtRenameKeyAddress = (pfnNtRenameKey)SSDTFuncAddress; + + ulIndex = GetSSDTApiFunIndex("NtDeleteValueKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtDeleteValueKeyAddress = (pfnNtDeleteValueKey)SSDTFuncAddress; + + break; + } + case WINDOWS_7: + { + + PreviousModeOffsetOf_KTHREAD = 0x1f6; + IndexOffset = 4; + SSDTDescriptor = GetKeServiceDescriptorTable64(); + + ulIndex = GetSSDTApiFunIndex("NtOpenKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtOpenKeyAddress = (pfnNtOpenKey)SSDTFuncAddress; + + ulIndex = GetSSDTApiFunIndex("NtEnumerateKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtEnumerateKeyAddress = (pfnNtEnumerateKey)SSDTFuncAddress; + + ulIndex = GetSSDTApiFunIndex("NtEnumerateValueKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtEnumerateValueKeyAddress = (pfnNtEnumerateValueKey)SSDTFuncAddress; + + + ulIndex = GetSSDTApiFunIndex("NtCreateKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtCreateKeyAddress = (pfnNtCreateKey)SSDTFuncAddress; + + ulIndex = GetSSDTApiFunIndex("NtSetValueKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtSetValueKeyAddress = (pfnNtSetValueKey)SSDTFuncAddress; + + + ulIndex = GetSSDTApiFunIndex("NtDeleteKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtDeleteKeyAddress = (pfnNtDeleteKey)SSDTFuncAddress; + + ulIndex = GetSSDTApiFunIndex("NtRenameKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtRenameKeyAddress = (pfnNtRenameKey)SSDTFuncAddress; + + ulIndex = GetSSDTApiFunIndex("NtDeleteValueKey"); + SSDTFuncAddress = GetSSDTApiFunAddress(ulIndex,SSDTDescriptor); + NtDeleteValueKeyAddress = (pfnNtDeleteValueKey)SSDTFuncAddress; + SYSTEM_ADDRESS_START = 0x80000000000; + break; + } + } +} + +PVOID GetFunctionAddressByName(WCHAR *wzFunction) +{ + UNICODE_STRING uniFunction; + PVOID AddrBase = NULL; + + if (wzFunction && wcslen(wzFunction) > 0) + { + RtlInitUnicodeString(&uniFunction, wzFunction); + AddrBase = MmGetSystemRoutineAddress(&uniFunction); + } + + return AddrBase; +} + + +ULONG_PTR GetKeServiceDescriptorTable64() +{ + PUCHAR StartSearchAddress = (PUCHAR)__readmsr(0xC0000082); + PUCHAR EndSearchAddress = StartSearchAddress + 0x500; + PUCHAR i = NULL; + UCHAR b1=0,b2=0,b3=0; + ULONG_PTR Temp = 0; + ULONG_PTR Address = 0; + for(i=StartSearchAddress;iOptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress){ + ExportTable =(IMAGE_EXPORT_DIRECTORY *)((ULONG_PTR)MapBase + NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress); + FunctionAddresses = (ULONG*)((ULONG_PTR)MapBase + ExportTable->AddressOfFunctions); + FunctionNames = (ULONG*)((ULONG_PTR)MapBase + ExportTable->AddressOfNames); + FunIndexs = (USHORT*)((ULONG_PTR)MapBase + ExportTable->AddressOfNameOrdinals); + for(i = 0; i < ExportTable->NumberOfNames; i++) + { + FunName = (LPSTR)((ULONG_PTR)MapBase + FunctionNames[i]); + if (_stricmp(FunName, lpszFunName) == 0) + { + ulFunIndex = FunIndexs[i]; + FunAddress = (ULONG_PTR)((ULONG_PTR)MapBase + FunctionAddresses[ulFunIndex]); + Index=*(ULONG*)(FunAddress+IndexOffset); + break; + } + } + } + }__except(EXCEPTION_EXECUTE_HANDLER) + { + ; + } + } + + if (Index == -1) + { + DbgPrint("%s Get Index Error\n", lpszFunName); + } + + ZwUnmapViewOfSection(NtCurrentProcess(), MapBase); + return Index; +} + + + + +NTSTATUS +MapFileInUserSpace(IN LPWSTR lpszFileName,IN HANDLE ProcessHandle OPTIONAL, + OUT PVOID *BaseAddress, + OUT PSIZE_T ViewSize OPTIONAL) +{ + NTSTATUS Status = STATUS_INVALID_PARAMETER; + HANDLE hFile = NULL; + HANDLE hSection = NULL; + OBJECT_ATTRIBUTES oa; + SIZE_T MapViewSize = 0; + IO_STATUS_BLOCK Iosb; + UNICODE_STRING uniFileName; + + if (!lpszFileName || !BaseAddress){ + return Status; + } + + RtlInitUnicodeString(&uniFileName, lpszFileName); + InitializeObjectAttributes(&oa, + &uniFileName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL + ); + + Status = IoCreateFile(&hFile, + GENERIC_READ | SYNCHRONIZE, + &oa, + &Iosb, + NULL, + FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ, + FILE_OPEN, + FILE_SYNCHRONOUS_IO_NONALERT, + NULL, + 0, + CreateFileTypeNone, + NULL, + IO_NO_PARAMETER_CHECKING + ); + + if (!NT_SUCCESS(Status)) + { + DbgPrint("ZwCreateFile Failed! Error=%08x\n",Status); + return Status; + } + + oa.ObjectName = NULL; + Status = ZwCreateSection(&hSection, + SECTION_QUERY | SECTION_MAP_READ, + &oa, + NULL, + PAGE_WRITECOPY, + SEC_IMAGE, + hFile + ); + ZwClose(hFile); + if (!NT_SUCCESS(Status)) + { + DbgPrint("ZwCreateSection Failed! Error=%08x\n",Status); + return Status; + + } + + if (!ProcessHandle){ + ProcessHandle = NtCurrentProcess(); + } + + Status = ZwMapViewOfSection(hSection, + ProcessHandle, + BaseAddress, + 0, + 0, + 0, + ViewSize ? ViewSize : &MapViewSize, + ViewUnmap, + 0, + PAGE_WRITECOPY + ); + ZwClose(hSection); + if (!NT_SUCCESS(Status)) + { + DbgPrint("ZwMapViewOfSection Failed! Error=%08x\n",Status); + return Status; + } + + return Status; +} + + + + +ULONG_PTR GetSSDTApiFunAddress(ULONG_PTR ulIndex,ULONG_PTR SSDTDescriptor) +{ + ULONG_PTR SSDTFuncAddress = 0; + switch(WinVersion) + { + case WINDOWS_7: + { + SSDTFuncAddress = GetSSDTFunctionAddress64(ulIndex,SSDTDescriptor); + break; + } + + case WINDOWS_XP: + { + SSDTFuncAddress = GetSSDTFunctionAddress32(ulIndex,SSDTDescriptor); + break; + } + } +} + + +ULONG_PTR GetSSDTFunctionAddress32(ULONG_PTR ulIndex,ULONG_PTR SSDTDescriptor) +{ + ULONG_PTR ServiceTableBase= 0 ; + PSYSTEM_SERVICE_TABLE32 SSDT = (PSYSTEM_SERVICE_TABLE32)SSDTDescriptor; + + ServiceTableBase=(ULONG_PTR)(SSDT ->ServiceTableBase); + + return (ULONG_PTR)(((ULONG*)ServiceTableBase)[(ULONG)ulIndex]); +} + +ULONG_PTR GetSSDTFunctionAddress64(ULONG_PTR ulIndex,ULONG_PTR SSDTDescriptor) +{ + LONG dwTemp=0; + ULONG_PTR qwTemp=0; + ULONG_PTR ServiceTableBase= 0 ; + ULONG_PTR FuncAddress =0; + PSYSTEM_SERVICE_TABLE64 SSDT = (PSYSTEM_SERVICE_TABLE64)SSDTDescriptor; + ServiceTableBase=(ULONG_PTR)(SSDT ->ServiceTableBase); + qwTemp = ServiceTableBase + 4 * ulIndex; + dwTemp = *(PLONG)qwTemp; + dwTemp = dwTemp>>4; + FuncAddress = ServiceTableBase + (ULONG_PTR)dwTemp; + return FuncAddress; +} + + + diff --git a/Register/RegisterManagerDrv/RegisterManagerDrv.h b/Register/RegisterManagerDrv/RegisterManagerDrv.h new file mode 100644 index 0000000..bb97e74 --- /dev/null +++ b/Register/RegisterManagerDrv/RegisterManagerDrv.h @@ -0,0 +1,237 @@ +#pragma once + +#include +#include +#include +#define SEC_IMAGE 0x01000000 + +typedef struct _OPEN_ +{ + ACCESS_MASK DesiredAccess; + POBJECT_ATTRIBUTES ObjectAttributes; +}OPEN,*POPEN; + +typedef struct _ENUM_ +{ + HANDLE hKey; + ULONG Index; + ULONG InformationClass; + ULONG Length; +}ENUM,*PENUM; + +typedef struct _ENUM_VALUE_ +{ + PULONG RetLength; + PVOID ValueInfor; +}ENUM_VALUE, *PENUM_VALUE; + + +typedef struct _CREATE_ +{ + ACCESS_MASK DesiredAccess; + POBJECT_ATTRIBUTES ObjectAttributes; +}CREATE,*PCREATE; + + + +typedef struct _CREATE_VALUE_ +{ + PHANDLE KeyHandle; + PULONG Disposition; +}CREATE_VALUE, *PCREATE_VALUE; + +typedef struct _SET_KEY_VALUE_ +{ + HANDLE hKey; + PUNICODE_STRING ValueName; + ULONG Type; + PVOID Data; + ULONG DataSize; +}SET_KEY_VALUE,*PSET_KEY_VALUE; + + +typedef struct _DELETE_ +{ + HANDLE hKey; + +}*PDELETE; + + +typedef struct _DELETE_KEY_VALUE_ +{ + HANDLE hKey; + PUNICODE_STRING uniValueName; + +}DELETE_KEY_VALUE,*PDELETE_KEY_VALUE; + + +typedef struct _RENAME_ +{ + HANDLE hKey; + PUNICODE_STRING uniNewName; +}RENAME,*PRENAME; + + + +typedef enum WIN_VERSION { + WINDOWS_UNKNOW, + WINDOWS_XP, + WINDOWS_7, + WINDOWS_8, + WINDOWS_8_1 +} WIN_VERSION; + + +typedef struct _SYSTEM_SERVICE_TABLE64{ + PVOID ServiceTableBase; + PVOID ServiceCounterTableBase; + ULONG64 NumberOfServices; + PVOID ParamTableBase; +} SYSTEM_SERVICE_TABLE64, *PSYSTEM_SERVICE_TABLE64; + +typedef struct _SYSTEM_SERVICE_TABLE32 { + PVOID ServiceTableBase; + PVOID ServiceCounterTableBase; + ULONG32 NumberOfServices; + PVOID ParamTableBase; +} SYSTEM_SERVICE_TABLE32, *PSYSTEM_SERVICE_TABLE32; + +#define DEVICE_NAME L"\\Device\\RegisterManagerDevice" +#define LINK_NAME L"\\??\\RegisterManagerLink" + + +#define CTL_CREATE_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x833,METHOD_NEITHER,FILE_ANY_ACCESS) +#define CTL_OPEN_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x830,METHOD_NEITHER,FILE_ANY_ACCESS) +#define CTL_ENUM_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x831,METHOD_NEITHER,FILE_ANY_ACCESS) +#define CTL_ENUM_KEY_VALUE \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x832,METHOD_NEITHER,FILE_ANY_ACCESS) +#define CTL_SET_KEY_VALUE \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x834,METHOD_NEITHER,FILE_ANY_ACCESS) +#define CTL_DELETE_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x835,METHOD_NEITHER,FILE_ANY_ACCESS) +#define CTL_RENAME_KEY \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x836,METHOD_NEITHER,FILE_ANY_ACCESS) +#define CTL_DELETE_KEY_VALUE \ + CTL_CODE(FILE_DEVICE_UNKNOWN,0x837,METHOD_NEITHER,FILE_ANY_ACCESS) + +NTSYSAPI PIMAGE_NT_HEADERS NTAPI RtlImageNtHeader(PVOID Base); + +typedef NTSTATUS(NTAPI *pfnNtOpenKey)(PHANDLE KeyHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes); + +typedef NTSTATUS(NTAPI *pfnNtEnumerateKey)( + HANDLE KeyHandle, + ULONG Index, + KEY_INFORMATION_CLASS KeyInformationClass, + PVOID KeyInformation, + ULONG Length, + PULONG ResultLength); + +typedef NTSTATUS(*pfnNtEnumerateValueKey)( + HANDLE KeyHandle, + ULONG Index, + KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + PVOID KeyValueInformation, + ULONG Length, + PULONG ResultLength); + + +typedef NTSTATUS (*pfnNtCreateKey)( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL); + +typedef NTSTATUS (*pfnNtSetValueKey)( + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex OPTIONAL, + IN ULONG Type, + IN PVOID Data, + IN ULONG DataSize); + +typedef NTSTATUS (*pfnNtDeleteKey)( + IN HANDLE KeyHandle); + +typedef NTSTATUS(*pfnNtRenameKey)( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniNewName); + +typedef NTSTATUS (*pfnNtDeleteValueKey)( + IN HANDLE KeyHandle, + IN PUNICODE_STRING uniValueName); + +VOID UnloadDriver(PDRIVER_OBJECT DriverObject); +NTSTATUS DefaultDispatch(PDEVICE_OBJECT DeviceObject,PIRP Irp); +NTSTATUS ControlDispatch(PDEVICE_OBJECT DeviceObject,PIRP Irp); + +typedef NTSTATUS (*pfnRtlGetVersion)(OUT PRTL_OSVERSIONINFOW lpVersionInformation); +PVOID GetFunctionAddressByName(WCHAR *wzFunction); +WIN_VERSION GetWindowsVersion(); +VOID SetGolbalMember(); +LONG GetSSDTApiFunIndex(IN LPSTR lpszFunName); +NTSTATUS MapFileInUserSpace(IN LPWSTR lpszFileName, + IN HANDLE ProcessHandle OPTIONAL, + OUT PVOID *BaseAddress, + OUT PSIZE_T ViewSize OPTIONAL); + +ULONG_PTR GetSSDTApiFunAddress(ULONG_PTR ulIndex,ULONG_PTR SSDTDescriptor); +ULONG_PTR GetSSDTFunctionAddress64(ULONG_PTR ulIndex,ULONG_PTR SSDTDescriptor); +ULONG_PTR GetSSDTFunctionAddress32(ULONG_PTR ulIndex,ULONG_PTR SSDTDescriptor); +ULONG_PTR GetKeServiceDescriptorTable64(); + +VOID RecoverPreMode(PETHREAD EThread, CHAR PreMode); +CHAR ChangePreMode(PETHREAD EThread); +NTSTATUS RegOpenKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelOpenKey(OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSTATUS RegEnumerateKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelEnumerateKey(IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_INFORMATION_CLASS KeyInformationClass, + OUT PVOID KeyInformation, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSTATUS RegEnumerateValueKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelEnumerateValueKey(IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + OUT PVOID KeyValueInformation, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSTATUS RegCreateKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelCreateKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL); +NTSTATUS RegSetValueKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelSetValueKey(IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex OPTIONAL, + IN ULONG Type, + IN PVOID Data, + IN ULONG DataSize); +NTSTATUS RegDeleteKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelDeleteKey( + IN HANDLE KeyHandle); +NTSTATUS RegRenameKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelRenameKey(IN HANDLE KeyHandle, IN PUNICODE_STRING uniNewName); +NTSTATUS RegDeleteValueKey(PVOID InBuffer,PVOID OutBuffer); +NTSTATUS KernelDeleteValueKey(IN HANDLE KeyHandle, + IN PUNICODE_STRING uniValueName); + diff --git a/Register/RegisterManagerDrv/RegisterManagerDrv.sln b/Register/RegisterManagerDrv/RegisterManagerDrv.sln new file mode 100644 index 0000000..48336fc --- /dev/null +++ b/Register/RegisterManagerDrv/RegisterManagerDrv.sln @@ -0,0 +1,16 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegisterManagerDrv", "RegisterManagerDrv.vcxproj", "{4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + WinDDK|Win32 = WinDDK|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.WinDDK|Win32.ActiveCfg = WinDDK|Win32 + {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41}.WinDDK|Win32.Build.0 = WinDDK|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Register/RegisterManagerDrv/RegisterManagerDrv.suo b/Register/RegisterManagerDrv/RegisterManagerDrv.suo new file mode 100644 index 0000000..131a38c Binary files /dev/null and b/Register/RegisterManagerDrv/RegisterManagerDrv.suo differ diff --git a/Register/RegisterManagerDrv/RegisterManagerDrv.vcxproj b/Register/RegisterManagerDrv/RegisterManagerDrv.vcxproj new file mode 100644 index 0000000..3b9d6ff --- /dev/null +++ b/Register/RegisterManagerDrv/RegisterManagerDrv.vcxproj @@ -0,0 +1,62 @@ + + + + + WinDDK + Win32 + + + + {4EE67C57-BE79-4CD7-B3B0-94AECE62DB41} + Win32Proj + "RegisterManagerDrv" + + + + + + + + .sys + false + $(WLHBASE)\bin\x86\x86;$(WLHBASE)\bin\x86 + $(WLHBASE)\inc\api;$(WLHBASE)\inc\crt;$(WLHBASE)\inc\ddk;$(WLHBASE)\inc + + $(WLHBASE)\lib\win7\i386 + + + + + + _X86_;DBG=1 + false + false + StdCall + CompileAsC + + + + + ntoskrnl.lib;hal.lib;wdm.lib;%(AdditionalDependencies) + + + true + Native + Driver + DriverEntry + true + 0x10000 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Register/RegisterManagerDrv/RegisterManagerDrv.vcxproj.user b/Register/RegisterManagerDrv/RegisterManagerDrv.vcxproj.user new file mode 100644 index 0000000..ace9a86 --- /dev/null +++ b/Register/RegisterManagerDrv/RegisterManagerDrv.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Register/RegisterManagerDrv/clean.bat b/Register/RegisterManagerDrv/clean.bat new file mode 100644 index 0000000..a92852f --- /dev/null +++ b/Register/RegisterManagerDrv/clean.bat @@ -0,0 +1,28 @@ +rem ///////////////// +rem / Add by ChiChou +rem / +rem / FileName:Clean.bat +rem / Description:Clean +rem / +rem //////////////// +rd .\bin /s /q +rd .\WinDDK /s /q +rd .\objchk_w2k_x86 /s /q +rd .\objchk_wxp_x86 /s /q +rd .\objchk_wnet_x86 /s /q +rd .\objchk_wlh_x86 /s /q +rd .\objfre_w2k_x86 /s /q +rd .\objfre_wxp_x86 /s /q +rd .\objfre_wnet_x86 /s /q +rd .\objfre_wlh_x86 /s /q +del .\*.log +del .\*.err +del .\*.xml +rem ***** del VS2005 file ***** +del .\*.ncb +del .\*.user +del .\*.suo /A:H +rem ***** del VS6.0 file ***** +del .\*.plg +del .\*.opt +exit \ No newline at end of file diff --git a/Register/RegisterManagerDrv/ddkbuild.cmd b/Register/RegisterManagerDrv/ddkbuild.cmd new file mode 100644 index 0000000..8acd7a4 --- /dev/null +++ b/Register/RegisterManagerDrv/ddkbuild.cmd @@ -0,0 +1,1122 @@ +@echo off +@set VERSION=V7.3 +@set OSR_DEBUG=off +@if "%OS%"=="Windows_NT" goto :Prerequisites +@echo This script requires Windows NT 4.0 or later to run properly! +goto :EOF +:Prerequisites +:: Check whether FINDSTR is available. It's used to show warnings etc. +findstr /? > NUL 2>&1 || echo "FINDSTR is a prerequisite but wasn't found!" && goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: $Id: ddkbuild.cmd 27 2008-09-06 12:02:06Z oliver $ +:: +:: This software is supplied for instructional purposes only. +:: +:: OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty +:: for this software. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY +:: OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, +:: THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR +:: PURPOSE. THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS +:: WITH YOU. OSR's entire liability and your exclusive remedy shall not +:: exceed the price paid for this material. In no event shall OSR or its +:: suppliers be liable for any damages whatsoever (including, without +:: limitation, damages for loss of business profit, business interruption, +:: loss of business information, or any other pecuniary loss) arising out +:: of the use or inability to use this software, even if OSR has been +:: advised of the possibility of such damages. Because some states/ +:: jurisdictions do not allow the exclusion or limitation of liability for +:: consequential or incidental damages, the above limitation may not apply +:: to you. +:: +:: OSR Open Systems Resources, Inc. +:: 105 Route 101A Suite 19 +:: Amherst, NH 03031 (603) 595-6500 FAX: (603) 595-6503 +:: report bugs to +:: alternatively report them via +:: +:: +:: MODULE: +:: +:: ddkbuild.cmd +:: +:: ABSTRACT: +:: +:: This script allows drivers to be built with Visual Studio 2002 through +:: Visual Studio 2008 and possibly future versions. It will also work fine +:: from the command line. +:: If you are interested in a project wizard that makes use of this script, +:: try DDKWizard from . +:: +:: AUTHOR(S): +:: +:: - OSR Open Systems Resources, Inc. +:: - Oliver Schneider (ddkwizard.assarbad.net) +:: +:: REQUIREMENTS: +:: +:: Environment variables that must be set. +:: %NT4BASE% - Set this up for "-NT4" builds (legacy, support not tested) +:: %W2KBASE% - Set this up for "-W2K*" builds (legacy, support not tested) +:: %WXPBASE% - Set this up for "-WXP*" builds +:: %WNETBASE% - Set this up for "-WNET*" builds +:: %WLHBASE% - Set this up for "-WLH*" builds +:: %WDF_ROOT% - Must be set if attempting to do a WDF Build. +:: +:: Examples: +:: NT4BASE : could be "D:\NT4DDK" +:: W2KBASE : could be "D:\Nt50DDK" +:: WXPBASE : could be "D:\WINDDK\2600" +:: WNETBASE: could be "D:\WINDDK\3790.1830" or "C:\WINDDK\3790" +:: +:: COMMAND FORMAT: +:: +:: Run the script without any parameters to get the whole help content! +:: Note: "-WDF" has been tested with the 01.00.5054 version of the framework +:: +:: RETURN CODES AND THEIR MEANING: +:: +:: 001 == Unknown build type. Check the parameter +:: 002 == No WDF_ROOT given using WDF build type. +:: 003 == The DDK-specific base directory variable (NT4BASE, W2KBASE, WXPBASE, +:: WNETBASE) is not set at all and could not be auto-detected! +:: 004 == BASEDIR variable is empty. Check to see that the DDK-specific +:: variable is set correctly (i.e. NT4BASE, W2KBASE, WXPBASE, WNETBASE) +:: 005 == No mode (checked/free) was given. Check the respective parameter! +:: 006 == No DIR or SOURCES file found in the given target directory. +:: 007 == No target directory given. +:: 008 == Given target directory does not exist. +:: 009 == The SETENV script failed. +:: +:: Note: If %OSR_ERRCODE% and %ERRORLEVEL% are equal, the return code stems +:: from one of the tools being called during the build process. +:: +:: BROWSE FILES: +:: +:: This procedure supports the building of BROWSE files to be used by +:: Visual Studio 6 and by Visual Studio.NET However, the BSCfiles created +:: by bscmake for the two are not compatible. When this command procedure +:: runs, it selects the first bscmake.exe found in the path. So, make sure +:: that the correct bscmake.exe is in the path ... +:: +:: Note that if using Visual Studio.NET the .BSC must be added to the project +:: in order for the project to be browsed. +:: Another alternative is the VS addon named "Visual Assist X" which will +:: parse the header files - no more need for browse files. +:: +:: COMPILERS: +:: +:: If you are building NT4 you should really be using the VC6 compiler. +:: Later versions of the DDK now contain the compiler and the linker. This +:: procedure should use the correct compiler. +:: +:: GENERAL COMMENTS: +:: +:: This procedure has been cleaned up to be modular and easy to understand. +:: +:: As of the Server 2003 SP1 DDK DDKBUILD now clears the NO_BROWSE_FILE and +:: NO_BINPLACE environment variables so that users can use these features. +:: +:: Starting with the Vista WDK, the output in the respective tool window +:: in VS is in Unicode by default. This garbles the output from DDKBUILD +:: and we therefore clear the environment variable VS_UNICODE_OUTPUT. +:: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / MAIN function of the script +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:MAIN +:: Building "stack frame" +setlocal ENABLEEXTENSIONS & pushd . +:: Check whether the REG utility is available +reg /? > NUL 2>&1 && set OSR_REGAVAILABLE=1 + +:: This is set by client-side keyword substitution +set SVN_REVISION=$Revision: 27 $ +:: Extract the revision number from the revision keyword +set SVN_REVISION=%SVN_REVISION:~0,-2% +set SVN_REVISION=%SVN_REVISION:~11% +:: This is set by client-side keyword substitution +set SVN_REVDATE=$Date: 2008-09-06 12:02:06 +0000 (Sat, 06 Sep 2008) $ +:: Extract the date from the Date keyword +set SVN_REVDATE=%SVN_REVDATE:~7,10% +set VERSION=%VERSION%/r%SVN_REVISION% + +:: Init some special variables +set OSR_VERSTR=OSR DDKBUILD.CMD %VERSION% (%SVN_REVDATE%) - OSR, Open Systems Resources, Inc. +set OSR_PREBUILD_SCRIPT=ddkprebld.cmd +set OSR_POSTBUILD_SCRIPT=ddkpostbld.cmd +set OSR_SETENV_SCRIPT=ddkbldenv.cmd +set OSR_ECHO=@echo DDKBLD: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Set error messages +:: Possible codes: 1 +set ERR_UnknownBuildType=Unknown type of build. Please recheck parameters. +:: Possible codes: 2 +set ERR_NoWdfRoot=WDF_ROOT is not defined, are you using 00.01.5054 or later? +:: Possible codes: 3 +set ERR_BaseDirNotSet=To build using type %%OSR_TARGET%% you need to set the %%%%%%BASEDIRVAR%%%%%% environment variable to point to the %%BASEDIROS%% DDK base directory! +:: Possible codes: 4 +set ERR_NoBASEDIR=NT4BASE, W2KBASE, WXPBASE and/or WNETBASE environment variable(s) not set. Environment variable(s) must be set by user according to DDK version(s) installed. +:: Possible codes: 5 +set ERR_BadMode=^ must be 'checked', 'free', 'chk' or 'fre' (case-insensitive). +:: Possible codes: 6 +set ERR_NoTarget=Target directory must contain a SOURCES or DIRS file. +:: Possible codes: 7, 8 +set ERR_NoDir=The ^ parameter must be a valid directory. +:: Possible codes: 9 +set ERR_SetEnvFailed=The SETENV script failed. + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Clear the error code variable +set OSR_ERRCODE=0 +set prefast_build=0 + +:: Turn on tracing, use %OSR_TRACE% instead of ECHO +if /i "%OSR_DEBUG%" == "on" (set OSR_TRACE=%OSR_ECHO% [TRACE]) else (set OSR_TRACE=rem) +:: Turn on echoing of current line if %OSR_DEBUG% is set to "on" +@echo %OSR_DEBUG% + +:: Output version string +@echo %OSR_VERSTR% +%OSR_TRACE% ^(Current module: ^"%~f0^"^) +@echo. + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Set the target platform variable +set OSR_TARGET=%~1 +:: Remove any dashes in the variable +if not "%OSR_TARGET%" == "" set OSR_TARGET=%OSR_TARGET:-=% +:: Show help if the target parameter is empty after removal of the dashes +if "%OSR_TARGET%" == "" goto :USAGE + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: In the build directory check for this script and call it if it exists. +:: This allows to override any global system variable setting, if desired. +if not "%3" == "" call :GetCustomEnvironment "%~f3" +if not "%OSR_ERRCODE%" == "0" goto :USAGE +:: Additional error handling for better usability +:: These subroutines will also attempt to locate the requested DDK!!! +set OSR_ERRCODE=3 +%OSR_TRACE% Checking whether the environment variable for the build type was set +:: Calling as a subroutine has 2 advantages: +:: 1. the script does not quit if the label was not found +:: 2. we return to the line after the call and can check variables there +call :%OSR_TARGET%Check > NUL 2>&1 +:: If the BASEDIROS/BASEDIRVAR variable is not defined, it means the subroutine did not exist! +if not DEFINED BASEDIROS call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (BASEDIROS)" & goto :USAGE +if not DEFINED BASEDIRVAR call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (BASEDIRVAR)" & goto :USAGE +if not "%OSR_ERRCODE%" == "0" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_BaseDirNotSet%" & goto :USAGE + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +set BASEDIR=%%%BASEDIRVAR%%% +call :ResolveVar BASEDIR +call :MakeShort BASEDIR "%BASEDIR%" +:: Check for existing %BASEDIR% +if "%BASEDIR%" == "" call :ShowErrorMsg 4 "%ERR_NoBASEDIR%" & goto :USAGE +set PATH=%BASEDIR%\bin;%PATH% +%OSR_TRACE% Now jump to the initialization of the commandline +:: Calling as a subroutine has 2 advantages: +:: 1. the script does not quit if the label was not found +:: 2. we return to the line after the call and can check variables there +call :%OSR_TARGET%Build + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +%OSR_TRACE% We returned from the variable initialization +if not DEFINED OSR_CMDLINE call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (OSR_CMDLINE)" & goto :USAGE + +%OSR_TRACE% Hurrah, all the variables have been initialized, continuing +:: Proceed with common build steps +goto :CommonBuild + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Check whether the parameter makes sense and try to +:: correct it if possible +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: These labels are for compatibility with the respective +:: modes supported by another flavor of DDKBUILD. +:WLH64Check +:WLHA64Check +:WLHXP64Check +:WLHNET64Check +:WLHNETA64Check +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:WLHCheck +:WLHX64Check +:WLHI64Check +:WLHNETX64Check +:WLHNETI64Check +:WLHXPCheck +:WLH2KCheck +:WLHNETCheck +set BASEDIROS=Windows Vista/Windows 2008 Server +set BASEDIRVAR=WLHBASE +:: Compatibility between BUILD and VS ... prevent pipes from being used +%OSR_ECHO% Clearing %%VS_UNICODE_OUTPUT%% ... +set VS_UNICODE_OUTPUT= +:: Return to caller if the BASEDIR is already defined (either customized or global) +if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn +call :DetectBaseDirTemp "6001.18000 6000" +if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn +goto :CommonCheckErrorNotSupportedWithReturn + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: These labels are for compatibility with the respective +:: modes supported by another flavor of DDKBUILD. +:WNETW2KCheck +:WNETA64Check +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:WNET2KCheck +:WNETXPCheck +:WNETWXPCheck +:WNETXP64Check +:WNET64Check +:WNETI64Check +:WNETAMD64Check +:WNETX64Check +:WNETCheck +set BASEDIROS=Windows 2003 Server +set BASEDIRVAR=WNETBASE +:: Return to caller if the BASEDIR is already defined (either customized or global) +if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn +call :DetectBaseDirTemp "3790.1830 3790.1218 3790" +if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn +goto :CommonCheckErrorNotDetectedWithReturn + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: These labels are for compatibility with the respective +:: modes supported by another flavor of DDKBUILD. +:XPCheck +:XP64Check +:XPW2KCheck +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:WXP64Check +:WXPI64Check +:WXPCheck +:WXP2KCheck +set BASEDIROS=Windows XP +set BASEDIRVAR=WXPBASE +:: Other flavor of DDKBUILD +if not DEFINED WXPBASE if DEFINED XPBASE set BASEDIRVAR=XPBASE +:: Return to caller if the BASEDIR is already defined (either customized or global) +if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn +call :DetectBaseDirTemp "2600.1106 2600" +if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn +goto :CommonCheckErrorNotDetectedWithReturn + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:W2K64Check +:W2KI64Check +:W2KCheck +set BASEDIROS=Windows 2000 +set BASEDIRVAR=W2KBASE +:: Return to caller +if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn +call :CommonCheckMsg2 +goto :CommonCheckErrorNotSupportedWithReturn + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:NT4Check +set BASEDIROS=Windows NT4 +set BASEDIRVAR=NT4BASE +:: Return to caller +if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn +call :CommonCheckMsg2 +goto :CommonCheckErrorNotSupportedWithReturn + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:CommonCheckMsg1 +echo. +%OSR_ECHO% WARNING: %%%BASEDIRVAR%%% NOT SET! +%OSR_ECHO% Attempting to auto-detect the installation folder and set %%%BASEDIRVAR%%%. +%OSR_ECHO% (If this fails *you* will have to set it!) +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:CommonCheckMsg2 +echo. +%OSR_ECHO% WARNING: +%OSR_ECHO% Auto-detection of the folder settings is not supported for the requested DDK. +%OSR_ECHO% Please set %%%BASEDIRVAR%%% yourself! +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:CommonCheckSetVarWithReturn +%OSR_ECHO% Found! +echo. +set %BASEDIRVAR%=%BASEDIRTEMP% +set BASEDIRTEMP= +:: Tell the caller it was successful +:CommonCheckNoErrorWithReturn +set OSR_ERRCODE=0 +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:CommonCheckErrorNotDetectedWithReturn +echo. +%OSR_ECHO% None of the usual default paths works. Set %%%BASEDIRVAR%%% manually! +:CommonCheckErrorNotSupportedWithReturn +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Initialize variables specific to the respective platform +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Valid parameters for setenv in different DDKs/WDKs: +:: +:: 2600 - "setenv [fre|chk] [64] [hal]" +:: 2600.1106 - "setenv [fre|chk] [64] [hal] [WXP|W2K]" +:: 3790 - "setenv [fre|chk] [64|AMD64] [hal] [WXP|WNET|W2K]" +:: 3790.1830 - "setenv [fre|chk] [64|AMD64] [hal] [WXP|WNET|W2K] [no_prefast] [bscmake]" +:: 6000 - "setenv [fre|chk] [64|AMD64] [hal] [WLH|WXP|WNET|W2K] [bscmake]" +:: 6001.18000 - "setenv [fre|chk] [64|x64] [hal] [WLH|WXP|WNET|W2K] [bscmake]" + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: NT 4.0 build using NT4 DDK +:NT4Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% "%%MSDEVDIR%%" +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: W2K build for 32bit using WXP DDK +:XPW2KBuild +:WXP2KBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\w2k\set2k.bat" %%BASEDIR%% %%BuildMode%% +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: W2K build for 64bit (Intel) using W2K DDK +:W2K64Build +:W2KI64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv64.bat" %%BASEDIR%% %%BuildMode%% +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: W2K build for 32bit using W2K DDK +:W2KBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WXP build for 64bit (Intel) using WXP DDK +:XP64Build +:WXP64Build +:WXPI64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WXP build for 32bit using WXP DDK +:XPBuild +:WXPBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: W2K build for 32bit using WNET DDK +:WNETW2KBuild +:WNET2KBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% W2K %%BuildMode%% +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WXP build for 32bit using WNET DDK +:WNETXPBuild +:WNETWXPBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WXP +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WXP build for 64bit using WNET DDK +:WNETXP64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WXP +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WNET build for 64bit (Intel) using WNET DDK +:WNET64Build +:WNETI64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WNET +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WNET build for 64bit (AMD) using WNET DDK +:WNETA64Build +:WNETAMD64Build +:WNETX64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% AMD64 WNET +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WNET build for 32bit using WNET DDK +:WNETBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WLH build for 32bit using WLH DDK +:WLHBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WLH +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WLH build for 64bit (AMD) using WLH DDK +:WLHA64Build +:WLHX64Build +call :DetectVistaWDK +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% %OSR_AMD64FLAG% WLH +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WLH build for 64bit (Intel) using WLH DDK +:WLH64Build +:WLHI64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WLH +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WNET build for 64bit (AMD) using WLH DDK +:WLHNETA64Build +:WLHNETX64Build +call :DetectVistaWDK +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% %OSR_AMD64FLAG% WNET +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WNET build for 64bit (Intel) using WLH DDK +:WLHNET64Build +:WLHNETI64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WNET +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WXP build for 32bit using WLH DDK +:WLHXPBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WXP +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WXP build for 64bit (Intel) using WLH DDK +:WLHXP64Build +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% 64 WXP +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: W2K build for 32bit using WLH DDK +:WLH2KBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% W2K +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: WNET build for 32bit using WLH DDK +:WLHNETBuild +set OSR_CMDLINE="%%BASEDIR%%\bin\setenv.bat" %%BASEDIR%% %%BuildMode%% WNET +goto :EOF + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: All builds go here for the rest of the procedure. Now, +:: we are getting ready to call build. The big problem +:: here is to figure our the name of the buildxxx files +:: being generated for the different platforms. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:CommonBuild +:: Remove first command line arg +shift +call :SetMode %1 +if not "%OSR_ERRCODE%" == "0" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_BadMode%" & goto :USAGE +set OSR_BUILDNAME=%OSR_TARGET% (%BuildMode%) using the %BASEDIROS% DDK and %%%BASEDIRVAR%%% + +call :CheckTargets %2 +if "%OSR_ERRCODE%" == "6" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoTarget%" & goto :USAGE +if not "%OSR_ERRCODE%" == "0" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoDir%" & goto :USAGE + +:: Resolve any variables in the command line string +call :ResolveVar OSR_CMDLINE + +pushd . +set ERRORLEVEL=0 +:: This external script prepares the build environment (e.g. setenv.bat) +call %OSR_CMDLINE% +:: Will only work with newer SETENV.BAT versions, but will be helpful in this case. +if not "%ERRORLEVEL%" == "0" call :ShowErrorMsg 9 "%ERR_SetEnvFailed%" & goto :USAGE +popd + +:: ---------------------------------------------------------------------------- +:: Setting global variables for the scope of this CMD session +set NO_BROWSER_FILE= +set NO_BINPLACE= +set buildDirectory=%~fs2 +call :MakeShort buildDirectory "%buildDirectory%" +set buildDirectory_raw=%2 +set buildDirectory_fname=%~n2 +%OSR_TRACE% buildDirectory == %buildDirectory% +%OSR_TRACE% buildDirectory_raw == %buildDirectory_raw% +%OSR_TRACE% buildDirectory_fname == %buildDirectory_fname% + +set mpFlag=-M +if "%BUILD_ALT_DIR%" == "" goto :NT4 + +:: W2K sets this! +set OSR_EXT=%BUILD_ALT_DIR% +set mpFlag=-MI + +:NT4 +if "%NUMBER_OF_PROCESSORS%" == "" set mpFlag= +if "%NUMBER_OF_PROCESSORS%" == "1" set mpFlag= + +:: Set additional variables at this point or do whatever you please +@if exist "%buildDirectory%\%OSR_PREBUILD_SCRIPT%" @( + %OSR_ECHO% ^>^> Performing pre-build steps [%OSR_PREBUILD_SCRIPT%] ... + pushd "%buildDirectory%" + call "%OSR_PREBUILD_SCRIPT%" > "%TEMP%\%OSR_PREBUILD_SCRIPT%.tmp" + for /f "tokens=*" %%x in ('type "%TEMP%\%OSR_PREBUILD_SCRIPT%.tmp"') do @( + %OSR_ECHO% %%x + ) + if exist "%TEMP%\%OSR_PREBUILD_SCRIPT%.tmp" del /f /q "%TEMP%\%OSR_PREBUILD_SCRIPT%.tmp" + popd + %OSR_ECHO% ^<^< Finished pre-build steps [%OSR_PREBUILD_SCRIPT%] ... +) +:: Save the current directory (before changing into the build directory!) +:: AFTERPREBUILD +pushd . + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Determine the settings of flags, WDF and PREFAST in +:: other words what was set for %3 and beyond.... +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +%OSR_ECHO% %OSR_BUILDNAME% +set OSR_ARGS= + argument(s): +if not "%3" == "" set OSR_ARGS=%OSR_ARGS% %3 +if not "%4" == "" set OSR_ARGS=%OSR_ARGS% %4 +if not "%5" == "" set OSR_ARGS=%OSR_ARGS% %5 +if /i "%OSR_ARGS%" == " + argument(s):" set OSR_ARGS= +%OSR_ECHO% Directory: %buildDirectory%%OSR_ARGS% +%OSR_ECHO% %BASEDIRVAR%: %BASEDIR% + +cd /D %~s2 +set bFlags=-Ze +set bscFlags= + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:ContinueParsing +if "%3" == "" goto :DONE +if "%3" == "/a" goto :RebuildallFound +if /i "%3" == "-WDF" goto :WDFFound +if /i "%3" == "-PREFAST" goto :PrefastFound +set bscFlags=/n +set bFlags=%bFlags% %3 +:: Remove next arg +shift +goto :ContinueParsing + +:WDFFound +shift +:: Note, that the setwdf.bat is called from setenv.bat in the WDK, +:: therefore we skip it. +if /i "%BASEDIRVAR%" == "WLHBASE" goto :WDFOkay +if "%WDF_ROOT%" == "" call :ShowErrorMsg 2 "%ERR_NoWdfRoot%" & goto :USAGE +pushd . +if exist "%WDF_ROOT%\set_wdf_env.cmd" call "%WDF_ROOT%\set_wdf_env.cmd" +popd +:WDFOkay +goto :ContinueParsing + +:PrefastFound +shift +set prefast_build=1 +goto :ContinueParsing + +:RebuildallFound +shift +set bscFlags=/n +set bFlags=%bFlags:-Ze=-cfeZ% +set bFlags=%bFlags: -cZ=% +goto :ContinueParsing +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:DONE +for %%x in (build%OSR_EXT%.err build%OSR_EXT%.wrn build%OSR_EXT%.log prefast%OSR_EXT%.log) do @( + if exist "%%x" del /f /q "%%x" +) + +if not "%prefast_build%" == "0" goto :RunPrefastBuild +%OSR_ECHO% Run build %mpFlag% %bFlags% for %BuildMode% version in %buildDirectory_raw% +pushd . +build %mpFlag% %bFlags% +popd +goto :BuildComplete + +:RunPrefastBuild +%OSR_ECHO% Run prefast build %mpFlag% %bFlags% for %BuildMode% version in %buildDirectory_raw% +setlocal ENABLEEXTENSIONS & pushd . +set PREFASTLOG=PREfast_defects_%OSR_EXT%.xml +prefast /log=%PREFASTLOG% /reset build %mpFlag% %bFlags% > NUL 2>&1 +if "%errorlevel%" GTR "0" set OSR_ERRCODE=%errorlevel% +prefast /log=%PREFASTLOG% list > prefast%OSR_EXT%.log +%OSR_ECHO% The PREfast logfile is ^"%prefastlog%^"! +popd & endlocal + +:BuildComplete +if not "%errorlevel%" == "0" set OSR_ERRCODE=%errorlevel% + +@echo %OSR_DEBUG% +:: Assume that the onscreen errors are complete! +setlocal +set WARNING_FILE_COUNT=0 +if exist "build%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][DRCLU][0-9][0-9]* error[^.][DRCLU][0-9][0-9]*" "build%OSR_EXT%.log"') do @( + set /a WARNING_FILE_COUNT=%WARNING_FILE_COUNT%+1 +) +if not "%WARNING_FILE_COUNT%" == "0" ( + %OSR_ECHO% ================ Build warnings ======================= + if exist "build%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][DRCLU][0-9][0-9]* error[^.][DRCLU][0-9][0-9]*" "build%OSR_EXT%.log"') do @( + @echo %%x + ) +) +set WARNING_FILE_COUNT_PRE=0 +if exist "prefast%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][CLU]*" "prefast%OSR_EXT%.log"') do @( + set /a WARNING_FILE_COUNT_PRE=%WARNING_FILE_COUNT_PRE%+1 +) +:: Reset if this is no PREfast build +if "%prefast_build%" == "0" set WARNING_FILE_COUNT_PRE=0 +if not "%WARNING_FILE_COUNT_PRE%" == "0" ( + %OSR_ECHO% =============== PREfast warnings ====================== + if exist "prefast%OSR_EXT%.log" for /f "tokens=*" %%x in ('findstr "warning[^.][CLU]*" "prefast%OSR_EXT%.log"') do @( + @echo %%x + ) +) +set /a WARNING_FILE_COUNT=%WARNING_FILE_COUNT%+%WARNING_FILE_COUNT_PRE% +if not "%WARNING_FILE_COUNT%" == "0" ( + %OSR_ECHO% ======================================================= +) +endlocal +@echo. +%OSR_ECHO% Build complete +%OSR_ECHO% Building browse information files +if exist "buildbrowse.cmd" call "buildbrowse.cmd" & goto :postBuildSteps +set sbrlist=sbrList.txt +if not exist sbrList%CPU%.txt goto :sbrDefault +set sbrlist=sbrList%CPU%.txt + +:sbrDefault +if not exist %sbrlist% goto :postBuildSteps +:: Prepend blank space +if not "%bscFlags%" == "" set bscFlags= %bscFlags% +:: bscmake%bscFlags% prevents a double blank space ... +bscmake%bscFlags% @%sbrlist% + +:: Perform whatever post-build steps +:postBuildSteps +:: Restore the current directory (after changing into the build directory!) +:: Search upwards for "AFTERPREBUILD" to find the corresponding PUSHD +popd +@if exist "%buildDirectory%\%OSR_POSTBUILD_SCRIPT%" @( + %OSR_ECHO% ^>^> Performing post-build steps [%OSR_POSTBUILD_SCRIPT%] ... + pushd "%buildDirectory%" + call "%OSR_POSTBUILD_SCRIPT%" > "%TEMP%\%OSR_POSTBUILD_SCRIPT%.tmp" + for /f "tokens=*" %%x in ('type "%TEMP%\%OSR_POSTBUILD_SCRIPT%.tmp"') do @( + %OSR_ECHO% %%x + ) + if exist "%TEMP%\%OSR_POSTBUILD_SCRIPT%.tmp" del /f /q "%TEMP%\%OSR_POSTBUILD_SCRIPT%.tmp" + popd + %OSR_ECHO% ^<^< Finished post-build steps [%OSR_POSTBUILD_SCRIPT%] ... +) +goto :END +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ MAIN function of the script +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / GetCustomEnvironment +:: First parameter is the "directory" that supposedly contains the SOURCES +:: or DIRS file (and the build scripts) +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:GetCustomEnvironment +pushd . +call :CheckTargets "%~f1" +@if not "%OSR_ERRCODE%" == "0" @( + echo. + %OSR_ECHO% The target directory seemed to not contain a DIRS or SOURCES file + %OSR_ECHO% when trying to set a custom environment! Quitting. + set buildDirectory=%~f1 + if "%OSR_ERRCODE%" == "6" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoTarget%" & goto :GetCustomEnvironment_ret + call :ShowErrorMsg %OSR_ERRCODE% "%ERR_NoDir%" & goto :GetCustomEnvironment_ret + goto :GetCustomEnvironment_ret +) +:: If the user provided a script to customize the environment, execute it. +@if exist "%~f1\%OSR_SETENV_SCRIPT%" @( + %OSR_ECHO% ^>^> Setting custom environment variables [%OSR_SETENV_SCRIPT%] ... + pushd "%~f1" + call "%OSR_SETENV_SCRIPT%" > "%TEMP%\%OSR_SETENV_SCRIPT%.tmp" + for /f "tokens=*" %%x in ('type "%TEMP%\%OSR_SETENV_SCRIPT%.tmp"') do @( + %OSR_ECHO% %%x + ) + if exist "%TEMP%\%OSR_SETENV_SCRIPT%.tmp" del /f /q "%TEMP%\%OSR_SETENV_SCRIPT%.tmp" + popd + %OSR_ECHO% ^<^< Finished setting custom environment variables [%OSR_SETENV_SCRIPT%] ... +) +:GetCustomEnvironment_ret +popd +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ GetCustomEnvironment +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / SetMode +:: Subroutine to validate the mode of the build passed in. It must be free, +:: FREE, fre, FRE or checked, CHECKED, chk, CHK. Anything else is an error. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:SetMode +set BuildMode= +if /i "%OSR_TARGET%" == "WLH2K" goto :SetModeWLH2K +for %%f in (free fre) do if /i "%%f" == "%1" set BuildMode=free +for %%f in (checked chk) do if /i "%%f" == "%1" set BuildMode=checked +goto :SetModeCommonEnd +:SetModeWLH2K +for %%f in (free fre) do if /i "%%f" == "%1" set BuildMode=f +for %%f in (checked chk) do if /i "%%f" == "%1" set BuildMode=c +:SetModeCommonEnd +%OSR_TRACE% Mode set to ^"%BuildMode%^" +if "%BuildMode%" == "" set OSR_ERRCODE=5 +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ SetMode +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / CheckTargets subroutine +:: Subroutine to validate that the target directory exists and that there is +:: either a DIRS or SOURCES and MakeFile in it. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:CheckTargets +:: Building "stack frame" +setlocal & pushd . & set OSR_ERRCODE=0 +set lTarget=%~1 +if not "%lTarget%" == "" goto :CheckTargets1 +set OSR_ERRCODE=7 +goto :CheckTargets_ret +:CheckTargets1 +if exist "%lTarget%" goto :CheckTargets2 +set OSR_ERRCODE=8 +goto :CheckTargets_ret +:CheckTargets2 +if not exist "%lTarget%\DIRS" goto :CheckTargets3 +set OSR_ERRCODE=0 +goto :CheckTargets_ret +:CheckTargets3 +if exist "%lTarget%\SOURCES" goto :CheckTargets4 +set OSR_ERRCODE=6 +goto :CheckTargets_ret +:CheckTargets4 +if exist "%lTarget%\MAKEFILE" goto :CheckTargets5 +set OSR_ERRCODE=6 +goto :CheckTargets_ret +:CheckTargets5 +set OSR_ERRCODE=0 +:CheckTargets_ret +:: Cleaning "stack frame" and returning error code into global scope +popd & endlocal & set OSR_ERRCODE=%OSR_ERRCODE% +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ CheckTargets subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / ResolveVar subroutine +:: There is only one parameter, the name of the variable to be resolved! +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:ResolveVar +:: Get the name of the variable we are working with +setlocal ENABLEEXTENSIONS & set VAR_NAME=%1 +set VAR_TEMPRET2=%%%VAR_NAME%%% +:ResolveVarLoop +set VAR_TEMPRET1=%VAR_TEMPRET2% +set VAR_TEMPRET2=%VAR_TEMPRET1% +for /f "tokens=*" %%i in ('echo %VAR_TEMPRET1%') do ( + set VAR_TEMPRET2=%%i +) +if not "%VAR_TEMPRET1%" == "%VAR_TEMPRET2%" goto :ResolveVarLoop +:: Re-export the variable out of the local scope +endlocal & set %VAR_NAME%=%VAR_TEMPRET1% +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ ResolveVar subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / MakeShort subroutine +:: Two parameters. First parameter is the variable name, second is the path +:: to convert into a short filename. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:MakeShort +setlocal ENABLEEXTENSIONS +:: Get the name of the variable we are working with and the path to convert +set VAR_NAME=%~1 +set PATH_SHORT=%~dpns2 +set PATH_EXTSHORT=%~xs2 +if not "" == "%PATH_EXTSHORT%" set PATH_EXTSHORT=%PATH_EXTSHORT:~0,4% +set PATH_SHORT=%PATH_SHORT%%PATH_EXTSHORT% +endlocal & set %VAR_NAME%=%PATH_SHORT% +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ MakeShort subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / ErrorWithUsage subroutine +:: This one will take the passed in parameters and build a nice error +:: message which is returned to the user along with the usage hints. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:ShowErrorMsg +@set OSR_ERRCODE=%~1 +@set OSR_ERRMSG=%~2 +@set OSR_ERRMSG=%OSR_ERRMSG:'="% +@set OSR_ERRMSG=ERROR #%OSR_ERRCODE%: %OSR_ERRMSG% +@echo. +%OSR_ECHO% %OSR_ERRMSG% +if DEFINED buildDirectory %OSR_ECHO% -^> Target directory: %buildDirectory% +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ ErrorWithUsage subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / SetVar subroutine +:: Param1 == name of the variable, Param2 == value to be set for the variable +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:SetVar +:: Get the name of the variable we are working with +setlocal ENABLEEXTENSIONS & set VAR_NAME=%1 +endlocal & set %VAR_NAME%=%~2 +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ SetVar subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / DetectVistaWDK subroutine +:: No parameters expected +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:DetectVistaWDK +setlocal ENABLEEXTENSIONS +:: Newer flag (starting with W2K8) is default +set OSR_AMD64FLAG=x64 +:: The Vista WDK accepted *only* "AMD64", the newer W2K8 WDK accepts only "x64" +:: We detect the older one by checking the setenv.bat for a certain string +findstr /C:"Windows Server Longhorn" "%BASEDIR%\bin\setenv.bat" > NUL 2>&1 && set OSR_AMD64FLAG=AMD64 +endlocal & set OSR_AMD64FLAG=%OSR_AMD64FLAG% +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ DetectVistaWDK subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / DetectBaseDirTemp subroutine +:: The first parameter is the list of directory names to check, separated by +:: blank spaces. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:DetectBaseDirTemp +:: Get the name of the variable we are working with +if "%~1" == "" goto :EOF +setlocal ENABLEEXTENSIONS +call :CommonCheckMsg1 +:: Try to find an installed DDK/WDK from the registry keys +if DEFINED OSR_REGAVAILABLE if not "%OSR_REGAVAILABLE%" == "0" ( + for %%i in (%~1) do @( + call :RegTryBaseDirTemp "%%i" + ) +) +:: Try all the "default" locations +if not DEFINED BASEDIRTEMP ( + for %%i in (%~1) do @( + for %%a in (WINDDK DDK) do @( + call :BruteTryBaseDirTemp "%SystemDrive%\%%a\%%i" + call :BruteTryBaseDirTemp "%ProgramFiles%\%%a\%%i" + ) + ) +) +endlocal & set BASEDIRTEMP=%BASEDIRTEMP% +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ DetectBaseDirTemp subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / RegTryBaseDirTemp subroutine +:: Attempt to find the install key in the registry. +:: This functions tests old-style DDKs and new-style WDKs. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:RegTryBaseDirTemp +if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :EOF +setlocal ENABLEEXTENSIONS +call :RegTryBaseDirTempSingle "%~1" "LFNDirectory" BASEDIRTEMP +if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :RegTryBaseDirTemp_EOF +call :RegTryBaseDirTempSingle "%~1\Setup" "BUILD" BASEDIRTEMP +if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :RegTryBaseDirTemp_EOF +if not DEFINED BASEDIRTEMP (endlocal & goto :EOF) +:RegTryBaseDirTemp_EOF +%OSR_ECHO% Found directory (%BASEDIRTEMP%) from install key +endlocal & set BASEDIRTEMP=%BASEDIRTEMP% & goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ RegTryBaseDirTemp subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / RegTryBaseDirTempSingle subroutine +:: Attempt to find the install key in the registry. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:RegTryBaseDirTempSingle +setlocal ENABLEEXTENSIONS +set REGSUBKEY=%~1 +set REGVALUE=%~2 +set VARIABLETOSET=%~3 +set REGMAINKEY=HKLM\SOFTWARE\Microsoft\WINDDK +:: Test whether we can read the value below this key +reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%" > NUL 2>&1 || goto :RegTryBaseDirTempSingle_WOW64 +for /f "tokens=2*" %%i in ('reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%"^|findstr /C:"%REGVALUE%"') do @( + call :SetVar _SETVARIABLE "%%j" +) +endlocal & set %VARIABLETOSET%=%_SETVARIABLE% +:RegTryBaseDirTempSingle_WOW64 +set REGMAINKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\WINDDK +:: Test whether we can read the value below this key +reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%" > NUL 2>&1 || goto :RegTryBaseDirTempSingle_EOF +for /f "tokens=2*" %%i in ('reg query "%REGMAINKEY%\%REGSUBKEY%" /v "%REGVALUE%"^|findstr /C:"%REGVALUE%"') do @( + call :SetVar _SETVARIABLE "%%j" +) +endlocal & set %VARIABLETOSET%=%_SETVARIABLE% +:RegTryBaseDirTempSingle_EOF +endlocal +goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ RegTryBaseDirTempSingle subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: / BruteTryBaseDirTemp subroutine +:: Brute-force test the given directory. +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:BruteTryBaseDirTemp +if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :EOF +setlocal ENABLEEXTENSIONS +:: We will not overwrite BASETEMPDIR if it has been set and is valid +:: Just try +set BASEDIRTEMP=%~1 +%OSR_ECHO% Trying %BASEDIRTEMP% ... +if not exist "%BASEDIRTEMP%" (endlocal & goto :EOF) +endlocal & set BASEDIRTEMP=%BASEDIRTEMP% & goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: \ BruteTryBaseDirTemp subroutine +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Usage output +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:USAGE +@echo. +@echo USAGE: +@echo ====== +@echo %~n0 ^ ^ ^ [flags] [-WDF] [-PREFAST] +@echo. +@echo Values for ^: +@echo -------------------------------------------------------------------------- +@echo Target platform and OS ^| Miscellaneous +@echo --------------------------^|----------------------------------------------- +@echo Target ^| Windows ^| CPU ^| Base directory ^| Target alias(es) +@echo ------------^|-------------^|---------^|----------------^|-------------------- +@echo -W2K ^| 2000 ^| x86 ^| %%W2KBASE%% ^| +@echo -W2K64 ^| 2000 ^| Itanium ^| %%W2KBASE%% ^| -W2KI64 +@echo -WXP ^| XP ^| x86 ^| %%WXPBASE%% ^| -XP +@echo -WXP64 ^| XP ^| Itanium ^| %%WXPBASE%% ^| -WXPI64, -XP64 +@echo -WXP2K ^| 2000 ^| x86 ^| %%WXPBASE%% ^| -XPW2K +@echo -WNET ^| 2003 ^| x86 ^| %%WNETBASE%% ^| +@echo -WNET64 ^| 2003 ^| Itanium ^| %%WNETBASE%% ^| -WNETI64 +@echo -WNETXP ^| XP ^| x86 ^| %%WNETBASE%% ^| +@echo -WNETXP64 ^| XP ^| Itanium ^| %%WNETBASE%% ^| +@echo -WNETAMD64 ^| 2003/XP x64 ^| x64 ^| %%WNETBASE%% ^| -WNETX64, -WNETA64 +@echo -WNET2K ^| 2000 SP3 ^| x86 ^| %%WNETBASE%% ^| -WNETW2K +@echo -WLH ^| Vista/2008 ^| x86 ^| %%WLHBASE%% ^| +@echo -WLH2K ^| 2000 SP4 ^| x86 ^| %%WLHBASE%% ^| +@echo -WLHXP ^| XP ^| x86 ^| %%WLHBASE%% ^| +@echo -WLHXP64 ^| XP ^| Itanium ^| %%WLHBASE%% ^| +@echo -WLHNET ^| 2003 ^| x86 ^| %%WLHBASE%% ^| +@echo -WLHNETI64 ^| 2003 ^| Itanium ^| %%WLHBASE%% ^| -WLHNET64 +@echo -WLHNETX64 ^| 2003/XP x64 ^| x64 ^| %%WLHBASE%% ^| -WLHNETA64 +@echo -WLHI64 ^| Vista/2008 ^| Itanium ^| %%WLHBASE%% ^| -WLH64 +@echo -WLHX64 ^| Vista/2008 ^| x64 ^| %%WLHBASE%% ^| -WLHA64 +@echo -NT4 ^| NT 4.0 ^| x86 ^| %%NT4BASE%% ^| +@echo -------------------------------------------------------------------------- +@echo Support for NT4 and W2K DDKs is deprecated and not checked anymore +@echo in new versions. It may or may not work properly. +@echo -------------------------------------------------------------------------- +@echo. +@echo Values for ^: +@echo checked, chk indicates a checked build +@echo free, fre indicates a free build +@echo. +@echo Remaining parameters ("opt!" = optional parameter): +@echo ^ path to build directory, try . (current directory) +@echo [flags] opt! any flags you think should be passed to build (try /a +@echo for clean) +@echo -WDF opt! performs a WDF build +@echo -PREFAST opt! performs a PREFAST build +@echo. +@echo Special files: +@echo The build target directory (where the DIRS or SOURCES file resides) can +@echo contain the following files: +@echo - %OSR_PREBUILD_SCRIPT% +@echo Allows to include a step before the BUILD tool from the DDK is called +@echo but after the environment for the respective DDK has been set! +@echo - %OSR_POSTBUILD_SCRIPT% +@echo Allows to include a step after the BUILD tool from the DDK is called, +@echo so the environment is still available to the script. +@echo - %OSR_SETENV_SCRIPT% +@echo Allows to set (or override) _any_ environment variables that may exist +@echo in the global environment. Thus you can set the base directory for the +@echo DDK from inside this script, making your project more self-contained. +@echo. +@echo DDKBUILD will only handle those files which exist, so you may choose to +@echo use none, one or multiple of these script files. +@echo (All scripts execute inside their current directory. Consider this!) +@echo. +@echo Examples: +@echo ^"%~n0 -NT4 checked .^" (for NT4 BUILD) +@echo ^"%~n0 -WXP64 chk .^" +@echo ^"%~n0 -WXP chk c:\projects\myproject^" +@echo ^"%~n0 -WNET64 chk .^" (IA64 build) +@echo ^"%~n0 -WNETAMD64 chk .^" (AMD64/EM64T build) +@echo ^"%~n0 -WNETXP chk . -cZ -WDF^" +@echo ^"%~n0 -WNETXP chk . -cZ -PREFAST^" +@echo. +@echo In order for this procedure to work correctly for each platform, it +@echo requires an environment variable to be set up for certain platforms. +@echo There is an auto-detection mechanism in this script, which will work best +@echo if the DDK/WDK was installed using the normal installer (i.e. not just +@echo copied). The auto-detection is based on the DDK/WDK for which you request +@echo a build. Whenever you set the variable explicitly, this will take +@echo precedence over the auto-detected path! +@echo The environment variables are as follows: +@echo. +@echo %%NT4BASE%% - Set this up for ^"-NT4^" builds +@echo %%W2KBASE%% - Set this up for ^"-W2K^" and ^"-W2K64^" builds +@echo %%WXPBASE%% - Set this up for ^"-WXP^", ^"-WXP64^", ^"-WXP2K^" builds +@echo %%WNETBASE%% - Set this up for ^"-WNET*^" builds +@echo %%WLHBASE%% - Set this up for ^"-WLH*^" builds +@echo. +@echo %%WDF_ROOT%% must be set if attempting to do a WDF Build previous to the +@echo Vista WDK (in later DDKs there is no need to set WDF_ROOT). +@echo. +@echo Path to this script: +@echo %~f0 +@echo. +@echo %OSR_VERSTR% +@echo -^> report any problems to ^ or ^ +@echo. + +:END +popd & endlocal & exit /b %OSR_ERRCODE% \ No newline at end of file diff --git a/Register/RegisterManagerDrv/makefile b/Register/RegisterManagerDrv/makefile new file mode 100644 index 0000000..98801a4 --- /dev/null +++ b/Register/RegisterManagerDrv/makefile @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def \ No newline at end of file diff --git a/Register/RegisterManagerDrv/mybuild.bat b/Register/RegisterManagerDrv/mybuild.bat new file mode 100644 index 0000000..ecb14fe --- /dev/null +++ b/Register/RegisterManagerDrv/mybuild.bat @@ -0,0 +1,3 @@ +set WLHBASE=C:\WINDDK\7600.16385.0 +set WDF_ROOT=C:\WINDDK\7600.16385.0 +ddkbuild.cmd -WLH chk . -cZ -WDF \ No newline at end of file diff --git a/Register/RegisterManagerDrv/readme.txt b/Register/RegisterManagerDrv/readme.txt new file mode 100644 index 0000000..f2b78db --- /dev/null +++ b/Register/RegisterManagerDrv/readme.txt @@ -0,0 +1,157 @@ +----------------------- +ithurricane [http://hi.baidu.com/ithurricane] +2010/02/04 +----------------------- +support WDK7/VS2008 +fix Privilege Problem +modify register source + +----------------------- +bobo 2009/05/21 +----------------------- +޸bug: VC6 + DDK2003 -> vc6.dsp --> # PROP Cmd_Line "ddkbuild -WNETWXP free ." + ޸: ddkbuild.cmd,DDk2003ûWNETWXPWNETWXPЧͬWNETXP + +----------------------- +bobo 2009/05/08 +----------------------- +exe: + 1.TestAppUnicodeΪMulti-Byte(Ϊʡ,ַƴ,עдMulti-Byte), + TestApp.vcprojCharacterSet="1" ΪCharacterSet="2" + 2.TestAppغжsys(modify from MyZwDriverControl.c) òƽ́E + a.app,load driver + b.appǿƹصEʱûunload driver + c.app,ʱٴload driver(˵ûloadʧ),һʹdriver + d.˳app,unload driver + + ps: MyZwDriverControl ӁEclass LoadNTDriver(copy from 0ginr.com), + MyZwDriverControlloadunload,ע,ɾׁE + class LoadNTDriverloadע᱁Eunloadɾע᱁E + MyZwDriverControlLockXxxDatabase. + 3.غжsysclass LoadNTDriver, ELoadNTDriver.h" + +sys: + DriverEntryEӡע޷ + default uIoControlCode 䳁EIoCode + кӷҳǷҳÁE#pragma alloc_text(PAGE, DispatchXX)) + +----------------------- +bobo 2009/04/27 +----------------------- +1.target osEֻѡһos +2.DDK汾OSѡԁE +3.fix bug : "mybuild.bat" ڵ PROJECT_MYBUILD_CMD_LINE (DDK + OS)д + DDK·Ĭϵģٸд鷳 + + DDK 2000 --- C:\\NTDDK + DDK XP --- C:\\WINDDK\\2600 + DDK 2003 --- C:\\WINDDK\\3790.1830 + WDK 6001.18002 --- C:\\WINDDK\\6001.18002 + +4.֧WDK + win2008 +// todo : 5.check freeѡԁE(mybuild.batűEҁE "chk ." ӁE"fre .") + +6.һEasySysʱԶ趨û(WXPBASE,WNETBASE...) + Ǹע᱁EHKEY_LOCAL_MACHINE -- SOFTWARE\\Microsoft\\WINDDK 趨DDK·ġ + (һûװ˶DDKټӸWDK·Ҫж) + + "mybuild.bat"ҲsetEʵûˡ + +7.űÁE忴 "ddkbuild.cmd":: Usage output + +----------------------- +bobo 2009/04/23 +----------------------- +1.MS sampleʽ޸"sources" + +-----------------------. +bobo 2009/04/18 +----------------------- +1. common.h, ڶexesysĹͨIOCTL +2. console APP (for VS2005), ڲsys. ĸhello world. + (ֻҪDriverMonitorͿԲ) +// todo : 3. dsp_proj.htm(VC6)EcleanҁE,VC6ʹclean.bat +// todo : 4. MFC APP,ڲsys +5. ޸ע +6.޸print꣬Ӧcheckfree汾build + #if DBG + #define dprintf DbgPrint + #else + #define dprintf + #endif + +ԽдԽˣeasy..... + +----------------------- +bobo 2009/04/16 +----------------------- +1.OnInitDialog()EOnChangeAuthor() +2.޸OnChangeAuthor()ַ +3.޸hfile.htm,cfile.htmӦԼϰ +----------------------- + +bobo 2009/04/10 +----------------------- +1.GenerateRandomStrings()new ûͷţ + ΪֲׁEֲ̫,64С) +2.OnInitDialog()EOnSelectIdeType(),ʼIdeType + OnSelchangeDdkVersion(),ʼDDK type +3.ddkbuild.cmd EΪ VERSION=V7.3 +4.VC6ddkbuild.batΪddkbuild.cmd +5.޸OnSelchangeDdkVersion()ڵDDK2000߼ж +6.VC6dsp.htmstruct.h + +----------------------- +ChiChou [http://hi.baidu.com/517826104] +2009/02/03 +----------------------- + +ChiChou sudami޸İEׁE + +* BUG + 1.dzصBUG˳ʱûƳͼ꣬ijЩ˳ʱ +ҵĵсE- -! + + 2.ԭDDK·ʱȡע޷дˣ޷ DDK +PathòƴֱԼҵDDK·֮δе㡣 + + 3.ԭûмE鹤E氁EǷַôĿ¼ʱE +ͻʱӶԷǷַcheckܡE/\|"<>*?: + + 4.һBUGû޸ڹE硰project..ʱ +Ҳļʴ󡣵ûаE޸ַжеѶȡ +ˮƽӡ(- -...) + +* ÁE + 1.ѴŪ XPBUTTON ȥ...ͼҁEٶȡ + 2.ȻPűͼ棬ÿ~~ + 3.ϰԵ XP Manifest ¡ + +* ޸ģE + 1.ݸϲôEĸʽ޸~ + 2.˳ѡ́EҹE濴ijжϷûȻE +ͬ豸˽ȥ + +* ́Eƹ + 1.sudamiе鷳˳Ҫֱ̡˳ +ť + 2.̴֮EasySYSûôˣˡ́Eɺ˳ѡ + 3.ɹ̺ԴEڡߵϢ + 4.ɹ̺IJҲǿѡġѡԶ򿪹ļĿ¼ + 5.Clean~~~ +----------------------- + + +----------------------- +sudami [sudami@163.com] +2008/08/13 +----------------------- + + VS 2005дVC 6.0ܶEöEasySYS汾(Include DIY)ֻ +֧VC 6.0.VBGOOD̳IceBoyСͬѧVBд˸֧vs 2005 +demo.,ҲдԼĹ,ԺEٵĿЁE + + ,ҪǷԼдcode,ɵcodeǰԼԸ +... + +----------------------- diff --git a/Register/RegisterManagerDrv/sources b/Register/RegisterManagerDrv/sources new file mode 100644 index 0000000..cbc6aaf --- /dev/null +++ b/Register/RegisterManagerDrv/sources @@ -0,0 +1,9 @@ +TARGETNAME=RegisterManagerDrv +#TARGETPATH=$(BASEDIR)\lib +TARGETPATH=obj +TARGETTYPE=DRIVER + +INCLUDES=.\ + +SOURCES=RegisterManagerDrv.c +