22#include "../../dll/win32/dbghelp/compat.h"
72 for (
n = 0;
n <
len;
n += 2)
86 PDWORD name_ptr, function_ptr;
93 error(
"No export directory\n");
98 if (export_directory ==
NULL)
100 error(
"Invalid rva for export directory\n");
114 DWORD load_config_rva = function_ptr[ordinal_ptr[
n]];
121 load_config_dir->
Size = *load_config_ptr;
127 error(
"Export '_load_config_used' not found\n");
145 if (
strncmp((
char*)Section->
Name,
".rsrc", 5) == 0)
166 if ((
strncmp((
char*)Section->
Name,
"PAGE", 4) == 0)
167 || (
strncmp((
char*)Section->
Name,
".rsrc", 5) == 0)
168 || (
strncmp((
char*)Section->
Name,
".edata", 6) == 0)
169 || (
strncmp((
char*)Section->
Name,
".reloc", 6) == 0))
188 char *sectionName, *newSectionName;
189 char *attribsSpec, *alignSpec;
195 if (!section_attribs || !*section_attribs)
197 error(
"Section attributes specification is empty.\n");
201 sectionName = section_attribs;
204 newSectionName =
strchr(section_attribs,
'=');
205 attribsSpec =
strchr(section_attribs,
',');
206 if (newSectionName && attribsSpec)
209 if (!(newSectionName < attribsSpec))
211 error(
"Invalid section attributes specification.\n");
216 *newSectionName++ = 0;
223 error(
"Invalid section attributes specification.\n");
227 if (newSectionName && !*newSectionName)
229 error(
"Invalid section attributes specification.\n");
251 if (alignSpec && *alignSpec)
254 "Section alignment specification not currently supported! Ignoring.\n");
258 dwAttribs[0] = dwAttribs[1] = 0;
259 if (attribsSpec && *attribsSpec)
311 error(
"Invalid section attributes specification.\n");
321 error(
"Invalid section attributes specification.\n");
334 Section = &SectionTable[
i];
336 if (newSectionName && *newSectionName)
351 error(
"Section '%s' does not exist.\n", sectionName);
363 printf(
"<options> can be one of the following options:\n"
364 " --loadconfig Fix the LOAD_CONFIG directory entry;\n"
365 " --kernelmodedriver Fix code, data and resource sections for driver images;\n"
366 " --wdmdriver Fix code, data and resource sections for WDM drivers;\n"
367 " --kerneldll Fix code, data and resource sections for Kernel-Mode DLLs;\n"
368 " --kernel Fix code, data and resource sections for kernels;\n"
370 "and/or a combination of the following ones:\n"
371 " --section:name[=newname][,[[!]{CDEIKOMPRSUW}][A{1248PTSX}]]\n"
372 " Overrides the attributes of a section, optionally\n"
373 " changing its name and its alignment.\n");
392 if (!(
argv[
i][0] ==
'-' &&
argv[
i][1] ==
'-'))
405 else if (
strcmp(&
argv[
i][2],
"kernelmodedriver") == 0)
445 if ((
i <= 1) || (
i >=
argc))
466 error(
"Image size too small to be a PE image\n");
476 error(
"Not enough memory available (Needed %lu bytes).\n",
len + 1);
514 if (!(
argv[
i][0] ==
'-' &&
argv[
i][1] ==
'-'))
int strcmp(const char *String1, const char *String2)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
char * strchr(const char *String, int ch)
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
#define IMAGE_DIRECTORY_ENTRY_EXPORT
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
static IMAGE_DOS_HEADER dos_header
static export_section_t export_dir
static IMAGE_NT_HEADERS32 nt_header
#define IMAGE_SCN_MEM_NOT_CACHED
#define IMAGE_SCN_MEM_WRITE
#define IMAGE_SCN_MEM_NOT_PAGED
#define IMAGE_SCN_CNT_INITIALIZED_DATA
#define IMAGE_SCN_CNT_CODE
#define IMAGE_SCN_MEM_EXECUTE
#define IMAGE_FIRST_SECTION(NtHeader)
#define IMAGE_SCN_MEM_DISCARDABLE
#define IMAGE_SCN_MEM_READ
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA
#define IMAGE_SCN_MEM_SHARED
#define IMAGE_SCN_LNK_INFO
#define IMAGE_SCN_LNK_REMOVE
#define IMAGE_NT_SIGNATURE
#define IMAGE_DOS_SIGNATURE
static int change_section_attribs(char *section_attribs, unsigned char *buffer, PIMAGE_NT_HEADERS nt_header)
static void print_usage(void)
static int add_loadconfig(unsigned char *buffer, PIMAGE_NT_HEADERS nt_header)
void * rva_to_ptr(unsigned char *buffer, PIMAGE_NT_HEADERS nt_header, DWORD rva)
static const char * g_Target
static int driver_fixup(enum fixup_mode mode, unsigned char *buffer, PIMAGE_NT_HEADERS nt_header)
static const char * g_ApplicationName
static void fix_checksum(unsigned char *buffer, size_t len, PIMAGE_NT_HEADERS nt_header)
DWORD AddressOfNameOrdinals
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress