2

Let's say i have a program.In this program i have a variable named PacketSize of type Short.I want to change the variable's type to Int.

Now if i am able to locate this variable's location in the memory while running the program , how can i use this to accomplish my aim or is it done by another way?

Edit :

*The application is a client.

*The variable is for the tcp packet's length which is sent in the packet header by the server to the client.

*I would guess that it's either a part of a structure (Maybe PacketHeader) or a stack one.

5
  • First figure out how can compiler store that variable which related with initialization, usage inside/outside of functions, your host system and even it can be differ because some optimizations. – Kerim Can Kalıpcıoğlu Feb 15 '17 at 20:06
  • If it's a single global variable then it's going to be a lot easier than if it's a member of a structure or allocated on a stack, because you can just move all references to it to another area of memory that has space. But you'll then need to rewrite all commands that reference it to use the new data size, and that's reasonably likely to mean you'll need more space for the instructions. This will be significant work. – Rup Feb 15 '17 at 23:03
  • 2
    There is no such thing as variable types in assembler, only fields of different (word-) sizes. Changing that means changing any instruction referring to this field and fixing alignment (stack / global). Its most likely not worth the effort. – Nordwald Feb 16 '17 at 7:08
  • If you did not give up yet, editing your question to supply some more information: Where is the variable located? stack, heap, part of a structure? Where is this variable accessed? How many times is it used? Can you provide code snippet with one or two variable usage examples? – NirIzr Feb 16 '17 at 17:26
  • I do not have the source code so little do i know but i will edit my question with all i can guess. – user3810737 Feb 17 '17 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.