forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryRead.h
More file actions
31 lines (26 loc) · 1.88 KB
/
MemoryRead.h
File metadata and controls
31 lines (26 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once
#include <stdint.h>
#include <memory.h>
#include "il2cpp-api-types.h"
// unaligned safe reading
namespace il2cpp
{
namespace utils
{
static inline Il2CppChar ReadChar(const char* p) { Il2CppChar val; memcpy(&val, p, sizeof(Il2CppChar)); return val; }
static inline uint16_t Read16(const char* p) { uint16_t val; memcpy(&val, p, sizeof(uint16_t)); return val; }
static inline uint32_t Read32(const char* p) { uint32_t val; memcpy(&val, p, sizeof(uint32_t)); return val; }
static inline uint64_t Read64(const char* p) { uint64_t val; memcpy(&val, p, sizeof(uint64_t)); return val; }
static inline float ReadFloat(const char* p) { float val; memcpy(&val, p, sizeof(float)); return val; }
static inline double ReadDouble(const char* p) { double val; memcpy(&val, p, sizeof(double)); return val; }
static inline Il2CppChar ReadChar(const char** p) { Il2CppChar val; memcpy(&val, *p, sizeof(Il2CppChar)); *p += sizeof(Il2CppChar); return val; }
static inline uint8_t Read8(const char** p) { uint8_t val; val = **(uint8_t**)p; *p += sizeof(uint8_t); return val; }
static inline uint16_t Read16(const char** p) { uint16_t val; memcpy(&val, *p, sizeof(uint16_t)); *p += sizeof(uint16_t); return val; }
static inline uint32_t Read32(const char** p) { uint32_t val; memcpy(&val, *p, sizeof(uint32_t)); *p += sizeof(uint32_t); return val; }
static inline uint64_t Read64(const char** p) { uint64_t val; memcpy(&val, *p, sizeof(uint64_t)); *p += sizeof(uint64_t); return val; }
static inline float ReadFloat(const char** p) { float val; memcpy(&val, *p, sizeof(float)); *p += sizeof(float); return val; }
static inline double ReadDouble(const char** p) { double val; memcpy(&val, *p, sizeof(double)); *p += sizeof(double); return val; }
uint32_t ReadCompressedUInt32(const char** p);
int32_t ReadCompressedInt32(const char** p);
} /* utils */
} /* il2cpp */