Hello Collins,
First of all, I apologize for the delayed reply.
Thank you for your patience on this.
After further investigating this, I think that I have found a way in which you can achieve what you want.
A little explanation before I give you the step by step which you can follow in order to achieve that: First of all, there are two functions from the "Secureprop.dll" which we need to call in order to decrypt your property. One is the "GetRevealedTextLength" which will return the length of the plain text, to which we need to add 1 more unit, because the next function (which will reveal our text) is developed to also take in consideration the null character that is present at the end of the string. Without doing so, the revealed text will miss its last character (for instance, for a property having its value: "YourValue" --> the "RevealText" function will return "YourValu", without the "e").
Now that I have (hopefully) explained the concept behind this well enough, it is time to work on an example:
Let's say we have a newly created project in which we have the following two props:
PROPERTY --> VALUE
MY_PROP --> YourValue
RESULT_PROP --> 0
where:
- RESULT_PROP is a property which we will further use as an argument to one of our function's call.
- MY_PROP is the property which will have the "Secure property" flag set for itself.
Now it is time to configure the custom actions that will decrypt the earlier encrypted property.
Before we begin, please not that all these custom actions should be scheduled after the
"Finish Execution" action group.
First thing we need to do is to call the "GetRevealedTextLength" function from our dll. To do so, you can use a
"Call function from standard DLL" custom action,
with sequence. The custom action should be configured as it follows:
Path: [#SecureProp.dll]
Return type: Unsigned Integer
Return property: PROPERTY_LENGTH
Calling convention: Standard Calling Convention
Name: GetRevealedTextLength
Arguments:
here you will need to create an argument as it follows:
IO Type: By reference
Type: Unicode String
Source Type: Property
Source: MY_PROP
Execution Time: Immediately
- FirstFunctionCall.PNG (143.29KiB)Viewed 6505 times
Now it is time to increase the property which stores the length (in our case, PROPERTY_LENGTH) value by 1, as explained above. To do so, please add a
"PowerShellScriptInline" custom action,
with sequence. Schedule it after the earlier added
"CallFunctionFromDLL" custom action. The custom action's content can be as it follows:
Code: Select all
$prop = AI_GetMsiProperty PROPERTY_LENGTH
$incremented = [int]$prop+1
AI_SetMsiProperty PROPERTY_LENGTH "$incremented"
Now the PROPERTY_LENGTH property will have the correct length.
Now it is time to configure the second custom action which will call the "RevealText" function. To do so, please add another "Call function from standard DLL" custom action and configure it as it follows:
Path: [#SecureProp.dll]
Return type: Void
Calling convention: Standard Calling Convention
Name: RevealText
Arguments:
here, the function takes 3 arguments as input. Here is how you can configure them:
First argument:
IO Type: By Reference
Type: Unicode String
Source type: Property
Source: MY_PROP
Second argument:
IO Type: By Reference
Type: Unicode string
Source type: Property
Source: RESULT_PROP
Third argument:
IO Type: By value
Type: Unsigned integer
Source type: Property
Source: PROPERTY_LENGTH
- SecondFunctionCall.PNG (145.86KiB)Viewed 6505 times
By calling this function, the result (the property in plain text) will be stored in the RESULT_PROP property.
Also, attached to this thread you can find a sample project which you can use for your reference:
Hope this helps.
All the best,
Catalin