Creating Your AppUp Application In DGDK
---------------------------------------
0. Download
AppUpForDarkBasicPro.rar which contains "appupplugin.dll".
1. Download and install the
Intel Atom Developer Program SDK.
2. Place the appupplugin.dll in the application folder.
3. Load the attached example project 'DGDK_AppUpExample.sln' (Don't forget to set it to 'release' mode, as no user options are attached), or use this code:
#include "windows.h"
#include "DarkGDK.h"
/*
DGDK is statically linked, and Intel SDK requires dynamic linking with Shared MFC (not good combo).
The solution is to use the APPUPDLL.DLL found in the last newsletter and load this at run-time,
performing the same calls as demonstrated in the APPUPEXAMPLE program:
*/
//Declare the dll function
typedef int (__cdecl *ApproveApp_PROC)(unsigned long,unsigned long,unsigned long,unsigned long,char *) ;
//This helps if an error raises and you need more info
//not strictly needed
void ErrorExit(LPTSTR lpszFunction) ;
//Exit routine
void terminate_execution(void);
void DarkGDK ( void )
{
char mypassword[256];
int myuniquevalue = 0;
//Set the password
strcpy ( mypassword, "anythingiwanthere" );
HINSTANCE hinstLib;
ApproveApp_PROC approve_app;
BOOL fFreeResult = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("./appupplugin.dll"));
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
approve_app = (ApproveApp_PROC) GetProcAddress( (HMODULE) hinstLib, TEXT("?ApproveApp@@YAHKKKKPAD@Z"));
// If the function address is valid, call the function.
if (NULL != approve_app)
{
//Get authentication from AppUp
myuniquevalue = approve_app ( (unsigned long)0, (unsigned long)0, (unsigned long)0, (unsigned long)0, mypassword );
}
else
{
terminate_execution();
ErrorExit(TEXT("GetProcAddress"));
return;
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
else
{
terminate_execution();
ErrorExit(TEXT("GetProcAddress"));
return;
}
//Comment this line once you know the code
dbPrint ( dbStr(myuniquevalue) ) ; dbWaitKey();
//Change 929 in this line for your code
if (myuniquevalue == 929)
{
dbPrint ("application is approved!");
}
else
{
terminate_execution();
return;
}
//Your application
dbPrint ("your application goes here");
dbPrint ("press any key to exit");
dbWaitKey();
//...
return;
}
void terminate_execution()
{
dbPrint ("application not approved, now quitting...");
dbSleep (1000);
return;
}
//This helps if an error raises and you need more info
//not strictly needed
#include <strsafe.h>
void ErrorExit(LPTSTR lpszFunction)
{
// Retrieve the system error message for the last-error code
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
// Display the error message and exit the process
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
(lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR));
StringCchPrintf((LPTSTR)lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("%s failed with error %d: %s"),
lpszFunction, dw, lpMsgBuf);
MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
ExitProcess(dw);
}
4. Change the following line, in the example project, to your own unique password string:
strcpy ( mypassword, "anythingiwanthere" );
5. Launch runATDS.bat found in Intel Atom Developer Program SDK\0.91\bin
6. Run the AppUpExample. It will display a value.
7. Comment the following line, it is not needed once you know your code:
dbPrint ( dbStr(myuniquevalue) ) ; dbWaitKey();
8. In the following line, replace the number 929 with the code you just saw on screen:
if (myuniquevalue == 929)
9. Now run the application again, it should say 'application is approved'.
10. At this point you have successfully integrated a DEBUG version of the AppUp security system into your DGDK application.
11. The next step is to obtain the GUID that uniquely identifies your application. For this you need to register on the Atom Developer website and create a new product entry on that system. Once complete, it will give you a GUID value which you will need for step 12.
12. Your GUID will resemble something like 0x32423432,0x32423432,0x32423432,0x32423432
13. To change your DEBUG session to a RELEASE session, you need to change the following line
myuniquevalue = approve_app ( (unsigned long)0, (unsigned long)0, (unsigned long)0, (unsigned long)0, mypassword );
and replace the 0,0,0,0 with the four parts of the GUID you have from step 12.
14. For example, the line should now look like:
myuniquevalue = approve_app ( (unsigned long)0x32423432, (unsigned long)0x32423432, (unsigned long)0x32423432, (unsigned long)0x32423432, mypassword );
15. Now when you run your application, it should fail with an authentication message. This is because your application is not running inside the AppUp client. It is this version of your application that you must submit through the Atom Developer site to get approved.
MSI Installer
-------------
Once you have finished your application and the release version of your AppUp authentication code has been integrated, you are ready to create your installer.
It is recommended you create an MSI installer to wrap your application and media in a deliverable ready for the Atom Developer website. Below are some tips to creating a good MSI installer for AppUp:
1. Use an off-the-shelf MSI installer maker such as Wise. These kind of products are reliable and sturdy, and will allow you to focus on application development instead of installer creation and tweaking.
2. Remember that the AppUp authentication code is dependent on some external system files, and the best way to assure that the target system has these files is to use Merge Modules inside your MSI installer. For example you will need to include merge modules for:
policy_9_0_Microsoft_VC90_MFC_x86
policy_9_0_Microsoft_VC90_CRT_x86
Microsoft_VC90_MFC_x86
Microsoft_VC90_CRT_x86
3. As DGDK applications are DirectX based (Octoboer 2006) you will also require your MSI Installer to silently install the above version of DirectX system files to the target PC. To do this, you can obtain the October 2006 REDIST files direct from the Microsoft website and copy the REDIST folder into your final installation files. From within your MSI installer, you can provide a command after the files have been installed to the target system to launch the "DXSETUP.EXE /silent" which will install DirectX silently.
4. Finally, it is highly recommended that you test your final MSI installer on a NetBook before submitting to the AppUp store for approval. Issues of resolution, performance, missing system files and other issues may arise and finding them early will save you weeks within the approval process.
Not tested until the last step yet.