Skip links

Registration-Free Activation of Deviare Hooking Engine COM in x86 and x64 platforms

Deviare 101 Part 1

Welcome to the first installment of Deviare 101.

In this article, we’ll explain how to use Deviare’s Reg-Free COM capability to easily deploy applications on end-user machines.

This guide uses Visual Studio 2013 but can also be followed on earlier versions.

The Manifest File

Reg-Free COM requires an XML file called a “manifest”. Manifest files specify which DLLs to load, and sets other application run-time properties.

If your project includes multiple Windows target platforms, you must use a different manifest for each platform.

This is what the manifest we use to support Deviare in the x86 platform looks like:

<?xml version=”1.0″ encoding=”utf-8″?>

<asmv1:assembly manifestVersion=”1.0″ xmlns=”urn:schemas-microsoft-com:asm.v1″ xmlns:asmv1=”urn:schemas-microsoft-com:asm.v1″ xmlns:asmv2=”urn:schemas-microsoft-com:asm.v2″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>

<assemblyIdentity version=”1.0.0.0″ name=”myApp” processorArchitecture=”x86″/>

 

<dependency>

<dependentAssembly>

<assemblyIdentity type=”win32″ name=”DeviareCOM” version=”2.0.0.0″ processorArchitecture=”x86″ />

</dependentAssembly>

</dependency>

 

</asmv1:assembly>

Here is the manifest we use to support Deviare in the x64 platform:

<?xml version=”1.0″ encoding=”utf-8″?>

<asmv1:assembly manifestVersion=”1.0″ xmlns=”urn:schemas-microsoft-com:asm.v1″ xmlns:asmv1=”urn:schemas-microsoft-com:asm.v1″ xmlns:asmv2=”urn:schemas-microsoft-com:asm.v2″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>

<assemblyIdentity version=”1.0.0.0″ name=”myApp” />

 

<dependency>

<dependentAssembly>

<assemblyIdentity type=”win32″ name=”DeviareCOM64″ version=”2.0.0.0″ processorArchitecture=”amd64″ />

</dependentAssembly>

</dependency>

 

</asmv1:assembly>

You must specify your application assembly name and version in the application’s <assemblyIdentity> tag. Additional attributes are optional.

How to Connect Your Application to the Manifest File

There are two ways to connect your application to the manifest file:

  • Place the manifest file in your application home directory. This requires the manifest file to have the same name as your application executable, with the “.manifest” suffix. For example, if your application executable is MyApp.exe, you must name the manifest MyApp.exe.manifest.
  • Embed the manifest in your application executable as a resource.

The second option involves a bit of work with project settings, and is described in the section below.

Deviare DLLs and database files should be placed in your application’s home directory or another searchable location (e.g: in the system path). Be aware that when you mix projects using Deviare with the Reg-Free COM mechanism with other projects using manual registration you may experience issues such as versioning problems. You can use the regsvr tool with the /U option to manually unregister Deviare.

Visual Studio C++ Project Setup Guide

To use Reg-Free COM Deviare in a C++ VS application, follow those steps:

  1. Create one manifest file for each target platform as shown at the beginning of this article. Name them “RegFreeCOM_x86.manifest” and “RegFreeCOM_x64.manifest”. Copy those files to your source file directory.
  2. Open your project settings, select the desired platform, go to “Manifest Tool >> Input and Output” and enter the filename in “Additional Manifest Files”. You can specify variables such as $(SolutionDir), $(ProjectDir) to modify the manifest path. Make sure the selected platform and manifest file platform match.

settings_c++_x86

Do the same for the other platforms in your project,. In this case, the x64 platform:

settings_c++_x64

DeviareCOM DLLs must be in the same directory as your executable. You can copy them manually; or use “Post-Build Event” in “Project Settings” to automate this step.

settings_postbuild

In the screenshot above, we show an example of how to use the “Command Line” field to copy Deviare DLLs and databases from a DLL directory within the solution directory ( $(SolutionDir) variable) to the output directory where the application executable is generated ( ($OutDir) variable).

  1. Build your project and test your application.

C# Project Setup Guide

Important: Visual Studio uses VSHOST.EXE to improve debugging when you launch an application. As a result Visual Studio ignores your embedded manifest and COM components are not loaded properly. There are two workarounds: 1) execute your application outside Visual Studio or 2) uncheck “Enable the Visual Studio hosting process” in your project settings:

vshost

If you want to use a single custom application manifest in a C# project, it’s easy to access the project settings dialog and choose a manifest file:

settings_c#

However, unlike Visual Studio C++ projects it is not possible to configure multiple-platform projects to use one manifest for each platform in Visual Studio C# projects. The above dialog only sets up a global manifest for the application.

Since Deviare 32-bit and 64-bit are different COM DLLs, you need to use different manifests to load them:

  1. Create manifest files as shown at the beginning of this article, one for each target platform. Name them “RegFreeCOM_x86.manifest” and “RegFreeCOM_x64.manifest”. Copy these files to your source file directory.
  2. Use a text editor to open your C# project file (“.csproj” extensión). Look for the “PropertyGroup” tags. There is one “PropertyGroup” for each configuration and platform target pair.

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Release|x86′”>

</PropertyGroup>

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Debug|x64′”>

</PropertyGroup>

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Release|x64′”>

</PropertyGroup>

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Debug|x86′”>

</PropertyGroup>

  1. With either VS closed or the project unloaded to allow modifications, you must insert the manifest declaration using the proper manifest file platform below the “<PropertyGroup …>” opening tag. If we have the RegFreeCOM_x86.manifest and RegFreeCOM_X64.manifest to use on the x86 and x64 builds, respectively, first, we’ll add the manifest declaration of the x86 build:

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Release|x86′”>
<ApplicationManifest>RegFreeCOM_x86.manifest</ApplicationManifest>

</PropertyGroup>

Repeat for all configuration combinations; be careful not to delete the existing tags between the PropertyGroup opening and closing tags.

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Debug|x64′”>
<ApplicationManifest>RegFreeCOM_x64.manifest</ApplicationManifest>

</PropertyGroup>

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Release|x64′”> <ApplicationManifest>RegFreeCOM_x64.manifest</ApplicationManifest>

</PropertyGroup>

<PropertyGroup Condition=”‘$(Configuration)|$(Platform)’ == ‘Debug|x86′”>
<ApplicationManifest>RegFreeCOM_x86.manifest</ApplicationManifest>

</PropertyGroup>

  1. Save the file, and reopen it in Visual Studio. Build the x86 and x64 platforms and test your application.

Checking Embedded Manifests

You may want to see if a manifest is properly embedded (or embedded at all) for debugging purposes. The Windows SDK included with VS provides a tool (MT) to work with manifest files.

To extract the manifest from your application, simply use the -inputresource and -out flags:

mt -inputresource:RegFreeComTest.Exe;#1 -out:CON

“CON” displays the manifest in the console. You can specify a filename to save it.

Additional Information

There’s plenty of general information about manifest files, and Registration-Free COM. Here are some useful links.

If you liked this article, you might also like:

Related Services

Don’t forget to read our data loss prevention solution developmentWindows driver development and Windows software development services.

This website uses cookies to improve your web experience.