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
2
votes
1 answer

Debugger and cpu emulator don't detect self-modified code

Problem: I made an elf executable that self modifies one of its byte. It simply changes a 0 for a 1. When I run the executable normally, I can see that the change was successful because it runs exactly as expected (more on that further down). The…
2
votes
4 answers

c# Multiple Timers Editing the same List

I currently have 4 Timers adding objects to a List but as soon as they get out of the WinForms Control they should be deleted. I've Tried this : foreach (Auto a in autoListe) { if (a.X > 550 || a.X < -50 || a.Y > 550 || a.Y < -50) { …
D.Mendes
  • 159
  • 1
  • 11
2
votes
2 answers

How to tell compiler to pad a specific amount of bytes on every C function?

I'm trying to practice some live instrumentation and I saw there was a linker option -call-nop=prefix-nop, but it has some restriction as it only works with GOT function (I don't know how to force compiler to generate GOT function, and not sure if…
Patrick
  • 4,186
  • 9
  • 32
  • 45
2
votes
1 answer

Can I force gcc/clang to emit a function call, even when optimising?

I have some code that runs x64 programs under ptrace and manipulates their code. For testing this sort of thing, I have a placeholder function in one of my test programs: uint32_t __attribute__((noinline)) func(void) { return 0xCCCCCCCC; } The…
Tom Seddon
  • 2,648
  • 1
  • 19
  • 28
2
votes
4 answers

Simplest self-modifying function in JavaScript?

I would like to research and fiddle around with self-modifying functions and knowing that JavaScript has eval and other interesting reflection-ish features, like making a function print its body from the inside, I figured I would like to do some…
Swiffy
  • 4,401
  • 2
  • 23
  • 49
2
votes
2 answers

x86_64 - Self-modifying code performance

I am reading the Intel architecture documentation, vol3, section 8.1.3; Self-modifying code will execute at a lower level of performance than non-self-modifying or normal code. The degree of the performance deterioration will depend upon the…
Amy Lindsen
  • 119
  • 6
2
votes
1 answer

Still getting segmentation fault after calling mprotect in self-modifying assembly code

I'm trying to learn some stack overflow techniques and use shellcode in them. I was able to successfully use some basic shellcodes. Then I started working on using exeve in assembly and invoke ls -l with that, again successful. Now I am trying to…
AKJ88
  • 713
  • 2
  • 10
  • 20
2
votes
0 answers

c++ - llvm and runtime jit

Context Linux 64 bits / osx 64 bits. C++ (gcc 5.1, llvm 3.6.1) Up to now, I always used gcc for my projects. The problem for the next thing I am creating is the licence. Hence, I decided to give clang/llvm a go. My needs : runtime self modifying…
Larry
  • 1,735
  • 1
  • 18
  • 46
2
votes
2 answers

Edit, save, self-modifying HTML document; format generated HTML, JavaScript

Motivation: https://stackoverflow.com/questions/28120689/create-self-modifying-html-page-on-box Bug: String escaping , formatting html , js generated by initial edited , saved html , js e.g., a) if open "saveFile.html" at local browser ; b) type…
guest271314
  • 1
  • 15
  • 104
  • 177
2
votes
2 answers

Modify next Instruction in memory with gcc

I want to modify next instruction before it fetches, in best answer of This post in foo function, *p points to the next instruction in main function. I want to modify content of where *p points at. For example I want to change the next instruction…
Javad Yousefi
  • 2,250
  • 4
  • 35
  • 52
2
votes
3 answers

Which lisp implementations allow me to modify code at runtime?

Lisp is homoiconic, meaning code can be treated as data. Which implementations allow me to do so at runtime? The following is an example of what I mean, in pseudocode: (defun (my-func) (display "foo ") (display "bar ") (display "baz…
LogicChains
  • 4,332
  • 2
  • 18
  • 27
2
votes
1 answer

What is the difference between self-modifying code and reflection?

Self-modifying code is code that "alters its own instructions while it is executing". This is not typically done outside of assembly language or viruses. Reflection is just the ability of a program to access its own namespace dynamically, in order…
Michael Currie
  • 13,721
  • 9
  • 42
  • 58
2
votes
0 answers

Why function's reference is lost in self modifying code in C?

I'm trying to understand why should I dereference functions while making a self-modifying code in C. Even though it works this way, I would like to know why! Here's an example of what I was dealing with:…
2
votes
2 answers

Write to own executable in Linux C program, error "Text file busy"

For a security class I am supposed to write self-modifying code for a program which finds its own executable on the disk, reads the binary data, and encrypts part of it before writing it back out to the disk. This is supposed to be like a…
Cory Gross
  • 36,833
  • 17
  • 68
  • 80
2
votes
1 answer

Are there modern compilers for high level languages on simple processors which produce self-modifying code?

Back in the days before caches and branch prediction, it was relatively common if not encouraged to make self-modifying code for certain kinds of optimizations. It was probably most common in games and demos written in assembler in the eras between…
hippietrail
  • 15,848
  • 18
  • 99
  • 158