Tip #1: Backup Outlook 2007 Accounts’ Information

This is a series of different tips and tricks for computer users. It will include: software usage tip, hacks, development tips, hardware tips, etc.

I will try to post tips every day but I don’t know if my schedule will allow me.

When you need to reinstall Windows and/or Outlook you might backup the .pst files (Outlook data files). Unfortunately these files do not contain account information. After reinstall and restore of backup files you need to reenter all information about each account which is a boring process – at least for me because I have 5 e-mail accounts.

If you want to backup accounts information you have to export the “HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook” key from Registry.

Export accounts’ information:

  1. Tip_01_01Start the Registry Editor (Start -> Run -> “regedit”) – in Windows Vista/7 you need administrative rights to start it.
  2. Navigate to the previously mentioned branch (HKEY_CURRENT_USER\Software\ … ).
  3. Right click the “Outlook” tree node.
  4. Choose export.
  5. Name the file accordingly.
  6. Click “Save”

After reinstalling Outlook, you have to import the accounts. Follow the steps below for this:

Import accounts’ information:

  1. Double click the exported file.
  2. Choose “Yes” when asked if you really want to import.

Windows Mobile 6.5 on Toshiba G900

aboutBefore writing anything else I must warn all readers that changing the operating systems on your mobile will void the warranty. If the upgrade process fails the phone might be damaged and no service will fix that for free. Do it on your own risk and make sure the following list is satisfied:

  • Ask people about the ROM you want to install. Make sure it did not brake any phone.
  • The phone’s battery must be at least 50% charged (better 100%)
  • Make sure you have and UPS. Or a laptop with good battery because if you cancel the process after it started the results might be unexpected.
  • Make sure the USB cable is firmly connect and is not broken!

I cannot be made responsible for any damages caused directly or indirectly by this article.

Read the rest of this entry »

Using UAC with C# – Part 2

In part 1 of this tutorial I have presented how to run an application with and without elevation by specifying this from another process.

However there are some situations when an application cannot be run without administrative rights. For example a system configuration utility requires administrative rights to change some global policies.

In order to force an application to run only if the current user is administrator or can provide administrative credentials you must add a manifest to the C# project.

The manifest is an XML file named <application_name>.exe.manifest with the following content:

< ?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
   <assemblyidentity version="1.0.0.0" processorArchitecture="X86" name="UACApp" type="win32"/>
      <trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
         <requestedprivileges>
            <requestedexecutionlevel level="requireAdministrator"/> 
         </requestedprivileges>
      </security>
   </trustinfo>
</assembly>

What is important is the requestedExecutionLevel element. It specifies what permissions (execution level) the application needs in order to start. If the current user does not have the required level then an elevation window is displayed (see part one of the tutorial that describes the elevation window).

The default value of requestedExecutionLevel if it is not specified in the manifest or the manifest does not exist is asInvoker. Except asInvoker and requireAdministrator there is another execution level. All three are described below:

Value Description Comment
asInvoker The application runs with the same access token as the parent process. Recommended for standard user applications. Do refractoring with internal elevation points, as per the guidance provided earlier in this document.
highestAvailable The application runs with the highest privileges the current user can obtain. Recommended for mixed-mode applications. Plan to refractor the application in a future release.
requireAdministrator The application runs only for administrators and requires that the application be launched with the full access token of an administrator. Recommended for administrator only applications. Internal elevation points are not needed. The application is already running elevated.

In order to embed the manifest in the aplication’s executable you can choose one of the following options:

Read the rest of this entry »

Using UAC with C# – Part 1

user_account_control_administrator_dialogUser Account Control (UAC) is a new technology introduced by Microsoft in Windows Vista and most of the time it is misunderstood by users and developers. It’s main purpose is to protect the operating system by running applications with reduced privileges.

Why should we use this? Most applications DO NOT require full privileges. Think to the applications you have written and ask yourself if most of the job can be done without full writes (if you write to disk think if you could write in the user’s folder or an isolated storage, if writing in registry to HKLM think if you could write to HKLU, etc). The answer is mostly sure “Yes”.

So why run applications with full privileges when they can be run with limited? Running with more privileges than required is just a security vulnerability -  If an attacker exploits a vulnerability in your application he will gain more control.

There are two mistakes developers tend to do:unidentified_uac

  1. Request the end-user to run an application with full rights even though this is not necessarily (most of the time because of bad design practices)
  2. Do not request to user to run the application elevated but try to perform operations that require more rights

By design UAC can only elevate code at process level and only at process’ startup (means that a running process cannot be elevated). In the .NET world this also means that you cannot elevate code running in another app domain because the app domain is part of a running process. In order to elevate an existing application this must be closed and reopen with more privileges.

There are two types on UAC dialogs: blue and yellow. When you see a blue dialog you can be sure that the application requesting privileges is signed and trusted. The yellow dialog shows for any application that is not digitally signed and is not fully trusted.

User Account Control also prevents a lower privilege process to do the following (list below taken from MSDN):

  • Perform a window handle validation of higher process privilege.
  • SendMessage or PostMessage to higher privilege application windows. These Application Programming Interfaces (APIs) return success but silently drop the window message.
  • Use thread hooks to attach to a higher privilege process.
  • Use Journal hooks to monitor a higher privilege process.
  • Perform DLL injection to a higher privilege process.

Let’s see how an UAC aware application should look.

Read the rest of this entry »

Access private data with Reflection

This article shows how one of the basic OOP principles – encapsulation – can be violated using reflection.

Let’s assume that we have a simple class with a private field called “someHiddenValue”.

class ClassThatHidesSomething
{
    private int someHiddenValue = 5;
}

We want to modify that field from outside the class. This can be done extremely easy through Reflection. First of all we need to get the Type of the ClassThatHidesSomething and get some information about the someHiddenValue field.

Type classThatHidesSomethingType = typeof(ClassThatHidesSomething);
FieldInfo field = classThatHidesSomethingType.GetField(
                         "someHiddenValue",
                         BindingFlags.NonPublic | BindingFlags.Instance);
  • BindingFlags.NonPublic specifies that we want to search in all fields; by default it searches only the public fields – actually here is the trick that violates encapsulation.
  • BindingFlags.Instance specified that we want to search in instance fields also; by default it searches only in static ones.

Now that we have the FieldInfo of that specific field we can do whatever we want with it. Let’s display its value. But first, because the field is an instance field we need an instance of ClassThatHidesSomething.

ClassThatHidesSomething c = new ClassThatHidesSomething();
 
int hiddenFieldValue = (int)field.GetValue(c);
Console.WriteLine("Hidden field value: {0}", hiddenFieldValue);

Using the same instance c we can set the private field’s value.

field.SetValue(c, 6);

Below you can see the entire code (it is a console application):

Read the rest of this entry »

Learn About Azure Services Platform

Microsoft provides two ways of learning about Azure Services:

1. Azure Services Traning Kit

The Azure Services Training Kit which includes a comprehensive set of technical content including hands-on labs, presentations, and demos that are designed to help you learn how to use the Azure Services Platform. The February release includes the following updates:

  • 19 demo scripts that walkthrough several of the services
  • 10 presentations covering the entire Azure Services Platform
  • 3 additional hands-on labs for Live Services’

The technical content covers services including: Windows Azure, .NET Services, SQL Services, and Live Services.

It can be downloaded from here.

2. “How Do I?” videos for Azure Services Platform

For Windows Azure:

How Do I: Get Started Developing on Windows Azure? If you’re a developer and you’re new to Windows Azure, start here! You’ll see what you need to download and install, and how to create a simple “Hello World” Windows Azure application.
How Do I: Deploy a Windows Azure Application? In this brief screencast you’ll see what it takes to move your application into the cloud – you’ll see how to request and register a token, how to upload your Windows Azure application and how to move it between staging and production in the cloud.
How Do I: Store Blobs in Windows Azure Storage? In this brief screencast, learn how to leverage Windows Azure storage to store data as blobs. You’ll learn about blob storage, containers and the API that makes it easy to manage everything from managed code.
How Do I: Leverage Queues in Windows Azure? In this screencast, learn how to use queues to facilitate communication between Web and Worker roles in Windows Azure.
Debugging Tips for Windows Azure Applications The Windows Azure SDK provides a development fabric that provides a “cloud on your desktop.” In this screencast, learn how to debug your Windows Azure applications in this environment.

For .NET Services:

How Do I: Get Started with .NET Services? .NET Services are a set of highly scalable building blocks for programming in the cloud. In this brief screencast, you’ll learn about the registration process, the SDK and the built-in samples – everything you need to know in order to get started.
How Do I: Harness the Microsoft .NET Service Bus? The .NET Service Bus makes it easy to access your Web services no matter where they are. In this brief screencast, you’ll see how to take a basic Windows Communication Foundation (WCF) service and expose it to the Internet with the .NET Service Bus.

For Live Services:

How Do I: Get Started with the Live Framework? If you are looking to get started developing with the Live Framework, this is the place to start! In this screencast you’ll learn how to get a Live Services token and what you need to download in order to start writing Live Framework applications.
How Do I: Use the Microsoft Live Framework Resource Browser? The Live Framework Resource Model is a simple, straightforward information model based on entities, collections and relationships. In this brief screencast you’ll learn how to navigate the relationships between entities by using the Live Framework Resource Browser, which is a tool that ships with the Live Framework SDK.

First CodeProject article – WPFDesigner

Today I’ve posted my first article on CodeProject.

The article describes how to create a custom control in which you add elements and you can move/resize them.

The article can be found here.

Install custom firmware on Asus WL500G Premium

If you are one of the Asus WL500G Premium owners than it is possible to have problems with an USB drive connected the the unit: the HDD won’t respond after a few MB written on disk and the unit restores it’s factory settings.

Maybe you don’t have problems like the one above but I am having problems with an Western Digital 500GB Essential Edition connected to the router so I decided to upgrade it’s firmware to a DD-WRT version (v24 std final). It’s a small Linux distribution that can be installed on many routers.

It brings a lot of new features:

  • Advanced banwidth management
  • DDNS support
  • Ad network support
  • Hotspot support
  • MAC Address Clone
  • Advanced DHCP options
  • Advanced Wireless configuration (mode, frequency, encryption, mac filter, etc)
  • XBOX and PSP connection
  • System log, traffic log, network map
  • SSH connection
  • A lot of filters for MAC, hostname, IP, etc.
  • Overclocking (!)
  • New web UI
  • Wake On Lan
  • etc.

See the difference between the classic Asus firmware and DDWRT:

Default Asus firmware

DD-WRT Firware

This guide is for Asus but a similar process can be applied to any router from the Supported Hardware List. Step 1 and 2 are different but the others are the same.

Very important: Before you read any further and/or try a firmware upgrade note that I am not responsible for any hardware/software/human (hope not) damages/injuries. Try to be sure that you have a backup supply for the router and PC because a power shortage in the middle of the upgrade process makes your router useless!

Read the rest of this entry »

Microsoft “How Do I?”

Surfing on Microsoft’s website a few days ago, I’ve found a link called “Got 15 minutes? Learn a new task” (yeah, I have 15 minutes :-) ). Followed the link and discovered “How Do I?”.

“How Do I?” is a section of MSDN on which video tutorials are posted. These tutorials are for programmers and show how to do various things using Microsoft tools and technologies (Visual Studio, .NET Framework, ASP.NET, Windows Mobile, etc). The clips vary from 5 to 40 minutes.

Every clip deals with one topic and most of them consist of one movie.

There are 12 categories:

  • ASP.NET
  • ASP.NET Ajax
  • Devices
  • Native Coding
  • Security
  • Silverlight
  • Visual Basic
  • Visual Studio Extensibility
  • Visual Studio Team System
  • Visual Studio Tools for Applications
  • Windows Forms
  • Windows Presentation Foundation

From all the clips I recommend (the other are not bad but these I liked most):

Devices: Programmatically Monitor for a Specific Time of Day Without Draining a Device Battery
Devices: Hide Standard Device UI Elements in a .NET Compact Framework Application
Security: Attach Client Credentials to a Web Service Call For Security
Security: Add Security to Applications by Digitally Signing XAML Documents
Security: Increase Web Site Security by Integrating Cardspace and ASP.NET for Login

Oh, and one more thing. All tutorials can be downloaded and most of them include source code ;-)

If you want to visit “How Do I?” follow this link.