Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ option(SOURCEPP_USE_KVPP "Build kvpp library" ${SOURC
option(SOURCEPP_USE_MDLPP "Build mdlpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_STEAMPP "Build steampp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_TOOLPP "Build toolpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VICEPP "Build vicepp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VCRYPTPP "Build vcryptpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VPKPP "Build vpkpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VTFPP "Build vtfpp library" ${SOURCEPP_LIBS_START_ENABLED})

Expand Down Expand Up @@ -117,16 +117,16 @@ endif()


# Add libraries
add_sourcepp_library(bsppp NO_TEST ) # sourcepp::bsppp
add_sourcepp_library(dmxpp ) # sourcepp::dmxpp
add_sourcepp_library(gamepp ) # sourcepp::gamepp
add_sourcepp_library(kvpp ) # sourcepp::kvpp
add_sourcepp_library(mdlpp ) # sourcepp::mdlpp
add_sourcepp_library(steampp C ) # sourcepp::steampp
add_sourcepp_library(toolpp ) # sourcepp::toolpp
add_sourcepp_library(vicepp C CSHARP ) # sourcepp::vicepp
add_sourcepp_library(vpkpp C CSHARP NO_TEST ) # sourcepp::vpkpp
add_sourcepp_library(vtfpp BENCH) # sourcepp::vtfpp
add_sourcepp_library(bsppp NO_TEST ) # sourcepp::bsppp
add_sourcepp_library(dmxpp ) # sourcepp::dmxpp
add_sourcepp_library(gamepp ) # sourcepp::gamepp
add_sourcepp_library(kvpp ) # sourcepp::kvpp
add_sourcepp_library(mdlpp ) # sourcepp::mdlpp
add_sourcepp_library(steampp C ) # sourcepp::steampp
add_sourcepp_library(toolpp ) # sourcepp::toolpp
add_sourcepp_library(vcryptpp C CSHARP ) # sourcepp::vcryptpp
add_sourcepp_library(vpkpp C CSHARP NO_TEST ) # sourcepp::vpkpp
add_sourcepp_library(vtfpp BENCH) # sourcepp::vtfpp


# Tests, part 2
Expand All @@ -149,6 +149,6 @@ endif()

# Print options
print_options(OPTIONS
USE_BSPPP USE_DMXPP USE_GAMEPP USE_KVPP USE_MDLPP USE_STEAMPP USE_TOOLPP USE_VICEPP USE_VPKPP USE_VTFPP
USE_BSPPP USE_DMXPP USE_GAMEPP USE_KVPP USE_MDLPP USE_STEAMPP USE_TOOLPP USE_VCRYPTPP USE_VPKPP USE_VTFPP
BUILD_BENCHMARKS BUILD_C_WRAPPERS BUILD_WITH_OPENCL BUILD_WITH_TBB BUILD_TESTS BUILD_WIN7_COMPAT
LINK_STATIC_MSVC_RUNTIME)
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,17 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
</tr>
<tr><!-- empty row to disable github striped bg color --></tr>
<tr>
<td rowspan="1"><code>vicepp</code></td>
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> Encrypted Files</td>
<td rowspan="3"><code>vcryptpp</code></td>
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> encrypted files</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td rowspan="1" align="center">C<br>C#</td>
<td rowspan="3" align="center">C<br>C#</td>
</tr>
<tr><!-- empty row to disable github striped bg color --></tr>
<tr>
<td><a href="https://developer.valvesoftware.com/wiki/Vfont">VFONT</a> encrypted fonts</td>
<td align="center">✅</td>
<td align="center">❌</td>
</tr>
<tr><!-- empty row to disable github striped bg color --></tr>
<tr>
Expand Down
11 changes: 8 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,16 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
<td align="center">✅</td>
</tr>
<tr>
<td rowspan="1"><code>vicepp</code></td>
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> Encrypted Files</td>
<td rowspan="2"><code>vcryptpp</code></td>
<td><a href="https://developer.valvesoftware.com/wiki/VICE">VICE</a> encrypted files</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td rowspan="1" align="center">C<br>C#</td>
<td rowspan="2" align="center">C<br>C#</td>
</tr>
<tr>
<td><a href="https://developer.valvesoftware.com/wiki/Vfont">VFONT</a> encrypted fonts</td>
<td align="center">✅</td>
<td align="center">❌</td>
</tr>
<tr>
<td rowspan="12"><code>vpkpp</code></td>
Expand Down
18 changes: 18 additions & 0 deletions include/vcryptpp/VFONT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <cstddef>
#include <span>
#include <string_view>
#include <vector>

#include <sourcepp/math/Integer.h>

namespace vcryptpp::VFONT {

constexpr std::string_view IDENTIFIER = "VFONT1";

constexpr uint8_t MAGIC = 167;

[[nodiscard]] std::vector<std::byte> decrypt(std::span<const std::byte> data);

} // namespace vcryptpp::VFONT
4 changes: 2 additions & 2 deletions include/vicepp/vicepp.h → include/vcryptpp/VICE.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string_view>
#include <vector>

namespace vicepp {
namespace vcryptpp::VICE {

// https://developer.valvesoftware.com/wiki/ICE
// https://developer.valvesoftware.com/wiki/Encrypted_Key_Values
Expand Down Expand Up @@ -47,4 +47,4 @@ constexpr std::string_view EKV_GPU_PORTAL_2 = "UrE66!Ap";

[[nodiscard]] std::vector<std::byte> decrypt(std::span<const std::byte> data, std::string_view code = KnownCodes::DEFAULT);

} // namespace vicepp
} // namespace vcryptpp::VICE
9 changes: 9 additions & 0 deletions include/vcryptpp/vcryptpp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

/*
* This header is just included so consumers of this library can
* include it the same way as any of the other SourcePP libraries.
*/

#include "VFONT.h"
#include "VICE.h"
28 changes: 14 additions & 14 deletions include/vpkpp/format/ZIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace vpkpp {

constexpr std::string_view BMZ_EXTENSION = ".bmz";
constexpr std::string_view BZ2_EXTENSION = ".bz2";
constexpr std::string_view BMZ_EXTENSION = ".bmz";
constexpr std::string_view BZ2_EXTENSION = ".bz2";
constexpr std::string_view GZIP_EXTENSION = ".gz";
constexpr std::string_view PK3_EXTENSION = ".pk3";
constexpr std::string_view PK4_EXTENSION = ".pk4";
constexpr std::string_view XZ_EXTENSION = ".xz";
constexpr std::string_view ZIP_EXTENSION = ".zip";
constexpr std::string_view ZSTD_EXTENSION = ".zstd";
constexpr std::string_view PK3_EXTENSION = ".pk3";
constexpr std::string_view PK4_EXTENSION = ".pk4";
constexpr std::string_view XZ_EXTENSION = ".xz";
constexpr std::string_view ZIP_EXTENSION = ".zip";
constexpr std::string_view ZST_EXTENSION = ".zst";

class ZIP : public PackFile {
public:
Expand Down Expand Up @@ -59,14 +59,14 @@ class ZIP : public PackFile {
bool zipOpen = false;

private:
VPKPP_REGISTER_PACKFILE_OPEN(BMZ_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(BZ2_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(BMZ_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(BZ2_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(GZIP_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(PK3_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(PK4_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(XZ_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(ZIP_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(ZSTD_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(PK3_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(PK4_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(XZ_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(ZIP_EXTENSION, &ZIP::open);
VPKPP_REGISTER_PACKFILE_OPEN(ZST_EXTENSION, &ZIP::open);
};

} // namespace vpkpp
6 changes: 6 additions & 0 deletions lang/c/include/vcryptppc/VFONT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <sourceppc/Buffer.h>

// REQUIRES MANUAL FREE: sourcepp_buffer_free
SOURCEPP_API sourcepp_buffer_t vcryptpp_vfont_decrypt(const unsigned char* buffer, size_t bufferLen);
33 changes: 33 additions & 0 deletions lang/c/include/vcryptppc/VICE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

#include <sourceppc/Buffer.h>

#define VCRYPTPP_VICE_KNOWN_CODES_DEFAULT "x9Ke0BY7";

#define VCRYPTPP_VICE_KNOWN_CODES_CONTAGION_WEAPONS "fUk0fF69"
#define VCRYPTPP_VICE_KNOWN_CODES_CONTAGION_SCRIPTS "5!rrFz6p"
#define VCRYPTPP_VICE_KNOWN_CODES_COUNTER_STRIKE_SOURCE "d7NSuLq2"
#define VCRYPTPP_VICE_KNOWN_CODES_COUNTER_STRIKE_GLOBAL_OFFENSIVE VICEPP_KNOWN_CODES_COUNTER_STRIKE_SOURCE
#define VCRYPTPP_VICE_KNOWN_CODES_COUNTER_STRIKE_2 VICEPP_KNOWN_CODES_COUNTER_STRIKE_GLOBAL_OFFENSIVE
#define VCRYPTPP_VICE_KNOWN_CODES_COUNTER_STRIKE_PROMOD "H1aRQ0n1"
#define VCRYPTPP_VICE_KNOWN_CODES_DAY_OF_DEFEAT_SOURCE "Wl0u5B3F"
#define VCRYPTPP_VICE_KNOWN_CODES_DYSTOPIA_1_2 "pH3apO8w"
#define VCRYPTPP_VICE_KNOWN_CODES_DYSTOPIA_1_3 "G8stUh3F"
#define VCRYPTPP_VICE_KNOWN_CODES_GOLDEN_EYE_SOURCE "Gr3naDes"
#define VCRYPTPP_VICE_KNOWN_CODES_HALF_LIFE_2_CTF "R1dj3axP"
#define VCRYPTPP_VICE_KNOWN_CODES_HALF_LIFE_2_DM VICEPP_KNOWN_CODES_DEFAULT
#define VCRYPTPP_VICE_KNOWN_CODES_INSURGENCY "DrA5e3EB"
#define VCRYPTPP_VICE_KNOWN_CODES_LEFT_4_DEAD_2 "SDhfi878"
#define VCRYPTPP_VICE_KNOWN_CODES_NO_MORE_ROOM_IN_HELL "lREeeapA"
#define VCRYPTPP_VICE_KNOWN_CODES_NUCLEAR_DAWN "TA+*veh9"
#define VCRYPTPP_VICE_KNOWN_CODES_TACTICAL_INTERVENTION "71B4Dt1Z"
#define VCRYPTPP_VICE_KNOWN_CODES_TEAM_FORTRESS_2 "E2NcUkG2"
#define VCRYPTPP_VICE_KNOWN_CODES_TEAM_FORTRESS_2_ITEMS "A5fSXbf7"
#define VCRYPTPP_VICE_KNOWN_CODES_THE_SHIP "eb3A4m79"
#define VCRYPTPP_VICE_KNOWN_CODES_ZOMBIE_PANIC_SOURCE "5R0ni0pZ"

// REQUIRES MANUAL FREE: sourcepp_buffer_free
SOURCEPP_API sourcepp_buffer_t vcryptpp_vice_encrypt(const unsigned char* buffer, size_t bufferLen, const char* code);

// REQUIRES MANUAL FREE: sourcepp_buffer_free
SOURCEPP_API sourcepp_buffer_t vcryptpp_vice_decrypt(const unsigned char* buffer, size_t bufferLen, const char* code);
9 changes: 9 additions & 0 deletions lang/c/include/vcryptppc/vcryptpp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

/*
* This header is just included so consumers of this library can
* include it the same way as any of the other SourcePP libraries.
*/

#include "VFONT.h"
#include "VICE.h"
34 changes: 0 additions & 34 deletions lang/c/include/viceppc/vicepp.h

This file was deleted.

14 changes: 14 additions & 0 deletions lang/c/src/vcryptppc/VFONT.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <vcryptppc/VFONT.h>

#include <sourceppc/Convert.hpp>
#include <sourceppc/Helpers.h>
#include <vcryptpp/vcryptpp.h>

using namespace vcryptpp;

SOURCEPP_API sourcepp_buffer_t vcryptpp_vfont_decrypt(const unsigned char* buffer, size_t bufferLen) {
SOURCEPP_EARLY_RETURN_VAL(buffer, SOURCEPP_BUFFER_INVALID);
SOURCEPP_EARLY_RETURN_VAL(bufferLen, SOURCEPP_BUFFER_INVALID);

return Convert::toBuffer(VFONT::decrypt(std::span<const std::byte>{reinterpret_cast<const std::byte*>(buffer), bufferLen}));
}
23 changes: 23 additions & 0 deletions lang/c/src/vcryptppc/VICE.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <vcryptppc/VICE.h>

#include <sourceppc/Convert.hpp>
#include <sourceppc/Helpers.h>
#include <vcryptpp/vcryptpp.h>

using namespace vcryptpp;

SOURCEPP_API sourcepp_buffer_t vcryptpp_vice_encrypt(const unsigned char* buffer, size_t bufferLen, const char* code) {
SOURCEPP_EARLY_RETURN_VAL(buffer, SOURCEPP_BUFFER_INVALID);
SOURCEPP_EARLY_RETURN_VAL(bufferLen, SOURCEPP_BUFFER_INVALID);
SOURCEPP_EARLY_RETURN_VAL(code, SOURCEPP_BUFFER_INVALID);

return Convert::toBuffer(VICE::encrypt(std::span<const std::byte>{reinterpret_cast<const std::byte*>(buffer), bufferLen}, code));
}

SOURCEPP_API sourcepp_buffer_t vcryptpp_vice_decrypt(const unsigned char* buffer, size_t bufferLen, const char* code) {
SOURCEPP_EARLY_RETURN_VAL(buffer, SOURCEPP_BUFFER_INVALID);
SOURCEPP_EARLY_RETURN_VAL(bufferLen, SOURCEPP_BUFFER_INVALID);
SOURCEPP_EARLY_RETURN_VAL(code, SOURCEPP_BUFFER_INVALID);

return Convert::toBuffer(VICE::decrypt(std::span<const std::byte>{reinterpret_cast<const std::byte*>(buffer), bufferLen}, code));
}
7 changes: 7 additions & 0 deletions lang/c/src/vcryptppc/_vcryptppc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_pretty_parser(vcryptpp C
SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/vcryptppc/vcryptpp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/vcryptppc/VFONT.h"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/vcryptppc/VICE.h"
"${CMAKE_CURRENT_LIST_DIR}/VFONT.cpp"
"${CMAKE_CURRENT_LIST_DIR}/VICE.cpp")
4 changes: 0 additions & 4 deletions lang/c/src/viceppc/_viceppc.cmake

This file was deleted.

21 changes: 0 additions & 21 deletions lang/c/src/viceppc/vicepp.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vicepp", "vicepp\vicepp.csproj", "{1A936830-5F97-4722-9012-67A324764879}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vcryptpp", "vcryptpp\vcryptpp.csproj", "{1A936830-5F97-4722-9012-67A324764879}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
41 changes: 41 additions & 0 deletions lang/csharp/src/vcryptpp/VFONT.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace vcryptpp
{
internal static unsafe partial class Extern
{
[DllImport("vcryptppc")]
public static extern Buffer vcryptpp_vfont_decrypt(byte* buffer, ulong bufferLen);
}

public static class VFONT
{
public static byte[] Decrypt(byte[] buffer)
{
unsafe
{
fixed (byte* bufferPtr = buffer)
{
Buffer ret = Extern.vcryptpp_vfont_decrypt(bufferPtr, (ulong) buffer.LongLength);
return BufferUtils.ConvertToArrayAndDelete(ref ret);
}
}
}

public static byte[] Decrypt(IEnumerable<byte> buffer)
{
unsafe
{
var data = buffer.ToArray();
fixed (byte* bufferPtr = data)
{
Buffer ret = Extern.vcryptpp_vfont_decrypt(bufferPtr, (ulong) data.LongLength);
return BufferUtils.ConvertToArrayAndDelete(ref ret);
}
}
}
}
}
Loading