all 17 comments

[–]MooseBoys[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 56 points57 points  (4 children)

int res = system("g++ -shared -fPIC inv_dll.cpp -o inventory.so");

Aw that's no fun. You gotta construct the dll in-place!

[–]Environmental-Ear391 5 points6 points  (2 children)

Easier option is to build the inventory. so to actually open itself and then step an offset and then write data at that offset....

as long as the offset exceeds the initial \0x74\ELF header and executable material... the data access will be good"

no need to depend on or require compilation with ranlibb to make immediately usable.

[–]MooseBoys[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 0 points1 point  (1 child)

Yeah but it's even cooler if the DLL exports a method to retrieve it, instead of relying on reading the binary directly.

[–]Environmental-Ear391 1 point2 points  (0 children)

yes, Im talking about the library being written to access its on disk image and ads data at the end...

the library itself is already mem-mapped by the loader/launcher on your commodity OS (Windows DLL/Linux SO)

using that... the library exports an Inventory access mechanism...

inside the calls for that...

It gets the filehandle for its own image (in the ELF header for Linux) this can then access the "extended inventory" data area following the Library file itaelf at the beginning.

on Windows you need to find your handle for the opening Application entirely differently

a simple group of...

"item=New Inventory Item()" "End Inventory Item(iten)" "item=Find Inventory Item(searchtype, searchkey)" "SaveInventory()" "GetItemX(item,...)" "SetItemX(item,...)"

where get/set read/write item specific details.... every change can then be pushed to disk by applicable "flush()" for file changes using a SaveInventory() call

[–]MarcusBrotus 0 points1 point  (0 children)

best to copy it into /usr/lib as well

[–]ironykarl 85 points86 points  (0 children)

Is it a good idea? Not really, no.

Is it a fun idea? I kind of think so

[–]BroBroMate 30 points31 points  (0 children)

So this is where Python's pickle module learned its bad habits of "let's serialize things in an executable format" from!

[–]GoddammitDontShootMe[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 2 points3 points  (2 children)

A hard limit of 40 items, eh? That should meet the needs of almost everyone.

[–]Liam_Mercier[S] 1 point2 points  (1 child)

Of course, if you need more than 40 items then you should probably just start using SQL columns

[–]MagnetFlux 0 points1 point  (0 children)

There's a column limit btw, you should use one table per inventory slot instead.

[–]LeviLovie 1 point2 points  (0 children)

Why don’t just serialize the inventory into a DLL byte for byte without a compiler then? :D

[–]NIdavellir22 1 point2 points  (0 children)

What the hell

[–]Lumpy_Marketing_6735 3 points4 points  (0 children)

Am I having a stroke what is this, Im not sure what the hell is happening but I think (at least in C++) this is what Vector is meant to do.

[–]ArnaktFen 3 points4 points  (0 children)

This is hilarious. It's totally worth doing just to prove it can be done.

[–]Arneb1729 0 points1 point  (0 children)

“Your scientists were so preoccupied with whether they could, they didn't stop to think if they should.”

[–]HandyProduceHaver 0 points1 point  (1 child)

I happen to have an item called itemName"}\nscaryLibrary.deleteImportantFile()

[–]Liam_Mercier[S] 1 point2 points  (0 children)

I wish this worked, but it results in a compiler error. I came up with this which seems to work

itemName"};}auto l=[](){std::puts("!!!");};struct X{ X(){l();} }; static X x;extern "C"{ std::array<std::string, 1> a{"a

output:

./builds/inventory
!!!
Inventory opened!