static int computeShiftCount( void ) { NEExeInfo * old; NEExeInfo * tmp; uint_32 filelen; int num_segs; int shift_count; old = &Pass2Info.OldFile.u.NEInfo; tmp = &Pass2Info.TmpFile.u.NEInfo; filelen = old->WinHead.nonres_off + old->WinHead.nonres_size + tmp->Res.Dir.TableSize + tmp->Res.Str.StringBlockSize; filelen += ComputeSegmentSize( Pass2Info.OldFile.Handle, &(tmp->Seg), old->WinHead.align ); if( ! CmdLineParms.NoResFile ) { filelen += ComputeWINResourceSize( Pass2Info.ResFiles->Dir ); } num_segs = old->WinHead.segments; if( ! CmdLineParms.NoResFile ) { num_segs += WResGetNumResources( Pass2Info.ResFiles->Dir ); } shift_count = FindShiftCount( filelen, num_segs ); if( shift_count == 0 ) { shift_count = 1; /* MS thinks 0 == 9 for shift count */ } if( shift_count > old->WinHead.align ) { return( shift_count ); } else { return( old->WinHead.align ); } } /* computeShiftCount */
extern void InitWINResTable( void ) /*********************************/ { ExeResDir *res; StringsBlock *str; WResDir dir; res = &(Pass2Info.TmpFile.u.NEInfo.Res.Dir); str = &(Pass2Info.TmpFile.u.NEInfo.Res.Str); dir = Pass2Info.ResFiles->Dir; if( CmdLineParms.NoResFile ) { res->NumTypes = 0; /* the 2 uint_16 are the resource shift count and the type 0 record */ res->TableSize = 2 * sizeof( uint_16 ); res->Head = NULL; res->Tail = NULL; str->StringBlockSize = 0; str->StringBlock = NULL; str->StringListLen = 0; str->StringList = NULL; } else { res->NumTypes = WResGetNumTypes( dir ); res->NumResources = WResGetNumResources( dir ); /* the 2 uint_16 are the resource shift count and the type 0 record */ res->TableSize = res->NumTypes * sizeof( resource_type_record ) + res->NumResources * sizeof( resource_record ) + 2 * sizeof( uint_16 ); res->Head = NULL; res->Tail = NULL; StringBlockBuild( str, dir, false ); } } /* InitWINResTable */