cookie CmProgram

Description

CmProgram programs entries into a CmDongle. The programming can be one of the following tasks:

•Adding a new Firm Item.

•Updating an existing Firm Item.

•Deleting an existing Firm Item.

•Adding a new Product Item to an existing Firm Item.

•Updating an existing Product Item.

•Deleting an existing Product Item.

•Setting a new value in the Box Control register of a CmDongle.

•(Un-)Locking a CmDongle.

•Programming a new Firm Key into a FSB entry.

•Programming a new Userkey into a CmDongle.

tmr_02

Triple Mode Redundancy-related information (TMR)

  • C, C++
  • C#
  • Python

Syntax

int CMAPIENTRY CmProgram(HCMSysEntry hcmse, CMULONG flCtrl, void *pvCtrl, CMUINT cbCtrl, void *pvVerify, CMUINT cbVerify)

Parameter

hcmse contains a handle opened by CmAccess / . The access mode can be Box Access, Firm Item Access or Entry Access. The required access mode depends on the operation set in flCtrl. The handle is connected to a CmLocal or a CmLAN subsystem with a connected CmDongle. This CmDongle will be used for programming.

flCtrl contains one of the following commands:

nav_open CM_GF_ADD_FIRMITEM adds a Firm Item into a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_ADD_FIRMITEM structure. hcmse must be Box Access.

nav_open CM_GF_UPDATE_FIRMITEM updates a Firm Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_UPDATE_FIRMITEM structure. hcmse must be Firm Item Access or Entry Access.

nav_open CM_GF_DELETE_FIRMITEM deletes a Firm Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_DELETE_FIRMITEM structure. hcmse must be Firm Item Access or Entry Access.

nav_open CM_GF_ADD_PRODUCTITEM adds a Product Item into a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_ADD_PRODUCTITEM structure. hcmse must be Entry Access.

nav_open CM_GF_UPDATE_PRODUCTITEM updates a Product Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_UPDATE_PRODUCTITEM structure. hcmse must be Entry Access.

nav_open CM_GF_DELETE_PRODUCTITEM deletes a Product Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_DELETE_PRODUCTITEM structure. hcmse must be Entry Access.

nav_open CM_GF_SET_BOXCONTROL sets the control flag of the CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_BOXCONTROL structure.

nav_open CM_GF_SET_FIRMKEY programs a Firm Key into an already programmed FSB entry in a CmDongle. pvCtrl is pointing to a 32 element byte array. hcmse must be Entry Access.

nav_open CM_GF_ADD_ENABLEBLOCK adds a new Enable Block Item to a Firm Item. The input parameters are stored in a hmtoggle_plus1 CMENABLING_WRITEADD structure. The return value of the function is the index of the created Enable Block Item in the Enable Block Table. If no Enable Block Item is created, then 0 is returned and an error code is set.

nav_open CM_GF_UPDATE_ENABLEBLOCK updates the content of an existing Enable Block Item. The input parameters are stored in a byte array (pointer to unsigned char). The return value for this flag is 1 (TRUE), if no error occurred, else 0 (FALSE).

nav_open CM_GF_DELETE_ENABLEBLOCK deletes an existing Enable Block Item in a Firm Item. The input parameters are stored in a hmtoggle_plus1 CMENABLING_WRITEDELETE structure. The return value for this flag is 1 (TRUE), if no error occurred, else 0 (FALSE).

nav_open CM_GF_ATTACH_ENABLEBLOCK attaches an existing Enable Block Item to a Firm Item or Product Item. The input parameters are stored in a hmtoggle_plus1 CMENABLING_WRITEATTACHDETACH structure. The return value for this flag is 1 (TRUE), if if no error occurred, else 0 (FALSE).

nav_open CM_GF_DETACH_ENABLEBLOCK detaches an existing Enable Block Item from a Firm Item or Product Item. The input parameters are stored in a CMENABLING_WRITEATTACHDETACH structure. The return value for this flag is 1 (TRUE), if no error occurred, else 0 (FALSE).

nav_openCM_GF_ENABLEITEM enables the Enabling Block Item defined in hmtoggle_plus1 CMENABLING_CONTEXT

nav_open CM_GF_DISABLEITEM disables the Enabling Block Item defined in CMENABLING_CONTEXT.

nav_open CM_GF_TEMPENABLEITEM enables temporarily the Enabling Block Item defined in CMENABLING_CONTEXT.

nav_open CM_GF_SET_BOXPASSWORD2 passes the CmDongle password in (UTF-8 character set) to the CodeMeter Runtime Server. If the CmDongle Password is passed using this option, no dialog will be opened to ask the user for the personal CmDongle password. The specified passsword must be 0 terminated.

nav_open CM_GF_CHANGE_BOXPASSWORD changes the CmDongle Password (UTF-8 character set) in a CmDongle. The input parameters (old and new password) are stored in a hmtoggle_plus1 CMPROGRAM_BOXPASSWORD structure.

nav_open CM_GF_RESET_BOXPASSWORD resets the cached CmDongle Password.

Additional flags:

nav_open CM_PROG_DEFRAGMEM can be or'ed. This flag cleans up the memory of the CmDongle after the programming step has been performed.

nav_open CM_PROG_MASTERPASSWORD can be or'ed. This flag will use a master password to set the new box password.
Note that all hyphens of the master password must be removed and all letters must be set in lower case.

pvCtrl contains a structure depending on the flCtrl flag (see above).

cbCtrl contains the number of bytes of the pvCtrl byte buffer/structure.

pvVerify contains a byte buffer receiving the verification sequence for the programmer. Except of the CM_GF_DELETE_FIRMITEM command this is a signed list command of the added/updated/deleted Firm Item (Signed List of the whole Firm Item). CM_GF_DELETE_FIRMITEM handles the creation of a verification sequence in the CmDongle internally. A hmtoggle_plus1 CMVALIDATE_DELETEFI structure must be passed here. If the parameter is NULL (==>> cbVerify = 0), no verification sequence is returned. If the buffer is to small for the verification sequence, the return value is larger than the cbVerify value and the error code CMERROR_BUFFER_OVERFLOW is set.

cbVerify contains the number of bytes of the byte buffer/structure stored in pvVerify.

Return

If the programming task is executed successfully and if pvVerify is NULL, then TRUE is returned, else FALSE is returned.

The following flags (and the corresponding functionality) are only available since CodeMeter Version 4.30:

•CM_GF_ENABLEITEM

•CM_GF_DISABLEITEM

•CM_GF_TEMPENABLEITEM

Syntax

This method is overloaded, i.e. the same method name is used with different type of parameters or different set of parameters.

Method 1:

public bool CmProgram(HCMSysEntry hcmse, GlobalProgrammingOption Option, byte[] Ctrl)

This method overload returns true or false.

Method 2:

public bool CmProgram(HCMSysEntry hcmse, GlobalProgrammingOption Option, byte[] Ctrl, out byte[] Verify)

This method overload returns true or false

Parameter

hcmse contains a handle opened by CmAccess / CmAccess2. The Access Mode must be Entry Access to a FSB Entry for a regular license. The handle is related to a CmLocal or a CmLAN subsystem with a connected Firm Security Box (FSB). If the license is an evaluation license not needing any security mechanisms like a FSB, the access can be Box Access. To update the IFI of a local CmDongle the access can also be Box Access. The access can be performed to the CmDongle to be programmed or updated. A matching entry in the CmLicensor/CmFirm.wbc file has to exist in both cases.

Option contains one of the following commands:

nav_open AddFirmItem calculates the sequence for adding a Firm Item into a CmDongle. Ctrl is pointing to a hmtoggle_plus1 CmProgramAddFirmItem class.

nav_open UpdateFirmItem calculates the sequence for updating a Firm Item in a CmDongle. Ctrl is pointing to a hmtoggle_plus1 CmProgramUpdateFirmItem class.

nav_open DeleteFirmItem calculates the sequence for deleting a Firm Item from a CmDongle. Ctrl is pointing to a hmtoggle_plus1 CmProgramDeleteFirmItem class.

nav_open AddProductItem calculates the sequence for adding a Product Item into a CmDongle. Ctrl is pointing to a hmtoggle_plus1 CmProgramAddProductItem class.

nav_open UpdateProductItem calculates the sequence for updating a Product Item in a CmDongle. Ctrl is pointing to a hmtoggle_plus1 CmProgramUpdateProductItem class.

nav_open DeleteProductItem calculates the sequence for deleting a Product Item in a CmDongle. Ctrl is pointing to a hmtoggle_plus1 CmProgramDeleteProductItem class.

nav_open SetBoxControl calculates the sequence for locking or unlocking a complete CmDongle. Ctrl is pointing to a hmtoggle_plus1 CmProgramBoxControl class.

nav_open SetFirmKey programs a Firm Key into an already programmed FSB entry in a CmDongle. Ctrl is a 32 element byte array. hcmse must be Entry Access.

nav_open SetUserKey tba.

nav_open AddEnableBlock calculates the sequence for adding a new Enable Block Item to a Firm Item. Ctrl is a hmtoggle_plus1 CmEnablingWriteAdd class.

nav_open UpdateEnableBlock calculates the sequence for updating an existing Enable Block Item in a Firm Item. Ctrl is a hmtoggle_plus1 CmEnablingWriteUpdate class.

nav_open DeleteEnableBlock calculates the sequence for deleting an existing Enable Block Item from a Firm Item. Ctrl is a hmtoggle_plus1 CmEnablingWriteDelete class.

nav_open AttachEnableBlock calculates the sequence for attaching an existing Enable Block Item in a Firm Item. Ctrl is a hmtoggle_plus1 CmEnablingWriteAttachDetach class.

nav_open DetachEnableBlock calculates the sequence for detaching an existing Enable Block Item in a Firm Item. Ctrl is a CmEnablingWriteAttachDetach class.

nav_open EnableItem enables the Enabling Block Item defined in the hmtoggle_plus1 CmEnablingContext class.

nav_open DisableItem disables the Enabling Block Item defined in the CmEnablingContext class.

nav_open TempEnableItem enables temporarily the Enabling Block Item defined in the CmEnablingContext class.

nav_open SetBoxPassword this option is obsolete; use ChangeBoxPassword instead.

nav_open ChangeBoxPassword CmProgramBoxPassword changes the CmDongle Password (UTF-8 character set) in a CmDongle. The input parameters (old and new password) are stored in a CmProgramBoxPassword class. The specified passsword must be 0 terminated.

nav_open ResetBoxPassword this option is obsolete; do not use further (resets the cached CmDongle Password).

nav_open UpdateCheckoutBorrow

nav_open SetBoxPassword2 passes the CmDongle password in (UTF-8 character set) to the CodeMeter Runtime Server. If the CmDongle Password is passed using this option, no dialog will be opened to ask the user for the personal CmDongle password. The specified passsword must be 0 terminated.

ctrl contains a structure depending on the Ctrl flag (see above). The following global flage of the enum CmProgramOption are used:

nav_open DefragMemory which cleans up the memory of the CmDongle after the programming step has been performed.

nav_open MasterPassword which will use a master password to set the new box password.

Verify contains a byte [] receiving the verification sequence for the programmer. Except of the DeleteFirmItem command this is a signed list command of the added/updated/deleted Firm Item (Signed List of the whole Firm Item). DeleteFirmItem handles the creation of a verification sequence in the CmDongle internally.

Return

If the programming task is executed successfully, then true is returned, else false is returned.

The following flags (and the corresponding functionality) are only available since CodeMeter Version 4.30:

•EnableItem

•DisableItem

•TempEnableItem

 

 

Currently not yet documented.