ReactOS 0.4.15-dev-5666-gc548b97
isotest.c
Go to the documentation of this file.
1/*
2 * isotest - display cdrom information
3 */
4
5#define WIN32_NO_STATUS
6#include <windows.h>
7#define NTOS_MODE_USER
8#include <ndk/ntndk.h>
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <ctype.h>
14#include <wchar.h>
15
16
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}
79
80
81#ifndef EVENT_ALL_ACCESS
82#define EVENT_ALL_ACCESS (0x1f0003L)
83#endif
84
85BOOL
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}
140
141
142
143int main (int argc, char *argv[])
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}
233
234/* EOF */
static int argc
Definition: ServiceArgs.c:12
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define isprint(c)
Definition: acclib.h:73
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#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 TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#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
int main()
Definition: test.c:6
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:939
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define printf
Definition: freeldr.h:94
Status
Definition: gdiplustypes.h:25
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLintptr offset
Definition: glext.h:5920
void HexDump(char *buffer, ULONG size)
Definition: isotest.c:17
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
BOOL ReadBlock(HANDLE FileHandle, PVOID Buffer, PLARGE_INTEGER Offset, ULONG Length, PULONG BytesRead)
Definition: isotest.c:86
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
static PVOID ptr
Definition: dispmode.c:27
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define argv
Definition: mplay32.c:18
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
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_PENDING
Definition: ntstatus.h:82
#define memset(x, y, z)
Definition: compat.h:39
#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)
uint32_t ULONG_PTR
Definition: typedefs.h:65
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2275 u
_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
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define CreateFile
Definition: winbase.h:3620
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857
char CHAR
Definition: xmlstorage.h:175