-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add the processing of extra data
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* @file extra_data.h | ||
* @brief Process the extra data behind the PE image. | ||
* @author Chen Zhenshuo (chenzs108@outlook.com) | ||
* @version 1.0 | ||
* @date 2020-01-12 | ||
* | ||
* @par GitHub | ||
* https://github.com/czs108/ | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <windows.h> | ||
|
||
#include <stdbool.h> | ||
|
||
/** | ||
* @brief The view of the extra data. | ||
* | ||
* @see `LoadPeImage()` | ||
*/ | ||
typedef struct _EXTRA_DATA_VIEW | ||
{ | ||
//! The base address of the data. | ||
const BYTE* base; | ||
|
||
//! The size of the data. | ||
DWORD size; | ||
|
||
} EXTRA_DATA_VIEW; | ||
|
||
|
||
/** | ||
* @brief Write the extra data to the file. | ||
* | ||
* @public @memberof _EXTRA_DATA_VIEW | ||
* | ||
* @param data The extra data. | ||
* @param file The file. | ||
* @return `true` if the method succeeds, otherwise `false`. | ||
*/ | ||
bool WriteExtraDataToFile( | ||
const EXTRA_DATA_VIEW *const data, | ||
const HANDLE file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @file extra_data.c | ||
* @brief Process the extra data behind the PE image. | ||
* @author Chen Zhenshuo (chenzs108@outlook.com) | ||
* @version 1.0 | ||
* @date 2020-01-12 | ||
* | ||
* @par GitHub | ||
* https://github.com/czs108/ | ||
*/ | ||
|
||
#include "extra_data.h" | ||
#include "utility/file_access.h" | ||
|
||
#include <assert.h> | ||
|
||
bool WriteExtraDataToFile( | ||
const EXTRA_DATA_VIEW *const data, | ||
const HANDLE file) | ||
{ | ||
assert(data != NULL); | ||
assert(file != INVALID_HANDLE_VALUE); | ||
|
||
if (data->size > 0) | ||
{ | ||
assert(data->base != NULL); | ||
|
||
return WriteAllToFile(file, data->base, data->size); | ||
} | ||
else | ||
{ | ||
return true; | ||
} | ||
} |