[video output=day021 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code template=code021_template.html title="Loading Game Code Dynamically" vod_platform=youtube id=WMSBRk5WG58 annotator=schme annotator=Kelimion] [1:29][Intro to the episode] [3:06][About implementing and using a scripting languages] [6:15][Benefits of loading game code dynamically] [8:29][Starting on dynamic code loading] [11:38][Separating platform and game code to different translation units] [15:56][Getting functions from game dll to the platform executable] [24:29][Getting Functions from platform executable to the game dll] [31:00][Searching compiler flags for building a dll] [35:18][Dll main] [40:08][Exporting functions from a dll] [47:27][Loading and unloading the game dll on the fly] [50:17][Moving local persist variables from the dll to game_state] [52:31][Avoid locking the dll to allow rewriting] [1:02:00][Episode recap] [1:03:37][Q&A][:speech] [1:03:51][-LD to build a dll and removing incremental building] [1:06:23][Question: We have small code right now. How does dynamic linking and compiling to an exe work with huge games that are multiple gigs?] [1:07:39][Casey spoils tomorrows stream by telling people not to spoil it] [1:08:00][Short recap on loops] [1:10:28][Question: Do you recommend playing around with dll files, or are they mainly used in specific cases?] [1:11:05][Question: Can someone now create a dummy handmade.dll and use it to intercept the GameUpdateAndRender function to get a pointer to game memory and change stuff. Is security something you will cover in a later stream?] [1:13:34][Question: We've got a tiny application right now so if code takes minutes to compile, how are we going to do what we just did?] [1:16:08][Question: Would you be able to load the dll yourself using ReadFile() and implement getProcAddress() as well, assuming there's an easy way to make the memory executable like mmap()] [1:18:16][Question: Is this technique still possible without using passing of the large memory blob between the dll and the exe?] [1:21:00][Question: Does the dll prevent the compiler from inlining?] [1:21:47][Question: How are we going to implement dll's on Linux/Mac?] [1:23:02][Question: Are you ever going to write the platform layers for other platforms on the stream in the far future?] [1:24:02][Question: Is the process roughly the same for doing the Linux equivalent of sharing libraries?] [1:25:42][Question: Your #define typedef magic kinda bugs me, in that it hides the arguments/return type away from the implementation. How much of a win is having the signature in one place?] [1:26:54][Question: How does Windows manage memory in a dll? Is there a dll process page? Where are variables made/the statics stored? How is heap managed when allocated from a dll?] [1:37:14][Question: Doesn't Windows know \[who called it\] by the instruction pointers leading up to the VirtualAlloc() call?] [/video]