服务端注册表

This commit is contained in:
Cc28257 2020-06-26 10:27:25 +08:00
parent 910efd3d65
commit 17da000043
12 changed files with 358 additions and 15 deletions

Binary file not shown.

Binary file not shown.

View File

@ -227,6 +227,7 @@
<ClInclude Include="InputDlg.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="PublicStruct.h" />
<ClInclude Include="RegDlg.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="SEU_QQwry.h" />
<ClInclude Include="targetver.h" />
@ -269,6 +270,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="RegDlg.cpp" />
<ClCompile Include="SEU_QQwry.cpp" />
<ClCompile Include="TrueColorToolBar.cpp" />
</ItemGroup>

View File

@ -96,6 +96,9 @@
<ClInclude Include="CServerDlg.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="RegDlg.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CcRemote.cpp">
@ -155,6 +158,9 @@
<ClCompile Include="CServerDlg.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="RegDlg.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CcRemote.rc">

View File

@ -0,0 +1,290 @@
// RegDlg.cpp : 实现文件
//
#include "pch.h"
#include "CcRemote.h"
#include "RegDlg.h"
#include "afxdialogex.h"
#include "..\..\common\macros.h"
// CRegDlg 对话框
IMPLEMENT_DYNAMIC(CRegDlg, CDialog)
enum MYKEY{
MHKEY_CLASSES_ROOT,
MHKEY_CURRENT_USER,
MHKEY_LOCAL_MACHINE,
MHKEY_USERS,
MHKEY_CURRENT_CONFIG
};
enum KEYVALUE{
MREG_SZ,
MREG_DWORD,
MREG_BINARY,
MREG_EXPAND_SZ
};
struct REGMSG{
int count; //名字个数
DWORD size; //名字大小
DWORD valsize; //值大小
};
CRegDlg::CRegDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext)
: CDialog(IDD_DIALOG_REGEDIT, pParent)
{
m_iocpServer = pIOCPServer;
m_pContext = pContext;
}
CRegDlg::~CRegDlg()
{
}
void CRegDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TREE, m_tree);
DDX_Control(pDX, IDC_LIST, m_list);
}
BEGIN_MESSAGE_MAP(CRegDlg, CDialog)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, &CRegDlg::OnTvnSelchangedTree)
END_MESSAGE_MAP()
// CRegDlg 消息处理程序
BOOL CRegDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
HICON hIcon = NULL;
m_ImageList_tree.Create(18, 18, ILC_COLOR16,10, 0);
//hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_FATHER_ICON), IMAGE_ICON, 18, 18, 0);
//m_ImageList_tree.Add(hIcon);
//hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_DIR_ICON), IMAGE_ICON, 32, 32, 0);
//m_ImageList_tree.Add(hIcon);
m_tree.SetImageList ( &m_ImageList_tree,TVSIL_NORMAL );
DWORD dwStyle = GetWindowLong(m_tree.m_hWnd,GWL_STYLE);
dwStyle |=TVS_HASBUTTONS | TVS_HASLINES;// | TVS_LINESATROOT;这里不可一设置这个样式不然ico图表无法显示
SetWindowLong(m_tree.m_hWnd,GWL_STYLE,dwStyle);
m_hRoot = m_tree.InsertItem("注册表管理",0,0,0,0);
HKCU=m_tree.InsertItem("HKEY_CURRENT_USER",1,1,m_hRoot,0);
HKLM=m_tree.InsertItem("HKEY_LOCAL_MACHINE",1,1,m_hRoot,0);
HKUS=m_tree.InsertItem("HKEY_USERS",1,1,m_hRoot,0);
HKCC=m_tree.InsertItem("HKEY_CURRENT_CONFIG",1,1,m_hRoot,0);
HKCR=m_tree.InsertItem("HKEY_CLASSES_ROOT",1,1,m_hRoot,0);
m_tree.Expand(m_hRoot,TVE_EXPAND);
m_list.InsertColumn(0,"名称",LVCFMT_LEFT,150,-1);
m_list.InsertColumn(1,"类型",LVCFMT_LEFT,60,-1);
m_list.InsertColumn(2,"数据",LVCFMT_LEFT,300,-1);
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
//////添加图标//////
//m_HeadIcon.Create(16,16,TRUE,2,2);
//m_HeadIcon.Add(AfxGetApp()->LoadIcon(IDI_STR_ICON));
//m_HeadIcon.Add(AfxGetApp()->LoadIcon(IDI_DWORD_ICON));
//m_list.SetImageList(&m_HeadIcon,LVSIL_SMALL);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CRegDlg::OnTvnSelchangedTree(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
if(!isEnable) return;
isEnable=false;;
TVITEM item = pNMTreeView->itemNew;
if(item.hItem == m_hRoot)
{
isEnable=true;;
return;
}
SelectNode=item.hItem; //保存用户打开的子树节点句柄
m_list.DeleteAllItems();
CString FullPath=GetFullPath(SelectNode);
HTREEITEM CurrentNode = item.hItem; //取得此节点的全路径
while(m_tree.GetChildItem(CurrentNode)!=NULL)
{
m_tree.DeleteItem(m_tree.GetChildItem(CurrentNode)); //删除 会产生 OnSelchangingTree事件 ***
}
char bToken=getFatherPath(FullPath);
//愈加一个键
int nitem=m_list.InsertItem(0,"(Data)",0);
m_list.SetItemText(nitem,1,"REG_SZ");
m_list.SetItemText(nitem,2,"(NULL)");
//BeginWaitCursor();
//char *buf=new char[FullPath.GetLength]
FullPath.Insert(0,bToken);//插入 那个根键
bToken=COMMAND_REG_FIND;
FullPath.Insert(0,bToken); //插入查询命令
m_iocpServer->Send(m_pContext, (LPBYTE)(FullPath.GetBuffer(0)), FullPath.GetLength()+1);
isEnable=true;;
*pResult = 0;
}
CString CRegDlg::GetFullPath(HTREEITEM hCurrent)
{
CString strTemp;
CString strReturn = "";
while(1){
if(hCurrent==m_hRoot) return strReturn;
strTemp = m_tree.GetItemText(hCurrent); //得到当前的
if(strTemp.Right(1) != "\\")
strTemp += "\\";
strReturn = strTemp + strReturn;
hCurrent = m_tree.GetParentItem(hCurrent); //得到父的
}
return strReturn;
}
char CRegDlg::getFatherPath(CString& FullPath)
{
char bToken;
if(!FullPath.Find("HKEY_CLASSES_ROOT")) //判断主键
{
//MKEY=HKEY_CLASSES_ROOT;
bToken=MHKEY_CLASSES_ROOT;
FullPath.Delete(0,sizeof("HKEY_CLASSES_ROOT"));
}else if(!FullPath.Find("HKEY_CURRENT_USER"))
{
bToken=MHKEY_CURRENT_USER;
FullPath.Delete(0,sizeof("HKEY_CURRENT_USER"));
}else if(!FullPath.Find("HKEY_LOCAL_MACHINE"))
{
bToken=MHKEY_LOCAL_MACHINE;
FullPath.Delete(0,sizeof("HKEY_LOCAL_MACHINE"));
}else if(!FullPath.Find("HKEY_USERS"))
{
bToken=MHKEY_USERS;
FullPath.Delete(0,sizeof("HKEY_USERS"));
}else if(!FullPath.Find("HKEY_CURRENT_CONFIG"))
{
bToken=MHKEY_CURRENT_CONFIG;
FullPath.Delete(0,sizeof("HKEY_CURRENT_CONFIG"));
}
return bToken;
}
void CRegDlg::OnReceiveComplete(void)
{
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
{
case TOKEN_REG_PATH: //接收项
AddPath((char*)(m_pContext->m_DeCompressionBuffer.GetBuffer(1)));
break;
case TOKEN_REG_KEY: //接收键 ,值
AddKey((char*)(m_pContext->m_DeCompressionBuffer.GetBuffer(1)));
break;
default:
break;
}
}
void CRegDlg::AddKey(char* lpBuffer)
{
m_list.DeleteAllItems();
int nitem=m_list.InsertItem(0,"(Data)",0);
m_list.SetItemText(nitem,1,"REG_SZ");
m_list.SetItemText(nitem,2,"(NULL)");
if(lpBuffer==NULL) return;
REGMSG msg;
memcpy((void*)&msg,lpBuffer,sizeof(msg));
char* tmp=lpBuffer+sizeof(msg);
for(int i=0;i<msg.count;i++)
{
BYTE Type=tmp[0]; //取出标志头
tmp+=sizeof(BYTE);
char* szValueName=tmp; //取出名字
tmp+=msg.size;
BYTE* szValueDate=(BYTE*)tmp; //取出值
tmp+=msg.valsize;
if(Type==MREG_SZ)
{
int nitem=m_list.InsertItem(0,szValueName,0);
m_list.SetItemText(nitem,1,"REG_SZ");
m_list.SetItemText(nitem,2,(char*)szValueDate);
}
if(Type==MREG_DWORD)
{
char ValueDate[256];
DWORD d=(DWORD)szValueDate;
memcpy((void*)&d,szValueDate,sizeof(DWORD));
CString value;
value.Format("0x%x",d);
sprintf(ValueDate," (%wd)",d);
value+=" ";
value+=ValueDate;
int nitem=m_list.InsertItem(0,szValueName,1);
m_list.SetItemText(nitem,1,"REG_DWORD");
m_list.SetItemText(nitem,2,value);
}
if(Type==MREG_BINARY)
{
char ValueDate[256];
sprintf(ValueDate,"%wd",szValueDate);
int nitem=m_list.InsertItem(0,szValueName,1);
m_list.SetItemText(nitem,1,"REG_BINARY");
m_list.SetItemText(nitem,2,ValueDate);
}
if(Type==MREG_EXPAND_SZ)
{
int nitem=m_list.InsertItem(0,szValueName,0);
m_list.SetItemText(nitem,1,"REG_EXPAND_SZ");
m_list.SetItemText(nitem,2,(char*)szValueDate);
}
}
}
void CRegDlg::AddPath(char* lpBuffer)
{
if(lpBuffer==NULL) return;
int msgsize=sizeof(REGMSG);
REGMSG msg;
memcpy((void*)&msg,lpBuffer,msgsize);
DWORD size =msg.size;
int count=msg.count;
if(size>0&&count>0){ //一点保护措施
for(int i=0;i<count;i++){
char* szKeyName=lpBuffer+size*i+msgsize;
m_tree.InsertItem(szKeyName,1,1,SelectNode,0);//插入子键名称
m_tree.Expand(SelectNode,TVE_EXPAND);
}
}
}

View File

@ -0,0 +1,46 @@
#pragma once
#include "include/IOCPServer.h"
// CRegDlg 对话框
class CRegDlg : public CDialog
{
DECLARE_DYNAMIC(CRegDlg)
public:
CRegDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
virtual ~CRegDlg();
// 对话框数据
enum { IDD = IDD_DIALOG_REGEDIT};
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
ClientContext* m_pContext;
CIOCPServer* m_iocpServer;
bool isEnable; //控件是否可用
HTREEITEM SelectNode;
public:
CTreeCtrl m_tree;
CListCtrl m_list;
CImageList m_HeadIcon;
protected:
HTREEITEM m_hRoot;
HTREEITEM HKLM;
HTREEITEM HKCR;
HTREEITEM HKCU;
HTREEITEM HKUS;
HTREEITEM HKCC;
CImageList m_ImageList_tree;
public:
virtual BOOL OnInitDialog();
afx_msg void OnTvnSelchangedTree(NMHDR *pNMHDR, LRESULT *pResult);
CString GetFullPath(HTREEITEM hCurrent);
char getFatherPath(CString& FullPath);
void OnReceiveComplete(void);
void AddKey(char* lpBuffer);
void AddPath(char* lpBuffer);
};

View File

@ -1,5 +1,3 @@
f:\myapp\ccremote\bin\ccremote.ipdb
f:\myapp\ccremote\bin\ccremote.iobj
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.pch
f:\myapp\ccremote\ccremote\ccremote\release\vc141.pdb
f:\myapp\ccremote\ccremote\ccremote\release\pch.obj
@ -21,17 +19,6 @@ f:\myapp\ccremote\ccremote\ccremote\release\cfilemanagerdlg.obj
f:\myapp\ccremote\ccremote\ccremote\release\ccremotedlg.obj
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.obj
f:\myapp\ccremote\ccremote\ccremote\release\caudiodlg.obj
f:\myapp\ccremote\bin\ccremote.exe
f:\myapp\ccremote\bin\ccremote.pdb
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.res
f:\myapp\ccremote\ccremote\ccremote\..\..\bin\ccremote.exe
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\ccremote.write.1u.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.command.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.read.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.write.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\link.command.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\link.read.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\link.write.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.command.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.read.1.tlog
f:\myapp\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.write.1.tlog

View File

@ -70,10 +70,17 @@ f:\myapp\ccremote\ccremote\ccremote\inputdlg.h(69): warning C4302: “类型强
f:\myapp\ccremote\ccremote\ccremote\inputdlg.cpp(124): warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\corecrt_wstring.h(123): note: 参见“wcscpy”的声明
f:\myapp\ccremote\ccremote\ccremote\inputdlg.cpp(159): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
RegDlg.cpp
f:\myapp\ccremote\ccremote\ccremote\regdlg.cpp(247): warning C4475: “sprintf”: 不可在格式说明符中将长度修饰符“w”与类型字段字符“d”一起使用
f:\myapp\ccremote\ccremote\ccremote\regdlg.cpp(258): warning C4475: “sprintf”: 不可在格式说明符中将长度修饰符“w”与类型字段字符“d”一起使用
f:\myapp\ccremote\ccremote\ccremote\regdlg.cpp(247): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
f:\myapp\ccremote\ccremote\ccremote\regdlg.cpp(258): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
SEU_QQwry.cpp
TrueColorToolBar.cpp
正在生成代码
All 717 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
All 731 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
nafxcwd.lib(afxmem.obj) : warning LNK4006: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已在 LIBCMTD.lib(new_scalar.obj) 中定义;已忽略第二个定义
nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) 已在 LIBCMTD.lib(delete_scalar.obj) 中定义;已忽略第二个定义

Binary file not shown.

Binary file not shown.

View File

@ -84,6 +84,8 @@ enum
COMMAND_SERVICES_AUTO, // 启动方式 - 自动启动
COMMAND_SERVICES_MANUAL, // 启动方式 - 手动启动
COMMAND_REGEDIT, //注册表管理
COMMAND_REG_FIND, //注册表 管理标识
// 服务端发出的标识
TOKEN_AUTH = 100, // 要求验证
@ -121,7 +123,10 @@ enum
TOKEN_WSLIST, // 窗口列表
TOKEN_DIALUPASS, // 拨号密码
TOKEN_SHELL_START, // 远程终端开始
TOKEN_SERVERLIST // ·þÎñÁбí
TOKEN_SERVERLIST, // 服务列表
TOKEN_REGEDIT, // 注册表初始化完毕
TOKEN_REG_PATH, // 注册表项缓冲区
TOKEN_REG_KEY // 注册表缓冲区
};