Skip to content

Warp Object

Neo edited this page Feb 21, 2022 · 7 revisions

Warp

Warp object is a representative of the tool and serves to provide access to values & functions outside the scope of Exe and System objects.

Table of Contents


Properties

Property name Description
Warp.Path Current running directory
Warp.Version Current version of the tool
Warp.TestMode Boolean to indicate whether running from Test Bench or not
Warp.SrcExe Path to the source exe. DO NOT MODIFY THIS IN SCRIPTS
Warp.TgtExe Path to the target exe. DO NOT MODIFY THIS IN SCRIPTS
Warp.SelCount No of selected patches.
Warp.TestDir Only in Test Bench. Current Test Directory from which the exe files have been listed.
Warp.ExtnSelCount Only in Test Bench. No of selected extensions.
Warp.ExeSelCount Only in Test Bench. No of selected test exe files.

Encryption functions

These functions allow you to use encrypted QJS code in your patches & extensions.

Encrypt

Encrypts the specified QJS code statements using the password & return the hex string result.

Please note that the code will not be validated with the engine at this point, so ensure you are using proper QJS code

Syntax:

Warp.Encrypt(code, pass)
Argument Description
code The QJS statements (provided as a string) to be encrypted.
pass The password to use for encryption.

*Returns: The encryption result as a hex string.


Execute

Executes a block of encrypted code (provided as a hex string) and returns the result

Syntax:

Warp.Execute(hexstring, pass)
Argument Description
hexstring The encrypted code which needs to be executed in the QJS engine.
This can be either 1 string or an array of hex strings which will get auto-concatenated.
pass The password which was used for encryption

Returns: The result of the execution (could very well be undefined as well).


Define

Executes a block of encrypted code (provided as a hex string) and assigns the result to the specified global variable.

The variable name itself can serve as the password. This would be useful for encrypting entire functions.

Syntax:

Warp.Define(varName, hexstring, [pass])
Argument Description
varName The global variable name to assign the result to.
hexstring The encrypted code which needs to be executed in the QJS engine.
This can be either 1 string or an array of hex strings which will get auto-concatenated.
pass Optional password which was used for encryption.
If not provided, varName is assumed to be the password.

Returns: true if successfully assigned a value else false. If the result of the execution is undefined, it will not be assigned.


EncryptFile

Encrypts the specified QJS file into a .ejs file using the specified password.

Please note that the code will not be validated with the engine at this point, so ensure you are using proper QJS code

WARP loads EJS files the same way as it loads QJS files (except that it is encrypted), so you can just drop them in any of the folders where you would place QJS files.

Syntax:

Warp.EncryptFile(qjsFile, pass, [dstFile])
Argument Description
qjsFile The source QJS file to be encrypted. Please use either .qjs or .qsrc suffix for clarity.
pass The password to use for encryption.
dstFile Optional file path for the encrypted EJS output. If not provided, qjsFile itself is used with the suffix changed from .qjs/.qsrc to .ejs

Returns: true if successfully encrypted else false.


File loaders

LoadYaml

Loads the specified YAML file, converts the Node hierarchy into equivalent JS hierarchy and returns the result.

Syntax:

Warp.LoadYaml(path)
Argument Description
path The file to be loaded. Any relative paths will be relative to the WARP folder.

Returns:
the root object/array if successful else false.
If any error occurs during the loading process, a message pops up.


LoadQJS

Loads the specified QJS file and returns its result.

Syntax:

Warp.LoadQJS(path)
Argument Description
path The file to be loaded. Any relative paths will be relative to the WARP folder.

Returns: the result of the last evaluated expression from the file.


LoadEJS

Loads the specified encrypted EJS file and returns its result.

Syntax:

Warp.LoadEJS(path)
Argument Description
path The file to be loaded. Any relative paths will be relative to the WARP folder.

Returns: the result of the last evaluated expression from the file.


LoadExe

Loads the specified 'exe' file into the Exe Object. Only available in Test Bench since it is only required there.

DO NOT USE THIS WITHIN A PATCH FUNCTION

Syntax:

Warp.LoadExe(path)
Argument Description
path The file to be loaded. Any relative paths will be relative to the WARP folder.

Returns:
true if successful else false.
If any error occurs during the loading process, a message pops up.


Display functions

Show

Displays the specified file/directory using the default application assigned in the OS.

Only available for the GUIs i.e. Main GUI & Test Bench. You can run it from Console but it won't do anything.

Syntax:

Warp.Show(path)
Argument Description
path The file/directory to be opened/displayed. Any relative paths will be relative to the WARP folder.

ShowInDir

Displays the specified file/directory inside it's parent directory using the file browser.

Warp.ShowInDir(path)
Argument Description
path The file/directory to be displayed. Any relative paths will be relative to the WARP folder.

Patch state functions

These functions pertain to the selected state of patches.

GetPatchState

Retrieves the selected state of the specified patch.

Syntax:

Warp.GetPatchState(name)
Argument Description
name The name of the patch which we want to know about (a.k.a the function name).
Remember this is not the title which gets displayed

Returns: true if selected else false.


SetPatchState

Sets the selected state of the specified patch. Mostly used for deselecting conflicting patches. Does nothing if the new state boolean matches the existing value of selected.

Syntax:

Warp.SetPatchState(name, state)
Argument Description
name The name of the patch which we want to modify (a.k.a the function name).
Remember this is not the title which gets displayed
{ state The new boolean selected state

Returns: true if successfully set the state else false.


Messaging functions

These functions are used for displaying message boxes explicitly from patches & extensions.

InformUser

Used for informing user about something generic.

Syntax:

Warp.InformUser(title, msg)
Argument Description
title The title to use for the Message Box.
msg The message to be displayed.

WarnUser

Used for warning user about some action.

Syntax:

Warp.WarnUser(title, msg)
Argument Description
title The title to use for the Message Box.
msg The message to be displayed.

Message Control functions

Controls the visibility of messages coming from scripts inside Script Window and Log file.

BlockMsgs

Blocks any messages from going to Script Window or Log file using a password to lock access. This includes reports about changes staged.

As a fail-safe, once the patch function completes, all messages are automatically re-allowed.

Syntax:

Warp.BlockMsgs(pass, [inform])
Argument Description
pass The password to use for locking access to messages.
inform Optional boolean to indicate whether the user should be informed that the block has happened. Default is false.

Returns: true if successfully blocked else false.


AllowMsgs

Undoes a blockage made by BlockMsgs function. The password need to match with the one used while calling BlockMsgs.

Syntax:

Warp.AllowMsgs(pass, [inform])
Argument Description
pass The password which was used for locking access to messages.
inform Optional boolean to indicate whether the user should be informed that the block has been removed. Default is false.

Returns: true if successfully unblocked else false.


Return to top


Further reading