72{
73 char *pszSourceFile;
74 char *pszDestFile;
75 unsigned long nFileSize, nBaseAddress;
76 FILE *pSourceFile, *pDestFile;
82
84 {
86 return -1;
87 }
88
89 pszSourceFile =
argv[1];
90 pszDestFile =
argv[2];
92
93 pSourceFile =
fopen(pszSourceFile,
"rb");
94 if (!pSourceFile)
95 {
96 fprintf(
stderr,
"Couldn't open source file '%s'\n", pszSourceFile);
97 return -2;
98 }
99
100
102 nFileSize =
ftell(pSourceFile);
104
105
108 {
110 fprintf(
stderr,
"Failed to allocate %lu bytes\n", nFileSize);
111 return -3;
112 }
113
114
116 {
119 fprintf(
stderr,
"Failed to read %lu bytes from source file\n", nFileSize);
120 return -4;
121 }
122
123
125
126
127 pDestFile =
fopen(pszDestFile,
"wb");
128 if (!pDestFile)
129 {
131 fprintf(
stderr,
"Couldn't open destination file '%s'\n", pszDestFile);
132 return -5;
133 }
134
135
139
140
142 {
143
144 if ((
strcmp((
char*)pSectionHeader->
Name,
".text") == 0) &&
146 {
148 pSectionHeader,
149 pSymbols,
150 nBaseAddress))
151 {
154 return -7;
155 }
156
157
160 {
163 fprintf(
stderr,
"Failed to write %u bytes to destination file\n",
165 return -6;
166 }
167
169 }
170
171 pSectionHeader++;
172 }
173
176
177 return 0;
178}
int strcmp(const char *String1, const char *String2)
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
_CRTIMP void __cdecl rewind(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_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)
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
static int RelocateSection(char *pData, IMAGE_SECTION_HEADER *pSectionHeader, PIMAGE_SYMBOL pSymbols, unsigned int iOffset)
struct _IMAGE_SYMBOL UNALIGNED * PIMAGE_SYMBOL
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData