Its funny how many times a day I get asked this at work, what is the best way to protect myself against data theft, or how can I hide my data from other people, etc.
I always give them the same answer and its why my computer has 8 drives instead of 5, TrueCrypt! Its very very fast, you dont even notice your using a TrueCrypt volume its actually so fast!
Below is a list of features from the site, its free and its open source!! Cant get any better than this!!
Main Features:
- Creates a virtual encrypted disk within a file and mounts it as a real disk.
- Encrypts an entire hard disk partition or a device, such as USB flash drive.
- Encryption is automatic, real-time (on-the-fly) and transparent.
- Provides two levels of plausible deniability, in case an adversary forces you to reveal the password:
1) Hidden volume (steganography – more information may be found here). 2) No TrueCrypt volume can be identified (volumes cannot be distinguished from random data)
- Encryption algorithms: AES-256, Blowfish (448-bit key), CAST5, Serpent, Triple DES, and Twofish.
- Mode of operation: LRW (CBC supported as legacy).
- Based on Encryption for the Masses (E4M) 2.02a, conceived in 1997.
Yeah, I know I havent posted in a while so I am getting rid of a backlog of links I posted to Del.icio.us and never posted to my blog!
Interesting read about Generics in .NET 2.0
Snippet from the blog... ".NET 2.0's Best New Language Feature It didn't take long after the release of .NET 2.0 for me to start finding all kinds of uses for what I consider to be the best new framework / language feature - generics. As a long-time C++ developer who used templates and the STL at every opportunity, I didn't realize how much I missed parameterized types until they were put back in my toolbox. I'm going to focus here on a concrete application of .NET generics and, in the process, point out some of their features and syntactic elements. For an excellent overview of .NET generics with comparisons to their counterparts in Java and C++, see Bruce Eckel's Interview with Anders Hejlsberg."
Well they have finally released Visual Studio 2003 Service Pack 1 Beta for testing, wow thats a mouthfull. Remember this is a service pack for Visual Studio 2003, NOT the .NET Framework so this will not affect your project in any way, well unless it starts deleting lines of code randomly and then saves the project before you can click anything!! Im joking thats unlikely to happen, but might not want to use it on a production machines as nil as the chances are there may be something, some incompatability!
But anyways you can go here to apply for the testing. (Note: I couldnt directly link it since its some kind of control their using, but if you login using passport and navigate to that site you will see it on the bottom of the list of products you can test!)
Have fun!
So Microsoft has delayed vista again? That really does suck but if you read into the entire ordeal it really doesnt mean much to us the cosumers. Why? Because we probably wouldnt be able to get ahold of it anyways, it goes to OEM sales first right? After all they sale the most copies through OEM so us geeks wouldnt get to buy a standalone version of Vista Ultimate until sometime into 2007, probably say around February! We will see, I just cant wait to give it a try! Of course I am also one of the ones that said "Wait til they can put everything they want in Vista, dont cut ANYTHING out! I want WinFS, Monad, EFI Support, etc." which I wish they did!
I feel like I am getting a "Ghetto" version if Windows Vista now, but I am still happy since it looks like one nice ass piece of technological wonder that are creating, some people dont realize that it alot of the features may "look" like OS X (Apple) but thats where it stops, it only looks like OS X. What they are missing is that WinPF the new Graphics foundation layer is revolutionary, using Vector graphics so anything can scale to any size without ever pixelating or looking blurry! In fact the new Alt-Tab where the windows are cascaded so you can browse through them has been said to be a copy of OS X, well if you notice OS X uses static images to do it, while Vista does it with the "Real" window so the video is still playing as you do it!
But anyways off of my rant! Its a shame they are delaying! Darn! or SH#@!!!
Scott Hansleman is one of my favorite bloggers to read on a daily basis with great computer, technology, and programming info. He is supporting this cause and as an avid reader and having several family members lost to it I feel the need to support. You can read more about this at his blog here. I personally donated, donate now its worth the cause!
Link: http://www.hanselman.com/blog/teamhanselmananddiabeteswalk2006.aspx
With some more research I found a BitTorrent client which David Smith has been developing for a couple of months now in .NET 2.0 C# and using all of .NET's features, which is basically what I was doing but he is way ahead of me on this whole ordeal!
So in case you have stumbled on this page and are interesting in a working implementation of the BitTorrent client in .NET his is the way to go, and there is a snapshot of his subversion repository here. I cant understand why this was so hard to find on the web, one would think this would be a huge project just like Azureus is wouldn't you?
ASP.NET 2.0 has a really cool feature, actually ASP.NET 1.x supported this but I never came across it for some reason. But while coding my new site with ASP.NET 2.0 using all the new features, I came across it. Its also posted on MSDN, in case your curious.
Here's the problem I was facing. For my site I am using the new PageControl class which saves a bunch of time which give you the web.sitemap xml file capability:
< siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url ="~/" title="ElucidWeb" description="ElucidWeb"> <siteMapNode url="~/default.aspx" title="Home" description="Welcome to ElucidWeb Software" /> <siteMapNode url="~/blognews.aspx" title="Blog/News" description="Developer Blogs & Site News" /> <siteMapNode url="~/products/products.aspx" title="Products" description="Products" /> <siteMapNode url="~/projects/projects.aspx" title="Projects" description="Projects" /> <siteMapNode url="~/beta/beta.aspx" title="Beta" description="Beta" /> <siteMapNode url="~/support/support.aspx" title="Support" description="Support" /> <siteMapNode url="~/help/help.aspx" title="Help" description="Help" /> </siteMapNode> </siteMap>
Mine looks a bit funny cause of the way I have laid it out so that my TreeView and my BreadCrumb control would look, and path correctly. But in any case by using PageControl.GetCurrent() you can retrieve the current URL, which comes in handy! You can also iterate over and query it, etc..
For me I wanted to disconnect the image paths from my UI design so I created an additional XML file that I called SiteImageMap.xml and I put this in my App_code folder for simplicity sake. I wanted this file and my web.sitemap file to be work in unison. Well I ran into a problem getting the images to map relative to the folder they were in, for instance if I was in www.elucidweb.com the images/image.gif worked fine but if i was in www.elucidweb.com/products/ then the URL would point to images/products/image.gif which doesn't exist!
Heres the SiteImageMap.xml file:
< SiteImageMap> <SiteImage ID="Home" CurrentImageUrl="~/images/home.gif" TopNavImageUrl="~/images/layout/nav/navheader_home_selected.gif"/> <SiteImage ID="Blog/News" CurrentImageUrl="~/images/news.gif" TopNavImageUrl="~/images/layout/nav/navheader_blognews_selected.gif" /> <SiteImage ID="Products" CurrentImageUrl="~/images/product.gif" TopNavImageUrl="~/images/layout/nav/navheader_products_selected.gif" /> <SiteImage ID="Projects" CurrentImageUrl="~/images/projects.gif" TopNavImageUrl="~/images/layout/nav/navheader_projects_selected.gif" /> <SiteImage ID="Beta" CurrentImageUrl="~/images/beta.gif" TopNavImageUrl="~/images/layout/nav/navheader_beta_selected.gif" /> <SiteImage ID="Support" CurrentImageUrl="~/images/support.gif" TopNavImageUrl="~/images/layout/nav/navheader_support_selected.gif" /> <SiteImage ID="Help" CurrentImageUrl="~/images/help.gif" TopNavImageUrl="~/images/layout/nav/navheader_help_selected.gif" /> </SiteImageMap>
So to get around the problem of linking my images directly in my UI design I came up with a rather simple class that inherits from Control, by inheriting I get to use the Control.ResolveUrl method which will Map any URL encoded in a special format beginning with "~/", this marks the root of your web application and it resolves the url from that point on, all you do is provide it the information from the root to the location and it will parse it accordingly. Now in my old web design I put this code directly into my HTML like <%= Control.ResolveURL("~/blah/...") %> but this is a much more elagant way of doing it IMHO.
The code for the class:
public class PageControl : Control { const string CurrentPageKey = "current_Page"; //specifies the key to use for the cache items...
static HttpContext current = HttpContext.Current;
public void SetCurrentPage(string page) { current.Cache[CurrentPageKey] = page; }
public string GetCurrentPage() { return current.Cache[CurrentPageKey].ToString(); }
public string MapCurrentImage() { string Url = GetCurrentPage(); string xmlpath = current.Server.MapPath("~/App_Data/SiteImageMap.xml"); XmlDocument doc = new XmlDocument();
doc.Load(xmlpath); string xpath = String.Format("/SiteImageMap/SiteImage[@ID='{0}']", Url); string imageURL = doc.SelectSingleNode(xpath).Attributes["CurrentImageUrl"].Value; return ResolveUrl(imageURL); }
public string MapTopNavImage() { string Url = GetCurrentPage(); string xmlpath = current.Server.MapPath("~/App_Data/SiteImageMap.xml"); XmlDocument doc = new XmlDocument();
doc.Load(xmlpath); string xpath = String.Format("/SiteImageMap/SiteImage[@ID='{0}']", Url); string imageURL = doc.SelectSingleNode(xpath).Attributes["TopNavImageUrl"].Value; return ResolveUrl(imageURL); }
}
So thats all there is to it, very very simple but it did take some digging around and testing for me to come up with but in the end its an extremely useful way of doing things. If you like or modify or dislike then go ahead and tell me, would love to hear your comments on it.
In my previous post I pointed you to a CodeProject page, the page had an example but it was using MFC and IMO MFC makes examples very unclear and hard to read. So I have stripped out everything except necessity and created a Win32 Windows application that will show a messagebox of the key you press! This example is as simple as it can get and you can probably see the beauty of the Hooker DLL I mentioned previously.
You can download the sample here: KeyHook_Test.zip
I compiled it using Visual Studio 2005, note you need to set your character type to Multibyte and not Unicode. I attempted to get it working in Unicode but I couldn't get the conversions to work properly, but then again I have little experience in Unicode programming, if I figure that out I will post the Unicode version! So right now it only works on non Unicode character sets...
I recompiled the Hooker DLL file in this example to block key inputs, so if you wanted it to capture the keys but also let them through to the focused application then you will need to drop in your changed version of the KeyHook.dll
While searching the internet for more information about Win32 Hooks, in particular a Keyboard hook sample I found something even better! A project on CodeProject that is quit extensive and impressive. Its an all purpose keyboard hooker, and should meet any need I have or anyone else searching for something similar!!
Note: To capture and block keys you will need to modify the KeyboardProc Callback to return 1, recompile the DLL.
Have you ever tried to install a system hook? It seems its much harder than what it should be, but the real issue is the sheer lack of documentation on how to do it the right way. I found a couple examples in forums and various sites which none of them worked, and in some instances they actually had the Proc code in the Hook DLL itself. Well thats just not right, it should be the Hook DLL captures the message, sends it to your EXE and then passes it onto the next hook on the hook chain.
For some reason I cannot for the life of me get this to work, granted ive only spent about 5 hours working on it so eventually I believe I will master it. But to show you exactly what I am talking about I have compiled the following rather cryptic code below (note this code is pure prototype code):
main.cpp - The main code for the HookDLL.dll
#include <windows.h>
#ifdef HOOKDLL_EXPORTS #define HOOKDLL_API __declspec(dllexport) #else #define HOOKDLL_API __declspec(dllimport) #endif
#define WM_HOOK WM_USER +100
// Shared data segment #pragma data_seg ("Shared") HHOOK g_hHook = NULL; HWND g_hWndNotify = NULL; #pragma data_seg ()
// KeyboardProc() HOOKDLL_API LRESULT CALLBACK KeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ) { if (nCode == HC_ACTION && !(lParam & 0x80000000)) { { PostMessage (g_hWndNotify, WM_HOOK, wParam, lParam); return 0; } } return nCode < 0 ? CallNextHookEx(g_hHook, nCode, wParam, lParam) : 0; }
// Function used to share variables HOOKDLL_API int SetHookDLL( HHOOK hLocalHook, HWND hLocalWnd) { g_hHook = hLocalHook; g_hWndNotify = hLocalWnd; return 1; }
hookdll.def - The definition file.
LIBRARY "HookDLL" EXPORTS KeyboardProc SetHookDLL SECTIONS Shared READ WRITE SHARED
So thats the end of the HookDLL.dll code, next is the main application which currently is setup only for testing. This is the part that doesnt work and its most likely something stupid that I have done on my part.
The main program, EXE for testing the HookDLL.dll
// Main definitions #include <windows.h> #include <string>
using namespace std;
#define WM_HOOK WM_USER +100 HHOOK hHook = NULL; HMODULE hDll; BOOL InstallHook(HWND hWndNotify); BOOL UninstallHook(void); BOOL bHooked; // For SetHookDLL typedef VOID (*LOADPROC)(HHOOK hHook, HWND hWndNotify); HINSTANCE hinst; HWND hwndMain;
// Install hook (after having done : hDll = LoadLibrary("hookdll.dll" ); ) BOOL InstallHook(HWND hWndNotify) { HMODULE hDLL = GetModuleHandle("HookDLL");
LOADPROC fPtrFcnt; hHook = SetWindowsHookEx(WH_KEYBOARD , (HOOKPROC)GetProcAddress(hDLL, "KeyboardProc"), hDLL, 0); if ( hHook == NULL ) return FALSE; else fPtrFcnt = (LOADPROC)GetProcAddress(hDLL,"SetHookDLL"); fPtrFcnt(hHook, hWndNotify); return TRUE; }
// Unistall hook BOOL UninstallHook(void) { if ( hHook ) { if (UnhookWindowsHookEx(hHook)) { hHook = NULL; return TRUE; } return FALSE; } return FALSE; }
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { MSG msg; BOOL bRet;
LoadLibrary("HookDLL.dll"); InstallHook(hwndMain);
// Show the window and paint its contents.
ShowWindow(hwndMain, nCmdShow); UpdateWindow(hwndMain);
// Start the message loop.
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) { TranslateMessage(&msg); DispatchMessage(&msg); }
return 0; }
LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam) { MessageBox(0, "Hook Intercept", "Test", 0); //should popup a message if a key is pressed but doesnt... return CallNextHookEx(hHook, 0, wParam, lParam); }
So mainly I am trying to figure out what the issue is here, my goal is to have a program with hotkeys. Thats my intention and its turning out to be rather difficult to accomplish this, I guess I could use .NET to do this since Keyboard hooking is possible, or perhaps I am going about this the wrong way entirely? I do believe a Hook is needed to capture a keyboard event systemwide unless I am mistaken.
|