document Packer::handleStub

This commit is contained in:
gogo 2024-12-13 03:28:07 +01:00 committed by Joe
parent 0ce21ff3d4
commit 80805eb0f2
3 changed files with 30 additions and 50 deletions

View File

@ -230,6 +230,26 @@ protected:
virtual void defineFilterSymbols(const Filter *ft);
// stub and overlay util
/**
* \brief Copy stub from exe.
*
* \param :
*
* \arg InputFile *fif \n
* Source file where `OutputFile *fo` will be copied.
*
* \arg OutputFile *fo \n
* Destination file oubject file where `OutputFile *fo` will be copied.
*
* \arg unsigned size \n
* Size of the destination stub. Should be same as `InputFile *fif`.
*
* \todo ensure if there is not a more posix friendly method to store the destination stub size for cpp. Might be better with str.length(). Might avoid memory corruption.
*
* \return void.
**/
static void handleStub(InputFile *fi, OutputFile *fo, unsigned size);
virtual void checkOverlay(unsigned overlay);
virtual void copyOverlay(OutputFile *fo, unsigned overlay, MemBuffer &buf, bool do_seek = true);

View File

@ -2281,45 +2281,6 @@ void PeFile::callProcessResources(Resource &res, unsigned &ic) {
ic += soresources;
}
/**
* @brief create UPX0 section
*
* @name pack0
*
* Reduct the file size.
*
* @param fo
* The OutputFile class to the path where the new file will be created.
*
* @param ih
* Input PE header.
*
* Native windows data structure required by the os to be understood and to make a valid executable. The documentation of this data type is present there: https://www.vergiliusproject.com/kernels/x64/windows-11/23h2/_IMAGE_FILE_HEADER and described there: https://wiki.osdev.org/PE#PE_header .
*
* @param oh
* Output PE header.
*
* Native windows data structure required by the os to be understood and to make a valid executable. The documentation of this data type is present there: https://www.vergiliusproject.com/kernels/x64/windows-11/23h2/_IMAGE_FILE_HEADER and described there: https://wiki.osdev.org/PE#PE_header .
*
* @param subsystem_mask
* Permission mask for UPX0, UPX1, etc... sections.
*
* Number between 0 and 255 to indicate the section permissions of the section UPX0, UPX1, etc...
*
* @param default_imagebase
* Base address of the image base of the process.
*
* Very first start of where is stored the data and the code run by the OS.
*
* @param last_section_rsrc_only
* This is true when the last PE section of the compressed file must only contain resources and must be called "rsrc"
*
* @return void, in any circonstance.
*
* @remarks None.
*
*/
template <typename LEXX, typename ht> void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask, upx_uint64_t default_imagebase, bool last_section_rsrc_only) {
// FIXME: we need to think about better support for --exact
if (opt->exact)
@ -2978,8 +2939,7 @@ void PeFile::rebuildImports(SPAN_S(byte) & extra_info, ord_mask_t ord_mask, bool
// memset(imdata, 0, ptr_udiff_bytes(p, imdata));
}
template <typename ht, typename LEXX, typename ord_mask_t>
void PeFile::unpack0(OutputFile *fo, const ht &ih, ht &oh, ord_mask_t ord_mask, bool set_oft) {
template <typename ht, typename LEXX, typename ord_mask_t> void PeFile::unpack0(OutputFile *fo, const ht &ih, ht &oh, ord_mask_t ord_mask, bool set_oft) {
// infoHeader("[Processing %s, format %s, %d sections]", fn_basename(fi->getName()), getName(),
// objs);

View File

@ -63,30 +63,30 @@ protected:
/**
* \brief create UPX0 section
* \brief Create UPX0 section with compressed full executable.
*
* \param :
*
* \arg fo
* \arg fo \n
* The OutputFile class to the path where the new file will be created.
*
* \arg ih
* \arg ih \n
* Input PE header. \n \n
* Native windows data structure required by the os to be understood and to make a valid executable. The documentation of this data type is present there: https://www.vergiliusproject.com/kernels/x64/windows-11/23h2/_IMAGE_FILE_HEADER and described there: https://wiki.osdev.org/PE#PE_header.
*
* \arg oh
* \arg oh \n
* Output PE header. \n \n
* Native windows data structure required by the os to be understood and to make a valid executable. The documentation of this data type is present there: https://www.vergiliusproject.com/kernels/x64/windows-11/23h2/_IMAGE_FILE_HEADER and described there: https://wiki.osdev.org/PE#PE_header.
*
* \arg subsystem_mask
* Permission mask for UPX0, UPX1, etc... sections. \n \n
* Number between 0 and 255 to indicate the section permissions of the section UPX0, UPX1, etc...
* \arg subsystem_mask \n
* Permission mask for the section UPX0. \n \n
* Number between 0 and 255 to indicate the section permissions of the section UPX0.
*
* \arg default_imagebase
* \arg default_imagebase \n
* Base address of the image base of the process. \n \n
* Very first start of where is stored the data and the code run by the OS.
*
* \arg last_section_rsrc_only
* \arg last_section_rsrc_only \n
* This is true when the last PE section of the compressed file must only contain resources and must be called "rsrc"
*
* \return void, in any circonstance.