ReactOS 0.4.16-dev-338-g34e76ad
isotest.c File Reference
#include <windows.h>
#include <ndk/ntndk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <wchar.h>
Include dependency graph for isotest.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define EVENT_ALL_ACCESS   (0x1f0003L)
 

Functions

void HexDump (char *buffer, ULONG size)
 
BOOL ReadBlock (HANDLE FileHandle, PVOID Buffer, PLARGE_INTEGER Offset, ULONG Length, PULONG BytesRead)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ EVENT_ALL_ACCESS

#define EVENT_ALL_ACCESS   (0x1f0003L)

Definition at line 82 of file isotest.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 7 of file isotest.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 5 of file isotest.c.

Function Documentation

◆ HexDump()

void HexDump ( char buffer,
ULONG  size 
)

Definition at line 17 of file isotest.c.

18{
19 ULONG offset = 0;
20 unsigned char *ptr;
21
22 while (offset < (size & ~15))
23 {
24 ptr = (unsigned char*)((ULONG_PTR)buffer + offset);
25 printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
26 offset,
27 ptr[0],
28 ptr[1],
29 ptr[2],
30 ptr[3],
31 ptr[4],
32 ptr[5],
33 ptr[6],
34 ptr[7],
35 ptr[8],
36 ptr[9],
37 ptr[10],
38 ptr[11],
39 ptr[12],
40 ptr[13],
41 ptr[14],
42 ptr[15]);
43
44 printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
45 isprint(ptr[0])?ptr[0]:'.',
46 isprint(ptr[1])?ptr[1]:'.',
47 isprint(ptr[2])?ptr[2]:'.',
48 isprint(ptr[3])?ptr[3]:'.',
49 isprint(ptr[4])?ptr[4]:'.',
50 isprint(ptr[5])?ptr[5]:'.',
51 isprint(ptr[6])?ptr[6]:'.',
52 isprint(ptr[7])?ptr[7]:'.',
53 isprint(ptr[8])?ptr[8]:'.',
54 isprint(ptr[9])?ptr[9]:'.',
55 isprint(ptr[10])?ptr[10]:'.',
56 isprint(ptr[11])?ptr[11]:'.',
57 isprint(ptr[12])?ptr[12]:'.',
58 isprint(ptr[13])?ptr[13]:'.',
59 isprint(ptr[14])?ptr[14]:'.',
60 isprint(ptr[15])?ptr[15]:'.');
61
62 offset += 16;
63 }
64
65 ptr = (unsigned char*)((ULONG_PTR)buffer + offset);
66 if (offset < size)
67 {
68 printf("%08lx ", offset);
69 while (offset < size)
70 {
71 printf(" %02hx", *ptr);
72 offset++;
73 ptr++;
74 }
75 }
76
77 printf("\n\n");
78}
#define isprint(c)
Definition: acclib.h:73
#define printf
Definition: freeldr.h:97
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLintptr offset
Definition: glext.h:5920
static PVOID ptr
Definition: dispmode.c:27
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 143 of file isotest.c.

144{
145 HANDLE hDisk;
146 DWORD dwRead;
147 char *Buffer;
148 CHAR Filename[80];
149 LARGE_INTEGER FilePosition;
150
151 if (argc != 2)
152 {
153 printf("Usage: isotest [Drive:]\n");
154 return 0;
155 }
156
157 strcpy(Filename, "\\\\.\\");
158 strcat(Filename, argv[1]);
159
160 hDisk = CreateFile(Filename,
163 NULL,
165 0,
166 NULL);
167 if (hDisk == INVALID_HANDLE_VALUE)
168 {
169 printf("CreateFile(): Invalid disk handle!\n");
170 return 0;
171 }
172
173 Buffer = (char*)malloc(2048);
174 if (Buffer == NULL)
175 {
176 CloseHandle(hDisk);
177 printf("Out of memory!\n");
178 return 0;
179 }
180 memset(Buffer, 0, 2048);
181
182
183 FilePosition.QuadPart = 16 * 2048;
184#if 0
186 SetFilePointer(hDisk,
187 FilePosition.u.LowPart,
188 &FilePosition.u.HighPart,
189 FILE_BEGIN);
190 if (GetLastError() != NO_ERROR)
191 {
192 CloseHandle(hDisk);
193 free(Buffer);
194 printf("SetFilePointer() failed!\n");
195 return 0;
196 }
197
198 if (ReadFile(hDisk,
199 Buffer,
200 2048,
201 &dwRead,
202 NULL) == FALSE)
203 {
204 CloseHandle(hDisk);
205 free(Buffer);
206 printf("ReadFile() failed!\n");
207 return 0;
208 }
209#endif
210
211 if (ReadBlock(hDisk,
212 Buffer,
213 &FilePosition,
214 2048,
215 &dwRead) == FALSE)
216 {
217 CloseHandle(hDisk);
218 free(Buffer);
219#if 0
220 printf("ReadBlock() failed!\n");
221#endif
222 return 0;
223 }
224
225 HexDump(Buffer, 128);
226
227 CloseHandle(hDisk);
228
229 free(Buffer);
230
231 return 0;
232}
static int argc
Definition: ServiceArgs.c:12
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
Definition: bufpool.h:45
#define NO_ERROR
Definition: dderror.h:5
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define FILE_BEGIN
Definition: compat.h:761
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:940
unsigned long DWORD
Definition: ntddk_ex.h:95
void HexDump(char *buffer, ULONG size)
Definition: isotest.c:17
BOOL ReadBlock(HANDLE FileHandle, PVOID Buffer, PLARGE_INTEGER Offset, ULONG Length, PULONG BytesRead)
Definition: isotest.c:86
#define argv
Definition: mplay32.c:18
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define memset(x, y, z)
Definition: compat.h:39
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2304 u
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateFile
Definition: winbase.h:3774
char CHAR
Definition: xmlstorage.h:175

◆ ReadBlock()

BOOL ReadBlock ( HANDLE  FileHandle,
PVOID  Buffer,
PLARGE_INTEGER  Offset,
ULONG  Length,
PULONG  BytesRead 
)

Definition at line 86 of file isotest.c.

91{
96
98 NULL, 0, NULL, NULL);
99
103 TRUE,
104 FALSE);
105 if (!NT_SUCCESS(Status))
106 {
107 printf("NtCreateEvent() failed\n");
108 return(FALSE);
109 }
110
113 NULL,
114 NULL,
116 Buffer,
117 Length,
118 Offset,
119 NULL);
120 if (Status == STATUS_PENDING)
121 {
124 }
125
127
128 if (Status != STATUS_PENDING && BytesRead != NULL)
129 {
131 }
133 {
134 printf("ReadBlock() failed (Status: %lx)\n", Status);
135 return(FALSE);
136 }
137
138 return(TRUE);
139}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
Status
Definition: gdiplustypes.h:25
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:96
#define STATUS_END_OF_FILE
Definition: shellext.h:67
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857

Referenced by main().