-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathKernel32.h
150 lines (134 loc) · 2.65 KB
/
Kernel32.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// SPDX-License-Identifier: MIT
#ifndef KERNEL32_H
#define KERNEL32_H
#include "Wrapper.h"
#ifdef WIN32
#include <windows.h>
#else
#include <SDL2/SDL_thread.h>
#include <SDL2/SDL_mutex.h>
#include <dirent.h>
typedef uint32_t (STDCALL *THREAD_START_ROUTINE)(void *);
enum {GENERIC_WRITE = 0x40000000, GENERIC_READ = 0x80000000};
typedef struct
{
uint32_t length;
uint32_t memoryLoad;
uint32_t totalPhys;
uint32_t availPhys;
uint32_t totalPageFile;
uint32_t availPageFile;
uint32_t totalVirtual;
uint32_t availVirtual;
} MEMORYSTATUS;
typedef struct
{
union
{
uint32_t oemId;
struct
{
uint16_t processorArchitecture;
uint16_t reserved;
};
};
uint32_t pageSize;
void *minimumApplicationAddress;
void *maximumApplicationAddress;
uint32_t activeProcessorMask;
uint32_t numberOfProcessors;
uint32_t processorType;
uint32_t allocationGranularity;
uint16_t processorLevel;
uint16_t processorRevision;
} SYSTEM_INFO;
typedef struct
{
void *reserved1, *reserved2, *reserved3;
SDL_mutex *mutex;
void *reserved4, *reserved5;
} CRITICAL_SECTION;
typedef struct
{
uint32_t Internal;
uint32_t InternalHigh;
union
{
struct
{
uint32_t Offset;
uint32_t OffsetHigh;
};
void *Pointer;
};
void *hEvent;
} OVERLAPPED;
typedef struct
{
uint32_t ReadIntervalTimeout;
uint32_t ReadTotalTimeoutMultiplier;
uint32_t ReadTotalTimeoutConstant;
uint32_t WriteTotalTimeoutMultiplier;
uint32_t WriteTotalTimeoutConstant;
} COMMTIMEOUTS;
typedef struct
{
uint32_t lowDateTime;
uint32_t highDateTime;
} FILETIME;
typedef struct
{
uint32_t fileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
uint32_t fileSizeHigh;
uint32_t fileSizeLow;
uint32_t reserved[2];
char fileName[MAX_PATH];
char alternateFileName[14];
} WIN32_FIND_DATA;
typedef void SECURITY_ATTRIBUTES;
typedef void COMMPROP;
typedef void DCB;
typedef enum {HandleThread = 1, HandleFile, HandleFileMapping, HandleEvent} HandleType;
typedef struct
{
HandleType handleType;
#ifdef NFS_CPP
int (*function)(void *);
void *arg;
#else
int (*threadParameter)();
#endif
SDL_sem *sem;
} Thread;
typedef struct
{
HandleType handleType;
int fd;
/* ASync */
BOOL async, pending;
uint32_t toRead, readSoFar;
uint8_t *asyncReadBuffer;
OVERLAPPED *readOverlapped;
SDL_mutex *mutex;
uint32_t us_timeout;
} File;
typedef struct
{
HandleType handleType;
int fd;
} FileMapping;
typedef struct
{
HandleType handleType;
BOOL manualReset, is_set;
} Event;
typedef struct
{
DIR *dir;
char *filter;
} FindFile;
#endif
#endif // KERNEL32_H