77
88#include " Exe.h"
99
10- #include < stdio.h>
1110#include < memory.h>
11+ #include < stdio.h>
1212
1313// construct via Exe file
1414Exe::Exe (const char *x_szFilename)
@@ -38,11 +38,11 @@ Exe::Exe(const char *x_szFilename)
3838 goto cleanup;
3939 }
4040
41- if (m_DOSHeader.m_magic == *(uint16*)" MZ" )
41+ if (m_DOSHeader.m_magic == *(uint16 *)" MZ" )
4242 {
4343 printf (" Found, Ignoring..." );
4444
45- if (fread (&m_DOSHeader.m_cblp , sizeof (m_DOSHeader)- 2 , 1 , ExeFile) != 1 )
45+ if (fread (&m_DOSHeader.m_cblp , sizeof (m_DOSHeader) - 2 , 1 , ExeFile) != 1 )
4646 {
4747 SetError (" Unexpected read error while reading DOS stub" , true );
4848 goto cleanup;
@@ -68,7 +68,7 @@ Exe::Exe(const char *x_szFilename)
6868 goto cleanup;
6969 }
7070
71- if (m_Header.m_magic != *(uint32*)" PE\0\0 " )
71+ if (m_Header.m_magic != *(uint32 *)" PE\0\0 " )
7272 {
7373 SetError (" Invalid file (could not locate PE header)" , true );
7474 goto cleanup;
@@ -93,7 +93,7 @@ Exe::Exe(const char *x_szFilename)
9393 goto cleanup;
9494 }
9595
96- printf (" OK\n " );
96+ printf (" OK\n " );
9797 }
9898
9999 // read section headers
@@ -102,7 +102,7 @@ Exe::Exe(const char *x_szFilename)
102102
103103 printf (" Exe::Exe: Reading Section Headers...\n " );
104104
105- for (uint32 v= 0 ;v< m_Header.m_sections ;v++)
105+ for (uint32 v = 0 ; v < m_Header.m_sections ; v++)
106106 {
107107 printf (" Exe::Exe: Reading Section Header 0x%.04X..." , v);
108108
@@ -122,9 +122,9 @@ Exe::Exe(const char *x_szFilename)
122122 {
123123 printf (" Exe::Exe: Reading Sections...\n " );
124124
125- m_bzSection = new uint08*[m_Header.m_sections ];
125+ m_bzSection = new uint08 *[m_Header.m_sections ];
126126
127- for (uint32 v= 0 ;v< m_Header.m_sections ;v++)
127+ for (uint32 v = 0 ; v < m_Header.m_sections ; v++)
128128 {
129129 printf (" Exe::Exe: Reading Section 0x%.04X..." , v);
130130
@@ -181,15 +181,15 @@ Exe::Exe(const char *x_szFilename)
181181void Exe::ConstructorInit ()
182182{
183183 m_SectionHeader = NULL ;
184- m_bzSection = NULL ;
184+ m_bzSection = NULL ;
185185}
186186
187187// deconstructor
188188Exe::~Exe ()
189189{
190190 if (m_bzSection != 0 )
191191 {
192- for (uint32 v= 0 ;v< m_Header.m_sections ;v++)
192+ for (uint32 v = 0 ; v < m_Header.m_sections ; v++)
193193 delete[] m_bzSection[v];
194194
195195 delete[] m_bzSection;
@@ -260,14 +260,15 @@ void Exe::Export(const char *x_szExeFilename)
260260 {
261261 printf (" Exe::Export: Writing Section Headers...\n " );
262262
263- for (uint32 v= 0 ;v< m_Header.m_sections ;v++)
263+ for (uint32 v = 0 ; v < m_Header.m_sections ; v++)
264264 {
265265 printf (" Exe::Export: Writing Section Header 0x%.04X..." , v);
266266
267267 if (fwrite (&m_SectionHeader[v], sizeof (SectionHeader), 1 , ExeFile) != 1 )
268268 {
269269 char buffer[255 ];
270- snprintf (buffer, sizeof (buffer), " Could not write PE section header %d (%Xh)" , v, v);
270+ snprintf (
271+ buffer, sizeof (buffer), " Could not write PE section header %d (%Xh)" , v, v);
271272 SetError (buffer, false );
272273 goto cleanup;
273274 }
@@ -280,7 +281,7 @@ void Exe::Export(const char *x_szExeFilename)
280281 {
281282 printf (" Exe::Export: Writing Sections...\n " );
282283
283- for (uint32 v= 0 ;v< m_Header.m_sections ;v++)
284+ for (uint32 v = 0 ; v < m_Header.m_sections ; v++)
284285 {
285286 printf (" Exe::Export: Writing Section 0x%.04X..." , v);
286287
@@ -326,19 +327,20 @@ void Exe::Export(const char *x_szExeFilename)
326327 return ;
327328}
328329
329- const uint08 *Exe::ReadAddr (uint32 x_dwVirtualAddress) const {
330- return const_cast <Exe*>(this )->GetAddr (x_dwVirtualAddress);
330+ const uint08 *Exe::ReadAddr (uint32 x_dwVirtualAddress) const
331+ {
332+ return const_cast <Exe *>(this )->GetAddr (x_dwVirtualAddress);
331333}
332334
333335// return a modifiable pointer inside this structure that corresponds to a virtual address
334336uint08 *Exe::GetAddr (uint32 x_dwVirtualAddress)
335337{
336- for (uint32 v= 0 ;v< m_Header.m_sections ;v++)
338+ for (uint32 v = 0 ; v < m_Header.m_sections ; v++)
337339 {
338340 uint32 virt_addr = m_SectionHeader[v].m_virtual_addr ;
339341 uint32 virt_size = m_SectionHeader[v].m_virtual_size ;
340342
341- if ( (x_dwVirtualAddress >= virt_addr) && (x_dwVirtualAddress < (virt_addr + virt_size)) )
343+ if ((x_dwVirtualAddress >= virt_addr) && (x_dwVirtualAddress < (virt_addr + virt_size)))
342344 return &m_bzSection[v][x_dwVirtualAddress - virt_addr];
343345 }
344346
0 commit comments