简体   繁体   English

如何通过取消引用内存中的另一个地址来取消引用内存中的特定地址?

[英]How to dereference a specific address in memory through dereferencing another address in memory?

I'm using a bootloader as a hex and s19 files in my project, so i'm not allowed to modify its content. 我在项目中使用引导加载程序作为hex和s19文件,因此不允许修改其内容。 In this bootloader there is a part implemented in the following way to verify if my application is a valid application: 在此引导加载程序中,有一部分通过以下方式实现,以验证我的应用程序是否为有效的应用程序:

#define CHECK_PATTERN_ADDRESS ((int32)0x00020000)
#define VALID_PATTERN             ((int16)0xE900)
#define VALID_PATTERN_MASK        ((int16)0xFF00)

    int16    pattern_data = *(int16 *)CHECK_PATTERN_ADDRESS;
    if ((pattern_data & VALID_PATTERN_MASK) == VALID_PATTERN)
    {
        //Valid application
    }
    else
    {
        //Not Valid application
    }

From the above code, for the bootloader to consider my application as valid, it is needed to put the valid pattern in the mentioned address "0x00020000". 从上面的代码中,引导加载程序将我的应用程序视为有效,需要将有效的模式放在提到的地址“ 0x00020000”中。

This pattern is loaded directly to this address while downloading the application. 下载应用程序时,此模式直接加载到该地址。

This is done by using an assembly file containing this pattern and by specifying the address where it will be loaded in the memory through the linker file. 这是通过使用包含该模式的程序集文件并通过链接器文件指定将其加载到内存中的地址来完成的。

So, currently the valid pattern is loaded successfully in the mentioned address "0x00020000" during the download process of my application. 因此,当前有效模式已在我的应用程序下载过程中成功加载到上述地址“ 0x00020000”中。

The main constrain is: 主要约束是:

The bootloader should find the valid pattern in this specific address "0x00020000" 引导加载程序应在此特定地址“ 0x00020000”中找到有效的模式

The problem is: 问题是:

I need to add my valid pattern in another address "let's say 0x00040000" while the DLL will keep de-referencing the data from the requested address "0x00020000" .. 我需要在另一个地址“让我们说0x00040000”中添加我的有效模式,而DLL将继续从请求的地址“ 0x00020000”中取消引用数据。

Still, it is Okay for me to add any data through an assembly file to the original address "0x00020000", or to directly add any specific hex data to this address. 不过,我可以通过程序集文件将任何数据添加到原始地址“ 0x00020000”,或者直接将任何特定的十六进制数据添加到该地址。

The Question is: 问题是:

What can i load in this address "0x00020000", such that when the bootloader uses it in its code "as provided above" it will take the values loaded in the other address "0x00040000" 我可以在该地址“ 0x00020000”中加载什么,以便当引导加载程序在其代码“如上所述”中使用它时,它将采用加载在另一个地址“ 0x00040000”中的值

At 0x00020000 you can put the starting point of the code that is aware of your 0x00040000 "extensions". 在0x00020000,您可以放置​​知道您的0x00040000“扩展”的代码的起点。 Then, without any further midifications your bootloader will be booting that code as usualy, and that code (let's refer to it as a "secodary bootloader") will boot the code you placed under 0x00040000. 然后,无需任何其他限制,您的引导程序将照常引导该代码,并且该代码(以下简称为“辅助引导程序”)将引导您放置在0x00040000以下的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM