AutoHotkey Community

It is currently May 26th, 2012, 10:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: April 4th, 2008, 6:58 am 
Offline

Joined: July 14th, 2006, 12:31 am
Posts: 290
Location: Berlin
great information, i'm going to test it later and post the result.

so this should be done in front of every
RegisterCallback() or only in front of the first time i use RegisterCallback() in a thread?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2008, 12:29 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Quote:
so this should be done in front of every RegisterCallback()
Each (and every) callback may potentially be in a different page of memory, so VirtualProtect should be called for each (and every) callback. "Address" in the code I posted refers to the return value of RegisterCallback, which is also the address of a callback structure. Its first 22 bytes are machine code.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2008, 1:39 pm 
Offline

Joined: July 14th, 2006, 12:31 am
Posts: 290
Location: Berlin
so this means everytime the callback function is called, this dllcall should be executed, but in this case where to put it? if i want to call it before the callback function is called, it must be in the unrar.dll, isn't it?

or am i wrong oO if yes where to put you posted call for example in the unrar-script?
in front of DLLCall("unrar.dll\RARSetCallback","UInt",hArchive,"Uint",Address,"Uint",0)
or in front of ExResult:=DLLCall("unrar.dll\RARProcessFile","UInt",hArchive,"Uint",2,"Uint",0,"Uint",&File)
or somewhere else or at all these positions?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2008, 12:43 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
ladiko wrote:
so this means everytime the callback function is called, this dllcall should be executed, but in this case where to put it?
No, only once for each callback that is created, at some point after RegisterCallback, before it is called for the first time.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2008, 8:31 pm 
Offline

Joined: July 14th, 2006, 12:31 am
Posts: 290
Location: Berlin
you're a genius Lexikos, if i insert the following line, it works with enabled DEP:

Code:
...

If (ShowProg){
   Address:=registercallback("RarCallback","",4,1)
   }
}
Else {
   Address:=registercallback("RarCallback","",4,0)
}
If (Address = ""){
      _ERROR_EXIT("%A_ScriptName% , Error extracting archive!`n`nReturned adress to machine-code function was empty.")
}
; to work with enabled DEP --> http://www.autohotkey.com/forum/viewtopic.php?t=25480
DllCall("VirtualProtect", "uint", Address, "uint", 8, "uint", 0x40, "uint*", 0)

DLLCall("unrar.dll\RARSetCallback","UInt",hArchive,"Uint",Address,"Uint",0)

...


thank you :-)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2008, 12:53 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
Thanks for the workaround :) . DEP seems to affect callbacks in AHK only when the DEP option specified is to "Turn on DEP for all programs and services except those I select" and when AHK has not been added to the exception list. Leaving the default option of "Turn on DEP for essential Windows programs and services only" does not seem to prevent callbacks in AHK. In other words, as soon as you are forced to make an exception for anything, you're pushed up the creek without a paddle... A "Turn DEP Off" option would be nice...
Lexikos wrote:
AutoHotkey uses GlobalAlloc to allocate memory for the callback. Presumably because Microsoft recommends against it, AutoHotkey doesn't change the memory protection to include PAGE_EXECUTE, so DEP will prevent callbacks from executing.

Try re-enabling DEP and using this for each callback:
Code:
; PAGE_EXECUTE_READWRITE = 0x40
DllCall("VirtualProtect", "uint", Address, "uint", 22, "uint", 0x40, "uint*", OldProtect)
This should change the protection of the page containing the callback (i.e. it will affect all memory blocks on that page, which is why Microsoft recommends against it.)

TBH, callbacks are rather useless if you can't call them. Perhaps it would be better if AutoHotkey did this, despite Microsoft's recommendation.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2008, 4:23 am 
Offline

Joined: June 14th, 2008, 7:47 pm
Posts: 56
Location: Sydney, Australia
Hi Superfraggle and everyone,

I've been learning from this a lot, I have hundreds of Rar file compressed with one of 3 different passwords or none. I would like some help to:

1) Pass a password parameter as:
pass1|pass2|passN
and a loopparse inside the function that tries them showing the input box only after the last one fails.

2) How can I tell when the extraction was completely successful?
I;ve notice that If (FileResult = 10) in line 138 does not mean that was OK???

Here is the funcion I slitly modify. NOt a big thing:
The style (so I can readit :oops: )
The input box
I declare global Password_Saved as the last password entered with success, which may not be necessary if a loop parse can be done. (still not working)
file is full path
If ExPath not exist the same rar folder will be use
If ExPath = propt you choose the folder.
Add if conditions to show progress on RarCallback function (avoid show an empty progress on errors)
Some comments (please correct me if Im wrong)

Bellow is a piece of how I use the function from my main script.
NOt working example, but the function should work!

Thanks!!!

Code:
      File := WE_CURRENT_SELECTED_ITEM_FULL_PATH_%A_Index%
      If A_ThisMenuItem = Extract &to...
         ExPath = Propt
      Else
         ExPath =                                    ;WILL USE THE ROOT DIR
      ExPaths = 1
      ShowProg = 1
      Password = %password1%|%password2%|%password3%         ;This is  how I want it to be
      
      ExtractFileResult := ExtractRAR(File,ExPath,ExPaths,ShowProg,Password)


   If ExtractFileResult <> FAIL
   If ExtractFileResult <>
   If A_ThisMenuItem = Extract Here && &Recycle
filedelete, %File%
Return


ExtractRAR(File,ExPath ="",ExPaths=1,ShowProg=1,Password="")
{
Global Prog,UnpackedFS,ExtractFileResult,Password_Saved
 
If Password =                                                ;Update If Blank
   Password := Password_Saved

If Password_Saved =                                             ;Update If Blank
   Password_Saved := Password
   
  IfNotExist, %File%                                       ;CHECK FILE EXIST
   {
    MsgBox , 262160, %A_ScriptName% ,`n`nPlease Set a Valid File to Extract.`n`nCureent Value: %File%`n`nPress OK to Close`n`n
   ExtractFileResult = FAIL
    Return ExtractFileResult
   }

   IfNotExist, %ExPath%
      {
      If ExPath = Propt
         FileSelectFolder, ExPath, %A_Desktop%, 3                                       ;SELECT PATH OR EXTACT ON SOURCE PARENT DIRR
      Else
         SplitPath, File, , ExPath
      
      ExPath := RegExReplace(ExPath, "\\$")                                               ; Removes the trailing backslash, if present.
      }
    
  IfNotExist, %ExPath%                                                               ;CHECK DIRR EXIST
   {
    MsgBox , 262160, %A_ScriptName%,`n`nPlease Select a Valid Directory to Extract.`n`nPress OK to Close`n`n
   ExtractFileResult = FAIL
    Return ExtractFileResult
   }
   
  Fname := File
  varsetcapacity(ArchiveData,32,0)
  Numput(&File,ArchiveData)
  Numput(1,ArchiveData,4)
 
  hModule := DllCall("LoadLibrary", "str", "unrar.dll")
  if (!hModule)
  {
    MsgBox , 262160 , %A_ScriptName% ,Could not Load Library
   ExtractFileResult = FAIL
   Goto, Sub_Return
  }
 
  hArchive:=DLLCall("unrar.dll\RAROpenArchive","Uint",&ArchiveData)            ;OPEN ARCHIVE
  Result:=Numget(&ArchiveData,8)
  If (Result = 11)
  {
    MsgBox , 262160 , %A_ScriptName% ,Not enough Memory
   ExtractFileResult = FAIL
   Goto, Sub_Return
  }
   If (Result = 12)
  {
    MsgBox , 262160 , %A_ScriptName% ,Archive Header Broken
   ExtractFileResult = FAIL
   Goto, Sub_Return
  }
   If (Result = 13)
  {
    MsgBox , 262160 , %A_ScriptName% ,Invalid Archive Type
   ExtractFileResult = FAIL
   Goto, Sub_Return
  }
   If (Result = 14)
  {
    MsgBox , 262160 , %A_ScriptName% ,Unknown encryption
   ExtractFileResult = FAIL
   Goto, Sub_Return
  }
   If (Result = 15)
  {
    MsgBox , 262160 , %A_ScriptName% ,Error Opening File
   ExtractFileResult = FAIL
   Goto, Sub_Return
  }
 
   If (ShowProg)
     {
       Address:=registercallback("RarCallback","",4,1)
       If (Address = "")
         {
            Msgbox , 262160 , %A_ScriptName% , Error extracting archive!`n`nReturned adress to machine-code function was empty.
      ExtractFileResult = FAIL
      Goto, Sub_Return
          }
      }
   Else
      {
       Address:=registercallback("RarCallback","",4,0)
       If (Address = "")
         {
          Msgbox , 262160 , %A_ScriptName% , Error extracting archive!`n`nReturned adress to machine-code function was empty.
         ExtractFileResult = FAIL
         Goto, Sub_Return
          }
      }

   
   
  DLLCall("unrar.dll\RARSetCallback","UInt",hArchive,"Uint",Address,"Uint",0)               ;READ ARCHIVE
  Varsetcapacity(ArchiveHeader,572,0)
  Loop
  {
    FileResult:=DLLCall("unrar.dll\RARReadHeader","UInt",hArchive,"Uint",&ArchiveHeader)
   
    If (FileResult = 12)
      {
      Progress, Off
       MsgBox, 262160, %A_ScriptName% ,File Header Currupt - Incorrect Password????
      ExtractFileResult = FAIL
      Goto, Sub_Return
       }
   
   If (FileResult = 10)                                                      ;FNISH READING
      {
      ExtractFileResult = OK                  ;NOT SURE HOW TO TELL OK OR FAIL
      Goto, Sub_Return
       }
   
    Varsetcapacity(CurFile,260,0)
    DllCall("lstrcpynA", "Str", CurFile, "UInt", &ArchiveHeader+260,   "int", 260)
    UnpackedFS:=Numget(&ArchiveHeader,528)
   
    If (ShowProg)
   If A_Index > 1         ;DO NOT SHOW THE FIRST FILE IN CASE GIVES ERROR
      {
       Progress,R0-%UnpackedFS% M P0 Y600 w1100,%CurFile%,Source: %Fname%, Compressed File Extraction in Progress...         ;THIS PROGRESS TITLE MUST MACH THE ONE ON THE OTHER FUNCTION
       Prog:=0
       }
      
   Sleep, 300 / A_Index               ;Sleep more at the begining just in case is a one or just a few files to extract
      
    If (substr(ExPath,0,1) != "\")
      {
         Expath.="\"
       }
      
    If (ExPaths)
      {
       File:=ExPath . CurFile
       }
    Else
      {
       File:=ExPath . Regexreplace(CurFile,".*\\","")
      }
      
    ExResult:=DLLCall("unrar.dll\RARProcessFile","UInt",hArchive,"Uint",2,"Uint",0,"Uint",&File)
    If (ExResult != 0)
      {
      Progress,Off
       MsgBox , 262160 , %A_ScriptName% ,`nError Extracting Compressed File.

      ExtractFileResult = FAIL
      Goto, Sub_Return
       }
      
   Sleep 10         ;CPU
  }
 
  ;____________________________________________CLOSE PROGRESS, RELEASE FILE, CLOSE LIBRERY AND Return Result
  Sub_Return:
  Progress,Off
  DLLCall("unrar.dll\RARCloseArchive","Uint",hArchive)
  DllCall("FreeLibrary ", "UInt", hModule)
 
  Return ExtractFileResult
}


  ;___________________________________________________FUNCTION CALL BACK
  RarCallback(Message,User,P1,P2)
   {
   Global Prog,ShowProg,ExtractFileResult,Password,Password_Saved
    
   If Message = 2
      {
      InputBox, Password, Please enter Compresed Rar File Password, Please enter Compresed File Password, , 550, 130, , , , , %Password%
      If ErrorLevel <> 0         ;CANCEL OR TIME OUT
         {
         ExtractFileResult = FAIL
         Progress,Off
         DLLCall("unrar.dll\RARCloseArchive","Uint",hArchive)
         DllCall("FreeLibrary ", "UInt", hModule)
         Return ExtractFileResult
         }
      
      DllCall("lstrcpynA","Uint",P1+0, "STR",Password,"int", P2)
      }
      
   If Message = 1
   If a_eventinfo = 1
   If ShowProg = 1                                                                     ;SOME HOW REDUNDANT
   IfWinExist, Compressed File Extraction in Progress... ahk_class AutoHotkey2                        ;PROGRESS BAR MUST EXIST, THIS PROGRESS TITLE MUST MACH THE ONE ON THE OTHER FUNCTION
      {
      Prog+=P2
      Progress,%Prog%
      }
       
   return,1
   }




_________________
Thanks, Yogui.
_____________________________


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2008, 10:54 am 
Offline

Joined: November 11th, 2005, 3:13 am
Posts: 202
in case of existing extracted files how to add in 'prompt before overwrite' function?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2008, 12:09 pm 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
These are the instructions for the DLL, I am unable to see anywhere it reports on existing files, although I may of just missed it.

Code:
    UnRAR.dll Manual
    ~~~~~~~~~~~~~~~~

    UnRAR.dll is a 32-bit Windows dynamic-link library which provides
 file extraction from RAR archives.


    Exported functions

====================================================================
HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData)
====================================================================

Description
~~~~~~~~~~~
  Open RAR archive and allocate memory structures

Parameters
~~~~~~~~~~
ArchiveData       Points to RAROpenArchiveData structure

struct RAROpenArchiveData
{
  char *ArcName; 0
  UINT OpenMode; 2
  UINT OpenResult; 6
  char *CmtBuf;
  UINT CmtBufSize;
  UINT CmtSize;
  UINT CmtState;
};

Structure fields:

ArcName
  Input parameter which should point to zero terminated string
  containing the archive name.

OpenMode
  Input parameter.

  Possible values

  RAR_OM_LIST           Open archive for reading file headers only
  RAR_OM_EXTRACT        Open archive for testing and extracting files

OpenResult
  Output parameter.

  Possible values

  0                     Success
  ERAR_NO_MEMORY        Not enough memory to initialize data structures
  ERAR_BAD_DATA         Archive header broken
  ERAR_BAD_ARCHIVE      File is not valid RAR archive
  ERAR_UNKNOWN_FORMAT   Unknown encryption used for archive headers
  ERAR_EOPEN            File open error

CmtBuf
  Input parameter which should point to the buffer for archive
  comments. Maximum comment size is limited to 64Kb. Comment text is
  zero terminated. If the comment text is larger than the buffer
  size, the comment text will be truncated. If CmtBuf is set to
  NULL, comments will not be read.

CmtBufSize
  Input parameter which should contain size of buffer for archive
  comments.

CmtSize
  Output parameter containing size of comments actually read into the
  buffer, cannot exceed CmtBufSize.

CmtState
  Output parameter.

  Possible values

  0                     comments not present
  1                     Comments read completely
  ERAR_NO_MEMORY        Not enough memory to extract comments
  ERAR_BAD_DATA         Broken comment
  ERAR_UNKNOWN_FORMAT   Unknown comment format
  ERAR_SMALL_BUF        Buffer too small, comments not completely read

Return values
~~~~~~~~~~~~~
  Archive handle or NULL in case of error


========================================================================
HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData)
========================================================================

Description
~~~~~~~~~~~
  Similar to RAROpenArchive, but uses RAROpenArchiveDataEx structure
  allowing to specify Unicode archive name and returning information
  about archive flags.

Parameters
~~~~~~~~~~
ArchiveData       Points to RAROpenArchiveDataEx structure

struct RAROpenArchiveDataEx
{
  char         *ArcName;
  wchar_t      *ArcNameW;
  unsigned int OpenMode;
  unsigned int OpenResult;
  char         *CmtBuf;
  unsigned int CmtBufSize;
  unsigned int CmtSize;
  unsigned int CmtState;
  unsigned int Flags;
  unsigned int Reserved[32];
};

Structure fields:

ArcNameW
  Input parameter which should point to zero terminated Unicode string
  containing the archive name or NULL if Unicode name is not specified.

Flags
  Output parameter. Combination of bit flags.

  Possible values

    0x0001  - Volume attribute (archive volume)
    0x0002  - Archive comment present
    0x0004  - Archive lock attribute
    0x0008  - Solid attribute (solid archive)
    0x0010  - New volume naming scheme ('volname.partN.rar')
    0x0020  - Authenticity information present
    0x0040  - Recovery record present
    0x0080  - Block headers are encrypted
    0x0100  - First volume (set only by RAR 3.0 and later)

Reserved[32]
  Reserved for future use. Must be zero.

Information on other structure fields and function return values
is available above, in RAROpenArchive function description.


====================================================================
int PASCAL RARCloseArchive(HANDLE hArcData)
====================================================================

Description
~~~~~~~~~~~
  Close RAR archive and release allocated memory. It must be called when
  archive processing is finished, even if the archive processing was stopped
  due to an error.

Parameters
~~~~~~~~~~
hArcData
  This parameter should contain the archive handle obtained from the
  RAROpenArchive function call.

Return values
~~~~~~~~~~~~~
  0                     Success
  ERAR_ECLOSE           Archive close error


====================================================================
int PASCAL RARReadHeader(HANDLE hArcData,
                         struct RARHeaderData *HeaderData)
====================================================================

Description
~~~~~~~~~~~
  Read header of file in archive.

Parameters
~~~~~~~~~~
hArcData
  This parameter should contain the archive handle obtained from the
  RAROpenArchive function call.

HeaderData
  It should point to RARHeaderData structure:

struct RARHeaderData
{
  char ArcName[260];0
  char FileName[260];260
  UINT Flags;520
  UINT PackSize;524
  UINT UnpSize;528
  UINT HostOS;532
  UINT FileCRC;536
  UINT FileTime;540
  UINT UnpVer;544
  UINT Method;548
  UINT FileAttr;552
  char *CmtBuf;
  UINT CmtBufSize;
  UINT CmtSize;
  UINT CmtState;
};

Structure fields:

ArcName
  Output parameter which contains a zero terminated string of the
  current archive name.  May be used to determine the current volume
  name.

FileName
  Output parameter which contains a zero terminated string of the
  file name in OEM (DOS) encoding.

Flags
  Output parameter which contains file flags:

  0x01 - file continued from previous volume
  0x02 - file continued on next volume
  0x04 - file encrypted with password
  0x08 - file comment present
  0x10 - compression of previous files is used (solid flag)

  bits 7 6 5

       0 0 0    - dictionary size   64 Kb
       0 0 1    - dictionary size  128 Kb
       0 1 0    - dictionary size  256 Kb
       0 1 1    - dictionary size  512 Kb
       1 0 0    - dictionary size 1024 Kb
       1 0 1    - dictionary size 2048 KB
       1 1 0    - dictionary size 4096 KB
       1 1 1    - file is directory

  Other bits are reserved.

PackSize
  Output parameter means packed file size or size of the
  file part if file was split between volumes.

UnpSize
  Output parameter - unpacked file size.

HostOS
  Output parameter - operating system used for archiving:

  0 - MS DOS;
  1 - OS/2.
  2 - Win32
  3 - Unix

FileCRC
  Output parameter which contains unpacked file CRC. It should not be
  used for file parts which were split between volumes.

FileTime
  Output parameter - contains date and time in standard MS DOS format.

UnpVer
  Output parameter - RAR version needed to extract file.
  It is encoded as 10 * Major version + minor version.

Method
  Output parameter - packing method.

FileAttr
  Output parameter - file attributes.

CmtBuf
  File comments support is not implemented in the new DLL version yet.
  Now CmtState is always 0.

/*
 * Input parameter which should point to the buffer for file
 * comments. Maximum comment size is limited to 64Kb. Comment text is
 * a zero terminated string in OEM encoding. If the comment text is
 * larger than the buffer size, the comment text will be truncated.
 * If CmtBuf is set to NULL, comments will not be read.
 */

CmtBufSize
  Input parameter which should contain size of buffer for archive
  comments.

CmtSize
  Output parameter containing size of comments actually read into the
  buffer, should not exceed CmtBufSize.

CmtState
  Output parameter.

  Possible values

  0                     Absent comments
  1                     Comments read completely
  ERAR_NO_MEMORY        Not enough memory to extract comments
  ERAR_BAD_DATA         Broken comment
  ERAR_UNKNOWN_FORMAT   Unknown comment format
  ERAR_SMALL_BUF        Buffer too small, comments not completely read

Return values
~~~~~~~~~~~~~

  0                     Success
  ERAR_END_ARCHIVE      End of archive
  ERAR_BAD_DATA         File header broken


====================================================================
int PASCAL RARReadHeaderEx(HANDLE hArcData,
                           struct RARHeaderDataEx *HeaderData)
====================================================================

Description
~~~~~~~~~~~
  Similar to RARReadHeader, but uses RARHeaderDataEx structure,
containing information about Unicode file names and 64 bit file sizes.

struct RARHeaderDataEx
{
  char         ArcName[1024];
  wchar_t      ArcNameW[1024];
  char         FileName[1024];
  wchar_t      FileNameW[1024];
  unsigned int Flags;
  unsigned int PackSize;
  unsigned int PackSizeHigh;
  unsigned int UnpSize;
  unsigned int UnpSizeHigh;
  unsigned int HostOS;
  unsigned int FileCRC;
  unsigned int FileTime;
  unsigned int UnpVer;
  unsigned int Method;
  unsigned int FileAttr;
  char         *CmtBuf;
  unsigned int CmtBufSize;
  unsigned int CmtSize;
  unsigned int CmtState;
  unsigned int Reserved[1024];
};


====================================================================
int PASCAL RARProcessFile(HANDLE hArcData,
                          int Operation,
                          char *DestPath,
                          char *DestName)
====================================================================

Description
~~~~~~~~~~~
  Performs action and moves the current position in the archive to
  the next file. Extract or test the current file from the archive
  opened in RAR_OM_EXTRACT mode. If the mode RAR_OM_LIST is set,
  then a call to this function will simply skip the archive position
  to the next file.

Parameters
~~~~~~~~~~
hArcData
  This parameter should contain the archive handle obtained from the
  RAROpenArchive function call.

Operation
  File operation.

  Possible values

  RAR_SKIP              Move to the next file in the archive. If the
                        archive is solid and RAR_OM_EXTRACT mode was set
                        when the archive was opened, the current file will
                        be processed - the operation will be performed
                        slower than a simple seek.

  RAR_TEST              Test the current file and move to the next file in
                        the archive. If the archive was opened with
                        RAR_OM_LIST mode, the operation is equal to
                        RAR_SKIP.

  RAR_EXTRACT           Extract the current file and move to the next file.
                        If the archive was opened with RAR_OM_LIST mode,
                        the operation is equal to RAR_SKIP.


DestPath
  This parameter should point to a zero terminated string containing the
  destination directory to which to extract files to. If DestPath is equal
  to NULL, it means extract to the current directory. This parameter has
  meaning only if DestName is NULL.

DestName
  This parameter should point to a string containing the full path and name
  to assign to extracted file or it can be NULL to use the default name.
  If DestName is defined (not NULL), it overrides both the original file
  name saved in the archive and path specigied in DestPath setting.

  Both DestPath and DestName must be in OEM encoding. If necessary,
  use CharToOem to convert text to OEM before passing to this function.

Return values
~~~~~~~~~~~~~
  0                     Success
  ERAR_BAD_DATA         File CRC error
  ERAR_BAD_ARCHIVE      Volume is not valid RAR archive
  ERAR_UNKNOWN_FORMAT   Unknown archive format
  ERAR_EOPEN            Volume open error
  ERAR_ECREATE          File create error
  ERAR_ECLOSE           File close error
  ERAR_EREAD            Read error
  ERAR_EWRITE           Write error


Note: if you wish to cancel extraction, return -1 when processing
      UCM_PROCESSDATA callback message.


====================================================================
int PASCAL RARProcessFileW(HANDLE hArcData,
                           int Operation,
                           wchar_t *DestPath,
                           wchar_t *DestName)
====================================================================

Description
~~~~~~~~~~~
  Unicode version of RARProcessFile. It uses Unicode DestPath
  and DestName parameters, other parameters and return values
  are the same as in RARProcessFile.


====================================================================
void PASCAL RARSetCallback(HANDLE hArcData,
            int PASCAL (*CallbackProc)(UINT msg,LONG UserData,LONG P1,LONG P2),
            LONG UserData);
====================================================================

Description
~~~~~~~~~~~
  Set a user-defined callback function to process Unrar events.

Parameters
~~~~~~~~~~
hArcData
  This parameter should contain the archive handle obtained from the
  RAROpenArchive function call.

CallbackProc
  It should point to a user-defined callback function.

  The function will be passed four parameters:


  msg                    Type of event. Described below.

  UserData               User defined value passed to RARSetCallback.

  P1 and P2              Event dependent parameters. Described below.


  Possible events

    UCM_CHANGEVOLUME     Process volume change.

      P1                   Points to the zero terminated name
                           of the next volume.

      P2                   The function call mode:

        RAR_VOL_ASK          Required volume is absent. The function should
                             prompt user and return a positive value
                             to retry or return -1 value to terminate
                             operation. The function may also specify a new
                             volume name, placing it to the address specified
                             by P1 parameter.

        RAR_VOL_NOTIFY       Required volume is successfully opened.
                             This is a notification call and volume name
                             modification is not allowed. The function should
                             return a positive value to continue or -1
                             to terminate operation.

    UCM_PROCESSDATA          Process unpacked data. It may be used to read
                             a file while it is being extracted or tested
                             without actual extracting file to disk.
                             Return a positive value to continue process
                             or -1 to cancel the archive operation

      P1                   Address pointing to the unpacked data.
                           Function may refer to the data but must not
                           change it.

      P2                   Size of the unpacked data. It is guaranteed
                           only that the size will not exceed the maximum
                           dictionary size (4 Mb in RAR 3.0).

    UCM_NEEDPASSWORD         DLL needs a password to process archive.
                             This message must be processed if you wish
                             to be able to handle archives with encrypted
                             file names. It can be also used as replacement
                             of RARSetPassword function even for usual
                             encrypted files with non-encrypted names.

      P1                   Address pointing to the buffer for a password.
                           You need to copy a password here.

      P2                   Size of the password buffer.


UserData
  User data passed to callback function.

  Other functions of UnRAR.dll should not be called from the callback
  function.

Return values
~~~~~~~~~~~~~
  None



====================================================================
void PASCAL RARSetChangeVolProc(HANDLE hArcData,
            int PASCAL (*ChangeVolProc)(char *ArcName,int Mode));
====================================================================

Obsoleted, use RARSetCallback instead.



====================================================================
void PASCAL RARSetProcessDataProc(HANDLE hArcData,
            int PASCAL (*ProcessDataProc)(unsigned char *Addr,int Size))
====================================================================

Obsoleted, use RARSetCallback instead.


====================================================================
void PASCAL RARSetPassword(HANDLE hArcData,
                           char *Password);
====================================================================

Description
~~~~~~~~~~~
  Set a password to decrypt files.

Parameters
~~~~~~~~~~
hArcData
  This parameter should contain the archive handle obtained from the
  RAROpenArchive function call.

Password
  It should point to a string containing a zero terminated password.

Return values
~~~~~~~~~~~~~
  None


====================================================================
void PASCAL RARGetDllVersion();
====================================================================

Description
~~~~~~~~~~~
  Returns API version.

Parameters
~~~~~~~~~~
  None.

Return values
~~~~~~~~~~~~~
  Returns an integer value denoting UnRAR.dll API version, which is also
defined in unrar.h as RAR_DLL_VERSION. API version number is incremented
only in case of noticeable changes in UnRAR.dll API. Do not confuse it
with version of UnRAR.dll stored in DLL resources, which is incremented
with every DLL rebuild.

  If RARGetDllVersion() returns a value lower than UnRAR.dll which your
application was designed for, it may indicate that DLL version is too old
and it will fail to provide all necessary functions to your application.

  This function is absent in old versions of UnRAR.dll, so it is safer
to use LoadLibrary and GetProcAddress to access this function.


_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], sks, toddintr and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group