### User defined callback function

int CALLBACK CallbackProc(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2);

### Description

This function is called by UnRAR.dll library to process different UnRAR events listed below. You can specify the address of this function either in RAROpenArchiveEx (preferable) or in RARSetCallback (obsolete)

### Function parameters

The function will be passed four parameters:

- msg

  > Event type. Possible values:

  > - UCM_CHANGEVOLUME
  >   UCM_CHANGEVOLUMEW

  >   > Process volume change.

  >   > P1 points to the zero terminated name of the next volume.

  >   > P2 defines the function call mode.

  >   > RAR_VOL_ASK | Required volume is absent. The function should prompt user and return 1 to retry or return -1 value to terminate operation. The function may also set a new volume name, placing up to 1024 characters to the address specified by P1 parameter. Volume name uses single byte ANSI encoding for UCM_CHANGEVOLUME and Unicode for UCM_CHANGEVOLUMEW. If application provides a new volume name in UCM_CHANGEVOLUMEW, UCM_CHANGEVOLUME is not sent.
  >   > RAR_VOL_NOTIFY | Required volume is successfully opened. This is a notification call and volume name modification is not allowed. The function should return 1 to continue or -1 to terminate operation. Volume name uses single byte ANSI encoding for UCM_CHANGEVOLUME and Unicode for UCM_CHANGEVOLUMEW.

  > - UCM_PROCESSDATA

  >   > Process unpacked data. It can be used to read a file from memory, while it is being extracted or tested. If you use this event while testing a file, then it makes possible to read file data without extracting file to disk.

  >   > Return 1 to continue processing or -1 to cancel the archive operation.

  >   > P1 contains the address pointing to the unpacked data. Callback function can read the data but must not modify it.

  >   > P2 contains the size of the unpacked data. It is guaranteed that this size will not exceed the maximum dictionary size (4 MB in RAR 3.0).

  > - UCM_NEEDPASSWORD
  >   UCM_NEEDPASSWORDW

  >   > DLL needs a password to process an archive. This message must be processed if you wish to be able to handle encrypted archives.

  >   > Return 1 to continue process or -1 to cancel the archive operation.

  >   > P1 contains the address pointing to the buffer for a password in single byte encoding. You need to copy a password here. Password uses single byte ANSI encoding for UCM_NEEDPASSWORD and little endian Unicode for UCM_NEEDPASSWORDW. If application provides a password in UCM_NEEDPASSWORDW, UCM_NEEDPASSWORD is not sent.

  >   > P2 contains the size of password buffer in characters.

- UserData

  > User defined value passed to RARSetCallback. You can specify it, when defining the callback function in RAROpenArchiveEx or RARSetCallback

- P1
  P2

  > Event dependent parameters. Read msg description above for detailed information.

### Return values

In general returning -1 means canceling the operation and returning 1 continues processing. Please also read event descriptions above in case we'll add some exceptions from this rule. Return 0 for those event types which you do not process including unknown event types.

### Notes

> Other UnRAR.dll functions must not be called from the callback function.