Questions tagged [self-modifying]

Self-modifying code is a piece of software which achieves its goal by rewriting itself as it goes along. Use this tag for questions related to self-modifying code, such as the writing and running of such codes in different languages, use cases and its detection.

Self-modifying code is a piece of software which achieves its goal by rewriting itself as it goes along. Use this tag for questions related to self-modifying code, such as the writing and running of such codes in different languages, use cases and its detection.

156 questions
1
vote
1 answer

How does self-modifying code work?

Is it generated by some kind of algorithm or mathematical procedure that tests whether or not the code produces the desired results and there are no runtime/stack errors? Or is there some other kind of heuristic process to decide what changes are to…
Mr X
  • 336
  • 1
  • 6
  • 22
1
vote
1 answer

Is Functional Programming Similar to Self-Modifying Code?

It seems that sometimes code in functional programs accepts other code (functions) as arguments and modifies it and returns it for execution. It seems similar to self-modifying code. Does this mean that the compactness of functional programs result…
necromancer
  • 23,916
  • 22
  • 68
  • 115
1
vote
2 answers

Self-modifying code in Ruby

I am concerned about writing self-modifying code in Ruby. And by self-modifying, I mean being able to write functions that take a code block as an input value, and output another code block based on this. (I am not asking about basics such as…
Boris Stitnicky
  • 12,444
  • 5
  • 57
  • 74
0
votes
1 answer

How to inline in C++ self modifying assembly code?

How would I inline this in C++ function. 0041F84E . 7B 02 JPO SHORT Unmodifi.0041F852 0041F850 B8 DB B8 0041F851 00 DB 00 0041F852 . 8B46 38 MOV EAX,DWORD PTR DS:[ESI+38] 0041F855 . 8B56 24 …
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
0 answers

How can I write self-modifying code on Windows?

When I was learning to program in assembler on a DOS system - the program could change its own code while the program was running and see it in the debugger. For some reason it doesn't work on Windows. The debugger (OllyDbg) just stops the program…
Jekgley
  • 9
  • 3
0
votes
5 answers

Is there any real application being self modifying code?

There are few examples on the web demonstrating how to write a self-modifying code. But they're just examples. I would like to know if there is any real application being self modifying code. Thanks!
chenwj
  • 1,989
  • 2
  • 16
  • 30
0
votes
0 answers

does c++ lock work for self-modifying code

I want to modify my function in multi threads env. like can c++ lock clear instruction cache like __builtin___clear_cache in gcc // thread 1 boost::unique_lock lock(func_mutext); mprotect(page_start, page_len, PROT_WRITE |…
sh_brk
  • 1
0
votes
2 answers

Using strreplace with variables against running script?

Update: A lot of progress was made to the ini result and the self-editing-code result; however, only the functions that make the edits are finished, not the gui/implementation. Will add more soon. My roommate is trying to replace a section of a…
Wolfpack'08
  • 3,982
  • 11
  • 46
  • 78
0
votes
0 answers

GCC API to compile a program within a program?

Is there a GCC C API (or some other C API) that I can use within a C program to compile other C programs? Something more programmatic than exec("gcc") and having to parse text intended for man (not machines) (eg. for debugging). More specifically,…
0
votes
0 answers

CFREQ_2400' was not declared in this scope

I am having a compilation error using modified code. original code as follows. #include #include #include 10 // MOSI => 11 // MISO…
0
votes
1 answer

Modifiying the linux system kernel

i want to modify the system kernell for linux, i want to change the open system call, so when i try to open one file, i want to open another one, but i cannot find where in the open.c file this can be done and which variables to work with, would…
0
votes
1 answer

Accesing 2 items in a list and store it as the variable first_two

I want to access the first two items in the list and change it to the variable "first_two" but i can't find my mistake, please help. Color_list = ["red", "blue", "green"] Color_list[0:2] ['red', 'blue'] first_two = "red", "blue" Color_list[0:2]…
0
votes
0 answers

Implement self-modification in the fork()

In fork, the parent and child share the code, so if I modify the code content in the child (for example, by self-modifying), can the parent execute the modified content when it reaches the corresponding part?
gazile
  • 105
  • 6
0
votes
0 answers

Self-modifying code does not work under advanced optimization

I tried to write a self-modifying code. (Refer to the link https://shanetully.com/2013/12/writing-a-self-mutating-x86_64-c-program/) The self-modifying code works when there is no optimization (-o0) gcc -O0 smc.c -o smc Calling foo... i: 1 Calling…
gazile
  • 105
  • 6
0
votes
1 answer

What is wrong with self-modifying codes with static-recompilation emulations?

I was searching for writing an emulator, and its techniques. But following paragraph made me wondered, I think I couldn't figure out which scenario can be present, if you write a self-modifying code to be static-recompilation emulated. In this…