Current News
Archived News
Search News
Discussion Forum


Old Forum
Install Programs More Downloads...
Troubleshooting
Source Code
Format Specs.
Misc. Information
Non-SF Stuff
Links




1 /* License information for this code is in license.txt */
3 #ifndef WINDOWS_H_INCLUDED
4 #define WINDOWS_H_INCLUDED
6 #include <stdlib.h>
7 #include <string.h>
8 #include <ctype.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <sys/stat.h>
12 #include <stdint.h>
14 #define LINUX_PORT
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 // Function related defines
21 #define __cdecl
22 #define __stdcall
23 #define WINAPI __stdcall
24 #define APIENTRY __stdcall
25 #define __declspec(x)
26 #define __inline inline
27 #define __forceinline inline
29 #define CONST const
31 // Type defines
32 typedef uint8_t BYTE;
33 typedef uint16_t WORD;
34 typedef uint32_t DWORD;
35 typedef uint64_t UINT64;
36 typedef int16_t SHORT;
37 typedef uint16_t USHORT;
38 typedef DWORD LCID;
39 typedef int32_t LONG;
40 typedef LONG * PLONG;
41 typedef int BOOL;
42 typedef void * LPVOID;
43 typedef CONST void *LPCVOID;
44 typedef char CHAR;
45 typedef char * LPSTR;
46 typedef const char * LPCSTR;
47 typedef DWORD * LPDWORD;
48 typedef BYTE * LPBYTE;
49 typedef LPVOID HANDLE;
50 typedef HANDLE HINSTANCE;
52 // Structs
53 typedef struct _OVERLAPPED {
54         DWORD  Internal;
55         DWORD  InternalHigh;
56         DWORD  Offset;
57         DWORD  OffsetHigh;
58         HANDLE hEvent;
59 } OVERLAPPED, *LPOVERLAPPED;
60 typedef struct _SECURITY_ATTRIBUTES {
61         DWORD nLength;
62         LPVOID lpSecurityDescriptor;
63         BOOL bInheritHandle;
64 } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
66 // Constants
67 #define FALSE 0
68 #define TRUE 1
69 #define MAX_PATH 260
70 #define INVALID_HANDLE_VALUE ((HANDLE)-1)
71 #define INVALID_FILE_SIZE ((DWORD)-1)
72 #define INVALID_SET_FILE_POINTER ((DWORD)-1)
73 #define DLL_PROCESS_ATTACH 1
74 #define DLL_THREAD_ATTACH  2
75 #define DLL_THREAD_DETACH  3
76 #define DLL_PROCESS_DETACH 0
77 #define PAGE_NOACCESS          0x01
78 #define PAGE_READONLY          0x02
79 #define PAGE_READWRITE         0x04
80 #define PAGE_WRITECOPY         0x08
81 #define PAGE_EXECUTE           0x10
82 #define PAGE_EXECUTE_READ      0x20
83 #define PAGE_EXECUTE_READWRITE 0x40
84 #define PAGE_EXECUTE_WRITECOPY 0x80
85 #define PAGE_GUARD            0x100
86 #define PAGE_NOCACHE          0x200
87 #define PAGE_WRITECOMBINE     0x400
88 #define MEM_COMMIT           0x1000
89 #define MEM_RESERVE          0x2000
90 #define MEM_DECOMMIT         0x4000
91 #define MEM_RELEASE          0x8000
92 #define MEM_FREE            0x10000
93 #define MEM_PRIVATE         0x20000
94 #define MEM_MAPPED          0x40000
95 #define MEM_RESET           0x80000
96 #define MEM_TOP_DOWN       0x100000
97 #define MEM_4MB_PAGES    0x80000000
98 #define DRIVE_UNKNOWN     0
99 #define DRIVE_NO_ROOT_DIR 1
100 #define DRIVE_REMOVABLE   2
101 #define DRIVE_FIXED       3
102 #define DRIVE_REMOTE      4
103 #define DRIVE_CDROM       5
104 #define DRIVE_RAMDISK     6
105 #define GENERIC_READ                     (0x80000000L)
106 #define GENERIC_WRITE                    (0x40000000L)
107 #define GENERIC_EXECUTE                  (0x20000000L)
108 #define GENERIC_ALL                      (0x10000000L)
109 #define FILE_SHARE_READ                 0x00000001
110 #define FILE_SHARE_WRITE                0x00000002
111 #define FILE_SHARE_DELETE               0x00000004
112 #define CREATE_NEW          1
113 #define CREATE_ALWAYS       2
114 #define OPEN_EXISTING       3
115 #define OPEN_ALWAYS         4
116 #define TRUNCATE_EXISTING   5
117 #define FILE_BEGIN           0
118 #define FILE_CURRENT         1
119 #define FILE_END             2
120 #define NO_ERROR 0L
121 #define ERROR_FILE_NOT_FOUND             2L
122 #define ERROR_ACCESS_DENIED              5L
123 #define ERROR_INVALID_PARAMETER          87L    // dderror
124 #define ERROR_ALREADY_EXISTS             183L
125 #define ERROR_FILE_INVALID               1006L
126 #define ERROR_UNKNOWN_PROPERTY           1608L
128 // Declarations for Windows API functions
129 void WINAPI SetLastError(DWORD dwLastError);
130 DWORD WINAPI GetLastError();
131 DWORD WINAPI GetCurrentDirectory(DWORD dwBufferLength, LPSTR lpBuffer);
132 DWORD WINAPI GetDriveType(LPCSTR lpRootPath);
133 HANDLE WINAPI CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
134 BOOL WINAPI CloseHandle(HANDLE hObject);
135 DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
136 DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod);
137 BOOL WINAPI SetEndOfFile(HANDLE hFile);
138 BOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
139 BOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
140 BOOL WINAPI DeleteFile(LPCSTR lpFileName);
142 // Declarations for C runtime functions
143 char * strlwr(char *lpString);
144 char * strupr(char *lpString);
145 //char * strdup(const char *lpString);
146 #define stricmp strcasecmp
147 #define strnicmp strncasecmp
148 int memicmp(const char *lpString1, const char *lpString2, size_t dwSize);
150 // Other functions
151 void SlashToBackslash(char *lpPath);
152 void BackslashToSlash(char *lpPath);
154 #ifdef __cplusplus
155 };  // extern "C"
156 #endif
158 #endif