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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
|
#ifndef FREEAGE_COMPAT_XBOX360_INCLUDED
#define FREEAGE_COMPAT_XBOX360_INCLUDED
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#include <windef.h>
#include <basetsd.h>
#include <winnt.h>
#include <winbase.h>
#include <winsockx.h>
#include <xbox.h>
#pragma warning(disable:4996)
#pragma warning(disable:4090)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef int socklen_t;
typedef int ssize_t;
typedef unsigned short sa_family_t;
typedef uint16_t in_port_t;
typedef ULONG_PTR HCRYPTPROV;
#ifndef inline
#define inline __inline
#endif
#ifndef _LITTLE_ENDIAN
#define _LITTLE_ENDIAN (1234)
#endif
#ifndef _BYTE_ORDER
#define _BYTE_ORDER (_LITTLE_ENDIAN)
#endif
#ifndef restrict
#define restrict
#endif
#ifndef snprintf
#define snprintf sprintf_s
#endif
#define INET_ADDRSTRLEN 22
#define INET6_ADDRSTRLEN 65
// Controls
#define SERVICE_CONTROL_STOP 0x00000001
#define SERVICE_CONTROL_PAUSE 0x00000002
#define SERVICE_CONTROL_CONTINUE 0x00000003
#define SERVICE_CONTROL_INTERROGATE 0x00000004
#define SERVICE_CONTROL_SHUTDOWN 0x00000005
#define SERVICE_CONTROL_PARAMCHANGE 0x00000006
#define SERVICE_CONTROL_NETBINDADD 0x00000007
#define SERVICE_CONTROL_NETBINDREMOVE 0x00000008
#define SERVICE_CONTROL_NETBINDENABLE 0x00000009
#define SERVICE_CONTROL_NETBINDDISABLE 0x0000000A
#define SERVICE_CONTROL_DEVICEEVENT 0x0000000B
#define SERVICE_CONTROL_HARDWAREPROFILECHANGE 0x0000000C
#define SERVICE_CONTROL_POWEREVENT 0x0000000D
#define SERVICE_CONTROL_SESSIONCHANGE 0x0000000E
#define SERVICE_CONTROL_PRESHUTDOWN 0x0000000F
// Service Types (Bit Mask)
#define SERVICE_WIN32_OWN_PROCESS 0x00000010
// Service State -- for CurrentState
#define SERVICE_STOPPED 0x00000001
#define SERVICE_START_PENDING 0x00000002
#define SERVICE_STOP_PENDING 0x00000003
#define SERVICE_RUNNING 0x00000004
#define SERVICE_CONTINUE_PENDING 0x00000005
#define SERVICE_PAUSE_PENDING 0x00000006
#define SERVICE_PAUSED 0x00000007
// Controls Accepted (Bit Mask)
#define SERVICE_ACCEPT_STOP 0x00000001
#define SERVICE_ACCEPT_PAUSE_CONTINUE 0x00000002
#define SERVICE_ACCEPT_SHUTDOWN 0x00000004
#define SERVICE_ACCEPT_PARAMCHANGE 0x00000008
#define SERVICE_ACCEPT_NETBINDCHANGE 0x00000010
#define SERVICE_ACCEPT_HARDWAREPROFILECHANGE 0x00000020
#define SERVICE_ACCEPT_POWEREVENT 0x00000040
#define SERVICE_ACCEPT_SESSIONCHANGE 0x00000080
#define SERVICE_ACCEPT_PRESHUTDOWN 0x00000100
// dwFlags definitions for CryptAcquireContext
#define CRYPT_VERIFYCONTEXT 0xF0000000
#define CRYPT_NEWKEYSET 0x00000008
#define CRYPT_DELETEKEYSET 0x00000010
#define CRYPT_MACHINE_KEYSET 0x00000020
#define CRYPT_SILENT 0x00000040
// certenrolld_begin -- PROV_RSA_*
#define PROV_RSA_FULL 1
#define PROV_RSA_SIG 2
#define PROV_DSS 3
#define PROV_FORTEZZA 4
#define PROV_MS_EXCHANGE 5
#define PROV_SSL 6
#define PROV_RSA_SCHANNEL 12
#define PROV_DSS_DH 13
#define PROV_EC_ECDSA_SIG 14
#define PROV_EC_ECNRA_SIG 15
#define PROV_EC_ECDSA_FULL 16
#define PROV_EC_ECNRA_FULL 17
#define PROV_DH_SCHANNEL 18
#define PROV_SPYRUS_LYNKS 20
#define PROV_RNG 21
#define PROV_INTEL_SEC 22
// Service Status Structures
typedef struct _SERVICE_STATUS
{
DWORD dwServiceType;
DWORD dwCurrentState;
DWORD dwControlsAccepted;
DWORD dwWin32ExitCode;
DWORD dwServiceSpecificExitCode;
DWORD dwCheckPoint;
DWORD dwWaitHint;
}
SERVICE_STATUS, *LPSERVICE_STATUS;
// Handle type
DECLARE_HANDLE(SERVICE_STATUS_HANDLE);
// Define API decoration for direct importing of DLL references.
#if !defined(_ADVAPI32_)
#define WINADVAPI DECLSPEC_IMPORT
#else
#define WINADVAPI
#endif
#ifdef _WIN32
#ifndef _WINMM_
#define WINMMAPI DECLSPEC_IMPORT
#else
#define WINMMAPI
#endif
#define _loadds
#define _huge
#else
#define WINMMAPI
#endif
// Prototype for the Service Control Handler Function
typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)
(
DWORD dwControl,
DWORD dwEventType,
LPVOID lpEventData,
LPVOID lpContext
);
__checkReturn
WINADVAPI
SERVICE_STATUS_HANDLE
WINAPI
RegisterServiceCtrlHandlerExA(
__in LPCSTR lpServiceName,
__in __callback
LPHANDLER_FUNCTION_EX lpHandlerProc,
__in_opt LPVOID lpContext
);
WINADVAPI
BOOL
WINAPI
SetServiceStatus(
__in SERVICE_STATUS_HANDLE hServiceStatus,
__in LPSERVICE_STATUS lpServiceStatus
);
WINADVAPI
BOOL
WINAPI
CryptGenRandom(
__in HCRYPTPROV hProv,
__in DWORD dwLen,
__inout_bcount(dwLen) BYTE * pbBuffer
);
WINADVAPI
BOOL
WINAPI
CryptAcquireContextA(
__out HCRYPTPROV * phProv,
__in_opt LPCSTR szContainer,
__in_opt LPCSTR szProvider,
__in DWORD dwProvType,
__in DWORD dwFlags
);
WINBASEAPI
DWORD
WINAPI
GetCurrentProcessId(
VOID
);
// Function Prototype for the Service Main Function
typedef VOID (WINAPI *LPSERVICE_MAIN_FUNCTIONA)
(
DWORD dwNumServicesArgs,
LPSTR *lpServiceArgVectors
);
// Service Start Table
typedef struct _SERVICE_TABLE_ENTRYA
{
LPSTR lpServiceName;
LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
}
SERVICE_TABLE_ENTRYA, *LPSERVICE_TABLE_ENTRYA;
WINADVAPI
BOOL
WINAPI
StartServiceCtrlDispatcherA(
__in CONST SERVICE_TABLE_ENTRYA *lpServiceStartTable
);
// Define inet_ntoa
WINSOCK_API_LINKAGE
char FAR *
WSAAPI
inet_ntoa(
IN struct in_addr in
);
// Define WSAEnumNetworkEvents (Unsupported Winsock API)
typedef struct _WSANETWORKEVENTS
{
long lNetworkEvents;
int iErrorCode[FD_MAX_EVENTS];
} WSANETWORKEVENTS, FAR * LPWSANETWORKEVENTS;
__control_entrypoint(DllExport)
WINSOCK_API_LINKAGE
int
WSAAPI
WSAEnumNetworkEvents(
IN SOCKET s,
IN WSAEVENT hEventObject,
OUT LPWSANETWORKEVENTS lpNetworkEvents
);
// Timer function prototype
WINMMAPI DWORD WINAPI timeGetTime(void);
static __inline uint16_t bswap16 ( const uint16_t value )
{
uint16_t _value;
__asm {
mov ax, value
xchg ah, al
mov _value, ax
}
return _value;
}
static __inline uint32_t bswap32 ( const uint32_t value )
{
uint32_t _value = value;
__asm {
mov eax, value
bswap eax
mov _value, eax
}
return _value;
}
/* Instruction __asm is not supported in 64 bits */
static __inline uint64_t bswap64 ( const uint64_t value )
{
uint32_t hi = (uint32_t)(value >> 32);
uint32_t lo = (uint32_t)(value & 0xFFFFFFFF);
return (uint64_t)bswap32(hi) | (uint64_t)((uint64_t)bswap32(lo) << 32);
}
static const char * inet_ntop ( int af, const void * src, char * dst, int size )
{
const char * tmp;
if (af == AF_INET)
{
tmp = inet_ntoa(*((const struct in_addr *)(src)));
if (tmp != NULL)
{
strncpy(dst, tmp, size - 1);
}
else
{
strncpy(dst, "inet_ntoa error", size - 1);
}
}
else
{
strncpy(dst, "not implemented", size - 1);
}
dst[size - 1] = '\0';
return dst;
}
#define MSG_NOSIGNAL 0
#define close closesocket
#define ioctl ioctlsocket
#ifndef getpid
#define getpid GetCurrentProcessId
#endif
#define dlopen(path,flags) (void *)(LoadLibraryA(path))
#define dlsym(module,symbol) GetProcAddress((HMODULE)(module),symbol)
#define dlclose(module) FreeLibrary((HMODULE)(module))
#endif /* FREEAGE_COMPAT_XBOX360_INCLUDED */ |
Partager