Skip to content

Commit

Permalink
Beginnings of VS_VERSION_INFO parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hpvb committed Mar 15, 2021
1 parent 7d97f7b commit d412750
Show file tree
Hide file tree
Showing 54 changed files with 442 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fuzz/corpus/05263bee0c20e5ae88e066baf38d2e7355ea7308
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/0d0001f9a938f91e376f8be813c5683e0217585c
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/0d458cf0a4290d76642663a6d6a1c3c9f6971c1c
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/13e37cfba44980f25d124a8c9e10376491caa26f
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/1660b0afec2f530eb5417854a597858fac9a1da1
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/1d84c6f461ff1ac255fb7850370c327d8df21eb9
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/3405f1f6d320443a9d2930126f25af9a5e385b6c
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/35a1fa441c28496b1ff721e8e7bc9ef1ac34da7d
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/35c8647d0ea4f9b0d463ca013e148e7a20ed6fa3
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/385eaec77239bf94016157f22bc02de7e77977fb
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/3fa0d0481de9ef9b9a0ae0ad1df61a05187aad5f
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/46f7feef70b4ef43254bf7bd48f6359ea7b8f531
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/4fe83b8d9aa42e676eb28bd6c69e6263e979446c
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/519fa1d1792c65b3ba8779e91148b768fc9cf7db
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/557f98f335b3280bd78c66d60771090d38acd9a0
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/64ccee0d795b31f3892a42bcafafc086e2047d04
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/650acade16561d6175abe20569d81246c5270af1
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/6bf120ebc0c6e4c59b3f92c9513cd7b49f1c264d
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/6d1ba09137d3b441739e052b6148c764b8e37ec7
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/70d00afff3ef95f6898e173e59e2d01e3b3e4e33
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/7462293fbf3187fc6e9cb431f262b05a88cab429
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/8067ad3421de1f993ad343ef44c7bd1564c88805
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/868fbc54ed4ca4353b152831f00060ef7cbc7c1d
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/869b297445f28d40f4c05bd40a40ef0e0ad6cfc6
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/87e9ddb7b378868ab95f61f1c7f06522b3e1ca03
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/88cb0762e27e036d945600e61189b6463bce4c5e
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/8a38fa9c6335541c9d2d7b4b47d5c5e4062ec3f1
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/8da92764607c79f7da5012ab7ac10332b6ab3e50
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/918e19b15e0e6d8de64a038127e8e161e4a28c39
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/9dae76ba6c6da3e93c6911270d2a169eb0fe83b9
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/9e3e2edc0dc1964c1eae1c87dffc91aa1246605e
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/a0ad01190a969aa4adcf84f5ea9d356a61b257ab
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/a1394b6900f783f97a4351eca2b8be1473d358ff
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/a848591243fdc18c6f6e18e941207211a236b4c1
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/b1df71706ef74c7d4605af835935ddec436b211e
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/bb5faf5f5470b597830a9ee28c236ad6e66e4858
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/bdced7a8a581a4258858f5a7200c0c84207e3bf6
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/c0eb47a3b31b5f56027ebda909133f886307f42e
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/c2092d0c2a9f53f18698d404081e92c8e46ffced
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/cbaba9b53c05e643551ee52de669ea989025ec8c
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/d8ead076dddcce68d62fad75cd99363cf121a22b
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/dbecf78a63a055f3775834a46a49918c10e8e62f
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/dd6751d06846c4530da1a9aabf064f5bc0dde849
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/e13c769237b9dccc06507b3b3cd41d39f486518a
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/e36dce4db1c38cdb90ff8a47962900921579f3f2
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/e4fc6babceec9f188519036bd4ac3267d35b02fb
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/e58a979979b917fdef36407c70980a0b11bd52e8
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/f6c85879a84b753c850e3e95f671dcf3cc354a96
Git LFS file not shown
3 changes: 3 additions & 0 deletions fuzz/corpus/fb47fe4c727725ff862ead430d058a0306354515
Git LFS file not shown
5 changes: 5 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ EXPORT_SYM ppelib_file_t *ppelib_create_from_buffer(const uint8_t *buffer, size_
}
}

resource_t *res = NULL;
size_t nmb = get_resource_by_type_id(&pe->resource_table, RT_VERSION, &res);
if (nmb == 1) {
versioninfo_deserialize(res->data, res->size, 0);
}
out:
if (ppelib_error_peek()) {
ppelib_destroy(pe);
Expand Down
2 changes: 2 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ pperesource_sources = files([
'pe/section_print.c',
'pe/section_serialize.c',
'ppe_error.c',
'resources/resource_table.c',
'resources/resource_table_deserialize.c',
'resources/resource_table_print.c',
'resources/resource_table_serialize.c',
'resources/string_table.c',
'resources/versioninfo.c',
'utils.c',
])

Expand Down
4 changes: 4 additions & 0 deletions src/resources/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ size_t resource_table_serialize(const section_t *section, const size_t offset, r
void resource_table_print(resource_table_t *resource_table);
void update_resource_table(ppelib_file_t *pe);

size_t get_resource_by_type_name(wchar_t *type);
size_t get_resource_by_type_id(const resource_table_t *resource_table, uint32_t type, resource_t **resource);

void versioninfo_deserialize(const uint8_t *buffer, size_t size, size_t offset);
#endif /* SRC_RESOURCES_RESOURCE_H_ */
45 changes: 45 additions & 0 deletions src/resources/resource_table.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Copyright 2021 Hein-Pieter van Braam-Stewart
*
* This file is part of ppelib (Portable Portable Executable LIBrary)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <inttypes.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

#include "main.h"
#include "platform.h"
#include "ppe_error.h"
#include "resources/resource.h"

size_t get_resource_by_type_id(const resource_table_t *resource_table, uint32_t type, resource_t **resource) {
ppelib_reset_error();
*resource = NULL;

size_t size = 0;

for (size_t i = 0; i < resource_table->size; ++i) {
if (resource_table->resources[i]->type_id == type) {
if (!*resource) {
*resource = resource_table->resources[i];
}

++size;
}
}

return size;
}
Loading

0 comments on commit d412750

Please sign in to comment.