/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
win32 calls
Copyright (C) Jay Sorg 2006
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef _WIN32_WCE
#define MYWINCE
#endif
#include <winsock2.h> /* winsock2.h first */
#include <windows.h>
#ifdef MYWINCE
#include <aygshell.h> /* aygshell.lib */
#endif /* MYWINCE */
#include <winuser.h>
#include <stdio.h>
#include "uimain.h"
extern char g_username[];
extern char g_hostname[];
extern char g_servername[];
extern char g_password[];
extern char g_shell[];
extern char g_directory[];
extern char g_domain[];
extern int g_width;
extern int g_height;
extern int g_tcp_sck;
extern int g_server_depth;
extern int g_tcp_port_rdp; /* in tcp.c */
extern int pal_entries[];
static HWND g_Wnd = 0;
static HINSTANCE g_Instance = 0;
static HCURSOR g_cursor = 0;
static int g_block = 0;
static int g_xoff = 0; /* offset from window to client coords */
static int g_yoff = 0;
static int g_xscroll = 0; /* current scroll position */
static int g_yscroll = 0;
static int g_screen_width = 0;
static int g_screen_height = 0;
static int g_wnd_cwidth = 0; /* set from WM_SIZE */
static int g_wnd_cheight = 0;
static int g_fullscreen = 0;
static int g_workarea = 0;
static int g_mousex = 0; /* in client coords */
static int g_mousey = 0;
static int g_width_height_set = 0;
static int g_clip_left = 0;
static int g_clip_top = 0;
static int g_clip_right = 800;
static int g_clip_bottom = 600;
static RECT g_wnd_clip; /* this client area of whats actually visable */
/* set from WM_SIZE */
#ifdef MYWINCE
static int g_sip_up = 0;
#endif
/*****************************************************************************/
static void
str_to_uni(TCHAR * sizex, char * size1)
{
int len;
int i;
len = strlen(size1);
for (i = 0; i < len; i++)
{
sizex[i] = size1[i];
}
sizex[len] = 0;
}
/*****************************************************************************/
/* returns non zero if it processed something */
static int
check_sck(void)
{
fd_set rfds;
struct timeval tm;
int count;
int rv;
rv = 0;
if (g_block == 0)
{
g_block = 1;
/* see if there really is data */
FD_ZERO(&rfds);
FD_SET((unsigned int)g_tcp_sck, &rfds);
ZeroMemory(&tm, sizeof(tm));
count = select(g_tcp_sck + 1, &rfds, 0, 0, &tm);
if (count > 0)
{
if (ui_read_wire())
{
rv = 1;
}
else
{
PostQuitMessage(0);
}
}
g_block = 0;
}
return rv;
}
/*****************************************************************************/
void
mi_error(char * msg)
{
#ifdef WITH_DEBUG
printf(msg);
#else /* WITH_DEBUG */
TCHAR lmsg[512];
TCHAR ltitle[512];
str_to_uni(lmsg, msg);
str_to_uni(ltitle, "Error");
MessageBox(g_Wnd, lmsg, ltitle, MB_OK);
#endif /* WITH_DEBUG */
}
/*****************************************************************************/
static int
get_scan_code_from_ascii(int code)
{
int rv;
rv = 0;
switch (code & 0xff)
{
case 0x30: rv = 0x0b; break; // 0
case 0x31: rv = 0x02; break; // 1
case 0x32: rv = 0x03; break; // 2
case 0x33: rv = 0x04; break; // 3
case 0x34: rv = 0x05; break; // 4
case 0x35: rv = 0x06; break; // 5
case 0x36: rv = 0x07; break; // 6
case 0x37: rv = 0x08; break; // 7
case 0x38: rv = 0x09; break; // 8
case 0x39: rv = 0x0a; break; // 9
case 0xbd: rv = 0x0c; break; // -
case 0xbb: rv = 0x0d; break; // =
case 0x08: rv = 0x0e; break; // backspace
case 0x09: rv = 0x0f; break; // tab
case 0xdb: rv = 0x1b; break; // ]
case 0xdd: rv = 0x1a; break; // [
case 0x14: rv = 0x3a; break; // capslock
case 0xba: rv = 0x27; break; // ;
case 0xde: rv = 0x28; break; // '
case 0x10: rv = 0x2a; break; // shift
case 0xbc: rv = 0x33; break; // ,
case 0xbe: rv = 0x34; break; // .
case 0xbf: rv = 0x35; break; // /
case 0x0d: rv = 0x1c; break; // enter
case 0x27: rv = 0x4d; break; // arrow right
case 0x25: rv = 0x4b; break; // arrow left
case 0x26: rv = 0x48; break; // arrow up
case 0x28: rv = 0x50; break; // arrow down
case 0x20: rv = 0x39; break; // space
case 0xdc: rv = 0x2b; break; // backslash
case 0xc0: rv = 0x29; break; // `
case 0x11: rv = 0x1d; break; // ctl
case 0x41: rv = 0x1e; break; // a
case 0x42: rv = 0x30; break; // b
case 0x43: rv = 0x2e; break; // c
case 0x44: rv = 0x20; break; // d
case 0x45: rv = 0x12; break; // e
case 0x46: rv = 0x21; break; // f
case 0x47: rv = 0x22; break; // g
case 0x48: rv = 0x23; break; // h
case 0x49: rv = 0x17; break; // i
case 0x4a: rv = 0x24; break; // j
case 0x4b: rv = 0x25; break; // k
case 0x4c: rv = 0x26; break; // l
case 0x4d: rv = 0x32; break; // m
case 0x4e: rv = 0x31; break; // n
case 0x4f: rv = 0x18; break; // o
case 0x50: rv = 0x19; break; // p
case 0x51: rv = 0x10; break; // q
case 0x52: rv = 0x13; break; // r
case 0x53: rv = 0x1f; break; // s
case 0x54: rv = 0x14; break; // t
case 0x55: rv = 0x16; break; // u
case 0x56: rv = 0x2f; break; // v
case 0x57: rv = 0x11; break; // w
case 0x58: rv = 0x2d; break; // x
case 0x59: rv = 0x15; break; // y
case 0x5a: rv = 0x2c; break; // z
}
return rv;
}
/*****************************************************************************/
static void
mi_scroll(int dx, int dy)
{
HRGN rgn;
rgn = CreateRectRgn(0, 0, 0, 0);
ScrollWindowEx(g_Wnd, dx, dy, 0, 0, rgn, 0, SW_ERASE);
InvalidateRgn(g_Wnd, rgn, 0);
DeleteObject(rgn);
}
/*****************************************************************************/
int
mi_read_keyboard_state(void)
{
short keydata;
int code;
code = 0;
keydata = GetKeyState(VK_SCROLL);
if (keydata & 0x0001)
{
code |= 1;
}
keydata = GetKeyState(VK_NUMLOCK);
if (keydata & 0x0001)
{
code |= 2;
}
keydata = GetKeyState(VK_CAPITAL);
if (keydata & 0x0001)
{
code |= 4;
}
return code;
}
/*****************************************************************************/
static void
mi_check_modifier(void)
{
int code;
code = mi_read_keyboard_state();
ui_set_modifier_state(code);
}
/*****************************************************************************/
static LRESULT
handle_WM_SETCURSOR(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (g_mousex >= g_wnd_clip.left &&
g_mousey >= g_wnd_clip.top &&
g_mousex < g_wnd_clip.right &&
g_mousey < g_wnd_clip.bottom)
{
SetCursor(g_cursor);
}
/* need default behavoir here */
return DefWindowProc(hWnd, message, wParam, lParam);
}
/*****************************************************************************/
static LRESULT
handle_WM_NCHITTEST(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
if (ScreenToClient(g_Wnd, &pt))
{
g_mousex = pt.x;
g_mousey = pt.y;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
/********************************
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
DP协议的破解, 是原rdesktop在windows下的版本, 非常适合初学者借鉴.-RDP protocol decipher, rdesktop in the original version under windows, very suitable for beginners and learn from.
资源推荐
资源详情
资源评论
收起资源包目录
69491743win32-rdesktop-source.zip (38个子文件)
rdp.c 33KB
tcp.c 6KB
orders.c 28KB
rdp5.c 3KB
win32.c 43KB
winrdesktop.opt 53KB
ssl_calls.c 39KB
uimain.c 22KB
uimain.h 2KB
mppc.c 8KB
rdesktop.h 3KB
bitmap.c 19KB
winrdesktop.vcw 550B
licence.c 9KB
bsops.h 2KB
orders.h 6KB
winrdesktop.vcb 161KB
winrdesktop.vcp 101KB
types.h 5KB
example-winrdesktop.ini 114B
makefile 474B
www.pudn.com.txt 218B
constants.h 12KB
mcs.c 9KB
winrdesktop.dsw 545B
proto.h 14KB
secure.c 25KB
winrdesktop.ncb 105KB
iso.c 4KB
cache.c 9KB
bsops.c 18KB
winrdesktop.vco 61KB
winrdesktop.vcl 2KB
parse.h 4KB
winrdesktop.plg 2KB
channels.c 5KB
pstcache.c 5KB
winrdesktop.dsp 5KB
共 38 条
- 1
tlmy
- 粉丝: 25
- 资源: 51
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页