mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-01-31 01:15:24 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba36d4b0c8 | ||
|
|
5de1c60d50 | ||
|
|
a8a170ebe6 | ||
|
|
d7937943b0 | ||
|
|
3f1df0ea92 | ||
|
|
caaa3519ad | ||
|
|
58ab271fc1 | ||
|
|
981fedfdd1 |
75
3rdparty/libzip/lib/compat.h
vendored
75
3rdparty/libzip/lib/compat.h
vendored
@@ -123,14 +123,64 @@ typedef char bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FSEEKO
|
||||
#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
|
||||
|
||||
#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__SEEK64)
|
||||
/* Windows API using int64 */
|
||||
typedef zip_int64_t zip_off_t;
|
||||
typedef struct _stat64 zip_os_stat_t;
|
||||
#define zip_os_stat _stat64
|
||||
#define zip_os_fstat _fstat64
|
||||
#define zip_os_seek _fseeki64
|
||||
#define ZIP_FSEEK_MAX ZIP_INT64_MAX
|
||||
#define ZIP_FSEEK_MIN ZIP_INT64_MIN
|
||||
#else
|
||||
|
||||
/* Normal API */
|
||||
#include <sys/stat.h>
|
||||
typedef struct stat zip_os_stat_t;
|
||||
#define zip_os_fstat fstat
|
||||
#define zip_os_stat stat
|
||||
|
||||
#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
|
||||
/* Using off_t */
|
||||
typedef off_t zip_off_t;
|
||||
#if SIZEOF_OFF_T == 8
|
||||
#define ZIP_OFF_MAX ZIP_INT64_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT64_MIN
|
||||
#elif SIZEOF_OFF_T == 4
|
||||
#define ZIP_OFF_MAX ZIP_INT32_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT32_MIN
|
||||
#elif SIZEOF_OFF_T == 2
|
||||
#define ZIP_OFF_MAX ZIP_INT16_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT16_MIN
|
||||
#else
|
||||
#error unsupported size of off_t
|
||||
#endif
|
||||
|
||||
#define ZIP_FSEEK_MAX ZIP_OFF_MAX
|
||||
#define ZIP_FSEEK_MIN ZIP_OFF_MIN
|
||||
|
||||
#define zip_os_fseek fseeko
|
||||
#define zip_os_ftell ftello
|
||||
#else
|
||||
|
||||
/* Using long */
|
||||
typedef long zip_off_t;
|
||||
#include <limits.h>
|
||||
#define ZIP_FSEEK_MAX LONG_MAX
|
||||
#define ZIP_FSEEK_MIN LONG_MIN
|
||||
|
||||
#define zip_os_fseek fseek
|
||||
#define zip_os_ftell ftell
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FTELLO
|
||||
#define ftello(s) ((long)ftell((s)))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_LOCALTIME_S
|
||||
#ifdef _WIN32
|
||||
/* Windows is incompatible to the C11 standard, hurray! */
|
||||
@@ -179,27 +229,6 @@ typedef char bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SIZEOF_OFF_T == 8
|
||||
#define ZIP_OFF_MAX ZIP_INT64_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT64_MIN
|
||||
#elif SIZEOF_OFF_T == 4
|
||||
#define ZIP_OFF_MAX ZIP_INT32_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT32_MIN
|
||||
#elif SIZEOF_OFF_T == 2
|
||||
#define ZIP_OFF_MAX ZIP_INT16_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT16_MIN
|
||||
#else
|
||||
#error unsupported size of off_t
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
|
||||
#define ZIP_FSEEK_MAX ZIP_OFF_MAX
|
||||
#define ZIP_FSEEK_MIN ZIP_OFF_MIN
|
||||
#else
|
||||
#include <limits.h>
|
||||
#define ZIP_FSEEK_MAX LONG_MAX
|
||||
#define ZIP_FSEEK_MIN LONG_MIN
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#if SIZEOF_SIZE_T == 8
|
||||
|
||||
11
3rdparty/libzip/lib/zip_dirent.c
vendored
11
3rdparty/libzip/lib/zip_dirent.c
vendored
@@ -39,7 +39,6 @@
|
||||
#include <time.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "zip.h"
|
||||
#include "zipint.h"
|
||||
|
||||
static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str, bool check_consistency);
|
||||
@@ -283,6 +282,7 @@ _zip_dirent_init(zip_dirent_t *de) {
|
||||
de->cloned = 0;
|
||||
|
||||
de->crc_valid = true;
|
||||
de->last_mod_mtime_valid = false;
|
||||
de->version_madeby = 63 | (ZIP_OPSYS_DEFAULT << 8);
|
||||
de->version_needed = 10; /* 1.0 */
|
||||
de->bitflags = 0;
|
||||
@@ -1264,3 +1264,12 @@ zip_dirent_check_consistency(zip_dirent_t *dirent) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
time_t zip_dirent_get_last_mod_mtime(zip_dirent_t *de) {
|
||||
if (!de->last_mod_mtime_valid) {
|
||||
de->last_mod_mtime = _zip_d2u_time(&de->last_mod);
|
||||
de->last_mod_mtime_valid = true;
|
||||
}
|
||||
|
||||
return de->last_mod_mtime;
|
||||
}
|
||||
20
3rdparty/libzip/lib/zip_file_set_mtime.c
vendored
20
3rdparty/libzip/lib/zip_file_set_mtime.c
vendored
@@ -33,8 +33,7 @@
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
|
||||
static int zip_file_set_time(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags, time_t *mtime) {
|
||||
zip_entry_t *e;
|
||||
|
||||
if (_zip_get_dirent(za, idx, 0, NULL) == NULL) {
|
||||
@@ -66,18 +65,29 @@ zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16
|
||||
|
||||
e->changes->last_mod.time = dtime;
|
||||
e->changes->last_mod.date = ddate;
|
||||
if (mtime != NULL) {
|
||||
e->changes->last_mod_mtime = *mtime;
|
||||
e->changes->last_mod_mtime_valid = true;
|
||||
}
|
||||
else {
|
||||
e->changes->last_mod_mtime_valid = false;
|
||||
}
|
||||
e->changes->changed |= ZIP_DIRENT_LAST_MOD;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZIP_EXTERN int
|
||||
zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) {
|
||||
ZIP_EXTERN int zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
|
||||
return zip_file_set_time(za, idx, dtime, ddate, flags, NULL);
|
||||
}
|
||||
|
||||
|
||||
ZIP_EXTERN int zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) {
|
||||
zip_dostime_t dostime;
|
||||
|
||||
if (_zip_u2d_time(mtime, &dostime, &za->error) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return zip_file_set_dostime(za, idx, dostime.time, dostime.date, flags);
|
||||
return zip_file_set_time(za, idx, dostime.time, dostime.date, flags, &mtime);
|
||||
}
|
||||
|
||||
1
3rdparty/libzip/lib/zip_new.c
vendored
1
3rdparty/libzip/lib/zip_new.c
vendored
@@ -68,6 +68,7 @@ _zip_new(zip_error_t *error) {
|
||||
za->nopen_source = za->nopen_source_alloc = 0;
|
||||
za->open_source = NULL;
|
||||
za->progress = NULL;
|
||||
za->torrent_mtime = 0;
|
||||
|
||||
return za;
|
||||
}
|
||||
|
||||
11
3rdparty/libzip/lib/zip_source_file_stdio.c
vendored
11
3rdparty/libzip/lib/zip_source_file_stdio.c
vendored
@@ -39,7 +39,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef S_IWUSR
|
||||
@@ -120,7 +119,7 @@ _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fseeko((FILE *)f, (off_t)offset, whence) < 0) {
|
||||
if (zip_os_fseek((FILE *)f, (zip_off_t)offset, whence) < 0) {
|
||||
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
|
||||
return false;
|
||||
}
|
||||
@@ -130,15 +129,15 @@ _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,
|
||||
|
||||
bool
|
||||
_zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
|
||||
struct stat sb;
|
||||
zip_os_stat_t sb;
|
||||
|
||||
int ret;
|
||||
|
||||
if (ctx->fname) {
|
||||
ret = stat(ctx->fname, &sb);
|
||||
ret = zip_os_stat(ctx->fname, &sb);
|
||||
}
|
||||
else {
|
||||
ret = fstat(fileno((FILE *)ctx->f), &sb);
|
||||
ret = zip_os_fstat(fileno((FILE *)ctx->f), &sb);
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
@@ -168,7 +167,7 @@ _zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
|
||||
|
||||
zip_int64_t
|
||||
_zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f) {
|
||||
off_t offset = ftello((FILE *)f);
|
||||
zip_off_t offset = zip_os_ftell((FILE *)f);
|
||||
|
||||
if (offset < 0) {
|
||||
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
|
||||
|
||||
@@ -178,9 +178,9 @@ _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uin
|
||||
{
|
||||
int fd;
|
||||
struct file_clone_range range;
|
||||
struct stat st;
|
||||
zip_os_stat_t st;
|
||||
|
||||
if (fstat(fileno(ctx->f), &st) < 0) {
|
||||
if (zip_os_fstat(fileno(ctx->f), &st) < 0) {
|
||||
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
|
||||
return -1;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uin
|
||||
ctx->tmpname = NULL;
|
||||
return -1;
|
||||
}
|
||||
if (fseeko(tfp, (off_t)offset, SEEK_SET) < 0) {
|
||||
if (zip_os_fseek(tfp, (zip_off_t)offset, SEEK_SET) < 0) {
|
||||
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
|
||||
(void)fclose(tfp);
|
||||
(void)remove(ctx->tmpname);
|
||||
@@ -290,11 +290,11 @@ _zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64
|
||||
static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) {
|
||||
char *temp;
|
||||
int mode;
|
||||
struct stat st;
|
||||
zip_os_stat_t st;
|
||||
int fd = 0;
|
||||
char *start, *end;
|
||||
|
||||
if (stat(ctx->fname, &st) == 0) {
|
||||
if (zip_os_stat(ctx->fname, &st) == 0) {
|
||||
mode = st.st_mode;
|
||||
}
|
||||
else {
|
||||
@@ -344,7 +344,7 @@ static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (stat(temp, &st) < 0) {
|
||||
if (zip_os_stat(temp, &st) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
break;
|
||||
}
|
||||
|
||||
11
3rdparty/libzip/lib/zip_stat_index.c
vendored
11
3rdparty/libzip/lib/zip_stat_index.c
vendored
@@ -77,7 +77,7 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
|
||||
}
|
||||
|
||||
if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
|
||||
st->mtime = _zip_d2u_time(&de->last_mod);
|
||||
st->mtime = zip_dirent_get_last_mod_mtime(de);
|
||||
st->valid |= ZIP_STAT_MTIME;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
|
||||
|
||||
st->crc = de->crc;
|
||||
st->size = de->uncomp_size;
|
||||
st->mtime = _zip_d2u_time(&de->last_mod);
|
||||
st->mtime = zip_dirent_get_last_mod_mtime(de);
|
||||
st->comp_size = de->comp_size;
|
||||
st->comp_method = (zip_uint16_t)de->comp_method;
|
||||
st->encryption_method = de->encryption_method;
|
||||
@@ -97,9 +97,12 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
|
||||
}
|
||||
|
||||
if ((za->ch_flags & ZIP_AFL_WANT_TORRENTZIP) && (flags & ZIP_FL_UNCHANGED) == 0) {
|
||||
zip_dostime_t dostime = {0xbc00, 0x2198};
|
||||
if (za->torrent_mtime == 0) {
|
||||
zip_dostime_t dostime = {0xbc00, 0x2198};
|
||||
za->torrent_mtime = _zip_d2u_time(&dostime);
|
||||
}
|
||||
st->comp_method = ZIP_CM_DEFLATE;
|
||||
st->mtime = _zip_d2u_time(&dostime);
|
||||
st->mtime = za->torrent_mtime;
|
||||
st->valid |= ZIP_STAT_MTIME | ZIP_STAT_COMP_METHOD;
|
||||
st->valid &= ~ZIP_STAT_COMP_SIZE;
|
||||
}
|
||||
|
||||
5
3rdparty/libzip/lib/zipint.h
vendored
5
3rdparty/libzip/lib/zipint.h
vendored
@@ -314,6 +314,7 @@ struct zip {
|
||||
zip_progress_t *progress; /* progress callback for zip_close() */
|
||||
|
||||
zip_uint32_t* write_crc; /* have _zip_write() compute CRC */
|
||||
time_t torrent_mtime;
|
||||
};
|
||||
|
||||
/* file in zip archive, part of API */
|
||||
@@ -346,6 +347,7 @@ struct zip_dirent {
|
||||
bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */
|
||||
|
||||
bool crc_valid; /* if CRC is valid (sometimes not for encrypted archives) */
|
||||
bool last_mod_mtime_valid;
|
||||
|
||||
zip_uint16_t version_madeby; /* (c) version of creator */
|
||||
zip_uint16_t version_needed; /* (cl) version needed to extract */
|
||||
@@ -366,6 +368,8 @@ struct zip_dirent {
|
||||
zip_uint32_t compression_level; /* level of compression to use (never valid in orig) */
|
||||
zip_uint16_t encryption_method; /* encryption method, computed from other fields */
|
||||
char *password; /* file specific encryption password */
|
||||
|
||||
time_t last_mod_mtime; /* cached last_mod in Unix time format */
|
||||
};
|
||||
|
||||
/* zip archive central directory */
|
||||
@@ -553,6 +557,7 @@ int zip_dirent_check_consistency(zip_dirent_t *dirent);
|
||||
zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *);
|
||||
void _zip_dirent_free(zip_dirent_t *);
|
||||
void _zip_dirent_finalize(zip_dirent_t *);
|
||||
time_t zip_dirent_get_last_mod_mtime(zip_dirent_t *de);
|
||||
void _zip_dirent_init(zip_dirent_t *);
|
||||
bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t);
|
||||
zip_dirent_t *_zip_dirent_new(void);
|
||||
|
||||
4
3rdparty/rcheevos/include/rc_api_runtime.h
vendored
4
3rdparty/rcheevos/include/rc_api_runtime.h
vendored
@@ -220,6 +220,8 @@ typedef struct rc_api_award_achievement_request_t {
|
||||
uint32_t hardcore;
|
||||
/* The hash associated to the game being played */
|
||||
const char* game_hash;
|
||||
/* The number of seconds since the achievement was unlocked */
|
||||
uint32_t seconds_since_unlock;
|
||||
}
|
||||
rc_api_award_achievement_request_t;
|
||||
|
||||
@@ -263,6 +265,8 @@ typedef struct rc_api_submit_lboard_entry_request_t {
|
||||
int32_t score;
|
||||
/* The hash associated to the game being played */
|
||||
const char* game_hash;
|
||||
/* The number of seconds since the leaderboard attempt was completed */
|
||||
uint32_t seconds_since_completion;
|
||||
}
|
||||
rc_api_submit_lboard_entry_request_t;
|
||||
|
||||
|
||||
17
3rdparty/rcheevos/src/rapi/rc_api_runtime.c
vendored
17
3rdparty/rcheevos/src/rapi/rc_api_runtime.c
vendored
@@ -412,6 +412,8 @@ int rc_api_init_award_achievement_request(rc_api_request_t* request, const rc_ap
|
||||
rc_url_builder_append_unum_param(&builder, "h", api_params->hardcore ? 1 : 0);
|
||||
if (api_params->game_hash && *api_params->game_hash)
|
||||
rc_url_builder_append_str_param(&builder, "m", api_params->game_hash);
|
||||
if (api_params->seconds_since_unlock)
|
||||
rc_url_builder_append_unum_param(&builder, "o", api_params->seconds_since_unlock);
|
||||
|
||||
/* Evaluate the signature. */
|
||||
md5_init(&md5);
|
||||
@@ -420,6 +422,14 @@ int rc_api_init_award_achievement_request(rc_api_request_t* request, const rc_ap
|
||||
md5_append(&md5, (md5_byte_t*)api_params->username, (int)strlen(api_params->username));
|
||||
snprintf(buffer, sizeof(buffer), "%d", api_params->hardcore ? 1 : 0);
|
||||
md5_append(&md5, (md5_byte_t*)buffer, (int)strlen(buffer));
|
||||
if (api_params->seconds_since_unlock) {
|
||||
/* second achievement id is needed by delegated unlock. including it here allows overloading
|
||||
* the hash generating code on the server */
|
||||
snprintf(buffer, sizeof(buffer), "%u", api_params->achievement_id);
|
||||
md5_append(&md5, (md5_byte_t*)buffer, (int)strlen(buffer));
|
||||
snprintf(buffer, sizeof(buffer), "%u", api_params->seconds_since_unlock);
|
||||
md5_append(&md5, (md5_byte_t*)buffer, (int)strlen(buffer));
|
||||
}
|
||||
md5_finish(&md5, digest);
|
||||
rc_format_md5(buffer, digest);
|
||||
rc_url_builder_append_str_param(&builder, "v", buffer);
|
||||
@@ -505,6 +515,9 @@ int rc_api_init_submit_lboard_entry_request(rc_api_request_t* request, const rc_
|
||||
if (api_params->game_hash && *api_params->game_hash)
|
||||
rc_url_builder_append_str_param(&builder, "m", api_params->game_hash);
|
||||
|
||||
if (api_params->seconds_since_completion)
|
||||
rc_url_builder_append_unum_param(&builder, "o", api_params->seconds_since_completion);
|
||||
|
||||
/* Evaluate the signature. */
|
||||
md5_init(&md5);
|
||||
snprintf(buffer, sizeof(buffer), "%u", api_params->leaderboard_id);
|
||||
@@ -512,6 +525,10 @@ int rc_api_init_submit_lboard_entry_request(rc_api_request_t* request, const rc_
|
||||
md5_append(&md5, (md5_byte_t*)api_params->username, (int)strlen(api_params->username));
|
||||
snprintf(buffer, sizeof(buffer), "%d", api_params->score);
|
||||
md5_append(&md5, (md5_byte_t*)buffer, (int)strlen(buffer));
|
||||
if (api_params->seconds_since_completion) {
|
||||
snprintf(buffer, sizeof(buffer), "%u", api_params->seconds_since_completion);
|
||||
md5_append(&md5, (md5_byte_t*)buffer, (int)strlen(buffer));
|
||||
}
|
||||
md5_finish(&md5, digest);
|
||||
rc_format_md5(buffer, digest);
|
||||
rc_url_builder_append_str_param(&builder, "v", buffer);
|
||||
|
||||
125
3rdparty/rcheevos/src/rc_client.c
vendored
125
3rdparty/rcheevos/src/rc_client.c
vendored
@@ -578,13 +578,7 @@ static int rc_client_get_image_url(char buffer[], size_t buffer_size, int image_
|
||||
image_request.image_name = image_name;
|
||||
result = rc_api_init_fetch_image_request(&request, &image_request);
|
||||
if (result == RC_OK)
|
||||
{
|
||||
const size_t url_length = strlen(request.url);
|
||||
if (url_length >= buffer_size)
|
||||
result = RC_INSUFFICIENT_BUFFER;
|
||||
else
|
||||
memcpy(buffer, request.url, url_length + 1);
|
||||
}
|
||||
snprintf(buffer, buffer_size, "%s", request.url);
|
||||
|
||||
rc_api_destroy_request(&request);
|
||||
return result;
|
||||
@@ -1440,7 +1434,6 @@ static void rc_client_activate_game(rc_client_load_state_t* load_state, rc_api_s
|
||||
rc_mutex_lock(&client->state.mutex);
|
||||
load_state->progress = (client->state.load == load_state) ?
|
||||
RC_CLIENT_LOAD_GAME_STATE_DONE : RC_CLIENT_LOAD_GAME_STATE_ABORTED;
|
||||
client->state.load = NULL;
|
||||
rc_mutex_unlock(&client->state.mutex);
|
||||
|
||||
if (load_state->progress != RC_CLIENT_LOAD_GAME_STATE_DONE) {
|
||||
@@ -1461,17 +1454,15 @@ static void rc_client_activate_game(rc_client_load_state_t* load_state, rc_api_s
|
||||
start_session_response->num_unlocks, RC_CLIENT_ACHIEVEMENT_UNLOCKED_SOFTCORE);
|
||||
}
|
||||
|
||||
/* make the loaded game active if another game is not aleady being loaded. */
|
||||
rc_mutex_lock(&client->state.mutex);
|
||||
if (client->state.load == NULL)
|
||||
if (client->state.load == load_state)
|
||||
client->game = load_state->game;
|
||||
else
|
||||
load_state->progress = RC_CLIENT_LOAD_GAME_STATE_ABORTED;
|
||||
rc_mutex_unlock(&client->state.mutex);
|
||||
|
||||
if (client->game != load_state->game) {
|
||||
/* previous load state was aborted */
|
||||
if (load_state->callback)
|
||||
load_state->callback(RC_ABORTED, "The requested game is no longer active", client, load_state->callback_userdata);
|
||||
}
|
||||
else {
|
||||
if (load_state->progress != RC_CLIENT_LOAD_GAME_STATE_ABORTED) {
|
||||
/* if a change media request is pending, kick it off */
|
||||
rc_client_pending_media_t* pending_media;
|
||||
|
||||
@@ -1481,6 +1472,9 @@ static void rc_client_activate_game(rc_client_load_state_t* load_state, rc_api_s
|
||||
rc_mutex_unlock(&load_state->client->state.mutex);
|
||||
|
||||
if (pending_media) {
|
||||
/* rc_client_check_pending_media will fail if it can't find the game in client->game or
|
||||
* client->state.load->game. since we've detached the load_state, this has to occur after
|
||||
* we've made the game active. */
|
||||
if (pending_media->hash) {
|
||||
rc_client_begin_change_media_from_hash(client, pending_media->hash,
|
||||
pending_media->callback, pending_media->callback_userdata);
|
||||
@@ -1494,12 +1488,50 @@ static void rc_client_activate_game(rc_client_load_state_t* load_state, rc_api_s
|
||||
rc_client_free_pending_media(pending_media);
|
||||
}
|
||||
|
||||
/* client->game must be set before calling this function so it can query the console_id */
|
||||
rc_mutex_lock(&client->state.mutex);
|
||||
if (client->state.load != load_state)
|
||||
load_state->progress = RC_CLIENT_LOAD_GAME_STATE_ABORTED;
|
||||
rc_mutex_unlock(&client->state.mutex);
|
||||
}
|
||||
|
||||
/* if the game is still being loaded, make sure all the required memory addresses are accessible
|
||||
* so we can mark achievements as unsupported before loading them into the runtime. */
|
||||
if (load_state->progress != RC_CLIENT_LOAD_GAME_STATE_ABORTED) {
|
||||
/* TODO: it is desirable to not do memory reads from a background thread. Some emulators (like Dolphin) don't
|
||||
* allow it. Dolphin's solution is to use a dummy read function that says all addresses are valid and
|
||||
* switches to the actual read function after the callback is called. latter invalid reads will
|
||||
* mark achievements as unsupported. */
|
||||
|
||||
/* ASSERT: client->game must be set before calling this function so the read_memory callback can query the console_id */
|
||||
rc_client_validate_addresses(load_state->game, client);
|
||||
|
||||
rc_mutex_lock(&client->state.mutex);
|
||||
if (client->state.load != load_state)
|
||||
load_state->progress = RC_CLIENT_LOAD_GAME_STATE_ABORTED;
|
||||
rc_mutex_unlock(&client->state.mutex);
|
||||
}
|
||||
|
||||
/* if the game is still being loaded, load any active acheivements/leaderboards into the runtime */
|
||||
if (load_state->progress != RC_CLIENT_LOAD_GAME_STATE_ABORTED) {
|
||||
rc_client_activate_achievements(load_state->game, client);
|
||||
rc_client_activate_leaderboards(load_state->game, client);
|
||||
|
||||
/* detach the load state to indicate that loading is fully complete */
|
||||
rc_mutex_lock(&client->state.mutex);
|
||||
if (client->state.load == load_state)
|
||||
client->state.load = NULL;
|
||||
else
|
||||
load_state->progress = RC_CLIENT_LOAD_GAME_STATE_ABORTED;
|
||||
rc_mutex_unlock(&client->state.mutex);
|
||||
}
|
||||
|
||||
/* one last sanity check to make sure the game is still being loaded. */
|
||||
if (load_state->progress == RC_CLIENT_LOAD_GAME_STATE_ABORTED) {
|
||||
/* game has been unloaded, or another game is being loaded over the top of this game */
|
||||
if (load_state->callback)
|
||||
load_state->callback(RC_ABORTED, "The requested game is no longer active", client, load_state->callback_userdata);
|
||||
}
|
||||
else {
|
||||
if (load_state->hash->hash[0] != '[') {
|
||||
if (load_state->client->state.spectator_mode != RC_CLIENT_SPECTATOR_MODE_LOCKED) {
|
||||
/* schedule the periodic ping */
|
||||
@@ -2007,7 +2039,6 @@ static int rc_client_attach_load_state(rc_client_t* client, rc_client_load_state
|
||||
{
|
||||
if (client->state.load == NULL) {
|
||||
rc_client_unload_game(client);
|
||||
client->state.load = load_state;
|
||||
|
||||
if (load_state->game == NULL) {
|
||||
load_state->game = rc_client_allocate_game();
|
||||
@@ -2018,6 +2049,10 @@ static int rc_client_attach_load_state(rc_client_t* client, rc_client_load_state
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
rc_mutex_lock(&client->state.mutex);
|
||||
client->state.load = load_state;
|
||||
rc_mutex_unlock(&client->state.mutex);
|
||||
}
|
||||
else if (client->state.load != load_state) {
|
||||
/* previous load was aborted */
|
||||
@@ -2621,8 +2656,6 @@ static void rc_client_game_mark_ui_to_be_hidden(rc_client_t* client, rc_client_g
|
||||
void rc_client_unload_game(rc_client_t* client)
|
||||
{
|
||||
rc_client_game_info_t* game;
|
||||
rc_client_scheduled_callback_data_t** last;
|
||||
rc_client_scheduled_callback_data_t* next;
|
||||
|
||||
if (!client)
|
||||
return;
|
||||
@@ -2649,29 +2682,38 @@ void rc_client_unload_game(rc_client_t* client)
|
||||
if (client->state.load) {
|
||||
/* this mimics rc_client_abort_async without nesting the lock */
|
||||
client->state.load->async_handle.aborted = RC_CLIENT_ASYNC_ABORTED;
|
||||
|
||||
/* if the game is still being loaded, let the load process clean it up */
|
||||
if (client->state.load->game == game)
|
||||
game = NULL;
|
||||
|
||||
client->state.load = NULL;
|
||||
}
|
||||
|
||||
if (client->state.spectator_mode == RC_CLIENT_SPECTATOR_MODE_LOCKED)
|
||||
client->state.spectator_mode = RC_CLIENT_SPECTATOR_MODE_ON;
|
||||
|
||||
if (game != NULL)
|
||||
if (game != NULL) {
|
||||
rc_client_scheduled_callback_data_t** last;
|
||||
rc_client_scheduled_callback_data_t* next;
|
||||
|
||||
rc_client_game_mark_ui_to_be_hidden(client, game);
|
||||
|
||||
last = &client->state.scheduled_callbacks;
|
||||
do {
|
||||
next = *last;
|
||||
if (!next)
|
||||
break;
|
||||
last = &client->state.scheduled_callbacks;
|
||||
do {
|
||||
next = *last;
|
||||
if (!next)
|
||||
break;
|
||||
|
||||
/* remove rich presence ping scheduled event for game */
|
||||
if (next->callback == rc_client_ping && game && next->related_id == game->public_.id) {
|
||||
*last = next->next;
|
||||
continue;
|
||||
}
|
||||
/* remove rich presence ping scheduled event for game */
|
||||
if (next->callback == rc_client_ping && next->related_id == game->public_.id) {
|
||||
*last = next->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
last = &next->next;
|
||||
} while (1);
|
||||
last = &next->next;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
rc_mutex_unlock(&client->state.mutex);
|
||||
|
||||
@@ -3534,7 +3576,7 @@ typedef struct rc_client_award_achievement_callback_data_t
|
||||
uint32_t retry_count;
|
||||
uint8_t hardcore;
|
||||
const char* game_hash;
|
||||
time_t unlock_time;
|
||||
rc_clock_t unlock_time;
|
||||
rc_client_t* client;
|
||||
rc_client_scheduled_callback_data_t* scheduled_callback_data;
|
||||
} rc_client_award_achievement_callback_data_t;
|
||||
@@ -3685,6 +3727,11 @@ static void rc_client_award_achievement_server_call(rc_client_award_achievement_
|
||||
api_params.hardcore = ach_data->hardcore;
|
||||
api_params.game_hash = ach_data->game_hash;
|
||||
|
||||
if (ach_data->retry_count) {
|
||||
const rc_clock_t now = ach_data->client->callbacks.get_time_millisecs(ach_data->client);
|
||||
api_params.seconds_since_unlock = (uint32_t)((now - ach_data->unlock_time) / 1000);
|
||||
}
|
||||
|
||||
result = rc_api_init_award_achievement_request(&request, &api_params);
|
||||
if (result != RC_OK) {
|
||||
RC_CLIENT_LOG_ERR_FORMATTED(ach_data->client, "Error constructing unlock request for achievement %u: %s", ach_data->id, rc_error_str(result));
|
||||
@@ -3751,7 +3798,8 @@ static void rc_client_award_achievement(rc_client_t* client, rc_client_achieveme
|
||||
callback_data->client = client;
|
||||
callback_data->id = achievement->public_.id;
|
||||
callback_data->hardcore = client->state.hardcore;
|
||||
callback_data->unlock_time = achievement->public_.unlock_time;
|
||||
callback_data->game_hash = client->game->public_.hash;
|
||||
callback_data->unlock_time = client->callbacks.get_time_millisecs(client);
|
||||
|
||||
if (client->game) /* may be NULL if this gets called while unloading the game (from another thread - events are raised outside the lock) */
|
||||
callback_data->game_hash = client->game->public_.hash;
|
||||
@@ -4185,7 +4233,7 @@ typedef struct rc_client_submit_leaderboard_entry_callback_data_t
|
||||
int32_t score;
|
||||
uint32_t retry_count;
|
||||
const char* game_hash;
|
||||
time_t submit_time;
|
||||
rc_clock_t submit_time;
|
||||
rc_client_t* client;
|
||||
rc_client_scheduled_callback_data_t* scheduled_callback_data;
|
||||
} rc_client_submit_leaderboard_entry_callback_data_t;
|
||||
@@ -4340,6 +4388,11 @@ static void rc_client_submit_leaderboard_entry_server_call(rc_client_submit_lead
|
||||
api_params.score = lboard_data->score;
|
||||
api_params.game_hash = lboard_data->game_hash;
|
||||
|
||||
if (lboard_data->retry_count) {
|
||||
const rc_clock_t now = lboard_data->client->callbacks.get_time_millisecs(lboard_data->client);
|
||||
api_params.seconds_since_completion = (uint32_t)((now - lboard_data->submit_time) / 1000);
|
||||
}
|
||||
|
||||
result = rc_api_init_submit_lboard_entry_request(&request, &api_params);
|
||||
if (result != RC_OK) {
|
||||
RC_CLIENT_LOG_ERR_FORMATTED(lboard_data->client, "Error constructing submit leaderboard entry for leaderboard %u: %s", lboard_data->id, rc_error_str(result));
|
||||
@@ -4383,7 +4436,7 @@ static void rc_client_submit_leaderboard_entry(rc_client_t* client, rc_client_le
|
||||
callback_data->id = leaderboard->public_.id;
|
||||
callback_data->score = leaderboard->value;
|
||||
callback_data->game_hash = client->game->public_.hash;
|
||||
callback_data->submit_time = time(NULL);
|
||||
callback_data->submit_time = client->callbacks.get_time_millisecs(client);
|
||||
|
||||
RC_CLIENT_LOG_INFO_FORMATTED(client, "Submitting %s (%d) for leaderboard %u: %s",
|
||||
leaderboard->public_.tracker_value, leaderboard->value, leaderboard->public_.id, leaderboard->public_.title);
|
||||
|
||||
36
3rdparty/rcheevos/src/rc_libretro.c
vendored
36
3rdparty/rcheevos/src/rc_libretro.c
vendored
@@ -36,6 +36,17 @@ typedef struct rc_disallowed_core_settings_t
|
||||
const rc_disallowed_setting_t* disallowed_settings;
|
||||
} rc_disallowed_core_settings_t;
|
||||
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_beetle_psx_settings[] = {
|
||||
{ "beetle_psx_cpu_freq_scale", "<100" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_beetle_psx_hw_settings[] = {
|
||||
{ "beetle_psx_hw_cpu_freq_scale", "<100" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_bsnes_settings[] = {
|
||||
{ "bsnes_region", "pal" },
|
||||
{ NULL, NULL }
|
||||
@@ -80,6 +91,11 @@ static const rc_disallowed_setting_t _rc_disallowed_fceumm_settings[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_flycast_settings[] = {
|
||||
{ "reicast_sh4clock", "<200" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_gpgx_settings[] = {
|
||||
{ "genesis_plus_gx_lock_on", ",action replay (pro),game genie" },
|
||||
{ "genesis_plus_gx_region_detect", "pal" },
|
||||
@@ -108,6 +124,7 @@ static const rc_disallowed_setting_t _rc_disallowed_neocd_settings[] = {
|
||||
};
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_pcsx_rearmed_settings[] = {
|
||||
{ "pcsx_rearmed_psxclock", "<55" },
|
||||
{ "pcsx_rearmed_region", "pal" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
@@ -140,6 +157,11 @@ static const rc_disallowed_setting_t _rc_disallowed_snes9x_settings[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_swanstation_settings[] = {
|
||||
{ "swanstation_CPU_Overclock", "<100" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const rc_disallowed_setting_t _rc_disallowed_vice_settings[] = {
|
||||
{ "vice_autostart", "disabled" }, /* autostart dictates initial load and reset from menu */
|
||||
{ "vice_reset", "!autostart" }, /* reset dictates behavior when pressing reset button (END) */
|
||||
@@ -152,6 +174,8 @@ static const rc_disallowed_setting_t _rc_disallowed_virtual_jaguar_settings[] =
|
||||
};
|
||||
|
||||
static const rc_disallowed_core_settings_t rc_disallowed_core_settings[] = {
|
||||
{ "Beetle PSX", _rc_disallowed_beetle_psx_settings },
|
||||
{ "Beetle PSX HW", _rc_disallowed_beetle_psx_hw_settings },
|
||||
{ "bsnes-mercury", _rc_disallowed_bsnes_settings },
|
||||
{ "cap32", _rc_disallowed_cap32_settings },
|
||||
{ "dolphin-emu", _rc_disallowed_dolphin_settings },
|
||||
@@ -160,6 +184,7 @@ static const rc_disallowed_core_settings_t rc_disallowed_core_settings[] = {
|
||||
{ "ecwolf", _rc_disallowed_ecwolf_settings },
|
||||
{ "FCEUmm", _rc_disallowed_fceumm_settings },
|
||||
{ "FinalBurn Neo", _rc_disallowed_fbneo_settings },
|
||||
{ "Flycast", _rc_disallowed_flycast_settings },
|
||||
{ "Genesis Plus GX", _rc_disallowed_gpgx_settings },
|
||||
{ "Genesis Plus GX Wide", _rc_disallowed_gpgx_wide_settings },
|
||||
{ "Mesen", _rc_disallowed_mesen_settings },
|
||||
@@ -171,6 +196,7 @@ static const rc_disallowed_core_settings_t rc_disallowed_core_settings[] = {
|
||||
{ "QUASI88", _rc_disallowed_quasi88_settings },
|
||||
{ "SMS Plus GX", _rc_disallowed_smsplus_settings },
|
||||
{ "Snes9x", _rc_disallowed_snes9x_settings },
|
||||
{ "SwanStation", _rc_disallowed_swanstation_settings },
|
||||
{ "VICE x64", _rc_disallowed_vice_settings },
|
||||
{ "Virtual Jaguar", _rc_disallowed_virtual_jaguar_settings },
|
||||
{ NULL, NULL }
|
||||
@@ -186,6 +212,12 @@ static int rc_libretro_string_equal_nocase_wildcard(const char* test, const char
|
||||
return (*value == '\0');
|
||||
}
|
||||
|
||||
static int rc_libretro_numeric_less_than(const char* test, const char* value) {
|
||||
int test_num = atoi(test);
|
||||
int value_num = atoi(value);
|
||||
return (test_num < value_num);
|
||||
}
|
||||
|
||||
static int rc_libretro_match_value(const char* val, const char* match) {
|
||||
/* if value starts with a comma, it's a CSV list of potential matches */
|
||||
if (*match == ',') {
|
||||
@@ -218,6 +250,10 @@ static int rc_libretro_match_value(const char* val, const char* match) {
|
||||
if (*match == '!')
|
||||
return !rc_libretro_match_value(val, &match[1]);
|
||||
|
||||
/* a leading less tahn means the provided value is the minimum allowed */
|
||||
if (*match == '<')
|
||||
return rc_libretro_numeric_less_than(val, &match[1]);
|
||||
|
||||
/* just a single value, attempt to match it */
|
||||
return rc_libretro_string_equal_nocase_wildcard(val, match);
|
||||
}
|
||||
|
||||
2
3rdparty/rcheevos/src/rc_version.h
vendored
2
3rdparty/rcheevos/src/rc_version.h
vendored
@@ -8,7 +8,7 @@
|
||||
RC_BEGIN_C_DECLS
|
||||
|
||||
#define RCHEEVOS_VERSION_MAJOR 11
|
||||
#define RCHEEVOS_VERSION_MINOR 5
|
||||
#define RCHEEVOS_VERSION_MINOR 6
|
||||
#define RCHEEVOS_VERSION_PATCH 0
|
||||
|
||||
#define RCHEEVOS_MAKE_VERSION(major, minor, patch) (major * 1000000 + minor * 1000 + patch)
|
||||
|
||||
49
3rdparty/rcheevos/src/rcheevos/consoleinfo.c
vendored
49
3rdparty/rcheevos/src/rcheevos/consoleinfo.c
vendored
@@ -721,16 +721,29 @@ static const rc_memory_regions_t rc_memory_regions_n64 = { _rc_memory_regions_n6
|
||||
/* ===== Nintendo DS ===== */
|
||||
/* https://www.akkit.org/info/gbatek.htm#dsmemorymaps */
|
||||
static const rc_memory_region_t _rc_memory_regions_nintendo_ds[] = {
|
||||
{ 0x000000U, 0x3FFFFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
{ 0x0000000U, 0x03FFFFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
/* To keep DS/DSi memory maps aligned, padding is set here for the DSi's extra RAM */
|
||||
{ 0x0400000U, 0x0FFFFFFU, 0x02400000U, RC_MEMORY_TYPE_UNUSED, "Unused (DSi exclusive)" },
|
||||
/* The DS/DSi have "tightly coupled memory": very fast memory directly connected to the CPU.
|
||||
* This memory has an instruction variant (ITCM) and a data variant (DTCM).
|
||||
* For achievement purposes it is useful to be able to access the data variant.
|
||||
* This memory does not have a fixed address on console, being able to be moved to any $0xxxx000 region.
|
||||
* While normally this kind of memory is addressed outside of the possible native addressing space, this is simply not possible,
|
||||
* as the DS/DSi's address space covers all possible uint32_t values.
|
||||
* $0E000000 is used here as a "pseudo-end," as this is nearly the end of all the memory actually mapped to addresses
|
||||
* This means that (with the exception of $FFFF0000 onwards, which has the ARM9 BIOS mapped) $0E000000 onwards has nothing mapped to it
|
||||
*/
|
||||
{ 0x1000000U, 0x1003FFFU, 0x0E000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Data TCM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_nintendo_ds = { _rc_memory_regions_nintendo_ds, 1 };
|
||||
static const rc_memory_regions_t rc_memory_regions_nintendo_ds = { _rc_memory_regions_nintendo_ds, 3 };
|
||||
|
||||
/* ===== Nintendo DSi ===== */
|
||||
/* https://problemkaputt.de/gbatek.htm#dsiiomap */
|
||||
static const rc_memory_region_t _rc_memory_regions_nintendo_dsi[] = {
|
||||
{ 0x000000U, 0xFFFFFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }
|
||||
{ 0x0000000U, 0x0FFFFFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" },
|
||||
{ 0x1000000U, 0x1003FFFU, 0x0E000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Data TCM" }
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_nintendo_dsi = { _rc_memory_regions_nintendo_dsi, 1 };
|
||||
static const rc_memory_regions_t rc_memory_regions_nintendo_dsi = { _rc_memory_regions_nintendo_dsi, 2 };
|
||||
|
||||
/* ===== Oric ===== */
|
||||
static const rc_memory_region_t _rc_memory_regions_oric[] = {
|
||||
@@ -956,6 +969,31 @@ static const rc_memory_region_t _rc_memory_regions_wonderswan[] = {
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_wonderswan = { _rc_memory_regions_wonderswan, 2 };
|
||||
|
||||
/* ===== ZX Spectrum ===== */
|
||||
/* https://github.com/TASEmulators/BizHawk/blob/3a3b22c/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum16K/ZX16.cs
|
||||
* https://github.com/TASEmulators/BizHawk/blob/3a3b22c/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs
|
||||
* https://worldofspectrum.org/faq/reference/128kreference.htm */
|
||||
static const rc_memory_region_t _rc_memory_regions_zx_spectrum[] = {
|
||||
/* ZX Spectrum is complicated as multiple models exist with varying amounts of memory.
|
||||
* In practice, this can be reduced to two categories: 16K/48K units, and 128K units.
|
||||
* 16K/48K units have RAM starting at $4000 onwards, 16K ending at $7FFF, 48K ending at $FFFF.
|
||||
* 128K units have banked memory, with $4000-$7FFF normally having RAM bank 5, and $8000-$BFFF normally having RAM bank 2.
|
||||
* $C000-$FFFF is normally reserved for banked RAM, having any of banks 0-7.
|
||||
* For the purposes of the RAM map, $C000-$FFFF is assumed to be bank 0, and $10000 onwards has the other banks in order (1, 3, 4, 6, 7)
|
||||
* Doing it this way always for 16K/48K games to have the same memory map on the 128K, and thus avoid issues due to the model selected.
|
||||
* Later 128K units also have a special banking mode that changes up banking completely, but for 16K/48K compatibility purposes this doesn't matter, and so is irrelevant.
|
||||
*/
|
||||
{ 0x00000U, 0x03FFFU, 0x04000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Screen RAM" }, /* RAM bank 5 on 128K units */
|
||||
{ 0x04000U, 0x07FFFU, 0x08000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RAM bank 2 on 128K units */
|
||||
{ 0x08000U, 0x0BFFFU, 0x0C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RAM bank 0-7 on 128K units, assumed to be bank 0 here */
|
||||
{ 0x0C000U, 0x0FFFFU, 0x10000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RAM bank 1 on 128K units */
|
||||
{ 0x10000U, 0x13FFFU, 0x14000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RAM bank 3 on 128K units */
|
||||
{ 0x14000U, 0x17FFFU, 0x18000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RAM bank 4 on 128K units */
|
||||
{ 0x18000U, 0x1BFFFU, 0x1C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RAM bank 6 on 128K units */
|
||||
{ 0x1C000U, 0x1FFFFU, 0x20000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Screen RAM" } /* RAM bank 7 on 128K units */
|
||||
};
|
||||
static const rc_memory_regions_t rc_memory_regions_zx_spectrum = { _rc_memory_regions_zx_spectrum, 8 };
|
||||
|
||||
/* ===== default ===== */
|
||||
static const rc_memory_regions_t rc_memory_regions_none = { 0, 0 };
|
||||
|
||||
@@ -1141,6 +1179,9 @@ const rc_memory_regions_t* rc_console_memory_regions(uint32_t console_id)
|
||||
case RC_CONSOLE_WONDERSWAN:
|
||||
return &rc_memory_regions_wonderswan;
|
||||
|
||||
case RC_CONSOLE_ZX_SPECTRUM:
|
||||
return &rc_memory_regions_zx_spectrum;
|
||||
|
||||
default:
|
||||
return &rc_memory_regions_none;
|
||||
}
|
||||
|
||||
16
3rdparty/rcheevos/src/rcheevos/lboard.c
vendored
16
3rdparty/rcheevos/src/rcheevos/lboard.c
vendored
@@ -199,19 +199,19 @@ int rc_evaluate_lboard(rc_lboard_t* self, int32_t* value, rc_peek_t peek, void*
|
||||
/* start and submit are both true in the same frame, just submit without announcing the leaderboard is available */
|
||||
self->state = RC_LBOARD_STATE_TRIGGERED;
|
||||
}
|
||||
else if (self->start.requirement == 0 && self->start.alternative == 0) {
|
||||
/* start condition is empty - this leaderboard is submit-only with no measured progress */
|
||||
else if (!self->start.requirement && !self->start.alternative) {
|
||||
/* start trigger is empty. assume the leaderboard is in development and ignore */
|
||||
}
|
||||
else {
|
||||
/* start the leaderboard attempt */
|
||||
self->state = RC_LBOARD_STATE_STARTED;
|
||||
|
||||
/* reset any hit counts in the value */
|
||||
if (self->progress)
|
||||
rc_reset_value(self->progress);
|
||||
|
||||
rc_reset_value(&self->value);
|
||||
}
|
||||
|
||||
/* reset any hit counts in the value */
|
||||
if (self->progress)
|
||||
rc_reset_value(self->progress);
|
||||
|
||||
rc_reset_value(&self->value);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
34
3rdparty/rcheevos/src/rcheevos/rc_validate.c
vendored
34
3rdparty/rcheevos/src/rcheevos/rc_validate.c
vendored
@@ -726,6 +726,7 @@ static int rc_validate_conflicting_conditions(const rc_condset_t* conditions, co
|
||||
const rc_condition_t* condition;
|
||||
const rc_condition_t* condition_chain_start;
|
||||
int overlap;
|
||||
int chain_matches;
|
||||
|
||||
/* empty group */
|
||||
if (conditions == NULL || compare_conditions == NULL)
|
||||
@@ -777,9 +778,9 @@ static int rc_validate_conflicting_conditions(const rc_condset_t* conditions, co
|
||||
|
||||
/* if combining conditions exist, make sure the same combining conditions exist in the
|
||||
* compare logic. conflicts can only occur if the combinining conditions match. */
|
||||
chain_matches = 1;
|
||||
if (condition_chain_start != condition)
|
||||
{
|
||||
int chain_matches = 1;
|
||||
const rc_condition_t* condition_chain_iter = condition_chain_start;
|
||||
while (condition_chain_iter != condition)
|
||||
{
|
||||
@@ -795,11 +796,8 @@ static int rc_validate_conflicting_conditions(const rc_condset_t* conditions, co
|
||||
if (compare_condition->oper != RC_OPERATOR_NONE &&
|
||||
!rc_validate_are_operands_equal(&compare_condition->operand2, &condition_chain_iter->operand2))
|
||||
{
|
||||
if (compare_condition->operand2.type != condition_chain_iter->operand2.type)
|
||||
{
|
||||
chain_matches = 0;
|
||||
break;
|
||||
}
|
||||
chain_matches = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!compare_condition->next)
|
||||
@@ -808,17 +806,27 @@ static int rc_validate_conflicting_conditions(const rc_condset_t* conditions, co
|
||||
break;
|
||||
}
|
||||
|
||||
if (compare_condition->type != RC_CONDITION_ADD_ADDRESS &&
|
||||
compare_condition->type != RC_CONDITION_ADD_SOURCE &&
|
||||
compare_condition->type != RC_CONDITION_SUB_SOURCE &&
|
||||
compare_condition->type != RC_CONDITION_AND_NEXT)
|
||||
{
|
||||
/* things like AddHits and OrNext are hard to definitively detect conflicts. ignore them. */
|
||||
chain_matches = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
compare_condition = compare_condition->next;
|
||||
condition_chain_iter = condition_chain_iter->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* combining field didn't match, or there's more unmatched combining fields. ignore this condition */
|
||||
if (!chain_matches || rc_validate_is_combining_condition(compare_condition))
|
||||
{
|
||||
while (compare_condition->next && rc_validate_is_combining_condition(compare_condition))
|
||||
compare_condition = compare_condition->next;
|
||||
continue;
|
||||
}
|
||||
/* combining field didn't match, or there's more unmatched combining fields. ignore this condition */
|
||||
if (!chain_matches || rc_validate_is_combining_condition(compare_condition))
|
||||
{
|
||||
while (compare_condition->next && rc_validate_is_combining_condition(compare_condition))
|
||||
compare_condition = compare_condition->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (compare_condition->required_hits)
|
||||
|
||||
@@ -360,6 +360,9 @@ static const char* rc_parse_richpresence_lookup(rc_richpresence_lookup_t* lookup
|
||||
do
|
||||
{
|
||||
line = nextline;
|
||||
if (line == NULL)
|
||||
break;
|
||||
|
||||
nextline = rc_parse_line(line, &endline, parse);
|
||||
|
||||
if (endline - line < 2) {
|
||||
@@ -438,6 +441,9 @@ static const char* rc_parse_richpresence_lookup(rc_richpresence_lookup_t* lookup
|
||||
|
||||
/* insert the current item and continue scanning the next one */
|
||||
rc_insert_richpresence_lookup_item(lookup, first, last, label, (int)(endline - label), parse);
|
||||
if (parse->offset < 0)
|
||||
break;
|
||||
|
||||
line = endptr + 1;
|
||||
} while (line < endline);
|
||||
|
||||
|
||||
25
3rdparty/rcheevos/src/rhash/hash.c
vendored
25
3rdparty/rcheevos/src/rhash/hash.c
vendored
@@ -3113,6 +3113,7 @@ int rc_hash_generate_from_buffer(char hash[33], uint32_t console_id, const uint8
|
||||
case RC_CONSOLE_VIRTUAL_BOY:
|
||||
case RC_CONSOLE_WASM4:
|
||||
case RC_CONSOLE_WONDERSWAN:
|
||||
case RC_CONSOLE_ZX_SPECTRUM:
|
||||
return rc_hash_buffer(hash, buffer, buffer_size);
|
||||
|
||||
case RC_CONSOLE_ARDUBOY:
|
||||
@@ -3411,6 +3412,7 @@ int rc_hash_generate_from_file(char hash[33], uint32_t console_id, const char* p
|
||||
case RC_CONSOLE_VIRTUAL_BOY:
|
||||
case RC_CONSOLE_WASM4:
|
||||
case RC_CONSOLE_WONDERSWAN:
|
||||
case RC_CONSOLE_ZX_SPECTRUM:
|
||||
/* generic whole-file hash - don't buffer */
|
||||
return rc_hash_whole_file(hash, path);
|
||||
|
||||
@@ -3466,6 +3468,9 @@ int rc_hash_generate_from_file(char hash[33], uint32_t console_id, const char* p
|
||||
case RC_CONSOLE_NINTENDO_64:
|
||||
return rc_hash_n64(hash, path);
|
||||
|
||||
case RC_CONSOLE_NINTENDO_3DS:
|
||||
return rc_hash_nintendo_3ds(hash, path);
|
||||
|
||||
case RC_CONSOLE_NINTENDO_DS:
|
||||
case RC_CONSOLE_NINTENDO_DSI:
|
||||
return rc_hash_nintendo_ds(hash, path);
|
||||
@@ -3573,6 +3578,7 @@ static void rc_hash_initialize_dsk_iterator(struct rc_hash_iterator* iterator, c
|
||||
/* check MSX first, as Apple II isn't supported by RetroArch, and RAppleWin won't use the iterator */
|
||||
rc_hash_iterator_append_console(iterator, RC_CONSOLE_MSX);
|
||||
rc_hash_iterator_append_console(iterator, RC_CONSOLE_AMSTRAD_PC);
|
||||
rc_hash_iterator_append_console(iterator, RC_CONSOLE_ZX_SPECTRUM);
|
||||
rc_hash_iterator_append_console(iterator, RC_CONSOLE_APPLE_II);
|
||||
}
|
||||
|
||||
@@ -3725,6 +3731,10 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_NINTENDO_3DS;
|
||||
}
|
||||
else if (rc_path_compare_extension(ext, "csw"))
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
@@ -3808,6 +3818,7 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
|
||||
iterator->consoles[1] = RC_CONSOLE_PSP;
|
||||
iterator->consoles[2] = RC_CONSOLE_3DO;
|
||||
iterator->consoles[3] = RC_CONSOLE_SEGA_CD; /* ASSERT: handles both Sega CD and Saturn */
|
||||
iterator->consoles[4] = RC_CONSOLE_GAMECUBE;
|
||||
need_path = 1;
|
||||
}
|
||||
break;
|
||||
@@ -3909,6 +3920,10 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_ELEKTOR_TV_GAMES_COMPUTER;
|
||||
}
|
||||
else if (rc_path_compare_extension(ext, "pzx"))
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
@@ -3947,11 +3962,16 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_THOMSONTO8; /* disk */
|
||||
}
|
||||
else if (rc_path_compare_extension(ext, "scl"))
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
|
||||
}
|
||||
break;
|
||||
|
||||
case 't':
|
||||
if (rc_path_compare_extension(ext, "tap"))
|
||||
{
|
||||
/* also Commodore 64 and ZX Spectrum, but all are full file hashes */
|
||||
iterator->consoles[0] = RC_CONSOLE_ORIC;
|
||||
}
|
||||
else if (rc_path_compare_extension(ext, "tic"))
|
||||
@@ -3962,6 +3982,11 @@ void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char*
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_ELEKTOR_TV_GAMES_COMPUTER;
|
||||
}
|
||||
else if (rc_path_compare_extension(ext, "trd") ||
|
||||
rc_path_compare_extension(ext, "tzx"))
|
||||
{
|
||||
iterator->consoles[0] = RC_CONSOLE_ZX_SPECTRUM;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
|
||||
@@ -132,7 +132,7 @@ typedef enum StdVideoAV1FrameRestorationType {
|
||||
|
||||
typedef enum StdVideoAV1ColorPrimaries {
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_709 = 1,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_UNSPECIFIED = 2,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_UNSPECIFIED = 2,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_470_M = 4,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_470_B_G = 5,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_601 = 6,
|
||||
@@ -144,6 +144,8 @@ typedef enum StdVideoAV1ColorPrimaries {
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_SMPTE_432 = 12,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_EBU_3213 = 22,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_INVALID = 0x7FFFFFFF,
|
||||
// STD_VIDEO_AV1_COLOR_PRIMARIES_BT_UNSPECIFIED is a deprecated alias
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_UNSPECIFIED = STD_VIDEO_AV1_COLOR_PRIMARIES_UNSPECIFIED,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1ColorPrimaries;
|
||||
|
||||
|
||||
143
3rdparty/vulkan/include/vk_video/vulkan_video_codec_av1std_encode.h
vendored
Normal file
143
3rdparty/vulkan/include/vk_video/vulkan_video_codec_av1std_encode.h
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_AV1STD_ENCODE_H_
|
||||
#define VULKAN_VIDEO_CODEC_AV1STD_ENCODE_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_av1std_encode is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_av1std_encode 1
|
||||
#include "vulkan_video_codec_av1std.h"
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0)
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_API_VERSION_1_0_0
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_av1_encode"
|
||||
typedef struct StdVideoEncodeAV1DecoderModelInfo {
|
||||
uint8_t buffer_delay_length_minus_1;
|
||||
uint8_t buffer_removal_time_length_minus_1;
|
||||
uint8_t frame_presentation_time_length_minus_1;
|
||||
uint8_t reserved1;
|
||||
uint32_t num_units_in_decoding_tick;
|
||||
} StdVideoEncodeAV1DecoderModelInfo;
|
||||
|
||||
typedef struct StdVideoEncodeAV1ExtensionHeader {
|
||||
uint8_t temporal_id;
|
||||
uint8_t spatial_id;
|
||||
} StdVideoEncodeAV1ExtensionHeader;
|
||||
|
||||
typedef struct StdVideoEncodeAV1OperatingPointInfoFlags {
|
||||
uint32_t decoder_model_present_for_this_op : 1;
|
||||
uint32_t low_delay_mode_flag : 1;
|
||||
uint32_t initial_display_delay_present_for_this_op : 1;
|
||||
uint32_t reserved : 29;
|
||||
} StdVideoEncodeAV1OperatingPointInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeAV1OperatingPointInfo {
|
||||
StdVideoEncodeAV1OperatingPointInfoFlags flags;
|
||||
uint16_t operating_point_idc;
|
||||
uint8_t seq_level_idx;
|
||||
uint8_t seq_tier;
|
||||
uint32_t decoder_buffer_delay;
|
||||
uint32_t encoder_buffer_delay;
|
||||
uint8_t initial_display_delay_minus_1;
|
||||
} StdVideoEncodeAV1OperatingPointInfo;
|
||||
|
||||
typedef struct StdVideoEncodeAV1PictureInfoFlags {
|
||||
uint32_t error_resilient_mode : 1;
|
||||
uint32_t disable_cdf_update : 1;
|
||||
uint32_t use_superres : 1;
|
||||
uint32_t render_and_frame_size_different : 1;
|
||||
uint32_t allow_screen_content_tools : 1;
|
||||
uint32_t is_filter_switchable : 1;
|
||||
uint32_t force_integer_mv : 1;
|
||||
uint32_t frame_size_override_flag : 1;
|
||||
uint32_t buffer_removal_time_present_flag : 1;
|
||||
uint32_t allow_intrabc : 1;
|
||||
uint32_t frame_refs_short_signaling : 1;
|
||||
uint32_t allow_high_precision_mv : 1;
|
||||
uint32_t is_motion_mode_switchable : 1;
|
||||
uint32_t use_ref_frame_mvs : 1;
|
||||
uint32_t disable_frame_end_update_cdf : 1;
|
||||
uint32_t allow_warped_motion : 1;
|
||||
uint32_t reduced_tx_set : 1;
|
||||
uint32_t skip_mode_present : 1;
|
||||
uint32_t delta_q_present : 1;
|
||||
uint32_t delta_lf_present : 1;
|
||||
uint32_t delta_lf_multi : 1;
|
||||
uint32_t segmentation_enabled : 1;
|
||||
uint32_t segmentation_update_map : 1;
|
||||
uint32_t segmentation_temporal_update : 1;
|
||||
uint32_t segmentation_update_data : 1;
|
||||
uint32_t UsesLr : 1;
|
||||
uint32_t usesChromaLr : 1;
|
||||
uint32_t show_frame : 1;
|
||||
uint32_t showable_frame : 1;
|
||||
uint32_t reserved : 3;
|
||||
} StdVideoEncodeAV1PictureInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeAV1PictureInfo {
|
||||
StdVideoEncodeAV1PictureInfoFlags flags;
|
||||
StdVideoAV1FrameType frame_type;
|
||||
uint32_t frame_presentation_time;
|
||||
uint32_t current_frame_id;
|
||||
uint8_t order_hint;
|
||||
uint8_t primary_ref_frame;
|
||||
uint8_t refresh_frame_flags;
|
||||
uint8_t coded_denom;
|
||||
uint16_t render_width_minus_1;
|
||||
uint16_t render_height_minus_1;
|
||||
StdVideoAV1InterpolationFilter interpolation_filter;
|
||||
StdVideoAV1TxMode TxMode;
|
||||
uint8_t delta_q_res;
|
||||
uint8_t delta_lf_res;
|
||||
uint8_t ref_order_hint[STD_VIDEO_AV1_NUM_REF_FRAMES];
|
||||
int8_t ref_frame_idx[STD_VIDEO_AV1_REFS_PER_FRAME];
|
||||
uint8_t reserved1[3];
|
||||
uint32_t delta_frame_id_minus_1[STD_VIDEO_AV1_REFS_PER_FRAME];
|
||||
const StdVideoAV1TileInfo* pTileInfo;
|
||||
const StdVideoAV1Quantization* pQuantization;
|
||||
const StdVideoAV1Segmentation* pSegmentation;
|
||||
const StdVideoAV1LoopFilter* pLoopFilter;
|
||||
const StdVideoAV1CDEF* pCDEF;
|
||||
const StdVideoAV1LoopRestoration* pLoopRestoration;
|
||||
const StdVideoAV1GlobalMotion* pGlobalMotion;
|
||||
const StdVideoEncodeAV1ExtensionHeader* pExtensionHeader;
|
||||
const uint32_t* pBufferRemovalTimes;
|
||||
} StdVideoEncodeAV1PictureInfo;
|
||||
|
||||
typedef struct StdVideoEncodeAV1ReferenceInfoFlags {
|
||||
uint32_t disable_frame_end_update_cdf : 1;
|
||||
uint32_t segmentation_enabled : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoEncodeAV1ReferenceInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeAV1ReferenceInfo {
|
||||
StdVideoEncodeAV1ReferenceInfoFlags flags;
|
||||
uint32_t RefFrameId;
|
||||
StdVideoAV1FrameType frame_type;
|
||||
uint8_t OrderHint;
|
||||
uint8_t reserved1[3];
|
||||
const StdVideoEncodeAV1ExtensionHeader* pExtensionHeader;
|
||||
} StdVideoEncodeAV1ReferenceInfo;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
28
3rdparty/vulkan/include/vulkan/vulkan_beta.h
vendored
28
3rdparty/vulkan/include/vulkan/vulkan_beta.h
vendored
@@ -53,13 +53,14 @@ typedef struct VkPhysicalDevicePortabilitySubsetPropertiesKHR {
|
||||
|
||||
// VK_AMDX_shader_enqueue is a preprocessor guard. Do not pass it to API calls.
|
||||
#define VK_AMDX_shader_enqueue 1
|
||||
#define VK_AMDX_SHADER_ENQUEUE_SPEC_VERSION 1
|
||||
#define VK_AMDX_SHADER_ENQUEUE_SPEC_VERSION 2
|
||||
#define VK_AMDX_SHADER_ENQUEUE_EXTENSION_NAME "VK_AMDX_shader_enqueue"
|
||||
#define VK_SHADER_INDEX_UNUSED_AMDX (~0U)
|
||||
typedef struct VkPhysicalDeviceShaderEnqueueFeaturesAMDX {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 shaderEnqueue;
|
||||
VkBool32 shaderMeshEnqueue;
|
||||
} VkPhysicalDeviceShaderEnqueueFeaturesAMDX;
|
||||
|
||||
typedef struct VkPhysicalDeviceShaderEnqueuePropertiesAMDX {
|
||||
@@ -70,12 +71,16 @@ typedef struct VkPhysicalDeviceShaderEnqueuePropertiesAMDX {
|
||||
uint32_t maxExecutionGraphShaderPayloadSize;
|
||||
uint32_t maxExecutionGraphShaderPayloadCount;
|
||||
uint32_t executionGraphDispatchAddressAlignment;
|
||||
uint32_t maxExecutionGraphWorkgroupCount[3];
|
||||
uint32_t maxExecutionGraphWorkgroups;
|
||||
} VkPhysicalDeviceShaderEnqueuePropertiesAMDX;
|
||||
|
||||
typedef struct VkExecutionGraphPipelineScratchSizeAMDX {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkDeviceSize size;
|
||||
VkDeviceSize minSize;
|
||||
VkDeviceSize maxSize;
|
||||
VkDeviceSize sizeGranularity;
|
||||
} VkExecutionGraphPipelineScratchSizeAMDX;
|
||||
|
||||
typedef struct VkExecutionGraphPipelineCreateInfoAMDX {
|
||||
@@ -116,12 +121,12 @@ typedef struct VkPipelineShaderStageNodeCreateInfoAMDX {
|
||||
} VkPipelineShaderStageNodeCreateInfoAMDX;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateExecutionGraphPipelinesAMDX)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkExecutionGraphPipelineCreateInfoAMDX* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineScratchSizeAMDX)(VkDevice device, VkPipeline executionGraph, VkExecutionGraphPipelineScratchSizeAMDX* pSizeInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineNodeIndexAMDX)(VkDevice device, VkPipeline executionGraph, const VkPipelineShaderStageNodeCreateInfoAMDX* pNodeInfo, uint32_t* pNodeIndex);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdInitializeGraphScratchMemoryAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, const VkDispatchGraphCountInfoAMDX* pCountInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, const VkDispatchGraphCountInfoAMDX* pCountInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectCountAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, VkDeviceAddress countInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineScratchSizeAMDX)(VkDevice device, VkPipeline executionGraph, VkExecutionGraphPipelineScratchSizeAMDX* pSizeInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineNodeIndexAMDX)(VkDevice device, VkPipeline executionGraph, const VkPipelineShaderStageNodeCreateInfoAMDX* pNodeInfo, uint32_t* pNodeIndex);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdInitializeGraphScratchMemoryAMDX)(VkCommandBuffer commandBuffer, VkPipeline executionGraph, VkDeviceAddress scratch, VkDeviceSize scratchSize);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, VkDeviceSize scratchSize, const VkDispatchGraphCountInfoAMDX* pCountInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, VkDeviceSize scratchSize, const VkDispatchGraphCountInfoAMDX* pCountInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectCountAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, VkDeviceSize scratchSize, VkDeviceAddress countInfo);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateExecutionGraphPipelinesAMDX(
|
||||
@@ -145,21 +150,26 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetExecutionGraphPipelineNodeIndexAMDX(
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdInitializeGraphScratchMemoryAMDX(
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkDeviceAddress scratch);
|
||||
VkPipeline executionGraph,
|
||||
VkDeviceAddress scratch,
|
||||
VkDeviceSize scratchSize);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphAMDX(
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkDeviceAddress scratch,
|
||||
VkDeviceSize scratchSize,
|
||||
const VkDispatchGraphCountInfoAMDX* pCountInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphIndirectAMDX(
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkDeviceAddress scratch,
|
||||
VkDeviceSize scratchSize,
|
||||
const VkDispatchGraphCountInfoAMDX* pCountInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphIndirectCountAMDX(
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkDeviceAddress scratch,
|
||||
VkDeviceSize scratchSize,
|
||||
VkDeviceAddress countInfo);
|
||||
#endif
|
||||
|
||||
|
||||
2308
3rdparty/vulkan/include/vulkan/vulkan_core.h
vendored
2308
3rdparty/vulkan/include/vulkan/vulkan_core.h
vendored
File diff suppressed because it is too large
Load Diff
330
3rdparty/winwil/include/wil/Tracelogging.h
vendored
330
3rdparty/winwil/include/wil/Tracelogging.h
vendored
File diff suppressed because it is too large
Load Diff
6
3rdparty/winwil/include/wil/com.h
vendored
6
3rdparty/winwil/include/wil/com.h
vendored
@@ -2398,7 +2398,7 @@ RETURN_IF_FAILED(wil::stream_seek_nothrow(source, LLONG_MAX, STREAM_SEEK_CUR));
|
||||
@param stream The stream to seek
|
||||
@param offset The position, in bytes from the current position, to seek
|
||||
@param from The starting point from which to seek, from the STREAM_SEEK_* set of values
|
||||
@param value Optionally recieves the new absolute position from the stream
|
||||
@param value Optionally receives the new absolute position from the stream
|
||||
*/
|
||||
inline HRESULT stream_seek_nothrow(_In_ IStream* stream, long long offset, unsigned long from, _Out_opt_ unsigned long long* value = nullptr)
|
||||
{
|
||||
@@ -2418,7 +2418,7 @@ RETURN_HR(wil::stream_set_position_nothrow(source, 16));
|
||||
~~~~
|
||||
@param stream The stream whose size is to be returned in `value`
|
||||
@param offset The position, in bytes from the start of the stream, to seek to
|
||||
@param value Optionally recieves the new absolute position from the stream
|
||||
@param value Optionally receives the new absolute position from the stream
|
||||
*/
|
||||
inline HRESULT stream_set_position_nothrow(_In_ IStream* stream, unsigned long long offset, _Out_opt_ unsigned long long* value = nullptr)
|
||||
{
|
||||
@@ -2888,7 +2888,7 @@ if (wcscmp(content.get(), L"waffles") == 0)
|
||||
@endcode
|
||||
@param source The stream from which to read a string
|
||||
@param options Controls the behavior when reading a zero-length string
|
||||
@return An non-null string (but possibly zero lengh) string read from `source`
|
||||
@return An non-null string (but possibly zero length) string read from `source`
|
||||
*/
|
||||
inline wil::unique_cotaskmem_string stream_read_string(_In_ ISequentialStream* source, empty_string_options options = empty_string_options::returns_empty)
|
||||
{
|
||||
|
||||
31
3rdparty/winwil/include/wil/common.h
vendored
31
3rdparty/winwil/include/wil/common.h
vendored
@@ -526,7 +526,7 @@ to be able to layer additional functionality into other libraries by their mere
|
||||
of initialization should be used whenever they are available.
|
||||
~~~~
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
|
||||
{
|
||||
g_pfnGetModuleName = GetCurrentModuleName;
|
||||
g_pfnFailFastInLoaderCallout = FailFastInLoaderCallout;
|
||||
@@ -537,16 +537,16 @@ WI_HEADER_INITITALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
|
||||
The above example is used within WIL to decide whether or not the library containing WIL is allowed to use
|
||||
desktop APIs. Building this functionality as `#IFDEF`s within functions would create ODR violations, whereas
|
||||
doing it with global function pointers and header initialization allows a runtime determination. */
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn)
|
||||
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn)
|
||||
#elif defined(_M_IX86)
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) \
|
||||
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) \
|
||||
extern "C" \
|
||||
{ \
|
||||
__declspec(selectany) unsigned char g_header_init_##name = static_cast<unsigned char>(fn()); \
|
||||
} \
|
||||
__pragma(comment(linker, "/INCLUDE:_g_header_init_" #name))
|
||||
#elif defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64)
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) \
|
||||
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) \
|
||||
extern "C" \
|
||||
{ \
|
||||
__declspec(selectany) unsigned char g_header_init_##name = static_cast<unsigned char>(fn()); \
|
||||
@@ -556,6 +556,9 @@ doing it with global function pointers and header initialization allows a runtim
|
||||
#error linker pragma must include g_header_init variation
|
||||
#endif
|
||||
|
||||
// Keep the misspelled name for backward compatibility.
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) WI_HEADER_INITIALIZATION_FUNCTION(name, fn)
|
||||
|
||||
/** All Windows Implementation Library classes and functions are located within the "wil" namespace.
|
||||
The 'wil' namespace is an intentionally short name as the intent is for code to be able to reference
|
||||
the namespace directly (example: `wil::srwlock lock;`) without a using statement. Resist adding a using
|
||||
@@ -687,32 +690,32 @@ boolean, BOOLEAN, and classes with an explicit bool cast.
|
||||
@param val The logical bool expression
|
||||
@return A C++ bool representing the evaluation of `val`. */
|
||||
template <typename T, __R_ENABLE_IF_IS_CLASS(T)>
|
||||
_Post_satisfies_(return == static_cast<bool>(val)) __forceinline constexpr bool verify_bool(const T& val)
|
||||
_Post_satisfies_(return == static_cast<bool>(val)) __forceinline constexpr bool verify_bool(const T& val) WI_NOEXCEPT
|
||||
{
|
||||
return static_cast<bool>(val);
|
||||
}
|
||||
|
||||
template <typename T, __R_ENABLE_IF_IS_NOT_CLASS(T)>
|
||||
__forceinline constexpr bool verify_bool(T /*val*/)
|
||||
__forceinline constexpr bool verify_bool(T /*val*/) WI_NOEXCEPT
|
||||
{
|
||||
static_assert(!wistd::is_same<T, T>::value, "Wrong Type: bool/BOOL/BOOLEAN/boolean expected");
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
_Post_satisfies_(return == val) __forceinline constexpr bool verify_bool<bool>(bool val)
|
||||
_Post_satisfies_(return == val) __forceinline constexpr bool verify_bool<bool>(bool val) WI_NOEXCEPT
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
template <>
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<int>(int val)
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<int>(int val) WI_NOEXCEPT
|
||||
{
|
||||
return (val != 0);
|
||||
}
|
||||
|
||||
template <>
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<unsigned char>(unsigned char val)
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<unsigned char>(unsigned char val) WI_NOEXCEPT
|
||||
{
|
||||
return (val != 0);
|
||||
}
|
||||
@@ -723,7 +726,7 @@ accept any `int` value as long as that is the underlying typedef behind `BOOL`.
|
||||
@param val The Win32 BOOL returning expression
|
||||
@return A Win32 BOOL representing the evaluation of `val`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == val) __forceinline constexpr int verify_BOOL(T val)
|
||||
_Post_satisfies_(return == val) __forceinline constexpr int verify_BOOL(T val) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Written in terms of 'int' as BOOL is actually: typedef int BOOL;
|
||||
static_assert((wistd::is_same<T, int>::value), "Wrong Type: BOOL expected");
|
||||
@@ -752,7 +755,7 @@ RETURN_HR_IF(static_cast<HRESULT>(UIA_E_NOTSUPPORTED), (patternId != UIA_DragPat
|
||||
@param hr The HRESULT returning expression
|
||||
@return An HRESULT representing the evaluation of `val`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == hr) inline constexpr long verify_hresult(T hr)
|
||||
_Post_satisfies_(return == hr) inline constexpr long verify_hresult(T hr) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Written in terms of 'long' as HRESULT is actually: typedef _Return_type_success_(return >= 0) long HRESULT
|
||||
static_assert(wistd::is_same<T, long>::value, "Wrong Type: HRESULT expected");
|
||||
@@ -781,7 +784,7 @@ NT_RETURN_IF_FALSE(static_cast<NTSTATUS>(STATUS_NOT_SUPPORTED), (dispatch->Versi
|
||||
@param status The NTSTATUS returning expression
|
||||
@return An NTSTATUS representing the evaluation of `val`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == status) inline long verify_ntstatus(T status)
|
||||
_Post_satisfies_(return == status) inline long verify_ntstatus(T status) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Written in terms of 'long' as NTSTATUS is actually: typedef _Return_type_success_(return >= 0) long NTSTATUS
|
||||
static_assert(wistd::is_same<T, long>::value, "Wrong Type: NTSTATUS expected");
|
||||
@@ -795,7 +798,7 @@ commonly used when manipulating Win32 error codes.
|
||||
@param error The Win32 error code returning expression
|
||||
@return An Win32 error code representing the evaluation of `error`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == error) inline T verify_win32(T error)
|
||||
_Post_satisfies_(return == error) inline T verify_win32(T error) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Win32 error code are defined as 'long' (#define ERROR_SUCCESS 0L), but are more frequently used as DWORD (unsigned
|
||||
// long). This accept both types.
|
||||
@@ -810,7 +813,7 @@ _Post_satisfies_(return == error) inline T verify_win32(T error)
|
||||
// Implementation details for macros and helper functions... do not use directly.
|
||||
namespace details
|
||||
{
|
||||
// Use size-specific casts to avoid sign extending numbers -- avoid warning C4310: cast truncates constant value
|
||||
// Use size-specific casts to avoid sign extending numbers -- avoid warning C4310: cast truncates constant value
|
||||
#define __WI_MAKE_UNSIGNED(val) \
|
||||
(__pragma(warning(push)) __pragma(warning(disable : 4310 4309))( \
|
||||
sizeof(val) == 1 ? static_cast<unsigned char>(val) \
|
||||
|
||||
10
3rdparty/winwil/include/wil/coroutine.h
vendored
10
3rdparty/winwil/include/wil/coroutine.h
vendored
@@ -191,7 +191,7 @@ struct com_task;
|
||||
/// @cond
|
||||
namespace wil::details::coro
|
||||
{
|
||||
// task and com_task are convertable to each other. However, not
|
||||
// task and com_task are convertible to each other. However, not
|
||||
// all consumers of this header have COM enabled. Support for saving
|
||||
// COM thread-local error information and restoring it on the resuming
|
||||
// thread is enabled using these function pointers. If COM is not
|
||||
@@ -764,8 +764,8 @@ inline void __stdcall DestroyRestrictedErrorInformation(_In_ void* restricted_er
|
||||
|
||||
struct apartment_info
|
||||
{
|
||||
APTTYPE aptType;
|
||||
APTTYPEQUALIFIER aptTypeQualifier;
|
||||
APTTYPE aptType{};
|
||||
APTTYPEQUALIFIER aptTypeQualifier{};
|
||||
|
||||
void load()
|
||||
{
|
||||
@@ -814,7 +814,7 @@ struct apartment_resumer
|
||||
|
||||
__WI_COROUTINE_NAMESPACE::coroutine_handle<> waiter;
|
||||
wil::com_ptr<IContextCallback> context{nullptr};
|
||||
apartment_info info;
|
||||
apartment_info info{};
|
||||
HRESULT resume_result = S_OK;
|
||||
|
||||
void capture_context(__WI_COROUTINE_NAMESPACE::coroutine_handle<> handle)
|
||||
@@ -925,7 +925,7 @@ auto task_base<T>::resume_same_apartment() && noexcept
|
||||
|
||||
// This section is lit up when COM headers are available. Initialize the global function
|
||||
// pointers such that error information can be saved and restored across thread boundaries.
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(CoroutineRestrictedErrorInitialize, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(CoroutineRestrictedErrorInitialize, [] {
|
||||
::wil::details::coro::g_pfnCaptureRestrictedErrorInformation = ::wil::details::coro::CaptureRestrictedErrorInformation;
|
||||
::wil::details::coro::g_pfnRestoreRestrictedErrorInformation = ::wil::details::coro::RestoreRestrictedErrorInformation;
|
||||
::wil::details::coro::g_pfnDestroyRestrictedErrorInformation = ::wil::details::coro::DestroyRestrictedErrorInformation;
|
||||
|
||||
2
3rdparty/winwil/include/wil/cppwinrt.h
vendored
2
3rdparty/winwil/include/wil/cppwinrt.h
vendored
@@ -255,7 +255,7 @@ namespace details
|
||||
{
|
||||
#ifndef CPPWINRT_SUPPRESS_STATIC_INITIALIZERS
|
||||
WI_ODR_PRAGMA("CPPWINRT_SUPPRESS_STATIC_INITIALIZERS", "0")
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(WilInitialize_CppWinRT, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(WilInitialize_CppWinRT, [] {
|
||||
::wil::WilInitialize_CppWinRT();
|
||||
return 1;
|
||||
});
|
||||
|
||||
24
3rdparty/winwil/include/wil/filesystem.h
vendored
24
3rdparty/winwil/include/wil/filesystem.h
vendored
@@ -476,7 +476,7 @@ next_entry_offset_iterator<T> create_next_entry_offset_iterator(T* p)
|
||||
|
||||
enum class FolderChangeEvent : DWORD
|
||||
{
|
||||
ChangesLost = 0, // requies special handling, reset state as events were lost
|
||||
ChangesLost = 0, // requires special handling, reset state as events were lost
|
||||
Added = FILE_ACTION_ADDED,
|
||||
Removed = FILE_ACTION_REMOVED,
|
||||
Modified = FILE_ACTION_MODIFIED,
|
||||
@@ -1122,9 +1122,9 @@ struct file_and_error_result
|
||||
DWORD last_error{};
|
||||
};
|
||||
|
||||
/** Non-throwing open existing using OPEN_EXISTING.
|
||||
/** Non-throwing open existing using OPEN_EXISTING, returns handle and error code.
|
||||
~~~
|
||||
auto handle = wil::try_open_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_open_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_open_file(
|
||||
@@ -1150,7 +1150,7 @@ inline wil::unique_hfile open_file(
|
||||
DWORD dwDesiredAccess = GENERIC_READ,
|
||||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
bool inheritHandle = false) noexcept
|
||||
bool inheritHandle = false)
|
||||
{
|
||||
auto result = try_open_file(path, dwDesiredAccess, dwShareMode, dwFlagsAndAttributes, inheritHandle);
|
||||
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
|
||||
@@ -1173,7 +1173,7 @@ namespace details
|
||||
|
||||
/** create using CREATE_NEW, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_create_new_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_create_new_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_create_new_file(
|
||||
@@ -1189,7 +1189,7 @@ inline file_and_error_result try_create_new_file(
|
||||
|
||||
/** create using OPEN_ALWAYS, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_open_or_create_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_open_or_create_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_open_or_create_file(
|
||||
@@ -1205,7 +1205,7 @@ inline file_and_error_result try_open_or_create_file(
|
||||
|
||||
/** create using CREATE_ALWAYS, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_open_or_truncate_existing_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_open_or_truncate_existing_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_open_or_truncate_existing_file(
|
||||
@@ -1221,7 +1221,7 @@ inline file_and_error_result try_open_or_truncate_existing_file(
|
||||
|
||||
/** create using TRUNCATE_EXISTING, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_truncate_existing_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_truncate_existing_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_truncate_existing_file(
|
||||
@@ -1247,7 +1247,7 @@ inline wil::unique_hfile create_new_file(
|
||||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result = try_create_new_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
|
||||
@@ -1265,7 +1265,7 @@ inline wil::unique_hfile open_or_create_file(
|
||||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result = try_open_or_create_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
|
||||
@@ -1283,7 +1283,7 @@ inline wil::unique_hfile open_or_truncate_existing_file(
|
||||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result = try_open_or_truncate_existing_file(
|
||||
path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
@@ -1302,7 +1302,7 @@ inline wil::unique_hfile truncate_existing_file(
|
||||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result =
|
||||
try_truncate_existing_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
|
||||
46
3rdparty/winwil/include/wil/resource.h
vendored
46
3rdparty/winwil/include/wil/resource.h
vendored
@@ -27,10 +27,10 @@
|
||||
// stdint.h and intsafe.h have conflicting definitions, so it's not safe to include either to pick up our dependencies,
|
||||
// so the definitions we need are copied below
|
||||
#ifdef _WIN64
|
||||
#define __WI_SIZE_MAX 0xffffffffffffffffui64 // UINT64_MAX
|
||||
#else /* _WIN64 */
|
||||
#define __WI_SIZE_MAX 0xffffffffui32 // UINT32_MAX
|
||||
#endif /* _WIN64 */
|
||||
#define __WI_SIZE_MAX 0xffffffffffffffffULL // UINT64_MAX
|
||||
#else /* _WIN64 */
|
||||
#define __WI_SIZE_MAX 0xffffffffUL // UINT32_MAX
|
||||
#endif /* _WIN64 */
|
||||
/// @endcond
|
||||
|
||||
// Forward declaration
|
||||
@@ -721,7 +721,7 @@ class com_ptr_t; // forward
|
||||
namespace details
|
||||
{
|
||||
// The first two attach_to_smart_pointer() overloads are ambiguous when passed a com_ptr_t.
|
||||
// To solve that use this functions return type to elminate the reset form for com_ptr_t.
|
||||
// To solve that use this functions return type to eliminate the reset form for com_ptr_t.
|
||||
template <typename T, typename err>
|
||||
wistd::false_type use_reset(wil::com_ptr_t<T, err>*)
|
||||
{
|
||||
@@ -1025,7 +1025,7 @@ struct empty_deleter
|
||||
};
|
||||
|
||||
/** unique_any_array_ptr is a RAII type for managing conformant arrays that need to be freed and have elements that may need to be
|
||||
freed. The intented use for this RAII type would be to capture out params from API like IPropertyValue::GetStringArray. This class
|
||||
freed. The intended use for this RAII type would be to capture out params from API like IPropertyValue::GetStringArray. This class
|
||||
also maintains the size of the array, so it can iterate over the members and deallocate them before it deallocates the base array
|
||||
pointer.
|
||||
|
||||
@@ -2892,6 +2892,7 @@ typedef unique_any_t<event_t<details::unique_storage<details::handle_resource_po
|
||||
typedef unique_any_t<event_t<details::unique_storage<details::handle_resource_policy>, err_exception_policy>> unique_event;
|
||||
#endif
|
||||
|
||||
#ifndef WIL_NO_SLIM_EVENT
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
|
||||
((_WIN32_WINNT >= _WIN32_WINNT_WIN8) || (__WIL_RESOURCE_ENABLE_QUIRKS && (_WIN32_WINNT >= _WIN32_WINNT_WIN7)))
|
||||
enum class SlimEventType
|
||||
@@ -2973,13 +2974,13 @@ public:
|
||||
return !!ReadAcquire(&m_isSignaled);
|
||||
}
|
||||
|
||||
bool wait(DWORD timeoutMiliseconds) WI_NOEXCEPT
|
||||
bool wait(DWORD timeoutMilliseconds) WI_NOEXCEPT
|
||||
{
|
||||
if (timeoutMiliseconds == 0)
|
||||
if (timeoutMilliseconds == 0)
|
||||
{
|
||||
return TryAcquireEvent();
|
||||
}
|
||||
else if (timeoutMiliseconds == INFINITE)
|
||||
else if (timeoutMilliseconds == INFINITE)
|
||||
{
|
||||
return wait();
|
||||
}
|
||||
@@ -2991,12 +2992,12 @@ public:
|
||||
|
||||
while (!TryAcquireEvent())
|
||||
{
|
||||
if (elapsedTimeMilliseconds >= timeoutMiliseconds)
|
||||
if (elapsedTimeMilliseconds >= timeoutMilliseconds)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD newTimeout = static_cast<DWORD>(timeoutMiliseconds - elapsedTimeMilliseconds);
|
||||
DWORD newTimeout = static_cast<DWORD>(timeoutMilliseconds - elapsedTimeMilliseconds);
|
||||
|
||||
if (!WaitForSignal(newTimeout))
|
||||
{
|
||||
@@ -3039,10 +3040,10 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
bool WaitForSignal(DWORD timeoutMiliseconds) WI_NOEXCEPT
|
||||
bool WaitForSignal(DWORD timeoutMilliseconds) WI_NOEXCEPT
|
||||
{
|
||||
LONG falseValue = FALSE;
|
||||
BOOL waitResult = WaitOnAddress(&m_isSignaled, &falseValue, sizeof(m_isSignaled), timeoutMiliseconds);
|
||||
BOOL waitResult = WaitOnAddress(&m_isSignaled, &falseValue, sizeof(m_isSignaled), timeoutMilliseconds);
|
||||
__FAIL_FAST_ASSERT__(waitResult || ::GetLastError() == ERROR_TIMEOUT);
|
||||
return !!waitResult;
|
||||
}
|
||||
@@ -3060,6 +3061,7 @@ using slim_event_manual_reset = slim_event_t<SlimEventType::ManualReset>;
|
||||
using slim_event = slim_event_auto_reset;
|
||||
|
||||
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
#endif // WIL_NO_SLIM_EVENT
|
||||
|
||||
typedef unique_any<HANDLE, decltype(&details::ReleaseMutex), details::ReleaseMutex, details::pointer_access_none> mutex_release_scope_exit;
|
||||
|
||||
@@ -4731,7 +4733,7 @@ inline unique_hstring make_unique_string_nothrow<unique_hstring>(
|
||||
_When_((source != nullptr) && length == static_cast<size_t>(-1), _In_z_) PCWSTR source,
|
||||
size_t length) WI_NOEXCEPT
|
||||
{
|
||||
WI_ASSERT(source != nullptr); // the HSTRING version of this function does not suport this case
|
||||
WI_ASSERT(source != nullptr); // the HSTRING version of this function does not support this case
|
||||
if (length == static_cast<size_t>(-1))
|
||||
{
|
||||
length = wcslen(source);
|
||||
@@ -5218,7 +5220,7 @@ struct cert_context_t
|
||||
}
|
||||
|
||||
/** A wrapper around CertEnumCertificatesInStore.
|
||||
CertEnumCertificatesInStore takes ownership of its second paramter in an unclear fashion,
|
||||
CertEnumCertificatesInStore takes ownership of its second parameter in an unclear fashion,
|
||||
making it error-prone to use in combination with unique_cert_context. This wrapper helps
|
||||
manage the resource correctly while ensuring the GetLastError state set by CertEnumCertificatesInStore.
|
||||
is not lost. See MSDN for more information on `CertEnumCertificatesInStore`.
|
||||
@@ -6264,7 +6266,7 @@ using wdf_wait_lock_release_scope_exit =
|
||||
using unique_wdf_device_init = unique_any<WDFDEVICE_INIT*, decltype(&::WdfDeviceInitFree), ::WdfDeviceInitFree>;
|
||||
#endif
|
||||
|
||||
inline WI_NODISCARD _IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
WI_NODISCARD inline _IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
_Acquires_lock_(lock)
|
||||
wdf_wait_lock_release_scope_exit acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_NOEXCEPT
|
||||
{
|
||||
@@ -6272,7 +6274,7 @@ wdf_wait_lock_release_scope_exit acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_NOEX
|
||||
return wdf_wait_lock_release_scope_exit(lock);
|
||||
}
|
||||
|
||||
inline WI_NODISCARD _IRQL_requires_max_(APC_LEVEL)
|
||||
WI_NODISCARD inline _IRQL_requires_max_(APC_LEVEL)
|
||||
_When_(return, _Acquires_lock_(lock))
|
||||
wdf_wait_lock_release_scope_exit try_acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_NOEXCEPT
|
||||
{
|
||||
@@ -6291,7 +6293,7 @@ wdf_wait_lock_release_scope_exit try_acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_
|
||||
using wdf_spin_lock_release_scope_exit =
|
||||
unique_any<WDFSPINLOCK, decltype(&::WdfSpinLockRelease), ::WdfSpinLockRelease, details::pointer_access_none>;
|
||||
|
||||
inline WI_NODISCARD _IRQL_requires_max_(DISPATCH_LEVEL)
|
||||
WI_NODISCARD inline _IRQL_requires_max_(DISPATCH_LEVEL)
|
||||
_IRQL_raises_(DISPATCH_LEVEL)
|
||||
_Acquires_lock_(lock)
|
||||
wdf_spin_lock_release_scope_exit acquire_wdf_spin_lock(WDFSPINLOCK lock) WI_NOEXCEPT
|
||||
@@ -6507,7 +6509,7 @@ private:
|
||||
// function only if the call-site source location is obtained from elsewhere (i.e., plumbed
|
||||
// through other abstractions).
|
||||
template <typename wdf_object_t>
|
||||
inline WI_NODISCARD unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
WI_NODISCARD inline unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
wdf_object_t wdfObject, PVOID tag, LONG lineNumber, PCSTR fileName) WI_NOEXCEPT
|
||||
{
|
||||
// Parameter is incorrectly marked as non-const, so the const-cast is required.
|
||||
@@ -6516,7 +6518,7 @@ inline WI_NODISCARD unique_wdf_object_reference<wdf_object_t> wdf_object_referen
|
||||
}
|
||||
|
||||
template <typename wdf_object_t>
|
||||
inline WI_NODISCARD unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
WI_NODISCARD inline unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
const wil::unique_wdf_any<wdf_object_t>& wdfObject, PVOID tag, LONG lineNumber, PCSTR fileName) WI_NOEXCEPT
|
||||
{
|
||||
return wdf_object_reference_increment(wdfObject.get(), tag, lineNumber, fileName);
|
||||
@@ -7451,7 +7453,7 @@ namespace details
|
||||
{
|
||||
// Only those lock types specialized by lock_proof_traits will allow either a write_lock_required or
|
||||
// read_lock_required to be constructed. The allows_exclusive value indicates if the type represents an exclusive,
|
||||
// write-safe lock aquisition, or a shared, read-only lock acquisition.
|
||||
// write-safe lock acquisition, or a shared, read-only lock acquisition.
|
||||
template <typename T>
|
||||
struct lock_proof_traits
|
||||
{
|
||||
@@ -7480,7 +7482,7 @@ another function that requires them.
|
||||
These types are implicitly convertible from various lock holding types, enabling callers to provide them as
|
||||
proof of the lock that they hold.
|
||||
|
||||
The following example is intentially contrived to demonstrate multiple use cases:
|
||||
The following example is intentionally contrived to demonstrate multiple use cases:
|
||||
- Methods that require only shared/read access
|
||||
- Methods that require only exclusive write access
|
||||
- Methods that pass their proof-of-lock to a helper
|
||||
|
||||
4
3rdparty/winwil/include/wil/result.h
vendored
4
3rdparty/winwil/include/wil/result.h
vendored
@@ -435,7 +435,7 @@ namespace details_abi
|
||||
private:
|
||||
struct Node
|
||||
{
|
||||
DWORD threadId = ULONG_MAX;
|
||||
DWORD threadId = 0xffffffff; // MAXDWORD
|
||||
Node* pNext = nullptr;
|
||||
T value{};
|
||||
};
|
||||
@@ -1169,7 +1169,7 @@ namespace details
|
||||
__declspec(selectany)::wil::details_abi::ProcessLocalStorage<::wil::details_abi::ProcessLocalData> g_processLocalData("WilError_03");
|
||||
__declspec(selectany)::wil::details_abi::ThreadLocalStorage<ThreadFailureCallbackHolder*> g_threadFailureCallbacks;
|
||||
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeResultHeader, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeResultHeader, [] {
|
||||
g_pfnGetContextAndNotifyFailure = GetContextAndNotifyFailure;
|
||||
::wil::details_abi::g_pProcessLocalData = &g_processLocalData;
|
||||
g_pThreadFailureCallbacks = &g_threadFailureCallbacks;
|
||||
|
||||
97
3rdparty/winwil/include/wil/result_macros.h
vendored
97
3rdparty/winwil/include/wil/result_macros.h
vendored
@@ -93,7 +93,7 @@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
|
||||
#endif
|
||||
#ifndef __NTSTATUS_FROM_WIN32
|
||||
#define __NTSTATUS_FROM_WIN32(x) \
|
||||
((NTSTATUS)(x) <= 0 ? ((NTSTATUS)(x)) : ((NTSTATUS)(((x)&0x0000FFFF) | (FACILITY_WIN32 << 16) | ERROR_SEVERITY_ERROR)))
|
||||
((NTSTATUS)(x) <= 0 ? ((NTSTATUS)(x)) : ((NTSTATUS)(((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | ERROR_SEVERITY_ERROR)))
|
||||
#endif
|
||||
|
||||
#ifndef WIL_AllocateMemory
|
||||
@@ -757,6 +757,14 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
|
||||
return __hr; \
|
||||
} \
|
||||
__WI_SUPPRESS_4127_E while ((void)0, 0)
|
||||
#define __RETURN_HR_FAIL_SUPPRESS_TELEMETRY(hr, str) \
|
||||
__WI_SUPPRESS_4127_S do \
|
||||
{ \
|
||||
const HRESULT __hr = (hr); \
|
||||
__R_FN(Return_HrSuppressTelemetry)(__R_INFO(str) __hr); \
|
||||
return __hr; \
|
||||
} \
|
||||
__WI_SUPPRESS_4127_E while ((void)0, 0)
|
||||
#define __RETURN_HR_FAIL_NOFILE(hr, str) \
|
||||
__WI_SUPPRESS_4127_S do \
|
||||
{ \
|
||||
@@ -1097,6 +1105,21 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
|
||||
} \
|
||||
} while ((void)0, 0)
|
||||
|
||||
// Always logs failed HR, if expected, telemetry will be called with 'alreadyReported'
|
||||
#define RETURN_IF_FAILED_SUPPRESS_TELEMETRY_IF_EXPECTED(hr, hrExpected, ...) \
|
||||
do \
|
||||
{ \
|
||||
const auto __hrRet = wil::verify_hresult(hr); \
|
||||
if (FAILED(__hrRet)) \
|
||||
{ \
|
||||
if ((__hrRet == wil::verify_hresult(hrExpected)) WI_FOREACH(__WI_OR_IS_EXPECTED_HRESULT, ##__VA_ARGS__)) \
|
||||
{ \
|
||||
__RETURN_HR_FAIL_SUPPRESS_TELEMETRY(__hrRet, #hr); \
|
||||
} \
|
||||
__RETURN_HR_FAIL(__hrRet, #hr); \
|
||||
} \
|
||||
} while ((void)0, 0)
|
||||
|
||||
//*****************************************************************************
|
||||
// Macros for logging failures (ignore or pass-through)
|
||||
//*****************************************************************************
|
||||
@@ -1267,7 +1290,7 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
|
||||
if (!wil::verify_bool(condition)) \
|
||||
{ \
|
||||
WI_ASSERT_FAIL(#condition); \
|
||||
__RFF_FN(FailFast_Unexpected)(__RFF_INFO_ONLY(#condition)) \
|
||||
__RFF_FN(FailFast_Unexpected)(__RFF_INFO_ONLY(#condition)); \
|
||||
} \
|
||||
} while (0, 0)
|
||||
#define WI_FAIL_FAST_ASSERT_MSG(condition, msg) \
|
||||
@@ -1738,7 +1761,7 @@ inline HRESULT GetFailureLogString(
|
||||
_Pre_satisfies_(cchDest > 0) _In_ size_t cchDest,
|
||||
_In_ FailureInfo const& failure) WI_NOEXCEPT
|
||||
{
|
||||
// This function was lenient to empty strings at one point and some callers became dependent on this beahvior
|
||||
// This function was lenient to empty strings at one point and some callers became dependent on this behavior
|
||||
if ((cchDest == 0) || (pszDest == nullptr))
|
||||
{
|
||||
return S_OK;
|
||||
@@ -2155,6 +2178,7 @@ namespace details
|
||||
_Pre_satisfies_(debugStringSizeChars > 0) size_t debugStringSizeChars,
|
||||
_Out_writes_(callContextStringSizeChars) _Post_z_ PSTR callContextString,
|
||||
_Pre_satisfies_(callContextStringSizeChars > 0) size_t callContextStringSizeChars,
|
||||
FailureFlags flags,
|
||||
_Out_ FailureInfo* failure) WI_NOEXCEPT;
|
||||
|
||||
__declspec(noinline) inline void ReportFailure(
|
||||
@@ -2168,12 +2192,13 @@ namespace details
|
||||
__R_FN_PARAMS_FULL,
|
||||
const ResultStatus& resultPair,
|
||||
_In_opt_ PCWSTR message = nullptr,
|
||||
ReportFailureOptions options = ReportFailureOptions::None);
|
||||
ReportFailureOptions options = ReportFailureOptions::None,
|
||||
FailureFlags flags = FailureFlags::None);
|
||||
template <FailureType>
|
||||
inline void ReportFailure_ReplaceMsg(__R_FN_PARAMS_FULL, HRESULT hr, _Printf_format_string_ PCSTR formatString, ...);
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, FailureType type, HRESULT hr);
|
||||
template <FailureType>
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr);
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags flags = FailureFlags::None);
|
||||
template <FailureType>
|
||||
__declspec(noinline) inline HRESULT
|
||||
ReportFailure_CaughtException(__R_FN_PARAMS_FULL, SupportedExceptions supported = SupportedExceptions::Default);
|
||||
@@ -2745,7 +2770,7 @@ namespace details
|
||||
{
|
||||
status =
|
||||
((NTSTATUS)(hr) <= 0 ? ((NTSTATUS)(hr))
|
||||
: ((NTSTATUS)(((hr)&0x0000FFFF) | (FACILITY_SSPI << 16) | ERROR_SEVERITY_ERROR)));
|
||||
: ((NTSTATUS)(((hr) & 0x0000FFFF) | (FACILITY_SSPI << 16) | ERROR_SEVERITY_ERROR)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2826,8 +2851,8 @@ namespace details
|
||||
// NOTE: The following two functions are unfortunate copies of strsafe.h functions that have been copied to reduce the friction associated with using
|
||||
// Result.h and ResultException.h in a build that does not have WINAPI_PARTITION_DESKTOP defined (where these are conditionally enabled).
|
||||
|
||||
static STRSAFEAPI WilStringLengthWorkerA(
|
||||
_In_reads_or_z_(cchMax) STRSAFE_PCNZCH psz,
|
||||
inline HRESULT WilStringLengthWorkerA(
|
||||
_In_reads_or_z_(cchMax) PCNZCH psz,
|
||||
_In_ _In_range_(<=, STRSAFE_MAX_CCH) size_t cchMax,
|
||||
_Out_opt_ _Deref_out_range_(<, cchMax) _Deref_out_range_(<=, _String_length_(psz)) size_t* pcchLength)
|
||||
{
|
||||
@@ -2858,8 +2883,8 @@ namespace details
|
||||
}
|
||||
|
||||
_Must_inspect_result_
|
||||
STRSAFEAPI StringCchLengthA(
|
||||
_In_reads_or_z_(cchMax) STRSAFE_PCNZCH psz,
|
||||
inline HRESULT StringCchLengthA(
|
||||
_In_reads_or_z_(cchMax) PCNZCH psz,
|
||||
_In_ _In_range_(1, STRSAFE_MAX_CCH) size_t cchMax,
|
||||
_Out_opt_ _Deref_out_range_(<, cchMax) _Deref_out_range_(<=, _String_length_(psz)) size_t* pcchLength)
|
||||
{
|
||||
@@ -2880,8 +2905,8 @@ namespace details
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
_Post_satisfies_(cchDest > 0 && cchDest <= cchMax) static STRSAFEAPI
|
||||
WilStringValidateDestA(_In_reads_opt_(cchDest) STRSAFE_PCNZCH /*pszDest*/, _In_ size_t cchDest, _In_ const size_t cchMax)
|
||||
_Post_satisfies_(cchDest > 0 && cchDest <= cchMax) inline HRESULT
|
||||
WilStringValidateDestA(_In_reads_opt_(cchDest) PCNZCH /*pszDest*/, _In_ size_t cchDest, _In_ const size_t cchMax)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
if ((cchDest == 0) || (cchDest > cchMax))
|
||||
@@ -2891,7 +2916,7 @@ namespace details
|
||||
return hr;
|
||||
}
|
||||
|
||||
static STRSAFEAPI WilStringVPrintfWorkerA(
|
||||
inline HRESULT WilStringVPrintfWorkerA(
|
||||
_Out_writes_(cchDest) _Always_(_Post_z_) STRSAFE_LPSTR pszDest,
|
||||
_In_ _In_range_(1, STRSAFE_MAX_CCH) size_t cchDest,
|
||||
_Always_(_Out_opt_ _Deref_out_range_(<=, cchDest - 1)) size_t* pcchNewDestLength,
|
||||
@@ -2948,7 +2973,7 @@ namespace details
|
||||
return hr;
|
||||
}
|
||||
|
||||
__inline HRESULT StringCchPrintfA(
|
||||
inline HRESULT StringCchPrintfA(
|
||||
_Out_writes_(cchDest) _Always_(_Post_z_) STRSAFE_LPSTR pszDest,
|
||||
_In_ size_t cchDest,
|
||||
_In_ _Printf_format_string_ STRSAFE_LPCSTR pszFormat,
|
||||
@@ -3080,7 +3105,7 @@ namespace details
|
||||
{
|
||||
#ifndef RESULT_SUPPRESS_STATIC_INITIALIZERS
|
||||
#if !defined(BUILD_WINDOWS) || defined(WIL_SUPPRESS_PRIVATE_API_USE)
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(WilInitialize_ResultMacros_DesktopOrSystem_SuppressPrivateApiUse, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(WilInitialize_ResultMacros_DesktopOrSystem_SuppressPrivateApiUse, [] {
|
||||
::wil::WilInitialize_ResultMacros_DesktopOrSystem_SuppressPrivateApiUse();
|
||||
return 1;
|
||||
});
|
||||
@@ -3091,7 +3116,7 @@ namespace details
|
||||
#else // !WINAPI_PARTITION_DESKTOP, !WINAPI_PARTITION_SYSTEM, explicitly assume these modules can direct link
|
||||
namespace details
|
||||
{
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(WilInitialize_ResultMacros_AppOnly, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(WilInitialize_ResultMacros_AppOnly, [] {
|
||||
g_pfnRaiseFailFastException = ::RaiseFailFastException;
|
||||
return 1;
|
||||
});
|
||||
@@ -3869,7 +3894,7 @@ namespace details
|
||||
}
|
||||
|
||||
#if !defined(RESULT_SUPPRESS_STATIC_INITIALIZERS)
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeWinRt, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeWinRt, [] {
|
||||
g_pfnResultFromCaughtException_WinRt = ResultFromCaughtException_WinRt;
|
||||
g_pfnResultFromKnownExceptions_WinRt = ResultFromKnownExceptions_WinRt;
|
||||
g_pfnThrowPlatformException = ThrowPlatformException;
|
||||
@@ -4124,7 +4149,7 @@ namespace details
|
||||
}
|
||||
}
|
||||
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeResultExceptions, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeResultExceptions, [] {
|
||||
g_pfnRunFunctorWithExceptionFilter = RunFunctorWithExceptionFilter;
|
||||
g_pfnRethrow = Rethrow;
|
||||
g_pfnThrowResultException = ThrowResultExceptionInternal;
|
||||
@@ -4320,6 +4345,7 @@ namespace details
|
||||
_Pre_satisfies_(debugStringSizeChars > 0) size_t debugStringSizeChars,
|
||||
_Out_writes_(callContextStringSizeChars) _Post_z_ PSTR callContextString,
|
||||
_Pre_satisfies_(callContextStringSizeChars > 0) size_t callContextStringSizeChars,
|
||||
FailureFlags flags,
|
||||
_Out_ FailureInfo* failure) WI_NOEXCEPT
|
||||
{
|
||||
debugString[0] = L'\0';
|
||||
@@ -4360,7 +4386,7 @@ namespace details
|
||||
};
|
||||
|
||||
failure->type = type;
|
||||
failure->flags = FailureFlags::None;
|
||||
failure->flags = flags;
|
||||
WI_SetFlagIf(failure->flags, FailureFlags::NtStatus, resultPair.kind == ResultStatus::Kind::NtStatus);
|
||||
failure->failureId = ::InterlockedIncrementNoFence(&s_failureId);
|
||||
failure->pszMessage = ((message != nullptr) && (message[0] != L'\0')) ? message : nullptr;
|
||||
@@ -4501,7 +4527,8 @@ namespace details
|
||||
}
|
||||
|
||||
template <FailureType T>
|
||||
inline __declspec(noinline) void ReportFailure_Return(__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
inline __declspec(noinline) void ReportFailure_Return(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags flags)
|
||||
{
|
||||
bool needPlatformException =
|
||||
((T == FailureType::Exception) && WI_IsFlagClear(options, ReportFailureOptions::MayRethrow) &&
|
||||
@@ -4522,6 +4549,7 @@ namespace details
|
||||
ARRAYSIZE(debugString),
|
||||
callContextString,
|
||||
ARRAYSIZE(callContextString),
|
||||
flags,
|
||||
&failure);
|
||||
|
||||
if (WI_IsFlagSet(failure.flags, FailureFlags::RequestFailFast))
|
||||
@@ -4531,9 +4559,10 @@ namespace details
|
||||
}
|
||||
|
||||
template <FailureType T, bool SuppressAction>
|
||||
inline __declspec(noinline) void ReportFailure_Base(__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
inline __declspec(noinline) void ReportFailure_Base(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags flags)
|
||||
{
|
||||
ReportFailure_Return<T>(__R_FN_CALL_FULL, resultPair, message, options);
|
||||
ReportFailure_Return<T>(__R_FN_CALL_FULL, resultPair, message, options, flags);
|
||||
}
|
||||
|
||||
template <FailureType T>
|
||||
@@ -4559,6 +4588,7 @@ namespace details
|
||||
ARRAYSIZE(debugString),
|
||||
callContextString,
|
||||
ARRAYSIZE(callContextString),
|
||||
FailureFlags::None,
|
||||
&failure);
|
||||
__WI_SUPPRESS_4127_S
|
||||
if ((T == FailureType::FailFast) || WI_IsFlagSet(failure.flags, FailureFlags::RequestFailFast))
|
||||
@@ -4587,14 +4617,14 @@ namespace details
|
||||
|
||||
template <>
|
||||
inline __declspec(noinline) RESULT_NORETURN void ReportFailure_Base<FailureType::FailFast, false>(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags)
|
||||
{
|
||||
ReportFailure_NoReturn<FailureType::FailFast>(__R_FN_CALL_FULL, resultPair, message, options);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline __declspec(noinline) RESULT_NORETURN void ReportFailure_Base<FailureType::Exception, false>(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags)
|
||||
{
|
||||
ReportFailure_NoReturn<FailureType::Exception>(__R_FN_CALL_FULL, resultPair, message, options);
|
||||
}
|
||||
@@ -4764,19 +4794,22 @@ namespace details
|
||||
}
|
||||
|
||||
template <FailureType T>
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr)
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags flags)
|
||||
{
|
||||
ReportFailure_Base<T>(__R_FN_CALL_FULL, ResultStatus::FromResult(hr));
|
||||
ReportFailure_Base<T>(
|
||||
__R_FN_CALL_FULL, ResultStatus::FromResult(hr), nullptr /*message*/, ReportFailureOptions::None /*options*/, flags);
|
||||
}
|
||||
|
||||
template <>
|
||||
__declspec(noinline) inline RESULT_NORETURN void ReportFailure_Hr<FailureType::FailFast>(__R_FN_PARAMS_FULL, HRESULT hr)
|
||||
__declspec(noinline) inline RESULT_NORETURN
|
||||
void ReportFailure_Hr<FailureType::FailFast>(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags)
|
||||
{
|
||||
ReportFailure_Base<FailureType::FailFast>(__R_FN_CALL_FULL, ResultStatus::FromResult(hr));
|
||||
}
|
||||
|
||||
template <>
|
||||
__declspec(noinline) inline RESULT_NORETURN void ReportFailure_Hr<FailureType::Exception>(__R_FN_PARAMS_FULL, HRESULT hr)
|
||||
__declspec(noinline) inline RESULT_NORETURN
|
||||
void ReportFailure_Hr<FailureType::Exception>(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags)
|
||||
{
|
||||
ReportFailure_Base<FailureType::Exception>(__R_FN_CALL_FULL, ResultStatus::FromResult(hr));
|
||||
}
|
||||
@@ -5182,6 +5215,7 @@ namespace details
|
||||
ARRAYSIZE(debugString),
|
||||
callContextString,
|
||||
ARRAYSIZE(callContextString),
|
||||
FailureFlags::None,
|
||||
&failure);
|
||||
|
||||
if (WI_IsFlagSet(failure.flags, FailureFlags::RequestFailFast))
|
||||
@@ -5228,6 +5262,13 @@ namespace details
|
||||
wil::details::ReportFailure_Hr<FailureType::Return>(__R_DIRECT_FN_CALL hr);
|
||||
}
|
||||
|
||||
__R_DIRECT_METHOD(void, Return_HrSuppressTelemetry)(__R_DIRECT_FN_PARAMS HRESULT hr) WI_NOEXCEPT
|
||||
{
|
||||
__R_FN_LOCALS;
|
||||
const FailureFlags flags = FailureFlags::RequestSuppressTelemetry;
|
||||
wil::details::ReportFailure_Hr<FailureType::Return>(__R_DIRECT_FN_CALL hr, flags);
|
||||
}
|
||||
|
||||
_Success_(true)
|
||||
_Translates_Win32_to_HRESULT_(err)
|
||||
__R_DIRECT_METHOD(HRESULT, Return_Win32)(__R_DIRECT_FN_PARAMS DWORD err) WI_NOEXCEPT
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace details
|
||||
} // namespace wil
|
||||
|
||||
// Automatically call RoOriginateError upon error origination by including this file
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(ResultStowedExceptionInitialize, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(ResultStowedExceptionInitialize, [] {
|
||||
::wil::SetOriginateErrorCallback(::wil::details::RaiseRoOriginateOnWilExceptions);
|
||||
::wil::SetFailfastWithContextCallback(::wil::details::FailfastWithContextCallback);
|
||||
return 1;
|
||||
|
||||
2
3rdparty/winwil/include/wil/safecast.h
vendored
2
3rdparty/winwil/include/wil/safecast.h
vendored
@@ -106,7 +106,7 @@ namespace details
|
||||
wistd::is_same<T, int>::value || wistd::is_same<T, unsigned int>::value || wistd::is_same<T, long>::value ||
|
||||
wistd::is_same<T, unsigned long>::value || wistd::is_same<T, __int64>::value || wistd::is_same<T, unsigned __int64>::value;
|
||||
|
||||
// True when either type is potentialy variably sized (e.g. size_t, ptrdiff_t)
|
||||
// True when either type is potentially variably sized (e.g. size_t, ptrdiff_t)
|
||||
template <typename OldT, typename NewT>
|
||||
constexpr bool is_potentially_variably_sized_cast_v =
|
||||
is_potentially_variably_sized_type_v<OldT> || is_potentially_variably_sized_type_v<NewT>;
|
||||
|
||||
107
3rdparty/winwil/include/wil/windowing.h
vendored
107
3rdparty/winwil/include/wil/windowing.h
vendored
@@ -24,19 +24,64 @@ namespace details
|
||||
{
|
||||
};
|
||||
|
||||
template <typename TCallback>
|
||||
BOOL __stdcall EnumWindowsCallbackNoThrow(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
auto pCallback = reinterpret_cast<TCallback*>(lParam);
|
||||
#ifdef __cpp_if_constexpr
|
||||
using result_t = decltype((*pCallback)(hwnd));
|
||||
if constexpr (wistd::is_void_v<result_t>)
|
||||
{
|
||||
(*pCallback)(hwnd);
|
||||
return TRUE;
|
||||
}
|
||||
else if constexpr (wistd::is_same_v<result_t, HRESULT>)
|
||||
{
|
||||
// NB: this works for both HRESULT and NTSTATUS as both S_OK and ERROR_SUCCESS are 0
|
||||
return (S_OK == (*pCallback)(hwnd)) ? TRUE : FALSE;
|
||||
}
|
||||
else if constexpr (std::is_same_v<result_t, bool>)
|
||||
{
|
||||
return (*pCallback)(hwnd) ? TRUE : FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(details::always_false<TCallback>::value, "Callback must return void, bool, or HRESULT");
|
||||
}
|
||||
#else
|
||||
return (*pCallback)(hwnd);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename TEnumApi, typename TCallback>
|
||||
void DoEnumWindowsNoThrow(TEnumApi&& enumApi, TCallback&& callback) noexcept
|
||||
{
|
||||
auto enumproc = [](HWND hwnd, LPARAM lParam) -> BOOL {
|
||||
auto pCallback = reinterpret_cast<TCallback*>(lParam);
|
||||
enumApi(EnumWindowsCallbackNoThrow<TCallback>, reinterpret_cast<LPARAM>(&callback));
|
||||
}
|
||||
|
||||
#ifdef WIL_ENABLE_EXCEPTIONS
|
||||
template <typename TCallback>
|
||||
struct EnumWindowsCallbackData
|
||||
{
|
||||
std::exception_ptr exception;
|
||||
TCallback* pCallback;
|
||||
};
|
||||
|
||||
template <typename TCallback>
|
||||
BOOL __stdcall EnumWindowsCallback(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
auto pCallbackData = reinterpret_cast<EnumWindowsCallbackData<TCallback>*>(lParam);
|
||||
try
|
||||
{
|
||||
auto pCallback = pCallbackData->pCallback;
|
||||
#ifdef __cpp_if_constexpr
|
||||
using result_t = decltype((*pCallback)(hwnd));
|
||||
if constexpr (wistd::is_void_v<result_t>)
|
||||
if constexpr (std::is_void_v<result_t>)
|
||||
{
|
||||
(*pCallback)(hwnd);
|
||||
return TRUE;
|
||||
}
|
||||
else if constexpr (wistd::is_same_v<result_t, HRESULT>)
|
||||
else if constexpr (std::is_same_v<result_t, HRESULT>)
|
||||
{
|
||||
// NB: this works for both HRESULT and NTSTATUS as both S_OK and ERROR_SUCCESS are 0
|
||||
return (S_OK == (*pCallback)(hwnd)) ? TRUE : FALSE;
|
||||
@@ -52,55 +97,19 @@ namespace details
|
||||
#else
|
||||
return (*pCallback)(hwnd);
|
||||
#endif
|
||||
};
|
||||
enumApi(enumproc, reinterpret_cast<LPARAM>(&callback));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
pCallbackData->exception = std::current_exception();
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef WIL_ENABLE_EXCEPTIONS
|
||||
template <typename TEnumApi, typename TCallback>
|
||||
void DoEnumWindows(TEnumApi&& enumApi, TCallback&& callback)
|
||||
{
|
||||
struct
|
||||
{
|
||||
std::exception_ptr exception;
|
||||
TCallback* pCallback;
|
||||
} callbackData = {nullptr, &callback};
|
||||
auto enumproc = [](HWND hwnd, LPARAM lParam) -> BOOL {
|
||||
auto pCallbackData = reinterpret_cast<decltype(&callbackData)>(lParam);
|
||||
try
|
||||
{
|
||||
auto pCallback = pCallbackData->pCallback;
|
||||
#ifdef __cpp_if_constexpr
|
||||
using result_t = decltype((*pCallback)(hwnd));
|
||||
if constexpr (std::is_void_v<result_t>)
|
||||
{
|
||||
(*pCallback)(hwnd);
|
||||
return TRUE;
|
||||
}
|
||||
else if constexpr (std::is_same_v<result_t, HRESULT>)
|
||||
{
|
||||
// NB: this works for both HRESULT and NTSTATUS as both S_OK and ERROR_SUCCESS are 0
|
||||
return (S_OK == (*pCallback)(hwnd)) ? TRUE : FALSE;
|
||||
}
|
||||
else if constexpr (std::is_same_v<result_t, bool>)
|
||||
{
|
||||
return (*pCallback)(hwnd) ? TRUE : FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(details::always_false<TCallback>::value, "Callback must return void, bool, or HRESULT");
|
||||
}
|
||||
#else
|
||||
return (*pCallback)(hwnd);
|
||||
#endif
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
pCallbackData->exception = std::current_exception();
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
enumApi(enumproc, reinterpret_cast<LPARAM>(&callbackData));
|
||||
EnumWindowsCallbackData<TCallback> callbackData = {nullptr, &callback};
|
||||
enumApi(EnumWindowsCallback<TCallback>, reinterpret_cast<LPARAM>(&callbackData));
|
||||
if (callbackData.exception)
|
||||
{
|
||||
std::rethrow_exception(callbackData.exception);
|
||||
|
||||
10
3rdparty/winwil/include/wil/winrt.h
vendored
10
3rdparty/winwil/include/wil/winrt.h
vendored
@@ -271,7 +271,7 @@ struct TwoPhaseHStringConstructor
|
||||
return TwoPhaseHStringConstructor{characterLength};
|
||||
}
|
||||
|
||||
//! Returns the HSTRING after it has been populated like Detatch() or release(); be sure to put this in a RAII type to manage
|
||||
//! Returns the HSTRING after it has been populated like Detach() or release(); be sure to put this in a RAII type to manage
|
||||
//! its lifetime.
|
||||
HSTRING Promote()
|
||||
{
|
||||
@@ -1700,8 +1700,8 @@ hr = run_when_complete_nothrow<StorageFile*>(getFileOp.Get(), [](HRESULT hr, ISt
|
||||
~~~
|
||||
*/
|
||||
|
||||
//! Run a fuction when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler agile
|
||||
//! and run on the async thread.
|
||||
//! Run a function when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler
|
||||
//! agile and run on the async thread.
|
||||
template <typename TAgility = IUnknown, typename TFunc>
|
||||
HRESULT run_when_complete_nothrow(_In_ ABI::Windows::Foundation::IAsyncAction* operation, TFunc&& func) WI_NOEXCEPT
|
||||
{
|
||||
@@ -1727,8 +1727,8 @@ HRESULT run_when_complete_nothrow(_In_ ABI::Windows::Foundation::IAsyncActionWit
|
||||
}
|
||||
|
||||
#ifdef WIL_ENABLE_EXCEPTIONS
|
||||
//! Run a fuction when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler agile
|
||||
//! and run on the async thread.
|
||||
//! Run a function when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler
|
||||
//! agile and run on the async thread.
|
||||
template <typename TAgility = IUnknown, typename TFunc>
|
||||
void run_when_complete(_In_ ABI::Windows::Foundation::IAsyncAction* operation, TFunc&& func)
|
||||
{
|
||||
|
||||
4
3rdparty/winwil/include/wil/wistd_config.h
vendored
4
3rdparty/winwil/include/wil/wistd_config.h
vendored
@@ -33,7 +33,7 @@
|
||||
// and non-exception based code should utilize this functionality.
|
||||
|
||||
// This header mimics libc++'s '__config' header to the extent necessary to get the wistd::* definitions compiling. Note
|
||||
// that this has a few key differences since libc++'s MSVC compatability is currently not functional and a bit behind
|
||||
// that this has a few key differences since libc++'s MSVC compatibility is currently not functional and a bit behind
|
||||
|
||||
#ifndef _WISTD_CONFIG_H_
|
||||
#define _WISTD_CONFIG_H_
|
||||
@@ -130,7 +130,7 @@
|
||||
#define __WI_CLANG_DISABLE_WARNING(warning)
|
||||
#endif
|
||||
|
||||
// NOTE: MSVC, which is what we primarily target, is severly underrepresented in libc++ and checks such as
|
||||
// NOTE: MSVC, which is what we primarily target, is severely underrepresented in libc++ and checks such as
|
||||
// __has_feature(...) are always false for MSVC, even when the feature being tested _is_ present in MSVC. Therefore, we
|
||||
// instead modify all checks to be __WI_HAS_FEATURE_IS_UNION, etc., which provides the correct value for MSVC and falls
|
||||
// back to the __has_feature(...), etc. value otherwise. We intentionally leave '__has_feature', etc. undefined for MSVC
|
||||
|
||||
@@ -1946,7 +1946,7 @@ struct __numeric_type<void>
|
||||
|
||||
// __promote
|
||||
|
||||
template <class _A1, class _A2 = void, class _A3 = void, bool = __numeric_type<_A1>::value&& __numeric_type<_A2>::value&& __numeric_type<_A3>::value>
|
||||
template <class _A1, class _A2 = void, class _A3 = void, bool = __numeric_type<_A1>::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value>
|
||||
class __promote_imp
|
||||
{
|
||||
public:
|
||||
@@ -4775,7 +4775,7 @@ struct underlying_type
|
||||
{
|
||||
static_assert(
|
||||
_Support,
|
||||
"The underyling_type trait requires compiler "
|
||||
"The underlying_type trait requires compiler "
|
||||
"support. Either no such support exists or "
|
||||
"libc++ does not know how to use it.");
|
||||
};
|
||||
|
||||
@@ -16715,6 +16715,7 @@ SLES-51434:
|
||||
- SoftwareRendererFMVHack # Fixes blackscreen when FMV.
|
||||
gsHWFixes:
|
||||
recommendedBlendingLevel: 4 # Fixes menu transparancy effects and text.
|
||||
deinterlace: 9 # Fixes incorrect field order in FMVs.
|
||||
memcardFilters:
|
||||
- "SLES-51434"
|
||||
- "SLES-50382"
|
||||
@@ -29241,6 +29242,7 @@ SLKA-25065:
|
||||
- SoftwareRendererFMVHack # Fixes blackscreen when FMV.
|
||||
gsHWFixes:
|
||||
recommendedBlendingLevel: 4 # Fixes menu transparancy effects and text.
|
||||
deinterlace: 9 # Fixes incorrect field order in FMVs.
|
||||
SLKA-25066:
|
||||
name: "Zone of the Enders - The 2nd Runner SE"
|
||||
region: "NTSC-K"
|
||||
@@ -38472,6 +38474,7 @@ SLPM-65257:
|
||||
- SoftwareRendererFMVHack # Fixes blackscreen when FMV.
|
||||
gsHWFixes:
|
||||
recommendedBlendingLevel: 4 # Fixes menu transparancy effects and text.
|
||||
deinterlace: 9 # Fixes incorrect field order in FMVs.
|
||||
memcardFilters:
|
||||
- "SLPM-65257"
|
||||
- "SLPM-65622"
|
||||
@@ -40463,6 +40466,7 @@ SLPM-65622:
|
||||
- SoftwareRendererFMVHack # Fixes blackscreen when FMV.
|
||||
gsHWFixes:
|
||||
recommendedBlendingLevel: 4 # Fixes menu transparancy effects and text.
|
||||
deinterlace: 9 # Fixes incorrect field order in FMVs.
|
||||
memcardFilters:
|
||||
- "SLPM-65257"
|
||||
- "SLPM-65622"
|
||||
@@ -42715,6 +42719,7 @@ SLPM-66018:
|
||||
- SoftwareRendererFMVHack # Fixes blackscreen when FMV.
|
||||
gsHWFixes:
|
||||
recommendedBlendingLevel: 4 # Fixes menu transparancy effects and text.
|
||||
deinterlace: 9 # Fixes incorrect field order in FMVs.
|
||||
memcardFilters:
|
||||
- "SLPM-65257"
|
||||
- "SLPM-65622"
|
||||
@@ -61354,6 +61359,7 @@ SLUS-20622:
|
||||
- SoftwareRendererFMVHack # Fixes blackscreen when FMV.
|
||||
gsHWFixes:
|
||||
recommendedBlendingLevel: 4 # Fixes menu transparancy effects and text.
|
||||
deinterlace: 9 # Fixes incorrect field order in FMVs.
|
||||
memcardFilters: # Reads Silent Hill 2 for easter egg.
|
||||
- "SLUS-20622"
|
||||
- "SLUS-20228"
|
||||
|
||||
@@ -5041,7 +5041,7 @@ Do you want to overwrite?</source>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../QtHost.cpp" line="1011"/>
|
||||
<source>Slot: %1 | Volume: %2% | 3% | EE: %4% | GS: %5%</source>
|
||||
<source>Slot: %1 | Volume: %2% | %3 | EE: %4% | GS: %5%</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace PacketReader::ARP
|
||||
{
|
||||
}
|
||||
|
||||
ARP_Packet::ARP_Packet(u8* buffer, int bufferSize)
|
||||
ARP_Packet::ARP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace PacketReader::ARP
|
||||
std::unique_ptr<u8[]> targetProtocolAddress;
|
||||
|
||||
ARP_Packet(u8 hwAddrLen, u8 procAddrLen);
|
||||
ARP_Packet(u8* buffer, int bufferSize);
|
||||
ARP_Packet(const u8* buffer, int bufferSize);
|
||||
ARP_Packet(const ARP_Packet&);
|
||||
|
||||
virtual int GetLength();
|
||||
|
||||
@@ -11,59 +11,59 @@
|
||||
|
||||
namespace PacketReader::ARP
|
||||
{
|
||||
ARP_PacketEditor::ARP_PacketEditor(PayloadPtr* pkt)
|
||||
ARP_PacketEditor::ARP_PacketEditor(PayloadPtrEditor* pkt)
|
||||
: basePkt{pkt}
|
||||
{
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetHardwareType()
|
||||
u16 ARP_PacketEditor::GetHardwareType() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[0]);
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetProtocol()
|
||||
u16 ARP_PacketEditor::GetProtocol() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[2]);
|
||||
}
|
||||
|
||||
u8 ARP_PacketEditor::GetHardwareAddressLength()
|
||||
u8 ARP_PacketEditor::GetHardwareAddressLength() const
|
||||
{
|
||||
return basePkt->data[4];
|
||||
}
|
||||
u8 ARP_PacketEditor::GetProtocolAddressLength()
|
||||
u8 ARP_PacketEditor::GetProtocolAddressLength() const
|
||||
{
|
||||
return basePkt->data[5];
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetOp()
|
||||
u16 ARP_PacketEditor::GetOp() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[6]);
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::SenderHardwareAddress()
|
||||
u8* ARP_PacketEditor::SenderHardwareAddress() const
|
||||
{
|
||||
return &basePkt->data[8];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::SenderProtocolAddress()
|
||||
u8* ARP_PacketEditor::SenderProtocolAddress() const
|
||||
{
|
||||
int offset = 8 + GetHardwareAddressLength();
|
||||
const int offset = 8 + GetHardwareAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::TargetHardwareAddress()
|
||||
u8* ARP_PacketEditor::TargetHardwareAddress() const
|
||||
{
|
||||
int offset = 8 + GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
const int offset = 8 + GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::TargetProtocolAddress()
|
||||
u8* ARP_PacketEditor::TargetProtocolAddress() const
|
||||
{
|
||||
int offset = 8 + 2 * GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
const int offset = 8 + 2 * GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
int ARP_PacketEditor::GetLength()
|
||||
int ARP_PacketEditor::GetLength() const
|
||||
{
|
||||
return 8 + 2 * GetHardwareAddressLength() + 2 * GetProtocolAddressLength();
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@ namespace PacketReader::ARP
|
||||
class ARP_PacketEditor
|
||||
{
|
||||
private:
|
||||
PayloadPtr* basePkt;
|
||||
PayloadPtrEditor* basePkt;
|
||||
|
||||
public:
|
||||
ARP_PacketEditor(PayloadPtr* pkt);
|
||||
ARP_PacketEditor(PayloadPtrEditor* pkt);
|
||||
|
||||
u16 GetHardwareType();
|
||||
u16 GetProtocol();
|
||||
u8 GetHardwareAddressLength();
|
||||
u8 GetProtocolAddressLength();
|
||||
u16 GetOp();
|
||||
u16 GetHardwareType() const;
|
||||
u16 GetProtocol() const;
|
||||
u8 GetHardwareAddressLength() const;
|
||||
u8 GetProtocolAddressLength() const;
|
||||
u16 GetOp() const;
|
||||
|
||||
u8* SenderHardwareAddress();
|
||||
u8* SenderProtocolAddress();
|
||||
u8* TargetHardwareAddress();
|
||||
u8* TargetProtocolAddress();
|
||||
u8* SenderHardwareAddress() const;
|
||||
u8* SenderProtocolAddress() const;
|
||||
u8* TargetHardwareAddress() const;
|
||||
u8* TargetProtocolAddress() const;
|
||||
|
||||
int GetLength();
|
||||
int GetLength() const;
|
||||
};
|
||||
} // namespace PacketReader::ARP
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace PacketReader
|
||||
//Note: we don't have to worry about the Ethernet Frame CRC as it is not included in the packet
|
||||
//Note: We don't support tagged frames
|
||||
|
||||
payload = std::make_unique<PayloadPtr>((u8*)&basePkt->buffer[14], pkt->size - headerLength);
|
||||
payload = std::make_unique<PayloadPtrEditor>((u8*)&basePkt->buffer[14], pkt->size - headerLength);
|
||||
}
|
||||
|
||||
MAC_Address EthernetFrameEditor::GetDestinationMAC()
|
||||
MAC_Address EthernetFrameEditor::GetDestinationMAC() const
|
||||
{
|
||||
return *(MAC_Address*)&basePkt->buffer[0];
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace PacketReader
|
||||
*(MAC_Address*)&basePkt->buffer[0] = value;
|
||||
}
|
||||
|
||||
MAC_Address EthernetFrameEditor::GetSourceMAC()
|
||||
MAC_Address EthernetFrameEditor::GetSourceMAC() const
|
||||
{
|
||||
return *(MAC_Address*)&basePkt->buffer[6];
|
||||
}
|
||||
@@ -40,12 +40,12 @@ namespace PacketReader
|
||||
*(MAC_Address*)&basePkt->buffer[6] = value;
|
||||
}
|
||||
|
||||
u16 EthernetFrameEditor::GetProtocol()
|
||||
u16 EthernetFrameEditor::GetProtocol() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->buffer[12]);
|
||||
}
|
||||
|
||||
PayloadPtr* EthernetFrameEditor::GetPayload()
|
||||
PayloadPtrEditor* EthernetFrameEditor::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@ namespace PacketReader
|
||||
//Length
|
||||
private:
|
||||
NetPacket* basePkt;
|
||||
std::unique_ptr<PayloadPtr> payload;
|
||||
std::unique_ptr<PayloadPtrEditor> payload;
|
||||
|
||||
public:
|
||||
EthernetFrameEditor(NetPacket* pkt);
|
||||
|
||||
MAC_Address GetDestinationMAC();
|
||||
MAC_Address GetDestinationMAC() const;
|
||||
void SetDestinationMAC(MAC_Address value);
|
||||
MAC_Address GetSourceMAC();
|
||||
MAC_Address GetSourceMAC() const;
|
||||
void SetSourceMAC(MAC_Address value);
|
||||
|
||||
u16 GetProtocol();
|
||||
u16 GetProtocol() const;
|
||||
|
||||
PayloadPtr* GetPayload();
|
||||
PayloadPtrEditor* GetPayload() const;
|
||||
};
|
||||
} // namespace PacketReader
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PacketReader::IP::ICMP
|
||||
: payload{data}
|
||||
{
|
||||
}
|
||||
ICMP_Packet::ICMP_Packet(u8* buffer, int bufferSize)
|
||||
ICMP_Packet::ICMP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31
|
||||
@@ -34,7 +34,7 @@ namespace PacketReader::IP::ICMP
|
||||
memcpy(headerData, original.headerData, 4);
|
||||
}
|
||||
|
||||
Payload* ICMP_Packet::GetPayload()
|
||||
Payload* ICMP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace PacketReader::IP::ICMP
|
||||
return new ICMP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 ICMP_Packet::GetProtocol()
|
||||
u8 ICMP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace PacketReader::IP::ICMP
|
||||
if (counter != pHeaderLen)
|
||||
NetLib::WriteByte08(segment, &counter, 0);
|
||||
|
||||
u16 csumCal = IP_Packet::InternetChecksum(segment, pHeaderLen);
|
||||
const u16 csumCal = IP_Packet::InternetChecksum(segment, pHeaderLen);
|
||||
delete[] segment;
|
||||
|
||||
return (csumCal == 0);
|
||||
|
||||
@@ -27,16 +27,16 @@ namespace PacketReader::IP::ICMP
|
||||
public:
|
||||
//Takes ownership of payload
|
||||
ICMP_Packet(Payload* data);
|
||||
ICMP_Packet(u8* buffer, int bufferSize);
|
||||
ICMP_Packet(const u8* buffer, int bufferSize);
|
||||
ICMP_Packet(const ICMP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual ICMP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
|
||||
namespace PacketReader::IP
|
||||
{
|
||||
bool IPOption::IsCopyOnFragment()
|
||||
bool IPOption::IsCopyOnFragment() const
|
||||
{
|
||||
return ((GetCode() & (1 << 0x7)) != 0);
|
||||
}
|
||||
u8 IPOption::GetClass()
|
||||
u8 IPOption::GetClass() const
|
||||
{
|
||||
return (GetCode() >> 5) & 0x3;
|
||||
}
|
||||
u8 IPOption::GetNumber()
|
||||
u8 IPOption::GetNumber() const
|
||||
{
|
||||
return GetCode() & 0x1F;
|
||||
}
|
||||
|
||||
IPopUnk::IPopUnk(u8* data, int offset)
|
||||
IPopUnk::IPopUnk(const u8* data, int offset)
|
||||
{
|
||||
NetLib::ReadByte08(data, &offset, &code);
|
||||
NetLib::ReadByte08(data, &offset, &length);
|
||||
@@ -27,7 +27,7 @@ namespace PacketReader::IP
|
||||
value.resize(length - 2);
|
||||
NetLib::ReadByteArray(data, &offset, length - 2, &value[0]);
|
||||
}
|
||||
void IPopUnk::WriteBytes(u8* buffer, int* offset)
|
||||
void IPopUnk::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, code);
|
||||
NetLib::WriteByte08(buffer, offset, length);
|
||||
@@ -38,12 +38,12 @@ namespace PacketReader::IP
|
||||
: value{parValue}
|
||||
{
|
||||
}
|
||||
IPopRouterAlert::IPopRouterAlert(u8* data, int offset)
|
||||
IPopRouterAlert::IPopRouterAlert(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &value);
|
||||
}
|
||||
void IPopRouterAlert::WriteBytes(u8* buffer, int* offset)
|
||||
void IPopRouterAlert::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace PacketReader::IP
|
||||
class BaseOption
|
||||
{
|
||||
public:
|
||||
virtual u8 GetLength() = 0;
|
||||
virtual u8 GetCode() = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) = 0;
|
||||
virtual u8 GetLength() const = 0;
|
||||
virtual u8 GetCode() const = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const = 0;
|
||||
virtual BaseOption* Clone() const = 0;
|
||||
virtual ~BaseOption() {}
|
||||
};
|
||||
@@ -22,9 +22,9 @@ namespace PacketReader::IP
|
||||
class IPOption : public BaseOption
|
||||
{
|
||||
public:
|
||||
bool IsCopyOnFragment();
|
||||
u8 GetClass(); //0 = control, 2 = debugging and measurement
|
||||
u8 GetNumber();
|
||||
bool IsCopyOnFragment() const;
|
||||
u8 GetClass() const; //0 = control, 2 = debugging and measurement
|
||||
u8 GetNumber() const;
|
||||
virtual IPOption* Clone() const = 0;
|
||||
};
|
||||
|
||||
@@ -35,12 +35,12 @@ namespace PacketReader::IP
|
||||
std::vector<u8> value;
|
||||
|
||||
public:
|
||||
IPopUnk(u8* data, int offset);
|
||||
IPopUnk(const u8* data, int offset);
|
||||
|
||||
virtual u8 GetLength() { return length; }
|
||||
virtual u8 GetCode() { return code; }
|
||||
virtual u8 GetLength() const { return length; }
|
||||
virtual u8 GetCode() const { return code; }
|
||||
|
||||
void WriteBytes(u8* buffer, int* offset);
|
||||
void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual IPopUnk* Clone() const
|
||||
{
|
||||
@@ -51,10 +51,10 @@ namespace PacketReader::IP
|
||||
class IPopNOP : public IPOption
|
||||
{
|
||||
public:
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
@@ -73,12 +73,12 @@ namespace PacketReader::IP
|
||||
u16 value;
|
||||
|
||||
IPopRouterAlert(u16 parValue);
|
||||
IPopRouterAlert(u8* data, int offset);
|
||||
IPopRouterAlert(const u8* data, int offset);
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 148; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 148; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual IPopRouterAlert* Clone() const
|
||||
{
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
namespace PacketReader::IP
|
||||
{
|
||||
int IP_Packet::GetHeaderLength()
|
||||
int IP_Packet::GetHeaderLength() const
|
||||
{
|
||||
return headerLength;
|
||||
}
|
||||
|
||||
u8 IP_Packet::GetDscpValue()
|
||||
u8 IP_Packet::GetDscpValue() const
|
||||
{
|
||||
return (dscp >> 2) & 0x3F;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace PacketReader::IP
|
||||
dscp = (dscp & ~(0x3F << 2)) | ((value & 0x3F) << 2);
|
||||
}
|
||||
|
||||
u8 IP_Packet::GetDscpECN()
|
||||
u8 IP_Packet::GetDscpECN() const
|
||||
{
|
||||
return dscp & 0x3;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace PacketReader::IP
|
||||
dscp = (dscp & ~0x3) | (value & 0x3);
|
||||
}
|
||||
|
||||
bool IP_Packet::GetDoNotFragment()
|
||||
bool IP_Packet::GetDoNotFragment() const
|
||||
{
|
||||
return (fragmentFlags1 & (1 << 6)) != 0;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace PacketReader::IP
|
||||
fragmentFlags1 = (fragmentFlags1 & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool IP_Packet::GetMoreFragments()
|
||||
bool IP_Packet::GetMoreFragments() const
|
||||
{
|
||||
return (fragmentFlags1 & (1 << 5)) != 0;
|
||||
}
|
||||
@@ -50,11 +50,11 @@ namespace PacketReader::IP
|
||||
fragmentFlags1 = (fragmentFlags1 & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
u16 IP_Packet::GetFragmentOffset()
|
||||
u16 IP_Packet::GetFragmentOffset() const
|
||||
{
|
||||
int x = 0;
|
||||
u8 fF1masked = fragmentFlags1 & 0x1F;
|
||||
u8 data[2] = {fF1masked, fragmentFlags2};
|
||||
const u8 fF1masked = fragmentFlags1 & 0x1F;
|
||||
const u8 data[2] = {fF1masked, fragmentFlags2};
|
||||
u16 offset;
|
||||
NetLib::ReadUInt16(data, &x, &offset);
|
||||
return offset;
|
||||
@@ -66,7 +66,7 @@ namespace PacketReader::IP
|
||||
{
|
||||
}
|
||||
|
||||
IP_Packet::IP_Packet(u8* buffer, int bufferSize, bool fromICMP)
|
||||
IP_Packet::IP_Packet(const u8* buffer, int bufferSize, bool fromICMP)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace PacketReader::IP
|
||||
bool opReadFin = false;
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opKind = buffer[offset];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
@@ -154,7 +154,7 @@ namespace PacketReader::IP
|
||||
options.push_back(original.options[i]->Clone());
|
||||
}
|
||||
|
||||
IP_Payload* IP_Packet::GetPayload()
|
||||
IP_Payload* IP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace PacketReader::IP
|
||||
|
||||
void IP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int startOff = *offset;
|
||||
const int startOff = *offset;
|
||||
CalculateChecksum(); //ReComputeHeaderLen called in CalculateChecksum
|
||||
payload->CalculateChecksum(sourceIP, destinationIP);
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace PacketReader::IP
|
||||
delete options[i];
|
||||
}
|
||||
|
||||
u16 IP_Packet::InternetChecksum(u8* buffer, int length)
|
||||
u16 IP_Packet::InternetChecksum(const u8* buffer, int length)
|
||||
{
|
||||
//source http://stackoverflow.com/a/2201090
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace PacketReader::IP
|
||||
std::unique_ptr<IP_Payload> payload;
|
||||
|
||||
public:
|
||||
int GetHeaderLength();
|
||||
int GetHeaderLength() const;
|
||||
|
||||
//DSCP/TOS Flags
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace PacketReader::IP
|
||||
* Class 5, Expedited Forwarding, 3
|
||||
* bit0: Set to zero
|
||||
*/
|
||||
u8 GetDscpValue();
|
||||
u8 GetDscpValue() const;
|
||||
void SetDscpValue(u8 value);
|
||||
|
||||
/* 2 bits
|
||||
@@ -97,34 +97,34 @@ namespace PacketReader::IP
|
||||
* 1,2 ECN Supported
|
||||
* 3 = Congestion Encountered
|
||||
*/
|
||||
u8 GetDscpECN();
|
||||
u8 GetDscpECN() const;
|
||||
void SetDscpECN(u8 value);
|
||||
|
||||
//Fragment Flags
|
||||
//bit 0, reserverd
|
||||
|
||||
bool GetDoNotFragment();
|
||||
bool GetDoNotFragment() const;
|
||||
void SetDoNotFragment(bool value);
|
||||
|
||||
bool GetMoreFragments();
|
||||
bool GetMoreFragments() const;
|
||||
void SetMoreFragments(bool value);
|
||||
|
||||
//Untested
|
||||
u16 GetFragmentOffset();
|
||||
u16 GetFragmentOffset() const;
|
||||
|
||||
//Takes ownership of payload
|
||||
IP_Packet(IP_Payload* data);
|
||||
IP_Packet(u8* buffer, int bufferSize, bool fromICMP = false);
|
||||
IP_Packet(const u8* buffer, int bufferSize, bool fromICMP = false);
|
||||
IP_Packet(const IP_Packet&);
|
||||
|
||||
IP_Payload* GetPayload();
|
||||
IP_Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual IP_Packet* Clone() const;
|
||||
|
||||
bool VerifyChecksum();
|
||||
static u16 InternetChecksum(u8* buffer, int length);
|
||||
static u16 InternetChecksum(const u8* buffer, int length);
|
||||
|
||||
~IP_Packet();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PacketReader::IP
|
||||
public: //Nedd GetProtocol
|
||||
virtual int GetLength() = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) = 0;
|
||||
virtual u8 GetProtocol() = 0;
|
||||
virtual u8 GetProtocol() const = 0;
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP) { return false; }
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP) {}
|
||||
virtual IP_Payload* Clone() const = 0;
|
||||
@@ -25,23 +25,21 @@ namespace PacketReader::IP
|
||||
std::unique_ptr<u8[]> data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
u8 protocol;
|
||||
const int length;
|
||||
const u8 protocol;
|
||||
|
||||
public:
|
||||
IP_PayloadData(int len, u8 prot)
|
||||
: length{len}
|
||||
, protocol{prot}
|
||||
{
|
||||
protocol = prot;
|
||||
length = len;
|
||||
|
||||
if (len != 0)
|
||||
data = std::make_unique<u8[]>(len);
|
||||
}
|
||||
IP_PayloadData(const IP_PayloadData& original)
|
||||
: length{original.length}
|
||||
, protocol{original.protocol}
|
||||
{
|
||||
protocol = original.protocol;
|
||||
length = original.length;
|
||||
|
||||
if (length != 0)
|
||||
{
|
||||
data = std::make_unique<u8[]>(length);
|
||||
@@ -60,7 +58,7 @@ namespace PacketReader::IP
|
||||
memcpy(&buffer[*offset], data.get(), length);
|
||||
*offset += length;
|
||||
}
|
||||
virtual u8 GetProtocol()
|
||||
virtual u8 GetProtocol() const
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
@@ -74,18 +72,18 @@ namespace PacketReader::IP
|
||||
class IP_PayloadPtr : public IP_Payload
|
||||
{
|
||||
public:
|
||||
u8* data;
|
||||
const u8* data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
u8 protocol;
|
||||
const int length;
|
||||
const u8 protocol;
|
||||
|
||||
public:
|
||||
IP_PayloadPtr(u8* ptr, int len, u8 prot)
|
||||
IP_PayloadPtr(const u8* ptr, int len, u8 prot)
|
||||
: data{ptr}
|
||||
, length{len}
|
||||
, protocol{prot}
|
||||
{
|
||||
data = ptr;
|
||||
length = len;
|
||||
protocol = prot;
|
||||
}
|
||||
IP_PayloadPtr(const IP_PayloadPtr&) = delete;
|
||||
virtual int GetLength()
|
||||
@@ -108,7 +106,7 @@ namespace PacketReader::IP
|
||||
memcpy(ret->data.get(), data, length);
|
||||
return ret;
|
||||
}
|
||||
virtual u8 GetProtocol()
|
||||
virtual u8 GetProtocol() const
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace PacketReader::IP::TCP
|
||||
: maxSegmentSize{mss}
|
||||
{
|
||||
}
|
||||
TCPopMSS::TCPopMSS(u8* data, int offset)
|
||||
TCPopMSS::TCPopMSS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &maxSegmentSize);
|
||||
}
|
||||
void TCPopMSS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopMSS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
@@ -27,12 +27,12 @@ namespace PacketReader::IP::TCP
|
||||
: windowScale{ws}
|
||||
{
|
||||
}
|
||||
TCPopWS::TCPopWS(u8* data, int offset)
|
||||
TCPopWS::TCPopWS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &windowScale);
|
||||
}
|
||||
void TCPopWS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopWS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
@@ -45,13 +45,13 @@ namespace PacketReader::IP::TCP
|
||||
, echoTimeStamp{echoTS}
|
||||
{
|
||||
}
|
||||
TCPopTS::TCPopTS(u8* data, int offset)
|
||||
TCPopTS::TCPopTS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &senderTimeStamp);
|
||||
NetLib::ReadUInt32(data, &offset, &echoTimeStamp);
|
||||
}
|
||||
void TCPopTS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopTS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace PacketReader::IP::TCP
|
||||
{
|
||||
class TCPopNOP : public BaseOption
|
||||
{
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
@@ -30,12 +30,12 @@ namespace PacketReader::IP::TCP
|
||||
u16 maxSegmentSize;
|
||||
|
||||
TCPopMSS(u16 mss);
|
||||
TCPopMSS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopMSS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 2; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 2; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopMSS* Clone() const
|
||||
{
|
||||
@@ -49,12 +49,12 @@ namespace PacketReader::IP::TCP
|
||||
u8 windowScale;
|
||||
|
||||
TCPopWS(u8 ws);
|
||||
TCPopWS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopWS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 3; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 3; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopWS* Clone() const
|
||||
{
|
||||
@@ -69,12 +69,12 @@ namespace PacketReader::IP::TCP
|
||||
u32 echoTimeStamp;
|
||||
|
||||
TCPopTS(u32 senderTS, u32 echoTS);
|
||||
TCPopTS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopTS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 10; }
|
||||
virtual u8 GetCode() { return 8; }
|
||||
virtual u8 GetLength() const { return 10; }
|
||||
virtual u8 GetCode() const { return 8; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopTS* Clone() const
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace PacketReader::IP::TCP
|
||||
{
|
||||
//Need flags
|
||||
bool TCP_Packet::GetNS()
|
||||
bool TCP_Packet::GetNS() const
|
||||
{
|
||||
return (dataOffsetAndNS_Flag & 1);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace PacketReader::IP::TCP
|
||||
dataOffsetAndNS_Flag = (dataOffsetAndNS_Flag & ~0x1) | (value & 0x1);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetCWR()
|
||||
bool TCP_Packet::GetCWR() const
|
||||
{
|
||||
return (flags & (1 << 7));
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetECE()
|
||||
bool TCP_Packet::GetECE() const
|
||||
{
|
||||
return (flags & (1 << 6));
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetURG()
|
||||
bool TCP_Packet::GetURG() const
|
||||
{
|
||||
return (flags & (1 << 5));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetACK()
|
||||
bool TCP_Packet::GetACK() const
|
||||
{
|
||||
return (flags & (1 << 4));
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 4)) | ((value & 0x1) << 4);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetPSH()
|
||||
bool TCP_Packet::GetPSH() const
|
||||
{
|
||||
return (flags & (1 << 3));
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 3)) | ((value & 0x1) << 3);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetRST()
|
||||
bool TCP_Packet::GetRST() const
|
||||
{
|
||||
return (flags & (1 << 2));
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 2)) | ((value & 0x1) << 2);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetSYN()
|
||||
bool TCP_Packet::GetSYN() const
|
||||
{
|
||||
return (flags & (1 << 1));
|
||||
}
|
||||
@@ -82,7 +82,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 1)) | ((value & 0x1) << 1);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetFIN()
|
||||
bool TCP_Packet::GetFIN() const
|
||||
{
|
||||
return (flags & 1);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace PacketReader::IP::TCP
|
||||
, payload{data}
|
||||
{
|
||||
}
|
||||
TCP_Packet::TCP_Packet(u8* buffer, int bufferSize)
|
||||
TCP_Packet::TCP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31
|
||||
@@ -125,8 +125,8 @@ namespace PacketReader::IP::TCP
|
||||
bool opReadFin = false;
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opKind = buffer[offset];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
@@ -180,7 +180,7 @@ namespace PacketReader::IP::TCP
|
||||
options.push_back(original.options[i]->Clone());
|
||||
}
|
||||
|
||||
Payload* TCP_Packet::GetPayload()
|
||||
Payload* TCP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -193,7 +193,7 @@ namespace PacketReader::IP::TCP
|
||||
|
||||
void TCP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int startOff = *offset;
|
||||
const int startOff = *offset;
|
||||
NetLib::WriteUInt16(buffer, offset, sourcePort);
|
||||
NetLib::WriteUInt16(buffer, offset, destinationPort);
|
||||
NetLib::WriteUInt32(buffer, offset, sequenceNumber);
|
||||
@@ -222,7 +222,7 @@ namespace PacketReader::IP::TCP
|
||||
return new TCP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 TCP_Packet::GetProtocol()
|
||||
u8 TCP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ namespace PacketReader::IP::TCP
|
||||
headerLength = Common::AlignUpPow2(opOffset, 4);
|
||||
|
||||
//Also write into dataOffsetAndNS_Flag
|
||||
u8 ns = dataOffsetAndNS_Flag & 1;
|
||||
const u8 ns = dataOffsetAndNS_Flag & 1;
|
||||
dataOffsetAndNS_Flag = (headerLength >> 2) << 4;
|
||||
dataOffsetAndNS_Flag |= ns;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ namespace PacketReader::IP::TCP
|
||||
if (counter != pHeaderLen)
|
||||
NetLib::WriteByte08(headerSegment, &counter, 0);
|
||||
|
||||
u16 csumCal = IP_Packet::InternetChecksum(headerSegment, pHeaderLen);
|
||||
const u16 csumCal = IP_Packet::InternetChecksum(headerSegment, pHeaderLen);
|
||||
delete[] headerSegment;
|
||||
|
||||
return (csumCal == 0);
|
||||
|
||||
@@ -38,45 +38,45 @@ namespace PacketReader::IP::TCP
|
||||
|
||||
public:
|
||||
//Flags
|
||||
bool GetNS();
|
||||
bool GetNS() const;
|
||||
void SetNS(bool value);
|
||||
|
||||
bool GetCWR();
|
||||
bool GetCWR() const;
|
||||
void SetCWR(bool value);
|
||||
|
||||
bool GetECE();
|
||||
bool GetECE() const;
|
||||
void SetECE(bool value);
|
||||
|
||||
bool GetURG();
|
||||
bool GetURG() const;
|
||||
void SetURG(bool value);
|
||||
|
||||
bool GetACK();
|
||||
bool GetACK() const;
|
||||
void SetACK(bool value);
|
||||
|
||||
bool GetPSH();
|
||||
bool GetPSH() const;
|
||||
void SetPSH(bool value);
|
||||
|
||||
bool GetRST();
|
||||
bool GetRST() const;
|
||||
void SetRST(bool value);
|
||||
|
||||
bool GetSYN();
|
||||
bool GetSYN() const;
|
||||
void SetSYN(bool value);
|
||||
|
||||
bool GetFIN();
|
||||
bool GetFIN() const;
|
||||
void SetFIN(bool value);
|
||||
|
||||
//Takes ownership of payload
|
||||
TCP_Packet(Payload* data);
|
||||
TCP_Packet(u8* buffer, int bufferSize);
|
||||
TCP_Packet(const u8* buffer, int bufferSize);
|
||||
TCP_Packet(const TCP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual TCP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
||||
@@ -12,12 +12,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: subnetMask{mask}
|
||||
{
|
||||
}
|
||||
DHCPopSubnet::DHCPopSubnet(u8* data, int offset)
|
||||
DHCPopSubnet::DHCPopSubnet(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &subnetMask);
|
||||
}
|
||||
void DHCPopSubnet::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopSubnet::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -28,7 +28,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: routers{routerIPs}
|
||||
{
|
||||
}
|
||||
DHCPopRouter::DHCPopRouter(u8* data, int offset)
|
||||
DHCPopRouter::DHCPopRouter(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -37,7 +37,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
routers = {(IP_Address*)&data[offset], (IP_Address*)&data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopRouter::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopRouter::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -49,7 +49,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: dnsServers{dnsIPs}
|
||||
{
|
||||
}
|
||||
DHCPopDNS::DHCPopDNS(u8* data, int offset)
|
||||
DHCPopDNS::DHCPopDNS(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -58,7 +58,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
dnsServers = {(IP_Address*)&data[offset], (IP_Address*)&data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopDNS::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopDNS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -76,7 +76,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
hostName = name;
|
||||
}
|
||||
DHCPopHostName::DHCPopHostName(u8* data, int offset)
|
||||
DHCPopHostName::DHCPopHostName(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -84,7 +84,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
hostName = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopHostName::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopHostName::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -92,7 +92,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
NetLib::WriteByteArray(buffer, offset, hostName.size(), (u8*)hostName.c_str());
|
||||
}
|
||||
|
||||
DHCPopDnsName::DHCPopDnsName(std::string name)
|
||||
DHCPopDnsName::DHCPopDnsName(const std::string& name)
|
||||
{
|
||||
if (name.size() > 255)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
domainName = name;
|
||||
}
|
||||
DHCPopDnsName::DHCPopDnsName(u8* data, int offset)
|
||||
DHCPopDnsName::DHCPopDnsName(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -110,7 +110,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
domainName = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopDnsName::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopDnsName::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -122,12 +122,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: broadcastIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopBCIP::DHCPopBCIP(u8* data, int offset)
|
||||
DHCPopBCIP::DHCPopBCIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &broadcastIP);
|
||||
}
|
||||
void DHCPopBCIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopBCIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -135,7 +135,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
NetLib::WriteIPAddress(buffer, offset, broadcastIP);
|
||||
}
|
||||
|
||||
bool DHCPopNBIOSType::GetHNode()
|
||||
bool DHCPopNBIOSType::GetHNode() const
|
||||
{
|
||||
return ((type & (1 << 3)) != 0);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
type &= ~(1 << 3);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetMNode()
|
||||
bool DHCPopNBIOSType::GetMNode() const
|
||||
{
|
||||
return ((type & (1 << 2)) != 0);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
type &= ~(1 << 2);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetPNode()
|
||||
bool DHCPopNBIOSType::GetPNode() const
|
||||
{
|
||||
return ((type & (1 << 1)) != 0);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
type &= ~(1 << 1);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetBNode()
|
||||
bool DHCPopNBIOSType::GetBNode() const
|
||||
{
|
||||
return ((type & 1) != 0);
|
||||
}
|
||||
@@ -196,12 +196,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
}
|
||||
}
|
||||
//
|
||||
DHCPopNBIOSType::DHCPopNBIOSType(u8* data, int offset)
|
||||
DHCPopNBIOSType::DHCPopNBIOSType(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &type);
|
||||
}
|
||||
void DHCPopNBIOSType::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopNBIOSType::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -213,12 +213,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: requestedIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopREQIP::DHCPopREQIP(u8* data, int offset)
|
||||
DHCPopREQIP::DHCPopREQIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &requestedIP);
|
||||
}
|
||||
void DHCPopREQIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopREQIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -230,12 +230,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: ipLeaseTime{LeaseTime}
|
||||
{
|
||||
}
|
||||
DHCPopIPLT::DHCPopIPLT(u8* data, int offset)
|
||||
DHCPopIPLT::DHCPopIPLT(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipLeaseTime);
|
||||
}
|
||||
void DHCPopIPLT::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopIPLT::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -247,12 +247,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: message{msg}
|
||||
{
|
||||
}
|
||||
DHCPopMSG::DHCPopMSG(u8* data, int offset)
|
||||
DHCPopMSG::DHCPopMSG(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &message);
|
||||
}
|
||||
void DHCPopMSG::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMSG::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -264,12 +264,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: serverIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopSERVIP::DHCPopSERVIP(u8* data, int offset)
|
||||
DHCPopSERVIP::DHCPopSERVIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &serverIP);
|
||||
}
|
||||
void DHCPopSERVIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopSERVIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -281,7 +281,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: requests{requestList}
|
||||
{
|
||||
}
|
||||
DHCPopREQLIST::DHCPopREQLIST(u8* data, int offset)
|
||||
DHCPopREQLIST::DHCPopREQLIST(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -290,7 +290,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
requests = {&data[offset], &data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopREQLIST::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopREQLIST::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -308,7 +308,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
message = msg;
|
||||
}
|
||||
DHCPopMSGStr::DHCPopMSGStr(u8* data, int offset)
|
||||
DHCPopMSGStr::DHCPopMSGStr(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -316,7 +316,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
message = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopMSGStr::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMSGStr::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -328,12 +328,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: maxMessageSize{mms}
|
||||
{
|
||||
}
|
||||
DHCPopMMSGS::DHCPopMMSGS(u8* data, int offset)
|
||||
DHCPopMMSGS::DHCPopMMSGS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &maxMessageSize);
|
||||
}
|
||||
void DHCPopMMSGS::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMMSGS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -345,12 +345,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: ipRenewalTimeT1{t1}
|
||||
{
|
||||
}
|
||||
DHCPopT1::DHCPopT1(u8* data, int offset)
|
||||
DHCPopT1::DHCPopT1(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipRenewalTimeT1);
|
||||
}
|
||||
void DHCPopT1::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopT1::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -362,12 +362,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: ipRebindingTimeT2{t2}
|
||||
{
|
||||
}
|
||||
DHCPopT2::DHCPopT2(u8* data, int offset)
|
||||
DHCPopT2::DHCPopT2(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipRebindingTimeT2);
|
||||
}
|
||||
void DHCPopT2::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopT2::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -385,7 +385,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
classID = id;
|
||||
}
|
||||
DHCPopClassID::DHCPopClassID(u8* data, int offset)
|
||||
DHCPopClassID::DHCPopClassID(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -393,7 +393,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
classID = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopClassID::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopClassID::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -405,7 +405,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: clientID{value}
|
||||
{
|
||||
}
|
||||
DHCPopClientID::DHCPopClientID(u8* data, int offset)
|
||||
DHCPopClientID::DHCPopClientID(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -414,7 +414,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
clientID = {&data[offset], &data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopClientID::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopClientID::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
//GetLength(), howver, includes the option header
|
||||
class DHCPopNOP : public BaseOption
|
||||
{
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 0; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 0; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
@@ -35,12 +35,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address subnetMask{};
|
||||
|
||||
DHCPopSubnet(IP_Address mask);
|
||||
DHCPopSubnet(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopSubnet(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopSubnet* Clone() const
|
||||
{
|
||||
@@ -53,12 +53,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
std::vector<IP_Address> routers;
|
||||
DHCPopRouter(const std::vector<IP_Address>& routerIPs);
|
||||
DHCPopRouter(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopRouter(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + 4 * routers.size(); }
|
||||
virtual u8 GetCode() { return 3; }
|
||||
virtual u8 GetLength() const { return 2 + 4 * routers.size(); }
|
||||
virtual u8 GetCode() const { return 3; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopRouter* Clone() const
|
||||
{
|
||||
@@ -71,12 +71,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
std::vector<IP_Address> dnsServers;
|
||||
DHCPopDNS(const std::vector<IP_Address>& dnsIPs);
|
||||
DHCPopDNS(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopDNS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + 4 * dnsServers.size(); }
|
||||
virtual u8 GetCode() { return 6; }
|
||||
virtual u8 GetLength() const { return 2 + 4 * dnsServers.size(); }
|
||||
virtual u8 GetCode() const { return 6; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopDNS* Clone() const
|
||||
{
|
||||
@@ -91,12 +91,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::string hostName;
|
||||
|
||||
DHCPopHostName(const std::string& name);
|
||||
DHCPopHostName(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopHostName(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + hostName.size(); }
|
||||
virtual u8 GetCode() { return 12; }
|
||||
virtual u8 GetLength() const { return 2 + hostName.size(); }
|
||||
virtual u8 GetCode() const { return 12; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopHostName* Clone() const
|
||||
{
|
||||
@@ -110,13 +110,13 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
//ASCII encoding
|
||||
std::string domainName;
|
||||
|
||||
DHCPopDnsName(std::string name);
|
||||
DHCPopDnsName(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopDnsName(const std::string& name);
|
||||
DHCPopDnsName(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + domainName.size(); }
|
||||
virtual u8 GetCode() { return 15; }
|
||||
virtual u8 GetLength() const { return 2 + domainName.size(); }
|
||||
virtual u8 GetCode() const { return 15; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopDnsName* Clone() const
|
||||
{
|
||||
@@ -130,12 +130,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address broadcastIP{};
|
||||
|
||||
DHCPopBCIP(IP_Address data);
|
||||
DHCPopBCIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopBCIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 28; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 28; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopBCIP* Clone() const
|
||||
{
|
||||
@@ -151,24 +151,24 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
|
||||
public:
|
||||
//Getters/Setters
|
||||
bool GetHNode();
|
||||
bool GetHNode() const;
|
||||
void SetHNode(bool value);
|
||||
|
||||
bool GetMNode();
|
||||
bool GetMNode() const;
|
||||
void SetMNode(bool value);
|
||||
|
||||
bool GetPNode();
|
||||
bool GetPNode() const;
|
||||
void SetPNode(bool value);
|
||||
|
||||
bool GetBNode();
|
||||
bool GetBNode() const;
|
||||
void SetBNode(bool value);
|
||||
|
||||
DHCPopNBIOSType(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopNBIOSType(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 46; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 46; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopNBIOSType* Clone() const
|
||||
{
|
||||
@@ -182,12 +182,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address requestedIP{};
|
||||
|
||||
DHCPopREQIP(IP_Address data);
|
||||
DHCPopREQIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopREQIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 50; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 50; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopREQIP* Clone() const
|
||||
{
|
||||
@@ -201,12 +201,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u32 ipLeaseTime;
|
||||
|
||||
DHCPopIPLT(u32 LeaseTime);
|
||||
DHCPopIPLT(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopIPLT(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 51; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 51; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopIPLT* Clone() const
|
||||
{
|
||||
@@ -219,12 +219,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
u8 message;
|
||||
DHCPopMSG(u8 msg);
|
||||
DHCPopMSG(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMSG(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 53; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 53; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMSG* Clone() const
|
||||
{
|
||||
@@ -238,12 +238,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address serverIP{};
|
||||
|
||||
DHCPopSERVIP(IP_Address data);
|
||||
DHCPopSERVIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopSERVIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 54; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 54; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopSERVIP* Clone() const
|
||||
{
|
||||
@@ -257,12 +257,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::vector<u8> requests;
|
||||
|
||||
DHCPopREQLIST(const std::vector<u8>& requestList);
|
||||
DHCPopREQLIST(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopREQLIST(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + requests.size(); }
|
||||
virtual u8 GetCode() { return 55; }
|
||||
virtual u8 GetLength() const { return 2 + requests.size(); }
|
||||
virtual u8 GetCode() const { return 55; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopREQLIST* Clone() const
|
||||
{
|
||||
@@ -277,12 +277,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::string message;
|
||||
|
||||
DHCPopMSGStr(const std::string& msg);
|
||||
DHCPopMSGStr(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMSGStr(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + message.size(); }
|
||||
virtual u8 GetCode() { return 56; }
|
||||
virtual u8 GetLength() const { return 2 + message.size(); }
|
||||
virtual u8 GetCode() const { return 56; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMSGStr* Clone() const
|
||||
{
|
||||
@@ -296,12 +296,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u16 maxMessageSize;
|
||||
|
||||
DHCPopMMSGS(u16 mms);
|
||||
DHCPopMMSGS(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMMSGS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 57; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 57; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMMSGS* Clone() const
|
||||
{
|
||||
@@ -315,12 +315,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u32 ipRenewalTimeT1;
|
||||
|
||||
DHCPopT1(u32 t1);
|
||||
DHCPopT1(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopT1(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 58; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 58; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopT1* Clone() const
|
||||
{
|
||||
@@ -334,12 +334,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u32 ipRebindingTimeT2;
|
||||
|
||||
DHCPopT2(u32 t2);
|
||||
DHCPopT2(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopT2(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 59; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 59; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopT2* Clone() const
|
||||
{
|
||||
@@ -354,12 +354,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::string classID;
|
||||
|
||||
DHCPopClassID(const std::string& id);
|
||||
DHCPopClassID(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopClassID(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + classID.size(); }
|
||||
virtual u8 GetCode() { return 60; }
|
||||
virtual u8 GetLength() const { return 2 + classID.size(); }
|
||||
virtual u8 GetCode() const { return 60; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopClassID* Clone() const
|
||||
{
|
||||
@@ -373,12 +373,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::vector<u8> clientID;
|
||||
|
||||
DHCPopClientID(const std::vector<u8>& value);
|
||||
DHCPopClientID(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopClientID(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + clientID.size(); }
|
||||
virtual u8 GetCode() { return 61; }
|
||||
virtual u8 GetLength() const { return 2 + clientID.size(); }
|
||||
virtual u8 GetCode() const { return 61; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopClientID* Clone() const
|
||||
{
|
||||
@@ -391,10 +391,10 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
DHCPopEND() {}
|
||||
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 255; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 255; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace PacketReader::IP::UDP::DHCP
|
||||
{
|
||||
DHCP_Packet::DHCP_Packet(u8* buffer, int bufferSize)
|
||||
DHCP_Packet::DHCP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31 //Bytes 0-3
|
||||
@@ -49,7 +49,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
const u8 opKind = buffer[offset];
|
||||
if (opKind == 255)
|
||||
{
|
||||
options.push_back(new DHCPopEND());
|
||||
@@ -64,7 +64,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
opReadFin = true;
|
||||
continue;
|
||||
}
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
@@ -172,7 +172,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
|
||||
void DHCP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int start = *offset;
|
||||
const int start = *offset;
|
||||
NetLib::WriteByte08(buffer, offset, op);
|
||||
NetLib::WriteByte08(buffer, offset, hardwareType);
|
||||
NetLib::WriteByte08(buffer, offset, hardwareAddressLength);
|
||||
@@ -210,7 +210,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
if (len == maxLength)
|
||||
{
|
||||
i -= 1;
|
||||
int pastLength = options[i]->GetLength();
|
||||
const int pastLength = options[i]->GetLength();
|
||||
len -= pastLength;
|
||||
*offset -= pastLength;
|
||||
}
|
||||
@@ -221,8 +221,8 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
}
|
||||
}
|
||||
|
||||
int end = start + GetLength();
|
||||
int delta = end - *offset;
|
||||
const int end = start + GetLength();
|
||||
const int delta = end - *offset;
|
||||
|
||||
memset(&buffer[*offset], 0, delta);
|
||||
*offset = start + GetLength();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
int maxLength = 576;
|
||||
|
||||
DHCP_Packet() {}
|
||||
DHCP_Packet(u8* buffer, int bufferSize);
|
||||
DHCP_Packet(const u8* buffer, int bufferSize);
|
||||
DHCP_Packet(const DHCP_Packet&);
|
||||
|
||||
virtual int GetLength();
|
||||
|
||||
@@ -12,20 +12,20 @@ namespace PacketReader::IP::UDP::DNS
|
||||
, entryClass{qClass}
|
||||
{
|
||||
}
|
||||
DNS_QuestionEntry::DNS_QuestionEntry(u8* buffer, int* offset)
|
||||
DNS_QuestionEntry::DNS_QuestionEntry(const u8* buffer, int* offset)
|
||||
{
|
||||
ReadDNS_String(buffer, offset, &name);
|
||||
NetLib::ReadUInt16(buffer, offset, &entryType);
|
||||
NetLib::ReadUInt16(buffer, offset, &entryClass);
|
||||
}
|
||||
|
||||
void DNS_QuestionEntry::ReadDNS_String(u8* buffer, int* offset, std::string* value)
|
||||
void DNS_QuestionEntry::ReadDNS_String(const u8* buffer, int* offset, std::string* value) const
|
||||
{
|
||||
*value = "";
|
||||
|
||||
while (buffer[*offset] != 0)
|
||||
{
|
||||
int len = buffer[*offset];
|
||||
const int len = buffer[*offset];
|
||||
|
||||
if (len >= 192)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
//null char
|
||||
*offset += 1;
|
||||
}
|
||||
void DNS_QuestionEntry::WriteDNS_String(u8* buffer, int* offset, const std::string& value)
|
||||
void DNS_QuestionEntry::WriteDNS_String(u8* buffer, int* offset, const std::string& value) const
|
||||
{
|
||||
int segmentLength = 0;
|
||||
int segmentStart = 0;
|
||||
@@ -86,12 +86,12 @@ namespace PacketReader::IP::UDP::DNS
|
||||
NetLib::WriteByte08(buffer, offset, 0);
|
||||
}
|
||||
|
||||
int DNS_QuestionEntry::GetLength()
|
||||
int DNS_QuestionEntry::GetLength() const
|
||||
{
|
||||
return 1 + name.size() + 1 + 4;
|
||||
}
|
||||
|
||||
void DNS_QuestionEntry::WriteBytes(u8* buffer, int* offset)
|
||||
void DNS_QuestionEntry::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
WriteDNS_String(buffer, offset, name);
|
||||
NetLib::WriteUInt16(buffer, offset, entryType);
|
||||
@@ -105,7 +105,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
{
|
||||
}
|
||||
|
||||
DNS_ResponseEntry::DNS_ResponseEntry(u8* buffer, int* offset)
|
||||
DNS_ResponseEntry::DNS_ResponseEntry(const u8* buffer, int* offset)
|
||||
: DNS_QuestionEntry(buffer, offset)
|
||||
{
|
||||
u16 dataLen;
|
||||
@@ -116,12 +116,12 @@ namespace PacketReader::IP::UDP::DNS
|
||||
*offset += dataLen;
|
||||
}
|
||||
|
||||
int DNS_ResponseEntry::GetLength()
|
||||
int DNS_ResponseEntry::GetLength() const
|
||||
{
|
||||
return DNS_QuestionEntry::GetLength() + 4 + 2 + data.size();
|
||||
}
|
||||
|
||||
void DNS_ResponseEntry::WriteBytes(u8* buffer, int* offset)
|
||||
void DNS_ResponseEntry::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
DNS_QuestionEntry::WriteBytes(buffer, offset);
|
||||
NetLib::WriteUInt32(buffer, offset, timeToLive);
|
||||
|
||||
@@ -18,16 +18,16 @@ namespace PacketReader::IP::UDP::DNS
|
||||
u16 entryClass;
|
||||
|
||||
DNS_QuestionEntry(const std::string& qName, u16 qType, u16 qClass);
|
||||
DNS_QuestionEntry(u8* buffer, int* offset);
|
||||
DNS_QuestionEntry(const u8* buffer, int* offset);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual int GetLength() const;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual ~DNS_QuestionEntry(){};
|
||||
|
||||
private:
|
||||
void ReadDNS_String(u8* buffer, int* offset, std::string* value);
|
||||
void WriteDNS_String(u8* buffer, int* offset, const std::string& value);
|
||||
void ReadDNS_String(const u8* buffer, int* offset, std::string* value) const;
|
||||
void WriteDNS_String(u8* buffer, int* offset, const std::string& value) const;
|
||||
};
|
||||
|
||||
class DNS_ResponseEntry : public DNS_QuestionEntry
|
||||
@@ -37,10 +37,10 @@ namespace PacketReader::IP::UDP::DNS
|
||||
std::vector<u8> data;
|
||||
|
||||
DNS_ResponseEntry(const std::string& rName, u16 rType, u16 rClass, const std::vector<u8>& rData, u32 rTTL);
|
||||
DNS_ResponseEntry(u8* buffer, int* offset);
|
||||
DNS_ResponseEntry(const u8* buffer, int* offset);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual int GetLength() const;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual ~DNS_ResponseEntry(){};
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace PacketReader::IP::UDP::DNS
|
||||
{
|
||||
bool DNS_Packet::GetQR()
|
||||
bool DNS_Packet::GetQR() const
|
||||
{
|
||||
return (flags1 & (1 << 7)) != 0;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetOpCode()
|
||||
u8 DNS_Packet::GetOpCode() const
|
||||
{
|
||||
return (flags1 >> 3) & 0xF;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0xF << 3)) | ((value & 0xF) << 3);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetAA()
|
||||
bool DNS_Packet::GetAA() const
|
||||
{
|
||||
return (flags1 & (1 << 2)) != 0;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0x1 << 2)) | ((value & 0x1) << 2);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetTC()
|
||||
bool DNS_Packet::GetTC() const
|
||||
{
|
||||
return (flags1 & (1 << 1)) != 0;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0x1 << 1)) | ((value & 0x1) << 1);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetRD()
|
||||
bool DNS_Packet::GetRD() const
|
||||
{
|
||||
return (flags1 & 1) != 0;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~0x1) | (value & 0x1);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetRA()
|
||||
bool DNS_Packet::GetRA() const
|
||||
{
|
||||
return (flags2 & (1 << 7)) != 0;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetZ0()
|
||||
u8 DNS_Packet::GetZ0() const
|
||||
{
|
||||
return (flags2 & (1 << 6)) != 0;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags2 & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetAD()
|
||||
bool DNS_Packet::GetAD() const
|
||||
{
|
||||
return (flags2 & (1 << 5)) != 0;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetCD()
|
||||
bool DNS_Packet::GetCD() const
|
||||
{
|
||||
return (flags2 & (1 << 4)) != 0;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0x1 << 4)) | ((value & 0x1) << 4);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetRCode()
|
||||
u8 DNS_Packet::GetRCode() const
|
||||
{
|
||||
return flags2 & 0xF;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0xF)) | ((value & 0xF));
|
||||
}
|
||||
|
||||
DNS_Packet::DNS_Packet(u8* buffer, int bufferSize)
|
||||
DNS_Packet::DNS_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31 //Bytes 0-3
|
||||
|
||||
@@ -33,38 +33,38 @@ namespace PacketReader::IP::UDP::DNS
|
||||
std::vector<DNS_ResponseEntry> authorities;
|
||||
std::vector<DNS_ResponseEntry> additional;
|
||||
|
||||
bool GetQR();
|
||||
bool GetQR() const;
|
||||
void SetQR(bool value);
|
||||
|
||||
u8 GetOpCode();
|
||||
u8 GetOpCode() const;
|
||||
void SetOpCode(u8 value);
|
||||
|
||||
bool GetAA();
|
||||
bool GetAA() const;
|
||||
void SetAA(bool value);
|
||||
|
||||
bool GetTC();
|
||||
bool GetTC() const;
|
||||
void SetTC(bool value);
|
||||
|
||||
bool GetRD();
|
||||
bool GetRD() const;
|
||||
void SetRD(bool value);
|
||||
|
||||
bool GetRA();
|
||||
bool GetRA() const;
|
||||
void SetRA(bool value);
|
||||
|
||||
u8 GetZ0();
|
||||
u8 GetZ0() const;
|
||||
void SetZ0(u8 value);
|
||||
|
||||
bool GetAD();
|
||||
bool GetAD() const;
|
||||
void SetAD(bool value);
|
||||
|
||||
bool GetCD();
|
||||
bool GetCD() const;
|
||||
void SetCD(bool value);
|
||||
|
||||
u8 GetRCode();
|
||||
u8 GetRCode() const;
|
||||
void SetRCode(u8 value);
|
||||
|
||||
DNS_Packet() {}
|
||||
DNS_Packet(u8* buffer, int bufferSize);
|
||||
DNS_Packet(const u8* buffer, int bufferSize);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PacketReader::IP::UDP
|
||||
: payload{data}
|
||||
{
|
||||
}
|
||||
UDP_Packet::UDP_Packet(u8* buffer, int bufferSize)
|
||||
UDP_Packet::UDP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31
|
||||
@@ -42,7 +42,7 @@ namespace PacketReader::IP::UDP
|
||||
{
|
||||
}
|
||||
|
||||
Payload* UDP_Packet::GetPayload()
|
||||
Payload* UDP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -67,7 +67,7 @@ namespace PacketReader::IP::UDP
|
||||
return new UDP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 UDP_Packet::GetProtocol()
|
||||
u8 UDP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
|
||||
@@ -24,16 +24,16 @@ namespace PacketReader::IP::UDP
|
||||
public:
|
||||
//Takes ownership of payload
|
||||
UDP_Packet(Payload* data);
|
||||
UDP_Packet(u8* buffer, int bufferSize);
|
||||
UDP_Packet(const u8* buffer, int bufferSize);
|
||||
UDP_Packet(const UDP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual UDP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
||||
@@ -45,41 +45,41 @@ namespace PacketReader::NetLib
|
||||
*(PacketReader::IP::IP_Address*)&data[*index] = value;
|
||||
*index += sizeof(PacketReader::IP::IP_Address);
|
||||
}
|
||||
inline void WriteByteArray(u8* data, int* index, int length, u8* value)
|
||||
inline void WriteByteArray(u8* data, int* index, int length, const u8* value)
|
||||
{
|
||||
memcpy(&data[*index], value, length);
|
||||
*index += length;
|
||||
}
|
||||
|
||||
// Read.
|
||||
inline void ReadByte08(u8* data, int* index, u8* value)
|
||||
inline void ReadByte08(const u8* data, int* index, u8* value)
|
||||
{
|
||||
*value = data[*index];
|
||||
*index += sizeof(u8);
|
||||
}
|
||||
inline void ReadUInt16(u8* data, int* index, u16* value)
|
||||
inline void ReadUInt16(const u8* data, int* index, u16* value)
|
||||
{
|
||||
*value = ntohs(*(u16*)&data[*index]);
|
||||
*index += sizeof(u16);
|
||||
}
|
||||
inline void ReadUInt32(u8* data, int* index, u32* value)
|
||||
inline void ReadUInt32(const u8* data, int* index, u32* value)
|
||||
{
|
||||
*value = ntohl(*(u32*)&data[*index]);
|
||||
*index += sizeof(u32);
|
||||
}
|
||||
|
||||
// Special read.
|
||||
inline void ReadMACAddress(u8* data, int* index, PacketReader::MAC_Address* value)
|
||||
inline void ReadMACAddress(const u8* data, int* index, PacketReader::MAC_Address* value)
|
||||
{
|
||||
*value = *(PacketReader::MAC_Address*)&data[*index];
|
||||
*index += sizeof(PacketReader::MAC_Address);
|
||||
}
|
||||
inline void ReadIPAddress(u8* data, int* index, PacketReader::IP::IP_Address* value)
|
||||
inline void ReadIPAddress(const u8* data, int* index, PacketReader::IP::IP_Address* value)
|
||||
{
|
||||
*value = *(PacketReader::IP::IP_Address*)&data[*index];
|
||||
*index += sizeof(PacketReader::IP::IP_Address);
|
||||
}
|
||||
inline void ReadByteArray(u8* data, int* index, int length, u8* value)
|
||||
inline void ReadByteArray(const u8* data, int* index, int length, u8* value)
|
||||
{
|
||||
memcpy(value, &data[*index], length);
|
||||
*index += length;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Pcsx2Defs.h"
|
||||
|
||||
namespace PacketReader
|
||||
@@ -30,16 +31,14 @@ namespace PacketReader
|
||||
|
||||
public:
|
||||
PayloadData(int len)
|
||||
: length{len}
|
||||
{
|
||||
length = len;
|
||||
|
||||
if (len != 0)
|
||||
data = std::make_unique<u8[]>(len);
|
||||
}
|
||||
PayloadData(const PayloadData& original)
|
||||
: length{original.length}
|
||||
{
|
||||
length = original.length;
|
||||
|
||||
if (length != 0)
|
||||
{
|
||||
data = std::make_unique<u8[]>(length);
|
||||
@@ -68,16 +67,16 @@ namespace PacketReader
|
||||
class PayloadPtr : public Payload
|
||||
{
|
||||
public:
|
||||
u8* data;
|
||||
const u8* data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
const int length;
|
||||
|
||||
public:
|
||||
PayloadPtr(u8* ptr, int len)
|
||||
PayloadPtr(const u8* ptr, int len)
|
||||
: data{ptr}
|
||||
, length{len}
|
||||
{
|
||||
data = ptr;
|
||||
length = len;
|
||||
}
|
||||
PayloadPtr(const PayloadPtr&) = delete;
|
||||
virtual int GetLength()
|
||||
@@ -101,4 +100,36 @@ namespace PacketReader
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
//Pointer to bytes not owned by class, used by *Editor classes only
|
||||
class PayloadPtrEditor : public Payload
|
||||
{
|
||||
public:
|
||||
u8* data;
|
||||
|
||||
private:
|
||||
const int length;
|
||||
|
||||
public:
|
||||
PayloadPtrEditor(u8* ptr, int len)
|
||||
: data{ptr}
|
||||
, length{len}
|
||||
{
|
||||
}
|
||||
PayloadPtrEditor(const PayloadPtrEditor&) = delete;
|
||||
virtual int GetLength()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
pxAssert(false);
|
||||
}
|
||||
virtual Payload* Clone() const
|
||||
{
|
||||
PayloadData* ret = new PayloadData(length);
|
||||
memcpy(ret->data.get(), data, length);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
} // namespace PacketReader
|
||||
|
||||
@@ -508,10 +508,10 @@ namespace Sessions
|
||||
ipInfo.Ttl = parTimeToLive;
|
||||
DWORD ret;
|
||||
if (parAdapterIP.integer != 0)
|
||||
ret = IcmpSendEcho2Ex(icmpFile, icmpEvent, nullptr, nullptr, parAdapterIP.integer, parDestIP.integer, parPayload->data, parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
ret = IcmpSendEcho2Ex(icmpFile, icmpEvent, nullptr, nullptr, parAdapterIP.integer, parDestIP.integer, const_cast<u8*>(parPayload->data), parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
static_cast<DWORD>(std::chrono::duration_cast<std::chrono::milliseconds>(ICMP_TIMEOUT).count()));
|
||||
else
|
||||
ret = IcmpSendEcho2(icmpFile, icmpEvent, nullptr, nullptr, parDestIP.integer, parPayload->data, parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
ret = IcmpSendEcho2(icmpFile, icmpEvent, nullptr, nullptr, parDestIP.integer, const_cast<u8*>(parPayload->data), parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
static_cast<DWORD>(std::chrono::duration_cast<std::chrono::milliseconds>(ICMP_TIMEOUT).count()));
|
||||
|
||||
// Documentation states that IcmpSendEcho2 returns ERROR_IO_PENDING
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Sessions
|
||||
int type;
|
||||
int code;
|
||||
int dataLength;
|
||||
u8* data;
|
||||
const u8* data;
|
||||
};
|
||||
|
||||
class Ping
|
||||
|
||||
@@ -342,7 +342,7 @@ void PCAPAdapter::SetMACBridgedRecv(NetPacket* pkt)
|
||||
if (frame.GetProtocol() == static_cast<u16>(EtherType::IPv4)) // IP
|
||||
{
|
||||
// Compare DEST IP in IP with the PS2's IP, if they match, change DEST MAC to ps2MAC.
|
||||
PayloadPtr* payload = frame.GetPayload();
|
||||
PayloadPtrEditor* payload = frame.GetPayload();
|
||||
IP_Packet ippkt(payload->data, payload->GetLength());
|
||||
if (ippkt.destinationIP == ps2IP)
|
||||
frame.SetDestinationMAC(ps2MAC);
|
||||
@@ -364,7 +364,7 @@ void PCAPAdapter::SetMACBridgedSend(NetPacket* pkt)
|
||||
EthernetFrameEditor frame(pkt);
|
||||
if (frame.GetProtocol() == static_cast<u16>(EtherType::IPv4)) // IP
|
||||
{
|
||||
PayloadPtr* payload = frame.GetPayload();
|
||||
PayloadPtrEditor* payload = frame.GetPayload();
|
||||
IP_Packet ippkt(payload->data, payload->GetLength());
|
||||
ps2IP = ippkt.sourceIP;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ void PCAPAdapter::HandleFrameCheckSequence(NetPacket* pkt)
|
||||
int payloadSize = -1;
|
||||
if (frame.GetProtocol() == static_cast<u16>(EtherType::IPv4)) // IP
|
||||
{
|
||||
PayloadPtr* payload = frame.GetPayload();
|
||||
PayloadPtrEditor* payload = frame.GetPayload();
|
||||
IP_Packet ippkt(payload->data, payload->GetLength());
|
||||
payloadSize = ippkt.GetLength();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user