Skip to content

Commit

Permalink
reformat comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Jul 31, 2023
1 parent 351d07e commit 7bff9e2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 39 deletions.
65 changes: 39 additions & 26 deletions bld/rc/rc/c/exeobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ static RcStatus readObjectTable( ExeFileInfo *src )
}

static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst )
/***************************************************************/
/* Copies the object table from src to dst adding one more entry to dst */
/***************************************************************
* Copies the object table from src to dst adding one more entry to dst
*/
{
uint_32 src_offset; /* start of the image pages */
uint_32 dst_offset;
Expand All @@ -87,24 +88,31 @@ static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst )
pe_exe_header *src_pehdr;
pe_exe_header *dst_pehdr;

/* check for a resource object in the src exe */
/*
* check for a resource object in the src exe
*/
src_pehdr = src->u.PEInfo.WinHead;
src_resource_rva = PE_DIRECTORY( *src_pehdr, PE_TBL_RESOURCE ).rva;
dst_num_objects = src_num_objects = src_pehdr->fheader.num_objects;
for( obj_num = 0; obj_num < src_num_objects; obj_num++ ) {
if( src_resource_rva != 0 && src->u.PEInfo.Objects[obj_num].rva == src_resource_rva ) {
/* there already was a resource object */
/*
* there already was a resource object
*/
if( obj_num + 1 == src_num_objects ) {
/* it is the last object so just ignore it */
/*
* it is the last object so just ignore it
*/
dst_num_objects--;
res_offset = src->u.PEInfo.Objects[obj_num].physical_offset + src->u.PEInfo.Objects[obj_num].physical_size;
if( res_offset > src->DebugOffset ) {
src->DebugOffset = res_offset;
}
continue;
} else {
/* can't ignore it otherwise the rva's in the file will
be off*/
/*
* can't ignore it otherwise the rva's in the file will be off
*/
RcWarning( ERR_OLD_RESOURCE_OBJECT );
}
}
Expand All @@ -129,9 +137,11 @@ static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst )
delta_offset = dst_offset - src_offset;

if( dst_rva != src_rva ) {
/* This means that all the rva's in all image pages are now wrong. */
/* Since this case is rare and the user can relink with a higher */
/* object_align we just print an error messages and quit */
/*
* This means that all the rva's in all image pages are now wrong.
* Since this case is rare and the user can relink with a higher
* object_align we just print an error messages and quit
*/
RcError( ERR_PE_HEADER_SIZE_CHANGE );
return( -1 );
}
Expand All @@ -149,18 +159,17 @@ static int copyObjectTable( ExeFileInfo *src, ExeFileInfo *dst )
return( dst_num_objects );
}

/*
static RcStatus copyOneObject( FILE *src_fp, pe_object *src_obj,
FILE *dst_fp, pe_object *dst_obj )
/***************************************************************
*
* copyOneObject
* if an error occurs this function MUST return without altering errno
*
* if this an uninitialized object (one for which there is not data in the file)
* then don't copy it
*/
static RcStatus copyOneObject( FILE *src_fp, pe_object *src_obj,
FILE *dst_fp, pe_object *dst_obj )
/***************************************************************/
{
/*
* if this an uninitialized object (one for which there is not
* data in the file) then don't copy it
*/
if( (src_obj->flags & PE_OBJ_UNINIT_DATA) && ( src_obj->physical_offset == 0 ) ) {
return( RS_OK );
}
Expand Down Expand Up @@ -213,9 +222,10 @@ bool CopyExeObjects( ExeFileInfo *src, ExeFileInfo *dst )
} /* CopyExeObjects */

uint_32 GetNextObjPhysOffset( PEExeInfo *peinfo )
/***********************************************/
/* This routine assumes the num_objects in the header include one for the */
/* resource object */
/************************************************
* This routine assumes the num_objects in the header include one for the
* resource object
*/
{
uint_32 next_off;
pe_object *last_obj;
Expand All @@ -228,18 +238,21 @@ uint_32 GetNextObjPhysOffset( PEExeInfo *peinfo )
} /* GetNextObjPhysOffset */

pe_va GetNextObjRVA( PEExeInfo *peinfo )
/**************************************/
/* This routine assumes the num_objects in the header include one for the */
/* resource object */
/***************************************
* This routine assumes the num_objects in the header include one for the
* resource object
*/
{
uint_32 next_rva;
pe_object *last_obj;
pe_exe_header *pehdr;

pehdr = peinfo->WinHead;
last_obj = peinfo->Objects + pehdr->fheader.num_objects - 2;
/* This next line should work if the nt loader followed the PE spec but it */
/* doesn't so we can't use it */
/*
* This next line should work if the nt loader followed the PE spec but it
* doesn't so we can't use it
*/
// next_rva = last_obj->rva + last_obj->virtual_size;
next_rva = last_obj->rva + last_obj->physical_size;
return( ALIGN_VALUE( next_rva, PE( *pehdr, object_align ) ) );
Expand Down
31 changes: 19 additions & 12 deletions bld/rc/rc/c/sharedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@


#if !defined( INSIDE_WLINK ) || defined( _OS2 )

#define MAX_OPEN_RESFILES 6

typedef struct {
Expand All @@ -67,7 +68,7 @@ int RCCloseFile( FILE **fp )
return( rc );
}

bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen,
bool OpenResFiles( ExtraRes *resnames, ResFileInfo **presfiles, bool *allopen,
ExeType type, const char *exename )
/**************************************************************************/
{
Expand All @@ -80,12 +81,12 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen,
WResTargetOS res_os;

*allopen = true;
*resinfo = NULL;
*presfiles = NULL;
rescnt = 0;
for( ; resnames != NULL; resnames = resnames->next ) {
resfile = RESALLOC( sizeof( ResFileInfo ) );
resfile->next = *resinfo;
*resinfo = resfile;
resfile->next = *presfiles;
*presfiles = resfile;
resfile->Dir = WResInitDir();
resfile->name = resnames->name;
resfile->fp = ResOpenFileRO( resfile->name );
Expand All @@ -112,8 +113,9 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen,
RCCloseFile( &(resfile->fp) );
*allopen = false;
}

// remove the autodepend resource
/*
* remove the autodepend resource
*/
res_name = WResIDFromStr( DEP_LIST_NAME );
res_type = WResIDFromNum( DEP_LIST_TYPE );
WResDelResource( resfile->Dir, res_type, res_name );
Expand All @@ -129,8 +131,10 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen,
}
break;
case EXE_TYPE_NE_OS2:
// No way to tell MS and IBM resource files apart, and I can't find
// a good way to figure out if this is a Watcom .res file
/*
* No way to tell MS and IBM resource files apart, and I can't find
* a good way to figure out if this is a Watcom .res file
*/
if( res_os != WRES_OS_WIN16 && res_os != WRES_OS_OS2 ) {
RcError( ERR_NONWIN_RES_TO_WIN_EXE, resfile->name, exename );
goto HANDLE_ERROR;
Expand All @@ -143,22 +147,24 @@ bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen,
}
break;
case EXE_TYPE_LX:
// Same problem as with EXE_TYPE_NE_OS2
/*
* Same problem as with EXE_TYPE_NE_OS2
*/
if( res_os != WRES_OS_OS2 && res_os != WRES_OS_WIN16 ) {
RcError( ERR_NONOS2_RES_TO_OS2_EXE, resfile->name, exename );
goto HANDLE_ERROR;
}
break;
default: // EXE_TYPE_UNKNOWN
default: /* EXE_TYPE_UNKNOWN */
break;
}
rescnt++;
}
return( true );

HANDLE_ERROR:
CloseResFiles( *resinfo );
*resinfo = NULL;
CloseResFiles( *presfiles );
*presfiles = NULL;
return( false );
}

Expand Down Expand Up @@ -325,4 +331,5 @@ void ReportDupResource( WResID *nameid, WResID *typeid, const char *file1,
RESFREE( type );
}
}

#endif
2 changes: 1 addition & 1 deletion bld/rc/rc/h/sharedio.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef struct ExtraRes {

extern int RCCloseFile( FILE **fp );
extern void ReportDupResource( WResID *nameid, WResID *typeid, const char *file1, const char *file2, bool warn );
extern bool OpenResFiles( ExtraRes *resnames, ResFileInfo **resinfo, bool *allopen, ExeType type, const char *exename );
extern bool OpenResFiles( ExtraRes *resnames, ResFileInfo **presfiles, bool *allopen, ExeType type, const char *exename );
extern void CloseResFiles( ResFileInfo *resfiles );
extern void SharedIOInitStatics( void );
extern char *LastWresErrStr( void );
Expand Down

0 comments on commit 7bff9e2

Please sign in to comment.