Author Topic: Program that can write its own code in C++?  (Read 5952 times)

0 Members and 1 Guest are viewing this topic.

Offline Satan911

  • VIP
  • Knight
  • *
  • Posts: 289
  • Cookies: 25
  • Retired god/admin
    • View Profile
Re: Program that can write its own code in C++?
« Reply #15 on: October 16, 2012, 06:52:15 am »
Again, good luck doing that in C/C++.

However language running on a virtual machine like C# or Java can use reflection to modify their behavior at runtime. What exactly are you trying to achieve?
Satan911
Evilzone Network Administrator

Offline Vacrin

  • /dev/null
  • *
  • Posts: 6
  • Cookies: 0
    • View Profile
Re: Program that can write its own code in C++?
« Reply #16 on: October 16, 2012, 07:38:33 pm »
i guess it would be to create a program that can create new classes while in runtime and either add predetermined statements or new ones that it comes up with.

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: Program that can write its own code in C++?
« Reply #17 on: October 29, 2012, 09:30:28 pm »
OOP was probably most popularized by this idea in conjunction with AI.  The basic thought is actually really simple and is often found with modular design for plugins & what-not.  Basically, create a program that manages a priority queue of function pointers that uses linked lists to mitigate conflicts.  Then you can create other code modules that, provided they use the API appropriately, can add code to be called by the manager.  Replacing the manager is possible by adding an updated manager to the priority queue that essentially just takes over control of the priority queue and doesn't return.  It may even be possible to release the old management and free the memory it used.  Updating or replacing the priority queue itself is done by adding a routine to copy memory to another location where the new PQ can manage it and adjusting the pointers that are used by the manager.  The old PQ gets freed/deleted/released and you eliminate memory leaks.

So, there ya go, how to create Skynet in a few easy steps.
-Xires

Offline EmilKXZ

  • Peasant
  • *
  • Posts: 109
  • Cookies: 10
  • likes monies :p
    • View Profile
    • EmilKXZ
Re: Program that can write its own code in C++?
« Reply #18 on: October 30, 2012, 04:58:07 am »
He perfectly refers to polymorphic code I'd say. There used to be a lot of examples in VX Heavens. Of course, no point saying this now (it's useless because the source I cited is down). However, polymorphic code for compiled languages does exist, it did these days with MS-DOS malware.

In fact, there used to be an example around (do your Google research) of Delphi code that "kinda" assembled itself and changed behaviour. Polymorphic code like the one you're asking, requires some sort of AI to determine what is going to be assembled "within itself". Basically your program requires to know how to code, and then what to do with that code he can code for itself. Polymorphic code also requires to be modular and to be prioritized somehow, a module for watching others, what to change and whatnot. Morphing stuff without an orchestrator can lead to undesirable results, yet... the order emerges from chaos.  ;)

If you aim for the Skynet-kind (soft/mal)ware, along with the community I can offer my help and opinion. Just start a thread, though (don't PM me for that, we EZ are a community, love & share). Of course, all of this for educational purposes.