C# Protect the Password inside a TextBox ZZ
If the Text property is called, it will send an WM_GETTEXT
message, so it will surely be an internal (safe) call. But if that message is received and the Text
property wasn't called, then it might be risky to return the password, so we'll not process that message.
I wrote a "safer" TextBox
here, just to show you the idea, feel free to write your own or simply improve this one.


class ProtectedTextBox : TextBox
{
// the malicious message, that needs to be handled
private const int WM_GETTEXT = 0x000D; // 'true' if the messages are sent from our program (from Text property)
// 'false' if they're sent by anything else
bool allowAccess { get; set; } public override string Text // overriding Text property
{
get
{
allowAccess = true; // allow WM_GETTEXT (because it's an internal call)
return base.Text; //this sends the message above in order to retrieve the TextBox's value
}
set
{
base.Text = value;
}
} protected override void WndProc(ref Message m)
{
if (m.Msg == WM_GETTEXT) // if the message is WM_GETTEXT
{
if (allowAccess) // and it comes from the Text property
{
allowAccess = false; //we temporarily remove the access
base.WndProc(ref m); //and finally, process the message
}
}
else
base.WndProc(ref m);
}
}
C# Protect the Password inside a TextBox ZZ的更多相关文章
- c# word interop encrypt with password protect with password
public static void EncryptWithPassword(string unEncryptedWordPath, string password) { Word.Applicati ...
- 使用Htmlhelper,创建文本框TextBox
下面通过HtmlHelper帮助类,创建文本框. 首先新建一个实体类,做为下面的例子: using System; using System.Collections.Generic; using Sy ...
- Linux基本操作命令
Linux基本操作命令 首先介绍一个名词“控制台(console)”,它就是我们通常见到的使用字符操作界面的人机接口,例如dos.我们说控制台命令,就是指通过字符界面输入的可以操作系统的命令,例如do ...
- Aspose.Cells相应操作及下载
Aspose.Cells相应操作 1,上传 1.1 Workbook Workbook workBook = new Workbook(); 属性: 名称 值类型 说明 Colors Color[] ...
- ASP.NET MVC 视图(五)
ASP.NET MVC 视图(五) 前言 上篇讲解了视图中的分段概念.和分部视图的使用,本篇将会对Razor的基础语法简洁的说明一下,前面的很多篇幅中都有涉及到视图的调用,其中用了很多视图辅助器,也就 ...
- WPF入门:数据绑定
上一篇我们将XAML大概做了个了解 ,这篇将继续学习WPF数据绑定的相关内容 数据源与控件的Binding Binding作为数据传送UI的通道,通过INotityPropertyChanged接口的 ...
- net-force.nl/steganography writeup
做CTF题好长一段时间了,真的可以学到很多东西.这次,我们开启 net-force.nl 的 Steganography之旅,所谓的隐写术. level 801: Training - Can you ...
- 在C#中使用Spire.doc对word的操作总结
在C#中使用Spire.doc对word的操作总结 在最近的工程中我们要处理一些word文档.通过在网上的大量搜索,我发现大多数软件功能不是不完整就是有重复.极少数可以完全实现的word组件又要收费. ...
- 浅谈Excel开发:三 Excel 对象模型
前一篇文章介绍了Excel中的菜单系统,在创建完菜单和工具栏之后,就要着手进行功能的开发了.不论您采用何种方式来开发Excel应用程序,了解Excel对象模型尤其重要,这些对象是您与Excel进行交互 ...
随机推荐
- ReactNative-----环境搭建(android)
1.参考文档 http://reactnative.cn/docs/0.26/getting-started.html http://reactnative.cn/docs/0.26/running- ...
- Codevs 3729 飞扬的小鸟
飞扬的小鸟 标签 动态规划 NOIp提高组 2014 难度 提高+/省选- 题目描述 Flappy Bird 是一款风靡一时的休闲手机游戏.玩家需要不断控制点击手机屏幕的频率来调节小鸟的飞行高度,让小 ...
- Q105971:Converting a Regular GUID to a Compressed GUID
Quote from: http://flexerasoftware.force.com/articles/en_US/INFO/Q105971 Synopsis The Windows Ins ...
- 系统监控的一些工具w , vmstat
w 命令:--w 查看的是系统整体上的负载 # w 15:23:46 up 3:34, 2 users, load average: 0.03, 0.05, 0.00 USER TTY FROM LO ...
- EF初始化mysql数据库codefirst
EF使用Code First修改生成数据库表名的方法 1. 重写OnModelCreating,去掉表名复数 System.Data.Entity.ModelConfiguration.Convent ...
- js json和对象互相转换
http://www.jb51.net/article/44562.htm obj = JSON.parse(string) | obj = jQuery.parseJSON(str) 将JSON字符 ...
- mysql扩展库操作mysql数据库
环境搭建 启用mysql扩展库,在php.ini文件中去配置mysql扩展库 extension=php_mysql.dll 查询数据库 1.建库建表 //建库testcreate database ...
- 使用Yii框架中遇到的三个问题
以下由我们在信易网络公司开发项目的时候终结出的一些经验 使用Yii框架中遇到的三个问题 1.main.php文件中欲引入全局变量的问题 还原一下此问题:在Yii框架中,main.php一般会作为整个应 ...
- 【 java版坦克大战--事件处理】 让坦克动起来--事件处理的准备
要能够控制坦克运动,必须用到事件处理的知识. 事件处理的一个demo. /** * 事件处理机制:委派事件模型.指当事件发生的时候,产生事件的对象(事件源),会把此 * "消息"传 ...
- ios8.1.2耗电情况严重的解决方法
打开cydia,搜索ifile(威锋源,版本2.1.0-1).打开ifile,进入路径/Applications.里面有许多程序文件,选择适当的进行禁用(ifile可以禁用程序的活动而不完全删除它,这 ...