Skip to content

Commit a5ca4a1

Browse files
feat(vcryptpp): add vfont decompiler
1 parent ee7ebdd commit a5ca4a1

File tree

16 files changed

+154
-11
lines changed

16 files changed

+154
-11
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,17 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
115115
</tr>
116116
<tr><!-- empty row to disable github striped bg color --></tr>
117117
<tr>
118-
<td rowspan="1"><code>vcryptpp</code></td>
119-
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> Encrypted Files</td>
118+
<td rowspan="3"><code>vcryptpp</code></td>
119+
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> encrypted files</td>
120120
<td align="center">✅</td>
121121
<td align="center">✅</td>
122-
<td rowspan="1" align="center">C<br>C#</td>
122+
<td rowspan="3" align="center">C<br>C#</td>
123+
</tr>
124+
<tr><!-- empty row to disable github striped bg color --></tr>
125+
<tr>
126+
<td><a href="https://developer.valvesoftware.com/wiki/Vfont">VFONT</a> encrypted fonts</td>
127+
<td align="center">✅</td>
128+
<td align="center">❌</td>
123129
</tr>
124130
<tr><!-- empty row to disable github striped bg color --></tr>
125131
<tr>

docs/index.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,16 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
103103
<td align="center">✅</td>
104104
</tr>
105105
<tr>
106-
<td rowspan="1"><code>vcryptpp</code></td>
107-
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> Encrypted Files</td>
106+
<td rowspan="2"><code>vcryptpp</code></td>
107+
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> encrypted files</td>
108108
<td align="center">✅</td>
109109
<td align="center">✅</td>
110-
<td rowspan="1" align="center">C<br>C#</td>
110+
<td rowspan="2" align="center">C<br>C#</td>
111+
</tr>
112+
<tr>
113+
<td><a href="https://developer.valvesoftware.com/wiki/Vfont">VFONT</a> encrypted fonts</td>
114+
<td align="center">✅</td>
115+
<td align="center">❌</td>
111116
</tr>
112117
<tr>
113118
<td rowspan="12"><code>vpkpp</code></td>

include/vcryptpp/VFONT.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include <cstddef>
4+
#include <span>
5+
#include <string_view>
6+
#include <vector>
7+
8+
#include <sourcepp/math/Integer.h>
9+
10+
namespace vcryptpp::VFONT {
11+
12+
constexpr std::string_view IDENTIFIER = "VFONT1";
13+
14+
constexpr uint8_t MAGIC = 167;
15+
16+
[[nodiscard]] std::vector<std::byte> decrypt(std::span<const std::byte> data);
17+
18+
} // namespace vcryptpp::VFONT

include/vcryptpp/vcryptpp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
* include it the same way as any of the other SourcePP libraries.
66
*/
77

8+
#include "VFONT.h"
89
#include "VICE.h"

lang/c/include/vcryptppc/VFONT.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include <sourceppc/Buffer.h>
4+
5+
// REQUIRES MANUAL FREE: sourcepp_buffer_free
6+
SOURCEPP_API sourcepp_buffer_t vcryptpp_vfont_decrypt(const unsigned char* buffer, size_t bufferLen);

lang/c/include/vcryptppc/VICE.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <sourceppc/Buffer.h>
4-
#include <sourceppc/String.h>
54

65
#define VCRYPTPP_VICE_KNOWN_CODES_DEFAULT "x9Ke0BY7";
76

lang/c/include/vcryptppc/vcryptpp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
* include it the same way as any of the other SourcePP libraries.
66
*/
77

8+
#include "VFONT.h"
89
#include "VICE.h"

lang/c/src/vcryptppc/VFONT.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <vcryptppc/VFONT.h>
2+
3+
#include <sourceppc/Convert.hpp>
4+
#include <sourceppc/Helpers.h>
5+
#include <vcryptpp/vcryptpp.h>
6+
7+
using namespace vcryptpp;
8+
9+
SOURCEPP_API sourcepp_buffer_t vcryptpp_vfont_decrypt(const unsigned char* buffer, size_t bufferLen) {
10+
SOURCEPP_EARLY_RETURN_VAL(buffer, SOURCEPP_BUFFER_INVALID);
11+
SOURCEPP_EARLY_RETURN_VAL(bufferLen, SOURCEPP_BUFFER_INVALID);
12+
13+
return Convert::toBuffer(VFONT::decrypt(std::span<const std::byte>{reinterpret_cast<const std::byte*>(buffer), bufferLen}));
14+
}

lang/c/src/vcryptppc/VICE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <vcryptppc/vcryptpp.h>
1+
#include <vcryptppc/VICE.h>
22

33
#include <sourceppc/Convert.hpp>
44
#include <sourceppc/Helpers.h>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
add_pretty_parser(vcryptpp C
22
SOURCES
33
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/vcryptppc/vcryptpp.h"
4+
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/vcryptppc/VFONT.h"
45
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/vcryptppc/VICE.h"
6+
"${CMAKE_CURRENT_LIST_DIR}/VFONT.cpp"
57
"${CMAKE_CURRENT_LIST_DIR}/VICE.cpp")

0 commit comments

Comments
 (0)