feat(binana): no special include directories now, you must pass GHIDRA or IDA as a definition into your preprocessor

This commit is contained in:
phaneron 2024-08-09 07:15:03 -04:00
parent de5bdadc78
commit 1042d9fa22
60 changed files with 3132 additions and 589 deletions

View file

@ -1,7 +1,7 @@
#ifndef STORM_ARRAY_H
#define STORM_ARRAY_H
#include <stdint.h>
#include "system/types.h"
#define STORM_TS_BASE_ARRAY(T) typedef struct TSBaseArray_##T TSBaseArray_##T; \
struct TSBaseArray_##T { \
@ -25,4 +25,28 @@ struct TSGrowableArray_##T { \
uint32_t m_chunk; \
};
// "pointer-to" types hack
#define STORM_TS_BASE_ARRAY_POINTER_TO(T) typedef struct TSBaseArray_pointer_to_##T TSBaseArray_pointer_to_##T; \
struct TSBaseArray_pointer_to_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T** m_data; \
};
#define STORM_TS_FIXED_ARRAY_POINTER_TO(T) typedef struct TSFixedArray_pointer_to_##T TSFixedArray_pointer_to_##T; \
struct TSFixedArray_pointer_to_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T** m_data; \
};
#define STORM_TS_GROWABLE_ARRAY_POINTER_TO(T) typedef struct TSGrowableArray_pointer_to_##T TSGrowableArray_pointer_to_##T; \
struct TSGrowableArray_pointer_to_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T** m_data; \
uint32_t m_chunk; \
};
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_POINTER_TO_VOID_H
#define STORM_ARRAY_POINTER_TO_VOID_H
#include "system/types.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY_POINTER_TO(void);
#endif

View file

@ -1,10 +1,10 @@
#ifndef STORM_ARRAY_UINT32_T_H
#define STORM_ARRAY_UINT32_T_H
#include <stdint.h>
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(uint32_t);
#ifndef STORM_ARRAY_UINT32_T_H
#define STORM_ARRAY_UINT32_T_H
#include "system/types.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(uint32_t);
#endif

View file

@ -1,10 +1,10 @@
#ifndef STORM_ARRAY_UINT8_T_H
#define STORM_ARRAY_UINT8_T_H
#include <stdint.h>
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(uint8_t);
#ifndef STORM_ARRAY_UINT8_T_H
#define STORM_ARRAY_UINT8_T_H
#include "system/types.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(uint8_t);
#endif

View file

@ -1,47 +1,48 @@
#ifndef STORM_HASH_H
#define STORM_HASH_H
#include <stdint.h>
#include "storm/array.h"
#include "storm/list.h"
#define STORM_TS_HASH(T, K) \
STORM_TS_LIST(T) \
STORM_TS_GROWABLE_ARRAY(TSList_##T) \
typedef struct TSHashTable_##T##_##K TSHashTable_##T##_##K; \
typedef struct TSHashObject_##T##_##K TSHashObject_##T##_##K; \
struct TSHashTable_##T##_##K { \
TSList_##T m_fulllist; \
uint32_t m_fullnessIndicator; \
TSGrowableArray_TSList_##T m_slotlistarray; \
uint32_t m_slotmask; \
}; \
struct TSHashObject_##T##_##K { \
uint32_t m_hashval; \
TSLink_##T m_linktoslot; \
TSLink_##T m_linktofull; \
K m_key; \
};
typedef struct HASHKEY_PTR HASHKEY_PTR;
typedef struct HASHKEY_STR HASHKEY_STR;
typedef struct HASHKEY_STRI HASHKEY_STRI;
typedef struct HASHKEY_NONE HASHKEY_NONE;
struct HASHKEY_PTR {
void* m_key;
};
struct HASHKEY_STR {
char* m_str;
};
struct HASHKEY_STRI {
char* m_str;
};
struct HASHKEY_NONE {
};
#ifndef STORM_HASH_H
#define STORM_HASH_H
#include "system/types.h"
#include "storm/array.h"
#include "storm/list.h"
#define STORM_TS_HASH(T, K) \
STORM_TS_LIST(T) \
STORM_TS_GROWABLE_ARRAY(TSList_##T) \
typedef struct TSHashTable_##T##_##K TSHashTable_##T##_##K; \
typedef struct TSHashObject_##T##_##K TSHashObject_##T##_##K; \
struct TSHashTable_##T##_##K { \
TSList_##T m_fulllist; \
uint32_t m_fullnessIndicator; \
TSGrowableArray_TSList_##T m_slotlistarray; \
uint32_t m_slotmask; \
}; \
struct TSHashObject_##T##_##K { \
uint32_t m_hashval; \
TSLink_##T m_linktoslot; \
TSLink_##T m_linktofull; \
K m_key; \
};
DECLARE_STRUCT(HASHKEY_PTR);
DECLARE_STRUCT(HASHKEY_STR);
DECLARE_STRUCT(HASHKEY_STRI);
DECLARE_STRUCT(HASHKEY_NONE);
struct HASHKEY_PTR {
void* m_key;
};
struct HASHKEY_STR {
char* m_str;
};
struct HASHKEY_STRI {
char* m_str;
};
struct HASHKEY_NONE {
int32_t m_unused;
};
#endif

View file

@ -1,31 +1,33 @@
#ifndef STORM_LIST_H
#define STORM_LIST_H
#include <stdint.h>
// to make an object self referential
// forward-declare 'struct Object_type' as 'Object_type'
// then define 'struct Object_type'
// TSLink<T>
#define STORM_TS_LINK(T) typedef struct TSLink_##T TSLink_##T; \
struct TSLink_##T { \
TSLink_##T* m_prevlink; \
T* m_next; \
};
// TSList<T>
// TSLinkedNode<T>
#define STORM_TS_LIST(T) \
STORM_TS_LINK(T) \
typedef struct TSList_##T TSList_##T; \
typedef struct TSLinkedNode_##T TSLinkedNode_##T; \
struct TSList_##T { \
ptrdiff_t m_linkoffset; \
TSLink_##T m_terminator; \
}; \
struct TSLinkedNode_##T { \
TSLink_##T m_link; \
};
#ifndef STORM_LIST_H
#define STORM_LIST_H
#include "system/types.h"
// to make an object self referential
// forward-declare 'struct Object_type' as 'Object_type'
// then define 'struct Object_type'
// TSLink<T>
#define STORM_TS_LINK(T) typedef struct TSLink_##T TSLink_##T; \
struct TSLink_##T { \
TSLink_##T* m_prevlink; \
T* m_next; \
};
// TSList<T>
// TSExplicitList<T>
// TSLinkedNode<T>
#define STORM_TS_LIST(T) \
STORM_TS_LINK(T) \
typedef struct TSList_##T TSList_##T; \
typedef struct TSList_##T TSExplicitList_##T; \
typedef struct TSLinkedNode_##T TSLinkedNode_##T; \
struct TSList_##T { \
ptrdiff_t m_linkoffset; \
TSLink_##T m_terminator; \
}; \
struct TSLinkedNode_##T { \
TSLink_##T m_link; \
};
#endif

View file

@ -0,0 +1,31 @@
#ifndef STORM_QUEUE_H
#define STORM_QUEUE_H
#include "system/types.h"
#include "storm/array/pointer_to_void.h"
DECLARE_STRUCT(CSBasePriorityQueue);
DECLARE_STRUCT(CSBasePriority);
struct CSBasePriorityQueue {
TSGrowableArray_pointer_to_void b_base;
uint32_t m_linkOffset;
};
struct CSBasePriority {
CSBasePriorityQueue* m_queue;
uint32_t m_index;
};
#define STORM_TS_TIMER_PRIORITY(T) \
typedef struct TSTimerPriority_##T TSTimerPriority_##T; \
struct TSTimerPriority_##T { \
CSBasePriority b_base; \
T m_val; \
};
#define STORM_TS_PRIORITY_QUEUE(T) \
typedef CSBasePriorityQueue TSPriorityQueue_##T;
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_QUEUE_TIMER_PRIORITY_UINT32_T_H
#define STORM_QUEUE_TIMER_PRIORITY_UINT32_T_H
#include "system/types.h"
#include "storm/queue.h"
STORM_TS_TIMER_PRIORITY(uint32_t);
#endif

View file

@ -0,0 +1,17 @@
#ifndef STORM_THREAD_H
#define STORM_THREAD_H
#include "system/types.h"
DECLARE_STRUCT(SCritSect);
typedef struct CSRWLock CSRWLock;
struct SCritSect {
uint8_t m_critsect[24];
};
struct CSRWLock {
uint8_t m_opaqueData[12];
};
#endif