FuBi .


84 views
Uploaded on:
Description
FuBi!. Programmed Capacity Sending out for Systems administration and Scripting (!!!). Scott Bilas Gas Controlled Amusements. Phones?. Presentation. Me Scott Bilas Foundation You C engineers taking a shot at exhausting back-end stuff Visual C 6.0 Win32 x86 (yet hold up!)
Transcripts
Slide 1

FuBi! Programmed Function Exporting for Networking and Scripting (!!!) Scott Bilas Gas Powered Games

Slide 2

Cell Phones?

Slide 3

Introduction Me Scott Bilas Background You C++ designers dealing with exhausting back-end stuff Visual C++ 6.0 Win32 x86 (yet hold up!) Developers for different stages don\'t clear out! Many if not these ideas are compact (however C++ is (for the most part) required ). Check the paper for specifics. This Talk Glossing over specifics, they are canvassed in the paper

Slide 4

What Is FuBi? To start with: I\'m amped up for FuBi! (You ought to be as well) What is it? FuBi initially signified "Work Binder" Now it signifies "establishment of Dungeon Siege" Originally distributed in Game Programming Gems I By the way, make sure to purchase a duplicate, I hear it\'s great ;) FuBi is 15 times greater from that point forward (over a year prior) Kept finding new applications for the framework It\'s the blessing that continues giving – getting feeble however Wait, we should discuss the issue first

Slide 5

Two Guinea Pigs Choose two specimen subsystems Scripting motor Like SiegeSkrit, Java, Python, LUA Say it\'s a standard p-code VM sort thing It\'s helpful (and quicker) in the event that it has a parameter stack Network remote system calls (RPC\'s) All we truly need is a system transport for subpackets Compression is constantly valuable

Slide 6

Why Choose These? They have something critical in like manner: the should have the capacity to call subjective motor capacities Script motor must process CALLFUNC opcode Networking must highway an approaching bundle to whatever question is expecting it Everybody knows how to make them Well treated in books, magazines, and online articles Most recreations need these frameworks in any case That incorporates diversions like Dungeon Siege

Slide 7

The Problem How do these frameworks to converse with the amusement? How does a script call a C++ motor capacity? How does a subpacket get to the right C++ protest? Reply: horrendously Often includes frightful pressing and unloading of parameters Other circumstances it\'s more awful: the motor capacities should physically parse approaching non specific parameters It\'s 10x an excess of work, and covers open doors for some propelled highlights that we will get to soon

Slide 8

Base Requirements Regardless of strategy, we will dependably require certain things Type database Built-in\'s: int , coast , const char* … UDT\'s: std::string , Model , Actor , World … Function database Table of capacity pointers Model::Animate() , Actor::Think() , World::Sim()

Slide 9

Base Requirements (cont.) Method of rounding out the databases Fill the sort database – each sort has an ID, name, measure, "Unit ness", is-a-handle-ness… Other stuff as well, such as string adaptations of enum constants Fill the capacity database – ID, address, name, calling tradition, parameter imperatives… Method of calling capacities Parameter pre-and post-preparing Direct capacity call

Slide 10

Typical Methods Databases filled physically Init work or other worldwide enrollment technique (dreary) Parameter pressing/unloading Each capacity gets a paired parameter information piece Requires serialization to be finished by guest and callee Disadvantages are self-evident: absence of sort security, overhead in pressing and unloading Generic parameters (argc/argv) Same weaknesses as above with the exception of more terrible: customers must execute scaled down parsers! Instruments (formats, macros) can help, however it\'s still excessively work, excessively risky, and I\'m lethargic

Slide 11

Typical Methods (cont.) Source code processor (SWIG or homebrew) Best and most secure arrangement up until this point, yet an excessive amount of work Adds ventures to assemble prepare, backs off prototyping Requires wrappers, bring down execution Exporting is as yet not totally robotized What acts as a burden We don\'t have admittance to the compiler\'s image table This is the single most prominent issue I have with C++

Slide 12

The FuBi Hack (Uh, Method) Use the module\'s fare table declspec(dllexport) to fare capacities to the framework Each fare section maps a capacity name to address Iterate through fare information to fill work database Take preferred standpoint of C++ name disfiguring Extract class, work name, parameter sorts, return sort, calling tradition and so on by de-damaging the C++ name and parsing the outcomes (lex/yacc) Easy to do utilizing capacities in dbghelp.dll

Slide 13

Sample Usage Function we need to send out bool PrintMsg( const char* content ) { gScreenConsole.Print( content ); } Exported code #define FUBI_EXPORT __declspec( dllexport ) FUBI_EXPORT PrintMsg( const char* content ) { gScreenConsole.Print( content ); }

Slide 14

Advantages Easy to trade any capacity Just include a tag! Takes a shot at any sort of capacity Class strategy (static or nonstatic), worldwide, vararg, over-burdens, namespaces, anything! Completely computerized All motor capacities and sorts can be identified at amusement startup

Slide 15

Fill The Databases Read EXE trade table (MSDN says how) For each capacity, de-mutilate the name Parse the outcomes, extricate essential information Function and class name Function pointer Parameter sorts and return sort Calling tradition Various banners: static, virtual, const Add information to capacity database, dole out ID

Slide 16

Script Compiler Parser distinguishes a capacity call (say it resembles C++) Look up the capacity passage in the database Verify parameter sort coordinate, do fundamental changes Emit CALLFUNC opcode with the capacity ID as information

Slide 17

Script Virtual Machine Assume common p-code based virtual stack machine Store stack in OS design for accommodation Grow descending, DWORD-adjusted Push parameters on stack left-to-right (going upwards in memory) Look up capacity pointer in light of ID Execute daze work call (more on this later)

Slide 18

Network Router Say it\'s only a bundle pipe Send lumps of information (subpackets) to it and it will course it to the goal machine(s) Each piece will be the capacity ID took after by parameters, trailed by roundabout information Careful to look for disregarding pointers the system Addresses can\'t resolve We can deal with this!

Slide 19

Network Router (cont.) Networked work naturally wraps up parameters for the vehicle Use a large scale to make it simple Requires some inline gathering Special taking care of for cruise by-reference parameters Pointers don\'t work over systems POD sorts can tack crude information onto end of piece Non-POD sorts can be changed over to/from an "organize treat" Special dealing with for const char* , std::string Resolve "this" pointers same as 2(b).

Slide 20

Network Dispatcher Resolve work ID from lump into pointer Resolve pointers, "this", and strings (switch of system switch)

Slide 21

Blind Function Caller Easiest to compose everything in get together code (see paper) Require one for every calling tradition cdecl , stdcall , thiscall , thiscall + vararg (no fastcall ) Each visually impaired guest performs same operations Receive work address, stack pointer, and size of parameters Reserve state on string stack, then duplicate virtual stack onto string stack CALL the capacity Pull ST0 off FPU stack if work gives back a buoy/twofold, generally return esteem is in eax

Slide 22

Convenience Is Power! Your diversion has a reassure (if not, it ought to) Give the comfort the capacity to execute scripts progressively This ought to be simple Just wrap up what\'s entered in the support in a capacity and execute it on the fly Now this is a phenomenal test apparatus

Slide 23

Quick Tests and Tweakers It takes 30 seconds to add something like this to any .cpp document and moment recompile: FUBI_EXPORT TestCrash( void ) { *(int*)0 = 0; } FUBI_EXPORT TweakMyVar( drift f ) { gMySystem.SetVar( f ); } Convenience like this is effective – can instantly raise a whole intuitive investigate framework in seconds. Prison Siege sends out almost 2000 capacities right now. Why? Since we can!

Slide 24

Insert Sexy Demo Here

Slide 25

Porting Notes No dllexport office on your stage? Linker can make an .outline that you can parse Or get what you require from investigate images Will require content document to state which capacities are traded (generally can\'t differentiate) No partner capacity to de-ruin names? In the event that utilizing an open source compiler like gcc , making sense of how the mangler functions ought to be simple

Slide 26

Porting Notes (cont.) Not x86 guideline set? Shouldn\'t be hard to port to another low level computing construct Programming in an option that is other than C++? C++ wrappers that call motor capacities All we need is the name disfiguring to get the sort data I utilize this method in turn around on Dungeon Siege for calling Skrit capacities from C++ The capacity itself is insignificant, we simply require the damaged name to get sort information!

Slide 27

Final Notes Regarding utilization of dbghelp.dll Probably would prefer not to ship this with the diversion Also security might be an issue if multiplayer Write a little postprocessor that strips the EXE of its fare table and tosses it in the asset segment in a shape that FuBi can read straightforwardly (perhaps scramble it as well, not that it will stop programmers) Regarding virtual capacities We don\'t know which passages in the vtbl are for what, so can\'t call the correct element work (simple to work around however)

Slide 28

The End (?)

Slide 29

Next Steps Pretty person on foot v1.0 stuff so far It took about seven days to execute FuBi 1.0 Around 1,000 lines of code initially Just the start of the truly fun stuff Why is this all justified regardless of the inconvenience? Venture back and analyze the framework from a more elevated amount: Function database + sort database = mindfulness

Slide 30

Self-Awareness Self-Awareness: the amusement knows its own particular sorts Then it can do heaps of things consequently Game can insightfully investigate and give an account of itself Other dialects, for example, C# and Java as of now have this capacity (damn them) Apparently the greater part of us utilize C++ We\'ll presumably never get this capacity in our dialect FuBi can help overcome any issues Can improve this through uncommon traditions

Slide 31

Special Conventions Tell

Recommended
View more...