diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2026-07-15 00:58:25 +0200 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2026-07-15 00:58:25 +0200 |
| commit | 45d31b1bb8699dbbb5fc89c807c95e8c8edbe895 (patch) | |
| tree | 5029da96a243e16038373fce54dd942f32e354d8 /src | |
| parent | 968d63f3eda7ba49fcba93e444788091cf3ccee8 (diff) | |
Fix some cl compilation errors
Diffstat (limited to 'src')
| -rw-r--r-- | src/loader.c | 8 | ||||
| -rw-r--r-- | src/pdb.c | 2 | ||||
| -rw-r--r-- | src/utils.c | 6 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/loader.c b/src/loader.c index 8f2ac28..2823a79 100644 --- a/src/loader.c +++ b/src/loader.c @@ -6,6 +6,12 @@ // ====== windows.h ====== // ======================= +#if defined(_MSC_VER) && !defined(__clang__) +#define offsetof(s,m) ((size_t)&(((s*)0)->m)) +#else +#define offsetof __builtin_offsetof +#endif + extern uint64_t __readgsqword(unsigned long offset); typedef struct _LIST_ENTRY { @@ -158,7 +164,7 @@ i32 wstr_cmpn(const u16* str1, const u16* str2, size_t count) { } PEB* get_PEB(void) { - return (PEB*)__readgsqword(__builtin_offsetof(TEB, ProcessEnvironmentBlock)); + return (PEB*)__readgsqword(offsetof(TEB, ProcessEnvironmentBlock)); } void* get_module(u16* name, size_t name_size) { @@ -182,7 +182,7 @@ // ======================== #if defined(_MSC_VER) && !defined(__clang__) - #define alloca + #define alloca _alloca #elif defined(__clang__) #define alloca __builtin_alloca #endif diff --git a/src/utils.c b/src/utils.c index 95a1d80..6de7c92 100644 --- a/src/utils.c +++ b/src/utils.c @@ -53,16 +53,18 @@ void str_cat(char* out, const char* str, size_t c_str) { } } -void memcpy(void* restrict dst, const void* restrict src, size_t size) { +void* memcpy(void* restrict dst, const void* restrict src, size_t size) { RtlCopyMemory(dst, src, size); + return dst; } -void memset(void* dst, int fill, size_t count) { +void* memset(void* dst, int fill, size_t count) { if (fill == 0) { RtlZeroMemory(dst, count); } else { RtlFillMemory(dst, count, fill); } + return dst; } void u64toa(u64 number, char* str, u32 base) { |
