Update resource generation and access to match C style

dependabot/npm_and_yarn/Src/WebController/UI/websocket-extensions-0.1.4
Grzegorz Rychlik 2020-01-09 17:31:53 +01:00
parent 8f908f020c
commit 6aec395e30
2 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,7 @@
#error Unknown resource guid. #error Unknown resource guid.
#endif // !EMBEDDED_DLL_PAYLOAD #endif // !EMBEDDED_DLL_PAYLOAD
// Payload form [16 byte guid][1 byte terminator 0xff][4 byte size][body] // Payload form [16 byte guid][1 byte terminator 0xff][4 byte size][body][4 byte size][ExportName (null terminated)]
static char* FindStartOfResource(void* startofImage) static char* FindStartOfResource(void* startofImage)
{ {
@ -41,7 +41,7 @@ inline size_t GetExportNameSize(void* startOfResource)
return *(int32_t*)(GetPayloadEnd(startOfResource)); return *(int32_t*)(GetPayloadEnd(startOfResource));
} }
inline std::string_view GetExportName(void* startOfResource) inline const char* GetExportName(void* startOfResource)
{ {
return {(char*)GetPayloadEnd(startOfResource) + 4, GetExportNameSize(startOfResource) }; return (char*)GetPayloadEnd(startOfResource) + 4;
} }

View File

@ -28,7 +28,6 @@ namespace ResourceGenerator
sw.Write("\"\n"); sw.Write("\"\n");
} }
using (var bw = new BinaryWriter(File.Open(Path.Join(outputDir, "EmbeddedResource.dat"), FileMode.Create))) using (var bw = new BinaryWriter(File.Open(Path.Join(outputDir, "EmbeddedResource.dat"), FileMode.Create)))
{ {
var data = File.ReadAllBytes(args[0]); var data = File.ReadAllBytes(args[0]);
@ -37,8 +36,9 @@ namespace ResourceGenerator
bw.Write(BitConverter.GetBytes(data.Length)); bw.Write(BitConverter.GetBytes(data.Length));
bw.Write(data); bw.Write(data);
string exportName = args.Length < 3 ? "" : args[2]; string exportName = args.Length < 3 ? "" : args[2];
bw.Write(BitConverter.GetBytes(exportName.Length)); bw.Write(BitConverter.GetBytes(exportName.Length + 1)); // + 1 for null termination
bw.Write(Encoding.ASCII.GetBytes(exportName)); bw.Write(Encoding.ASCII.GetBytes(exportName));
bw.Write((byte)0x00);
} }
return 0; return 0;