Resizing a char[x] to char[y] at runtime

后端 未结 11 1105
我在风中等你
我在风中等你 2021-02-11 01:33

OK, I hope I explain this one correctly. I have a struct:

typedef struct _MyData
{
   char Data[256];
   int  Index;
} MyData;

Now, I run into

11条回答
  •  我在风中等你
    2021-02-11 01:55

    Let me sum up two important points I see in this thread:

    1. The structure is used to interact between two programs through some IPC mechanism
    2. The destination program cannot be changed

    You cannot therefore change that structure in any way, because the destination program is stuck trying to read it as currently defined. I'm afraid you are stuck.

    You can try to find ways to get the equivalent behavior, or find some evil hack to force the destination program to read a new structure (e.g., modifying the binary offsets in the executable). That's all pretty application specific so I can't give much better guidance than that.

    You might consider writing a third program to act as an interface between the two. It can take the "long" messages and do something with them, and pass the "short" messages onward to the old program. You can inject that in between the IPC mechanisms fairly easily.

提交回复
热议问题