Skip to content

Commit

Permalink
Feat: Add the processing of import table
Browse files Browse the repository at this point in the history
  • Loading branch information
czs108 committed Feb 6, 2024
1 parent ea1f418 commit fb808fc
Show file tree
Hide file tree
Showing 3 changed files with 446 additions and 0 deletions.
59 changes: 59 additions & 0 deletions include/import_table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @file import_table.h
* @brief Transform the import table.
*
* @author Chen Zhenshuo (chenzs108@outlook.com)
* @version 1.0
* @date 2020-01-10
*
* @par GitHub
* https://github.com/czs108/
*/

#pragma once

#include "image.h"

#include <windows.h>

#include <stdbool.h>

/**
* @brief Calculate the size required for the import table of the new format.
*
* @public @memberof _PE_IMAGE_INFO
*
* @param image_info The PE image.
* @return The required size.
*/
DWORD CalcNewImpTableSize(
const PE_IMAGE_INFO *const image_info);


/**
* @brief Transform the import table into the new format.
*
* @public @memberof _PE_IMAGE_INFO
*
* @param image_info The PE image.
* @param new_table
* The space where the new table will be constructed,
* and its size must be larger than the value returned by `CalcNewImpTableSize()` method.
* Set this to `NULL` to get the required size.
*
* @return The required size for the new import table.
*/
DWORD TransformImpTable(
const PE_IMAGE_INFO *const image_info,
BYTE *const new_table);


/**
* @brief Clear the original import table.
*
* @public @memberof _PE_IMAGE_INFO
*
* @param image_info The PE image.
*/
void ClearImpTable(
const PE_IMAGE_INFO *const image_info);
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ target_sources(PE-Packer

${CMAKE_CURRENT_LIST_DIR}/image.c
${HEADER_PATH}/image.h

${CMAKE_CURRENT_LIST_DIR}/import_table.c
${HEADER_PATH}/import_table.h
)

target_link_libraries(PE-Packer utility)
Loading

0 comments on commit fb808fc

Please sign in to comment.