在共享部分的调试器中设置值 [英] Setting a value in the debugger of a shared section

查看:44
本文介绍了在共享部分的调试器中设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 DLL 中有以下代码:

I have the following code in a DLL:

 #pragma data_seg("ABC")
 __declspec (dllexport) char abc[2000] = { 0 };
 #pragma data_seg()
 #pragma comment(linker, "-section:ABC,rws")

我在可执行文件中有以下代码:

I have the following code in an executable:

extern "C" __declspec(dllimport) char abc[];
char *abcPtr = abc;
#define iVar0 (*(long *)(abcPtr))

int main()
{
    printf("Value: %d %p\n", iVar0, &iVar0);
    iVar0 = 66;
    printf("Value: %d %p\n", iVar0, &iVar0);

    char buffer[256];
    scanf_s("%s", buffer, 256);
}

当我运行程序的第一个实例时,我得到:

When I run the first instance of the program I get:

Value: 0 0FC2A000
Value: 66 0FC2A000

如果我运行第二个实例,我会得到以下结果,因为它们使用相同的共享部分:

If I run a second instance I get the following because they are using the same shared section:

Value: 66 0FC2A000 <- Notice the value here is set
Value: 66 0FC2A000

但是,如果我在第一个实例中使用 Visual Studio 调试器更改值,我可以看到它在内存位置发生了变化;但是,如果我重新运行第二个实例,我看不到值的变化.

However if I change the value in the first instance using Visual Studio debugger, I can see that it changed in the memory location; however, I cannot see the value change if I rerun the second instance.

为什么调试器无法写入实际的共享(内存)部分?

Why is the debugger not able to write the actual shared (memory) section?

推荐答案

我得到了和你一样的结果:

I got the same result as yours:

我的理解是调试过程中共享内存中没有共享某些值.

My understanding is that certain value was not shared in the shared memory during debugging.

https://blogs.msdn.microsoft.com/oldnewthing/20040804-00/?p=38253/

这篇关于在共享部分的调试器中设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆