[ActiveLock-Development] CVS: activelock/examples/example1 ALTestApp.vbp,1.2,1.3 frmMain.frm,1.4,1.5
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-10-13 07:45:35
|
Update of /cvsroot/activelock/activelock/examples/example1 In directory sc8-pr-cvs1:/tmp/cvs-serv18918 Modified Files: ALTestApp.vbp frmMain.frm modMain.bas Log Message: - Removed dependency on modActiveLock - Added simple encryption routine to illustrate handling of ValidateValue() event. Index: ALTestApp.vbp =================================================================== RCS file: /cvsroot/activelock/activelock/examples/example1/ALTestApp.vbp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ALTestApp.vbp 22 Sep 2003 03:09:18 -0000 1.2 +++ ALTestApp.vbp 13 Oct 2003 07:45:31 -0000 1.3 @@ -1,11 +1,10 @@ Type=Exe Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#stdole2.tlb#OLE Automation -Reference=*\G{C3B56087-6690-42ED-8914-633AA166AB41}#1.0#0#ActiveLock2.dll#ActiveLock2 +Reference=*\G{C3B56087-6690-42ED-8914-633AA166AB41}#1.0#0#..\..\bin\activelock2.dll#ActiveLock2 Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; TABCTL32.OCX Form=frmMain.frm UserControl=atViewPort.ctl Module=modMain; modMain.bas -Module=modActiveLock; ..\..\src\modActiveLock.bas Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0; COMCTL32.OCX ResFile32="atDisplay.RES" IconForm="frmMain" @@ -23,7 +22,6 @@ AutoIncrementVer=0 ServerSupportFiles=0 VersionCompanyName="The ActiveLock Software Group" -CondComp="AL_DEBUG = 1" CompilationType=0 OptimizationType=0 FavorPentiumPro(tm)=0 Index: frmMain.frm =================================================================== RCS file: /cvsroot/activelock/activelock/examples/example1/frmMain.frm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- frmMain.frm 5 Oct 2003 08:36:26 -0000 1.4 +++ frmMain.frm 13 Oct 2003 07:45:31 -0000 1.5 @@ -58,11 +58,11 @@ TabCaption(1) = "Sample App" TabPicture(1) = "frmMain.frx":0CE6 Tab(1).ControlEnabled= 0 'False - Tab(1).Control(0)= "fraViewport" - Tab(1).Control(1)= "fraTicker" + Tab(1).Control(0)= "lblLockStatus" + Tab(1).Control(1)= "lblLockStatus2" Tab(1).Control(2)= "Frame1" - Tab(1).Control(3)= "lblLockStatus2" - Tab(1).Control(4)= "lblLockStatus" + Tab(1).Control(3)= "fraTicker" + Tab(1).Control(4)= "fraViewport" Tab(1).ControlCount= 5 Begin VB.Frame fraViewport BorderStyle = 0 'None @@ -494,7 +494,8 @@ ' 08.03.03 - th2tran - Added SoftwareCode generator and usage instructions. ' 09.14.03 - th2tran - Removed Key Generator functionality. This is now handled ' by ALUGEN. -' +' 10.13.03 - th2tran - Added simple Encrypt routine to illustrate handling of +' ActiveLockEventNotifier.ValidateValue() event. ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// @@ -581,9 +582,20 @@ ' We can use any kind of encryption we'd like here, as long as it's deterministic. ' i.e. there's a one-to-one correspondence between unencrypted value and encrypted value. ' NOTE: BlowFish is NOT an example of deterministic encryption so you can't use it here. -Private Sub ActiveLockEventSink_ValidateValue(ByVal Value As String, Result As String) - Result = Value ' modMain.Encrypt(Value) +Private Sub ActiveLockEventSink_ValidateValue(ByRef Value As String) + Value = Encrypt(Value) End Sub + +Private Function Encrypt(strData As String) As String + Dim i&, n& + Dim sResult$ + n = Len(strData) + For i = 1 To n + sResult = sResult & Asc(Mid$(strData, i, 1)) * 7 + Next i + Encrypt = sResult +End Function + ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Key Request and Registration Functionalities Index: modMain.bas =================================================================== RCS file: /cvsroot/activelock/activelock/examples/example1/modMain.bas,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- modMain.bas 6 Oct 2003 03:51:11 -0000 1.5 +++ modMain.bas 13 Oct 2003 07:45:31 -0000 1.6 @@ -54,9 +54,11 @@ ' Compute the expected CRC instead leaving it as a plain ' value to make it more difficult to spot in a hex editor. ' 09.21.03 - th2tran - Dumped PRIV_KEY. PRIV_KEY should only be accessible to ALUGEN. +' 10.13.03 - th2tran - Copied a small number of functions from modActiveLock.bas into here +' so that our test app doesn't need to depend on modActiveLock. ' </pre> -' /////////////////////////////////////////////////////////////////////// +'* /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// Option Explicit @@ -261,6 +263,10 @@ End Enum +'' +' Windows API Declares +Private Declare Function MapFileAndCheckSum Lib "imagehlp" Alias "MapFileAndCheckSumA" (ByVal FileName As String, HeaderSum As Long, CheckSum As Long) As Long + ' Application Encryption keys: ' !!!WARNING!!! ' It is alright to use these same keys for testing your application. But it is highly recommended @@ -300,7 +306,7 @@ ' Public Function VerifyActiveLockdll(obj As IUnknown) As String Dim crc As Long - crc = modActiveLock.CRCCheckSumTypeLib(obj) + crc = CRCCheckSumTypeLib(obj) Debug.Print "Hash: " & crc If crc <> Value Then MsgBox "activelock2.dll has been corrupted. If you were running a real application, it should terminate at this point." @@ -312,7 +318,7 @@ ' Returns the expected CRC value of ActiveLock2.dll ' Private Property Get Value() As Long - Value = 139926 + 1792 ' 141718 - computed so that it can't be easily spotted via a Hex Editor + Value = 176794 + 1856 ' 178650 - computed so that it can't be easily spotted via a Hex Editor End Property '' @@ -321,3 +327,27 @@ Public Sub ProgressUpdate(ByVal param As Long, ByVal action As Long, ByVal phase As Long, ByVal iprogress As Long) frmMain.UpdateStatus "Progress Update received " & param & ", action: " & action & ", iprogress: " & iprogress End Sub + + +Private Function GetTypeLibPathFromObject(obj As IUnknown) As String + ' Retrieve TypeLib info using TLI library (tlbinfo.dll) + ' Use late-binding so that the user doesn't have to add it to their project reference + Dim tliApp As Object + Set tliApp = CreateObject("TLI.TLIApplication") + Dim ti As Object ' actually TLI.TypeInfo + Set ti = tliApp.ClassInfoFromObject(obj) + Dim strDllPath As String + GetTypeLibPathFromObject = ti.Parent.ContainingFile +End Function + +'' +' Performs CRC checksum on the type library containing the object. +' @param obj COM object used to determine the file path to the type library +' +Public Function CRCCheckSumTypeLib(obj As IUnknown) As Long + Dim strDllPath As String + strDllPath = GetTypeLibPathFromObject(obj) + Dim HeaderSum As Long, RealSum As Long + MapFileAndCheckSum strDllPath, HeaderSum, RealSum + CRCCheckSumTypeLib = RealSum +End Function |