1*c2c66affSColin Finck ////////////////////////////////////////////////////////////////////
2*c2c66affSColin Finck // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3*c2c66affSColin Finck // All rights reserved
4*c2c66affSColin Finck // This file was released under the GPLv2 on June 2015.
5*c2c66affSColin Finck ////////////////////////////////////////////////////////////////////
6*c2c66affSColin Finck
7*c2c66affSColin Finck #ifndef __ENV_SPEC_NT_NATIVE__H__
8*c2c66affSColin Finck #define __ENV_SPEC_NT_NATIVE__H__
9*c2c66affSColin Finck
10*c2c66affSColin Finck #ifdef NT_NATIVE_MODE
11*c2c66affSColin Finck
12*c2c66affSColin Finck #include "zw_2_nt.h"
13*c2c66affSColin Finck
14*c2c66affSColin Finck #ifdef __cplusplus
15*c2c66affSColin Finck extern "C" {
16*c2c66affSColin Finck #endif //__cplusplus
17*c2c66affSColin Finck
18*c2c66affSColin Finck #ifndef MAX_PATH
19*c2c66affSColin Finck #define MAX_PATH 260
20*c2c66affSColin Finck #endif //MAX_PATH
21*c2c66affSColin Finck
22*c2c66affSColin Finck BOOLEAN
23*c2c66affSColin Finck GetOsVersion(
24*c2c66affSColin Finck PULONG MajorVersion OPTIONAL,
25*c2c66affSColin Finck PULONG MinorVersion OPTIONAL,
26*c2c66affSColin Finck PULONG BuildNumber OPTIONAL,
27*c2c66affSColin Finck PUNICODE_STRING CSDVersion OPTIONAL
28*c2c66affSColin Finck );
29*c2c66affSColin Finck
30*c2c66affSColin Finck #define PsGetVersion(a,b,c,d) GetOsVersion(a,b,c,d)
31*c2c66affSColin Finck
32*c2c66affSColin Finck #define InterlockedIncrement(addr) \
33*c2c66affSColin Finck ((*addr)++)
34*c2c66affSColin Finck #define InterlockedDecrement(addr) \
35*c2c66affSColin Finck ((*addr)--)
36*c2c66affSColin Finck int
37*c2c66affSColin Finck __inline
InterlockedExchangeAdd(PLONG addr,LONG i)38*c2c66affSColin Finck InterlockedExchangeAdd(PLONG addr, LONG i) {
39*c2c66affSColin Finck LONG Old = (*addr);
40*c2c66affSColin Finck (*addr) += i;
41*c2c66affSColin Finck return Old;
42*c2c66affSColin Finck }
43*c2c66affSColin Finck
44*c2c66affSColin Finck #define DeviceIoControl(h, ctlc, ib, is, ob, os, r, ov) MyDeviceIoControl(h, ctlc, ib, is, ob, os, r, ov)
45*c2c66affSColin Finck
46*c2c66affSColin Finck BOOLEAN
47*c2c66affSColin Finck MyDeviceIoControl(
48*c2c66affSColin Finck HANDLE hDevice,
49*c2c66affSColin Finck DWORD dwIoControlCode,
50*c2c66affSColin Finck PVOID lpInBuffer,
51*c2c66affSColin Finck DWORD nInBufferSize,
52*c2c66affSColin Finck PVOID lpOutBuffer,
53*c2c66affSColin Finck DWORD nOutBufferSize,
54*c2c66affSColin Finck DWORD* lpBytesReturned,
55*c2c66affSColin Finck PVOID lpOverlapped
56*c2c66affSColin Finck );
57*c2c66affSColin Finck
58*c2c66affSColin Finck #define OemToCharW(ansi_s, uni_s) (swprintf(uni_s, L"%S", ansi_s))
59*c2c66affSColin Finck #define MultiByteToWideChar(cp, f, ansi_s, a_sz, uni_s, u_sz) (swprintf(uni_s, L"%S", ansi_s))
60*c2c66affSColin Finck
61*c2c66affSColin Finck VOID
62*c2c66affSColin Finck Sleep(
63*c2c66affSColin Finck ULONG t
64*c2c66affSColin Finck );
65*c2c66affSColin Finck
66*c2c66affSColin Finck #define GlobalAlloc(foo, size) MyGlobalAlloc( size );
67*c2c66affSColin Finck #define GlobalFree(ptr) MyGlobalFree( ptr );
68*c2c66affSColin Finck
69*c2c66affSColin Finck extern "C"
70*c2c66affSColin Finck PVOID MyGlobalAlloc(ULONG Size);
71*c2c66affSColin Finck
72*c2c66affSColin Finck extern "C"
73*c2c66affSColin Finck VOID MyGlobalFree(PVOID Addr);
74*c2c66affSColin Finck
75*c2c66affSColin Finck #define ExitProcess(Status) NtTerminateProcess( NtCurrentProcess(), Status );
76*c2c66affSColin Finck
77*c2c66affSColin Finck extern "C"
78*c2c66affSColin Finck VOID
79*c2c66affSColin Finck PrintNtConsole(
80*c2c66affSColin Finck PCHAR DebugMessage,
81*c2c66affSColin Finck ...
82*c2c66affSColin Finck );
83*c2c66affSColin Finck
84*c2c66affSColin Finck extern "C"
85*c2c66affSColin Finck NTSTATUS
86*c2c66affSColin Finck EnvFileOpenW(
87*c2c66affSColin Finck PWCHAR Name,
88*c2c66affSColin Finck HANDLE* ph
89*c2c66affSColin Finck );
90*c2c66affSColin Finck
91*c2c66affSColin Finck extern "C"
92*c2c66affSColin Finck NTSTATUS
93*c2c66affSColin Finck EnvFileOpenA(
94*c2c66affSColin Finck PCHAR Name,
95*c2c66affSColin Finck HANDLE* ph
96*c2c66affSColin Finck );
97*c2c66affSColin Finck
98*c2c66affSColin Finck extern "C"
99*c2c66affSColin Finck NTSTATUS
100*c2c66affSColin Finck EnvFileClose(
101*c2c66affSColin Finck HANDLE hFile
102*c2c66affSColin Finck );
103*c2c66affSColin Finck
104*c2c66affSColin Finck extern "C"
105*c2c66affSColin Finck NTSTATUS
106*c2c66affSColin Finck EnvFileGetSizeByHandle(
107*c2c66affSColin Finck HANDLE hFile,
108*c2c66affSColin Finck PLONGLONG lpFileSize
109*c2c66affSColin Finck );
110*c2c66affSColin Finck
111*c2c66affSColin Finck extern "C"
112*c2c66affSColin Finck NTSTATUS
113*c2c66affSColin Finck EnvFileGetSizeA(
114*c2c66affSColin Finck PCHAR Name,
115*c2c66affSColin Finck PLONGLONG lpFileSize
116*c2c66affSColin Finck );
117*c2c66affSColin Finck
118*c2c66affSColin Finck extern "C"
119*c2c66affSColin Finck NTSTATUS
120*c2c66affSColin Finck EnvFileGetSizeW(
121*c2c66affSColin Finck PWCHAR Name,
122*c2c66affSColin Finck PLONGLONG lpFileSize
123*c2c66affSColin Finck );
124*c2c66affSColin Finck
125*c2c66affSColin Finck extern "C"
126*c2c66affSColin Finck BOOLEAN
127*c2c66affSColin Finck EnvFileExistsA(PCHAR Name);
128*c2c66affSColin Finck
129*c2c66affSColin Finck extern "C"
130*c2c66affSColin Finck BOOLEAN
131*c2c66affSColin Finck EnvFileExistsW(PWCHAR Name);
132*c2c66affSColin Finck
133*c2c66affSColin Finck extern "C"
134*c2c66affSColin Finck NTSTATUS
135*c2c66affSColin Finck EnvFileWrite(
136*c2c66affSColin Finck HANDLE h,
137*c2c66affSColin Finck PVOID ioBuffer,
138*c2c66affSColin Finck ULONG Length,
139*c2c66affSColin Finck PULONG bytesWritten
140*c2c66affSColin Finck );
141*c2c66affSColin Finck
142*c2c66affSColin Finck extern "C"
143*c2c66affSColin Finck NTSTATUS
144*c2c66affSColin Finck EnvFileRead(
145*c2c66affSColin Finck HANDLE h,
146*c2c66affSColin Finck PVOID ioBuffer,
147*c2c66affSColin Finck ULONG Length,
148*c2c66affSColin Finck PULONG bytesRead
149*c2c66affSColin Finck );
150*c2c66affSColin Finck
151*c2c66affSColin Finck #define ENV_FILE_CURRENT 1
152*c2c66affSColin Finck #define ENV_FILE_END 2
153*c2c66affSColin Finck #define ENV_FILE_BEGIN 3
154*c2c66affSColin Finck
155*c2c66affSColin Finck extern "C"
156*c2c66affSColin Finck NTSTATUS
157*c2c66affSColin Finck EnvFileSetPointer(
158*c2c66affSColin Finck HANDLE hFile,
159*c2c66affSColin Finck LONGLONG lDistanceToMove,
160*c2c66affSColin Finck LONGLONG* lResultPointer,
161*c2c66affSColin Finck DWORD dwMoveMethod
162*c2c66affSColin Finck );
163*c2c66affSColin Finck
164*c2c66affSColin Finck extern "C"
165*c2c66affSColin Finck NTSTATUS
166*c2c66affSColin Finck EnvFileDeleteW(
167*c2c66affSColin Finck PWCHAR fName
168*c2c66affSColin Finck );
169*c2c66affSColin Finck
170*c2c66affSColin Finck #define PrintDbgConsole PrintNtConsole
171*c2c66affSColin Finck
172*c2c66affSColin Finck #ifdef __cplusplus
173*c2c66affSColin Finck };
174*c2c66affSColin Finck #endif //__cplusplus
175*c2c66affSColin Finck
176*c2c66affSColin Finck #endif //NT_NATIVE_MODE
177*c2c66affSColin Finck
178*c2c66affSColin Finck #endif //__ENV_SPEC_NT_NATIVE__H__
179