Closed LegalizeAdulthood closed 4 years ago
Note: one wrinkle with this is when the resource is embedded in a DLL, in which case the code that fetches the resources will need to make sure that it uses the result of LoadLibraryA
on the DLL filename for the HMODULE
parameter to the resource functions, or it won't locate the resources properly.
It's too complicated to support this feature because it involves integration with VS, or at the very least MSBuild. It gets complicated when the project already has a resource file and it requires generating some initialization code. I wanted to keep this as straight forward as possible. Ideally you'd have to do nothing but include this header (as is the case with any compiler but VS.) The reason the tool exists at all is mostly because I could not find a work around that was not intrusive like the resource approach. Still not happy with it but I generally view VS as a black sheep of the family of compilers.
Instead of doing the big data array approach when you don't have the .incbin directive, why not use a custom resource type and generate a resource file as well as a source file that loads the data from the resource?
You use a user-defined resource type to point the resource to the binary blob. Each embedded binary gets its own resource id in the generated resource script and the generated C++ source file loads the resources and obtains pointers to their data. The code would call FindResourceA to get the
HRSRC
for the blob and then LoadResource followed by LockResource to get the pointer to the data and SizeofResource to get the data length.For large binary payloads, this avoids all the compiler processing work of C++ source files of large data arrays.