2 * isotest - display cdrom information
5 #define WIN32_NO_STATUS
17 void HexDump(char *buffer
, ULONG size
)
22 while (offset
< (size
& ~15))
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",
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]:'.');
65 ptr
= (unsigned char*)((ULONG_PTR
)buffer
+ offset
);
68 printf("%08lx ", offset
);
71 printf(" %02hx", *ptr
);
81 #ifndef EVENT_ALL_ACCESS
82 #define EVENT_ALL_ACCESS (0x1f0003L)
86 ReadBlock(HANDLE FileHandle
,
88 PLARGE_INTEGER Offset
,
92 IO_STATUS_BLOCK IoStatusBlock
;
93 OBJECT_ATTRIBUTES ObjectAttributes
;
97 InitializeObjectAttributes(&ObjectAttributes
,
100 Status
= NtCreateEvent(&EventHandle
,
105 if (!NT_SUCCESS(Status
))
107 printf("NtCreateEvent() failed\n");
111 Status
= NtReadFile(FileHandle
,
120 if (Status
== STATUS_PENDING
)
122 NtWaitForSingleObject(EventHandle
, FALSE
, NULL
);
123 Status
= IoStatusBlock
.Status
;
126 NtClose(EventHandle
);
128 if (Status
!= STATUS_PENDING
&& BytesRead
!= NULL
)
130 *BytesRead
= IoStatusBlock
.Information
;
132 if (!NT_SUCCESS(Status
) && Status
!= STATUS_END_OF_FILE
)
134 printf("ReadBlock() failed (Status: %lx)\n", Status
);
143 int main (int argc
, char *argv
[])
149 LARGE_INTEGER FilePosition
;
153 printf("Usage: isotest [Drive:]\n");
157 strcpy(Filename
, "\\\\.\\");
158 strcat(Filename
, argv
[1]);
160 hDisk
= CreateFile(Filename
,
162 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
167 if (hDisk
== INVALID_HANDLE_VALUE
)
169 printf("CreateFile(): Invalid disk handle!\n");
173 Buffer
= (char*)malloc(2048);
177 printf("Out of memory!\n");
180 memset(Buffer
, 0, 2048);
183 FilePosition
.QuadPart
= 16 * 2048;
185 SetLastError(NO_ERROR
);
186 SetFilePointer(hDisk
,
187 FilePosition
.u
.LowPart
,
188 &FilePosition
.u
.HighPart
,
190 if (GetLastError() != NO_ERROR
)
194 printf("SetFilePointer() failed!\n");
206 printf("ReadFile() failed!\n");
220 printf("ReadBlock() failed!\n");
225 HexDump(Buffer
, 128);