Jump to content


Accessing functions as memory in C/C++ at run-time.


6 replies to this topic

#1 GroundKeeper

    Valued Member

  • Members
  • PipPipPip
  • 110 posts

Posted 01 June 2007 - 07:07 PM

I have a need to distribute algorithms over a network without really knowing what algorithms being transfer. Therefor I figure why not try to send the data pointed to by the function identifier and try to send it over the network.

My first attempt was to use a script engine in which I could embed my algorithms. Problem being the efficiency!

Does anyone know of any already existing research in this area or perhaps some articles?

Specifically I'm interested in find out how the effects would be on memory and how to deal with the fact that the memory allocation might differ on diffrent machines.

I'm sure there are some haxxors out there that know how this would work.

Thanks in advanced for any help.

#2 .oisyn

    DevMaster Staff

  • Moderators
  • 1810 posts

Posted 01 June 2007 - 09:31 PM

I don't know what platform you're working on, but the best bet would be to send over a shared library such as a DLL containing your algorithm, and load it on the other side.

You could also do a binary copy of a function if the compiler does not reorder functions inside your executable and your function does not call other functions. However, that might be troublesome as some regular operations even call other functions (such as the conversion of float to int)
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#3 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 02 June 2007 - 10:09 AM

have a look at RAIL and Brakes

http://www.bat.org/~tomba/monoco.html
http://blog.secondli...threading-mono/

I don't think you'll find anything like them for C++

#4 GroundKeeper

    Valued Member

  • Members
  • PipPipPip
  • 110 posts

Posted 02 June 2007 - 12:37 PM

Thanks for the feedback!

My plattform would be targeted against Win32, Xbox 360 and perhaps Playstation 3. But initially I have a requirement for a Win32 implementation.
Dll:s crossed my mind. Might even be the best way to go. The problem will be speed. Haven't really done any analyse of what type of operations that will be the time consumers but the more to send on the network the more time you need to spend of sending is/was my initial thoughts. But in contrast of the data transfer of the algorithm the actual algorithm is a one-time transfer.

You actually convince me that the only sane method is a dll.
To actually manipulate the program sequence might be problematic.
On the other hand I don't know of what kind of dll capability the Xbox and Playstation has. Will have to find out.

Thanks guys!

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 02 June 2007 - 04:38 PM

The Playstation 3 can be run with a special distribution of Linux, so you can use its .so (shared object) functionality, which works similiarly to Windows DLLs. I don't know much about the XBox360 OS, except that it was originally based on Windows 2000, but has been completely reengineered along the way. It most likely still supports some kind of dynamic linking, but you'd have to get docs from Microsoft to figure out how to make it work.
reedbeta.com - developer blog, OpenGL demos, and other projects

#6 .oisyn

    DevMaster Staff

  • Moderators
  • 1810 posts

Posted 03 June 2007 - 10:03 PM

Is this about official gamecode or homebrew?

For native code, the 360 can handle DLLs like Windows does (LoadLibrary()), but I don't know what XNA's options are (but since it's basically just .Net you could probably dynamically load assemblies)

As for the PS3 and Reedbeta's remark, while linux is especially relevant for homebrew stuff, it is not for official games. I don't know whether games can load dynamic libraries (I imagine they could), but if it's official you should have the documentation so you could check for yourself :P
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#7 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 04 June 2007 - 07:56 AM

.oisyn said:

Is this about official gamecode or homebrew?

For native code, the 360 can handle DLLs like Windows does (LoadLibrary()), but I don't know what XNA's options are (but since it's basically just .Net you could probably dynamically load assemblies)

As for the PS3 and Reedbeta's remark, while linux is especially relevant for homebrew stuff, it is not for official games. I don't know whether games can load dynamic libraries (I imagine they could), but if it's official you should have the documentation so you could check for yourself ;)
Thats right its not Linux for games on the PS3. It can load dynamic libraries, but you can't talk about specific functions on the net cos of the PS3 Dev Kit license. Sony are afraid of people reverse engineering the API.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users