当前位置: 首页>>代码示例>>C#>>正文


C# IMemory.WriteWord方法代码示例

本文整理汇总了C#中IMemory.WriteWord方法的典型用法代码示例。如果您正苦于以下问题:C# IMemory.WriteWord方法的具体用法?C# IMemory.WriteWord怎么用?C# IMemory.WriteWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMemory的用法示例。


在下文中一共展示了IMemory.WriteWord方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyRelocations


//.........这里部分代码省略.........
                    //offsetBase = dataSection;
                    pointer += dataSection.Address;
                }
                //else if( relocation.BaseAddress == 0x1 )
                //{
                //    offsetBase = textSection;
                //    pointer += textSection.Address;
                //}
                else
                {
                    //offsetBase = textSection;
                    pointer += baseAddress;
                }
                //ElfSection offsetBase = _sections[ ( int )relocation.Symbol ];
                //ElfSection addressBase = _sections[ ( int )relocation.BaseAddress ];

                // Happens sometime
                if( _symbols.Count == 0 )
                {
                    Debug.WriteLine( "Unable to relocate symbol; symbol table is empty - possibly no .symtab section?" );
                    return;
                }

                ElfSymbol symbol = _symbols[ ( int )relocation.Symbol ];
                uint symbolValue = symbol.Value;

                // !!! This could be bogus
                if( ( ( rel.Info >> 8 ) & RelocationRelativeData ) == RelocationRelativeData )
                    symbolValue += dataSection.Address;
                else
                    symbolValue += baseAddress;
                //if( addressBase.Address == 0 )
                //	symbolValue += baseAddress;
                //else
                //	symbolValue += addressBase.Address;

                uint value = ( uint )memory.ReadWord( ( int )pointer );

                //Debug.WriteLine( string.Format( " Relocation pointer 0x{0:X8} (elf {1:X8}), value {2:X8}, type {3}, existing memory value {4:X8}",
                //	pointer, relocation.Offset, symbolValue, relocation.RelocationType, value ) );

                bool writeMemory = false;
                switch( relocation.RelocationType )
                {
                    case ElfRelocationType.None:
                        break;
                    case ElfRelocationType.Mips32:
                        value += symbolValue;
                        writeMemory = true;
                        break;
                    case ElfRelocationType.Mips26:
                        Debug.Assert( symbolValue % 4 == 0 );
                        value = ( uint )( ( value & ~0x03FFFFFF ) | ( ( value + ( symbolValue >> 2 ) ) & 0x03FFFFFF ) );
                        writeMemory = true;
                        break;
                    case ElfRelocationType.Hi16:
                        {
                            HiReloc hiReloc = new HiReloc();
                            hiReloc.Address = pointer;
                            hiReloc.Value = symbolValue;
                            hiRelocs.Add( hiReloc );
                        }
                        break;
                    case ElfRelocationType.Lo16:
                        {
                            uint vallo = ( ( value & 0x0000FFFF ) ^ 0x00008000 ) - 0x00008000;
                            while( hiRelocs.Count > 0 )
                            {
                                HiReloc hiReloc = hiRelocs[ hiRelocs.Count - 1 ];
                                hiRelocs.RemoveAt( hiRelocs.Count - 1 );

                                Debug.Assert( hiReloc.Value == symbolValue );

                                uint value2 = ( uint )memory.ReadWord( ( int )hiReloc.Address );
                                uint temp = ( ( value2 & 0x0000FFFF ) << 16 ) + vallo;
                                temp += symbolValue;

                                temp = ( ( temp >> 16 ) + ( ( ( temp & 0x00008000 ) != 0 ) ? ( uint )1 : ( uint )0 ) ) & 0x0000FFFF;

                                value2 = ( uint )( ( value2 & ~0x0000FFFF ) | temp );

                                //Debug.WriteLine( string.Format( "   Updating memory at 0x{0:X8} to {1:X8} (from previous HI16)", hiReloc.Address, value2 ) );
                                memory.WriteWord( ( int )hiReloc.Address, 4, ( int )value2 );
                            }
                            value = ( uint )( ( value & ~0x0000FFFF ) | ( ( symbolValue + vallo ) & 0x0000FFFF ) );
                        }
                        writeMemory = true;
                        break;
                    default:
                        // Unsupported type
                        Debugger.Break();
                        break;
                }
                if( writeMemory == true )
                {
                    //Debug.WriteLine( string.Format( "   Updating memory at 0x{0:X8} to {1:X8}", pointer, value ) );
                    memory.WriteWord( ( int )pointer, 4, ( int )value );
                }
            }
        }
开发者ID:BradFuller,项目名称:pspplayer,代码行数:101,代码来源:ElfFile.cs


注:本文中的IMemory.WriteWord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。