HTML 4 to 5 Cheat sheet, see what's new and removed for Tags and Attributes.
How To Code HTML, What's New and Obsolete HTML Tags and Attributes
A great quick reference for the transition from HTML 4 to HTML 5. Designed to help authors create polyglot HTML documents, this can also help in creating HTML 4 and XHTML documents, in addition to upgrading to HTML 5. Most HTML cheat sheets, usually based on the technical specifications for a specific version of HTML, show only the valid features in that version of the HTML specs. In contrast, this one helps developers transition from earlier versions of HTML by indicating new features in HTML 5 with a "New" flag and using a strike-through font to indicate the tags and attributes previously used in HTML 4, XHTML 1 and earlier versions that are now obsolete in HTML 5.
For a quick reference of HTML character entities, see the HTML character codes reference.
Required or recommended HTML attributes for the HTML tags are shown in bold.
Read more: Greg's Cool [Insert Clever Name] of the Day
Read more: HTML Cheat Sheet for Transition to HTML 5
Database Performance Tips You Won’t Want To Miss
Posted by
jasper22
at
10:37
|
In a data-driven web application, poor database performance can needlessly burden your server or, worse, make your website slow enough that your user gives up and goes somewhere else.
So we have put together some of the common pitfalls we have seen with database performance. We’re mainly gearing this towards SQL Server, though many database (Oracle, Sybase, MySQL, etc.) concepts are applicable across platforms.
- Think before you index. An index is a construct that enables faster lookup of data from a table. Rather than doing a table scan of all of the rows of the table, an index allows SQL Server to more directly seek the desired data. Adding indexes to your database is important, but adding indexes you don’t need can do more harm than good. When you insert or update rows in your table, SQL Server has to update your indexes as well. Though SQL Server 2008 will actually allow you to have 1000 indexes in a table, if you find yourself desiring anything remotely close to that number, you should reconsider your design.
- Do you really need to use functions? In general, user-defined functions are much slower than incorporating your operation in a join or a view, as appropriate. Test out your function using the SQL Profiler to see if it is taking a long time to execute.
- Use bound parameters. In nearly all cases, it’s faster to use bound parameters than to not use them. When you bind your parameters, you allow the server to only have to optimize your query the first time it sees it. In Oracle, this is extremely important as the server reserves a set amount of memory for queries it has “learned” and if you don’t use bound parameters, you will constantly fill this space up with the same query. As a side note, should you ever find yourself using the ODBC API, you can use SQLExecDirect to execute a statement in a single command. In this case, it is marginally faster because it does not require the extra overhead for preparing the ODBC statement with SQLPrepare.
Read more: JASE Digital Media blog
PortableTPL for Silverlight / Windows Phone and XBox
Posted by
jasper22
at
10:36
|
Project Description
PortableTPL is a portable project inspired by the Task Parallel Library.
It can be used with .Net 4.0, Silverlight 4.0, XNA 4.0 for XBox 360 and Silverlight for Windows Phone.
PortableTPL supports following features:
Task
Task<T>
Task Continuation
Task Cancelleation with CancellationTokenSource
AggregationException
Parallel.For
Parallel.ForEach
Schedulers
Read more: Codeplex
Generate better NHibernate logs
Posted by
jasper22
at
10:36
|
I will show you in this post two tricks you can do to enhance and add value to your nhibernate logs.
Format Sql
This is widely know trick, you can add a configuration setting to your hibernate.cfg.xml, app.config or web.config as follow:
<property name="hibernate.format_sql" value="true" />
or you can simply do it in code:
config.DataBaseIntegration(db => db.LogFormatedSql = true)
with this trick you will get nicely formated sql in your logs files.
Logging the session identifier
All nice, we have a bunch of sql logs, but we don’t know which queries belongs to which sessions. This might be useful when you are debugging an application with multiples threads or requests.
I found this trick inside NHibernate, the easy way I found so far is to add a log4net appender like this one:
<appender name="NHibernateAppender" type="log4net.Appender.RollingFileAppender">
<appendToFile value="true"/>
<datePattern value="yyyyMMdd"/>
<file value="./logs/NHibernate.log"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date Session id: %property{sessionId} - %message%newline"/>
</layout>
<rollingStyle value="Date"/>
</appender>
See the %property{sessionId} in the conversion pattern?
Well, in order to log something there you need to do two steps.
Add a class like this one:
public class SessionIdCapturer
{
public override string ToString()
{
return SessionIdLoggingContext.SessionId.ToString();
}
}
Read more: NHibernate forge
Responding to Windows power management events (standby, hibernate, shutdown)
Posted by
jasper22
at
10:35
|
Introduction
This article provides a way for a .NET Windows application to respond to Windows Power Management events such as suspend, hibernate, standby, power switch etc.
Background
My organization uses Lotus Notes as an email client which hangs badly on our laptops when we go from one meeting room to another since the network breaks between the meeting rooms. And since Lotus Notes continuously monitors the network for any incoming mail, it tends to get hung up taking the whole window down with it. So to avoid forcefully restarting Windows, I created this application to capture the standby event and close the mail client before going to standby and automatically start the mail client when the system resumes. I got a lot of reference help from the article: http://www.codeproject.com/KB/system/OSEvents.aspx.
Using the code
We need to override the WndProc method which will allow us to interact with all the events that the OS tends to provide to the application on different conditions.
The Windows OS communicates with the application by sending different messages which need to be captured and worked on. For this implementation, we need to capture the WM_POWERBROADCAST (0x0218) value which will specify that this is a power event change and that we need to capture the WParam which can have the following values:
PBT_APMQUERYSUSPEND (0x0000)
PBT_APMRESUMESUSPEND (0x0007)
PBT_APMQUERYSTANDBY (0x0001)
PBT_APMQUERYSUSPENDFAILED (0x0002)
PBT_APMQUERYSTANDBYFAILED (0x0003)
PBT_APMSUSPEND (0x0004)
PBT_APMSTANDBY (0x0005)
PBT_APMRESUMECRITICAL (0x0006)
PBT_APMRESUMESTANDBY (0x0008)
PBTF_APMRESUMEFROMFAILURE (0x00000001)
PBT_APMBATTERYLOW (0x0009)
PBT_APMPOWERSTATUSCHANGE (0x000A)
PBT_APMOEMEVENT (0x000B)
PBT_APMRESUMEAUTOMATIC (0x0012)
Read more: Codeproject
Unlocking the Secrets of REST with WCF
Posted by
jasper22
at
10:34
|
In this session we will travel to the very depths of our new WCF WEB stack where there treasures which will delight the RESTful eye.
Read more: Channel9
Шифрование данных по алгоритму DES в Android
Posted by
jasper22
at
10:33
|
DES (Data Encryption Standard) — симметричный алгоритм шифрования, разработанный фирмой IBM и утвержденный правительством США в 1977 году как официальный стандарт (FIPS 46-3). Он используется во многих криптографических системах. Это блочный алгоритм шифрования с симметричным ключом. Ключ состоит из 64 битов, но лишь 56 из них применяются непосредственно при шифровании. Оставшиеся 8 предназначены для контроля четности: они устанавливаются так, чтобы каждый из 8 байтов ключа имел нечетное значение. Шифруемая информация обрабатывается блоками по 64 бита, причем каждый блок модифицируется с помощью ключа в интерационной процедуре, включающей 16 циклов.
Более подробная информация об алгоритме - http://ru.wikipedia.org/wiki/DES
Для шифрования данных в Android используются классы пакета javax.crypto, входящего в состав Android SDK. Класс javax.crypto.Cipher реализует базовые функции популярных криптографических алгоритмов шифрования – DES, AES, RSA и других. Для создания экземпляра такого класса используется статистический метод Cipher.getInstance , который в качестве параметра получает имя криптографического алгоритма шифрования:
Cipher chr = Cipher.getInstance("DES");
Далее необходимо настроить экземпляр класса javax.crypto.Cipher и указать в каком режиме он будет работать: в режиме шифрования chr.init(Cipher.ENCRYPT_MODE, key); - , или дешифрования
chr.init(Cipher.DECRYPT_MODE, key); . Параметр key здесь – это ключ шифрования для алгоритма DES. Данный параметр имеет тип javax.crypto.SecretKey и может быть создан так:
javax.crypto.KeyGenerator.SecretKey key = KeyGenerator.getInstance("DES").generateKey();
Read more: Plaincodesource
SQL Server: Conditional WHERE clause (Filter for a Filter)
Posted by
jasper22
at
10:32
|
No one is unaware of WHERE clause. Everyone knows that we can filter output records by using WHERE clause but recently I found my team member stuck when he need a Conditional WHERE clause (filter for a filter). Let’s try to figure out the problem and its solution with a simple scenario.
Suppose we have a table to keep students result with follow structure
CREATE TABLE #Result
(
StudentId INT,
TeacherId INT,
GroupId INT,
Result VARCHAR(10),
MarksObtained INT
)
GO
INSERT INTO #Result
SELECT 101,1,1,'PASS',510 UNION ALL
SELECT 102,1,1,'PASS',622 UNION ALL
SELECT 103,2,1,'FAIL',174 UNION ALL
SELECT 104,2,2,'PASS',652 UNION ALL
SELECT 105,3,2,'FAIL',134
Our requirement is to create a stored procedure with only two parameters, one for id (it could be student, teacher or group id), we will call it @id and other to hold information that will decide that what type of id is being passed to stored procedure i.e. student, teacher or group, we will call it @idType
DECLARE @Id INT -- It could be StudentId,TeacherId,GroupId
DECLARE @IdType VARCHAR(10) -- Type could be Student,Teacher or Group
SELECT @Id = 2, @IdType= 'Teacher'
--OR-- @Id = 102, @IdType= 'Student'
--OR-- @Id = 1, @IdType= 'Group'
Let’s move to our targeted query, with conditional where clause.
SELECT * FROM #Result
WHERE 1 = (CASE
WHEN @IdType='Student' AND StudentId = @Id
THEN 1
Read more: Connect SQL
What is AppManifest.xaml in Silverlight?
Posted by
jasper22
at
10:30
|
Many of you don't aware of it in depth, mainly the freshers who just started doing their hands dirty with the light of Silver. In this post I am going to describe you about AppManifest.xaml file and it's uses in depth. Read the complete post to know more about it.
Don't forget to leave your feedback and/or any queries at the end of this post. Appreciate for reading this post.
The AppManifest.xaml file contains the deployment details needed to run the Silverlight application. The first element of it starts with a Deployment node which defines the Assembly information, Runtime version, Application Entry point and the assembly, extension parts.
You can find the complete AppManifest.xaml file inside the .XAP file. It is also available in the Silverlight project's Properties folder (named as "AppManifest.xml"), but you will find it almost empty there. Once you build your project, it gets generated by the IDE and placed inside your XAP file.
To find out it, build your solution and go to your Client Bin folder. Open your .XAP with a Zip utility. If you are unable to open that file, rename it to .Zip extension. You will be able to open now.
Once you open the AppManifest.xaml file, you will see the following code there:
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
EntryPointAssembly="AppManifestDemo1"
EntryPointType="AppManifestDemo1.App"
RuntimeVersion="4.0.50826.0">
<Deployment.Parts>
<AssemblyPart x:Name="AppManifestDemo1" Source="AppManifestDemo1.dll" />
</Deployment.Parts>
</Deployment>
The root element is the Deployment node. It defines the Entry Point Assembly, Entry Point Type (basically the main application class name with full namespace) and the Silverlight Runtime Version.
This node contains the Deployment.Parts and/or Deployment.ExternalParts as the child. The Deployment.Parts defines the Assembly Parts those are referenced in the project and present in the .XAP file. It also defines the main output dll as the Assembly part. As shown in the above figure, we have only one assembly in our XAP (the main project output) and hence only one entry in the AppManifest.xaml file.
Read more: Kunal's Blog
Silently Pwning Protected-Mode IE9 and Innocent Windows Applications
Posted by
jasper22
at
09:50
|
Those familiar with Windows COM servers know that they come in two types, in-process and out-of-process. For this post, the former type is of interest: an in-process COM server is a dynamic link library (DLL) that a COM client instantiates when needed, usually by calling the CoCreateInstance function with the class identifier (CLSID) of the said COM server. What happens then is the COM server initialization code looks up the provided CLSID in local registry under key HKEY_CLASSES_ROOT\CLSID, and finds the path to the DLL under the InProcServer32 subkey. It then expands eventual environment strings in the obtained DLL path and calls LoadLibrary with the resulting path. Whatever happens afterwards is of no interest to us here.
From the binary planting perspective the above process would be vulnerable if both of the following conditions were met:
- the path to the COM server DLL is a relative path instead of an absolute one; and
- the DLL doesn't exist in the LoadLibrary search path prior to the current working directory (i.e., in COM client's home directory or any one of the Windows system folders).
Condition #1 is at the discretion of whoever registers the COM server. While most COM servers are registered with full absolute paths to their DLLs, some merely specify the name of the DLL without the path. This may not be due to a developer's oversight or laziness: the so-called side-by-side COM components (see here and here) require the DLL to be specified with a relative path.
Condition #2 is a bit more tricky as it seems unlikely, at the first glance, that someone - or some application - would register a COM server that doesn't exist on the system. But for reasons beyond our willingness to investigate, some software products do just that. Furthermore, some other software products fail to unregister their COM servers upon removal, leaving the user's computer with exploitable remnants of a removed COM server DLL. And finally, in the case of side-by-side COM components, these DLLs are successfully found and loaded when the COM server is invoked by the original application (the DLL is in the same folder as the COM client executable), but if another applications tries to invoke the same COM server, it won't find the DLL and will finally try to find it in the current working directory - to attacker's great satisfaction.
Read more: Acros
R-fx Networks Projects
Posted by
jasper22
at
09:45
|
Welcome to the R-fx Networks Projects, here you will find a number of projects which have been developed to help make a system administrators life a little more convenient. All projects are released under the GNU GPL v2 License and as such are free for use and redistribution in accordance with it.
» Active Projects:
APF (Advanced Policy Firewall)
BFD (Brute Force Detection)
IRSYNC (Incremental Rsync)
LES (Linux Environment Security)
LMD (Linux Malware Detect)
LSM (Linux Socket Monitor)
NSIV (Network Socket Inode Validation)
PRM (Process Resource Monitor)
SIM (System Integrity Monitor)
SPRI (System Priority)
Read more: R-fx Networks
Transform Windows 7 Into Ubuntu 11.04 Natty Narwhal With Ubuntu Skin Pack
Some Linux users find it hard to adjust to the Windows operating systems at office, as they are more accustomed to using operating systems like Ubuntu. Over the years some transformation packs have helped Mac and Linux users to migrate towards Windows 7 by giving it a Mac or Linux OS look. These transformation packs, have also been handy for people who might prefer another operating system’s interface on Windows 7, as they are more accustomed to using it.
Ubuntu fans who for some reason happen to use Windows 7, are in for a treat with a wonderful Ubuntu Skin Pack released by user hamed. This is the same developer who has previously brought us the Mac OS X Lion Skin Pack and Windows 8 Transformation Pack. Like the former two, this Ubuntu 11.04 transformation pack does not require any third-party theme patching application. Just launch the .exe file, select the desired options and install the theme with a simple installation wizard.
Read more: Addictive tips
Patent 5,893,120 Reduced To Pure Math
Posted by
jasper22
at
15:35
|
US Patent #5,893,120 has been reduced to mathematical formulae as a demonstration of the oft-ignored fact that there is an equivalence relation between programs and mathematics. You may recognize Patent #5,893,210 as the one over which Google was ordered to pay $5M for infringing due to some code in Linux. It should be interesting to see how legal fiction will deal with this. Will Lambda calculus no longer be 'math'? Or will they just decide to fix the inconsistency and make mathematics patentable?
Read more: Slashdot
Android Commander Is A Swiss Army Knife For Android Devices
Posted by
jasper22
at
15:26
|
The Android world is full of tools, hacks and guides that let you customize your device the way you see fit. Most of these utilize the official Android SDK tools provided by Google, but using these isn’t always the simplest of tasks. Enter Android Commander – a free app for Windows that is basically a front-end for the core Android tools laid out in such a way that enables even a novice to use them without much hassle. For our detailed review and screenshot tour of this gem of an app, continue reading.
We at AddictiveTips love Android and we know you do too. That’s the reason we do our best to bring you apps and tools to help you make the best out of your Android phone or tablet. While most of the apps are pretty straight-forward to install and use, other more advanced modifications to your device often involve the use of command-line utilities and complex methods that can be intimidating to those used to GUI tools, and although we try our best to make our guides the safest possible for you, there is still a relatively high risk involved with using such methods that can result in potentially bricking your device due to any mistakes being made in entering the commands. That’s why when we came across Android Commander, we were delighted at the way it provides a well laid-out graphical front-end for several standard Android tools in one package that makes the process of using these tools a breeze!
Read more: Addictive tips
ConFavor – Add Frequently Used File And Folders In Windows Shell Menu
Posted by
jasper22
at
15:09
|

Windows right-click context menu extensions provide a great utility to quickly access favorite applications, files and folders, but generally require long steps to configure and register each option. In the past, we have covered a handful of context menu extensions to keep mostly frequntly used files, folders and apps at fingertips, such as, CMenu, Moo0 RightClicker, and FileMenu Tools. ConFavor offers the easiest way to add customized menu (Favorites menu) in Windows right-click context menu. It not only integrates with Windows right-click menu, but adds itself in My Computer (Explorer Window) as well to lets you quickly add files and folders via simple drag & drop. You can optionally choose to use its main interface for same purpose, which provides simple add, rename and delete user-added context menu options.
Read more: Addictive tips
Create your first CLR Trigger in SQL Server 2008 using C#
Posted by
jasper22
at
10:35
|
Create your first CLR Trigger for SQL Server 2008 using C#
What are CLR Triggers?
CLR triggers are trigger based on CLR.
CLR integration is new in SQL Server 2008. It allows for the database objects (such as trigger) to be coded in .NET.
Object that have heavy computation or require reference to object outside SQL are coded in the CLR.
We can code both DDL and DML triggers by using a supported CLR language like C#.
Let us follow below simple steps to create a CLR trigger:
Step 1: Create the CLR class. We code the CLR class module with reference to the namespace required to compile CLR database objects.
Add below reference:
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
So below is the complete code for class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
using System.Text.RegularExpressions;
namespace CLRTrigger
{
public class CLRTrigger
{
public static void showinserted()
{
SqlTriggerContext triggContext = SqlContext.TriggerContext;
SqlConnection conn = new SqlConnection(" context connection =true ");
conn.Open();
SqlCommand sqlComm = conn.CreateCommand();
SqlPipe sqlP = SqlContext.Pipe;
SqlDataReader dr;
sqlComm.CommandText = "SELECT pub_id, pub_name from inserted";
dr = sqlComm.ExecuteReader();
while (dr.Read())
sqlP.Send((string)dr[0] + "," + (string)dr[1]);
}
}
}
Step 2: Compile this class and in the BIN folder of project we will get CLRTrigger.dll generated. After compiling for CLRTrigger.dll, we need to load the assembly into SQL Server
Step 3: Now we will use T-SQL command to execute to create the assembly for CLRTrigger.dll. For that we will use CREATE ASSEMBLY in SQL Server.
CREATE ASSEMBLY triggertest
FROM 'C:\CLRTrigger\CLRTrigger.dll'
WITH PERMISSION_SET = SAFE
Read more: C# Corner
When to go for XBAP,WPF and Silverlight
Posted by
jasper22
at
10:20
|
Recently , i have given session on Silver light 4. Where Participants posted be question of Differences between Silverlight ,XBAP and WPF. Though I have given answer in the session, i want to make sure other participant who could not turn session and having same doubt to clarify.
Firstly: XBAP is XAML Browser application , It require .NET Framework to installed on the machine where it runs. it is Depployed through Click Once gets updated with latest version. XBAP application should be online and run in Browser scope. It is almost same as WPF but with Browser scope. It works on only Window Operation. I think it is best option for intranet browser applications.WCF not supported. Only FireFox and IE
Secondly Silverlight, It is require .NET Compact framework to be present in Browser. It works very where indepedent of platform and browser. it has limitation of Triggers, No DynamicResource. Rendered along with HTMl content
Read more: WELCOME TO MAHENDER'S BLOG
Visual Studio go faster! Faster!… (Well okay, maybe just phone home and tell Microsoft you’re feeling a little slow…) - Visual Studio PerfWatson
Posted by
jasper22
at
10:17
|
Would you like your performance issues to be reported automatically? Well now you can, with PerfWatson extension! Install this extension and assist the Visual Studio team in providing a faster future IDE for you.
We’re constantly working to improve the performance of Visual Studio and take feedback about it very seriously. Our investigations into these issues have found that there are a variety of scenarios where a long running task can cause the UI thread to hang or become unresponsive. Visual Studio PerfWatson is a low overhead telemetry system that helps us capture these instances of UI unresponsiveness and report them back to Microsoft automatically and anonymously. We then use this data to drive performance improvements that make Visual Studio faster.
Here’s how it works: when the tool detects that the Visual Studio UI has become unresponsive, it records information about the length of the delay and the root cause, and submits a report to Microsoft. The Visual Studio team can then aggregate the data from these reports to prioritize the issues that are causing the largest or most frequent delays across our user base. By installing the PerfWatson extension, you are helping Microsoft identify and fix the performance issues that you most frequently encounter on your PC.
To allow PerfWatson to submit performance reports to Microsoft, please make sure that Windows Error Reporting (WER) is enabled on your machine, please see how to configure WER setting session. PerfWatson employs the WER service to send the collected data to Microsoft.
Using PerfWatson
PerfWatson is an automatic feedback service. Once it is installed, all you need to do is use the product, and it will automatically create an error report for every UI delay you experience in the product. It stores these error reports in%LOCALAPPDATA%\PerfWatson. This data is then submitted to Microsoft on next Visual Studio launch.
If your Windows Error Reporting permissions are set to Automatically check for solutions and upload data, the performance reports will be submitted to Microsoft automatically. Otherwise, PerfWatson will prompt the user for permission to send the collected data. This prompt can be disabled by checking “Do not show this dialog again. Report problems automatically” on the dialog.
Read more: Greg's Cool [Insert Clever Name] of the Day
Read more: Visual Studio PerfWatson
Three helpful SSH tips for developers
Posted by
jasper22
at
09:48
|
If you're a developer that deploys stuff to unix systems, then one of the most common tools you interact with is SSH. It never ceases to amaze me, in spite of this, how little developers really know about SSH.
SSH config file
The first thing any developer needs to know is that SSH has a config file that allows you to configure defaults for SSH on a host by host basis. It also allows aliases, and bash completion can use this config file to make sshing into a system much easier. This file lives under the .ssh folder in your home directory, ~/.ssh/config. Here's a sample of things that I have in my config file.
Host home
HostName jamesroper.homelinux.org
Port 2222
User james
Host sshjump
Hostname sshjump.atlassian.com
User jamesroper
ForwardAgent yes
So I can SSH home by running ssh home and that will automatically use james as the username, jamesroper.homelinux.org as the host name, and 2222 as the port number. For details on all the configuration just read the man page, man ssh_config. You'll see that you can configure everything including port forwarding and much more.
Jump boxes
There are a number of times when I need to SSH into a jump box to SSH to another system. The annoying thing about this is to get to a system, I need to run two commands, and scp is even more annoying because I have to copy first to the jump box, then to the remote system.
Enter ProxyCommand. The proxy command config option allows you to specify a command that SSH will run first in order to establish the connection to the remote system, and then it will pipe its communication through that command. Combined with nc on the jump box end to create a TCP connection to the your destination host, this can be used to tunnel an SSH connection through another SSH connection. The configuration in the SSH config file looks like this:
Host *.atlassian.com
ProxyCommand nohup ssh sshjump nc -w1 %h %p
The other thing I've made use of here is wildcards, and the ability for SSH to substitute the host name and port number for the particular host into option values. Now I can run ssh jira.atlassian.com, and the SSH connection will be piped through an ssh connection to sshjump, which is an alias defined above as sshjump.atlassian.com. I can also scp directly.
Read more: Atlassian blog
USB & CD/DVD Blocking: One Way to Keep Data Free of Theft
Posted by
jasper22
at
09:48
|
Introduction
Have you ever thought of blocking access to USB Memory and CD? I will introduce an example of this. Perhaps some of you will not be interested in this, but I think this technique will be useful for more large-scale projects. I referenced a sample in Microsoft Windows DDK. This sample is implemented by file system filter driver. As you know, File System Filter Driver is commonly used in Anti-Virus and it can be used for some other purposes. In this sample, we can not only block access, but log the file path written to USB.
How to Use
This sample consists of 2 sysfiles and a DLL file. In order to test this sample, first execute install.exe in 1_install folder. You can uninstall this by executing uninstall.exe in 3_uninstall folder.
As seen above, click OK button first and then test the functions.
Using the Code
Here I would explain the file system filter driver. There are two ways of developing file system filter driver. One is to use filter function supported by FLTLIB.DLL in system32 directory. In this case, we can communicate with driver by using FilterConnectCommunicationPort() function and FilterSendMessage() function. Another one is to get file system driver's pointer and attach our driver to it by using IoAttachDeviceToDeviceStack() function.
DriverEntry
DriverEntry() function should be written like below:
NTSTATUS
DriverEntry (
__in PDRIVER_OBJECT DriverObject,
__in PUNICODE_STRING RegistryPath
)
{
PSECURITY_DESCRIPTOR sd;
OBJECT_ATTRIBUTES oa;
UNICODE_STRING uniString;
NTSTATUS status;
PFLT_VOLUME fltvolume;
HANDLE handle = (PVOID)-1;
PROCESS_DEVICEMAP_INFORMATION ldrives;
ULONG drive, bit;
STRING ansiString, ansiVolString;
UNICODE_STRING unString, unVolString;
CHAR szDrv[20];
ULONG sizeneeded;
HANDLE hThread;
OBJECT_ATTRIBUTES oaThread;
KIRQL irql;
ULONG i;
try {
ACDrvData.LogSequenceNumber = 0;
ACDrvData.MaxRecordsToAllocate = DEFAULT_MAX_RECORDS_TO_ALLOCATE;
ACDrvData.RecordsAllocated = 0;
ACDrvData.NameQueryMethod = DEFAULT_NAME_QUERY_METHOD;
ACDrvData.DriverObject = DriverObject;
InitializeListHead( &ACDrvData.OutputBufferList );
KeInitializeSpinLock( &ACDrvData.OutputBufferLock );
#if ACDRV_LONGHORN
//
// Dynamically import FilterMgr APIs for transaction support
//
ACDrvData.PFltSetTransactionContext =
FltGetRoutineAddress( "FltSetTransactionContext" );
ACDrvData.PFltGetTransactionContext =
FltGetRoutineAddress( "FltGetTransactionContext" );
ACDrvData.PFltEnlistInTransaction =
FltGetRoutineAddress( "FltEnlistInTransaction" );
#endif
SpyReadDriverParameters(RegistryPath);
Read more: Codeproject
Subscribe to:
Posts (Atom)