2 * isotest - display cdrom information
12 void HexDump(char *buffer
, ULONG size
)
17 while (offset
< (size
& ~15))
19 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
20 printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
39 printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
40 isprint(ptr
[0])?ptr
[0]:'.',
41 isprint(ptr
[1])?ptr
[1]:'.',
42 isprint(ptr
[2])?ptr
[2]:'.',
43 isprint(ptr
[3])?ptr
[3]:'.',
44 isprint(ptr
[4])?ptr
[4]:'.',
45 isprint(ptr
[5])?ptr
[5]:'.',
46 isprint(ptr
[6])?ptr
[6]:'.',
47 isprint(ptr
[7])?ptr
[7]:'.',
48 isprint(ptr
[8])?ptr
[8]:'.',
49 isprint(ptr
[9])?ptr
[9]:'.',
50 isprint(ptr
[10])?ptr
[10]:'.',
51 isprint(ptr
[11])?ptr
[11]:'.',
52 isprint(ptr
[12])?ptr
[12]:'.',
53 isprint(ptr
[13])?ptr
[13]:'.',
54 isprint(ptr
[14])?ptr
[14]:'.',
55 isprint(ptr
[15])?ptr
[15]:'.');
60 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
63 printf("%08lx ", offset
);
66 printf(" %02hx", *ptr
);
76 #ifndef EVENT_ALL_ACCESS
77 #define EVENT_ALL_ACCESS (0x1f0003L)
81 ReadBlock(HANDLE FileHandle
,
83 PLARGE_INTEGER Offset
,
87 IO_STATUS_BLOCK IoStatusBlock
;
88 OBJECT_ATTRIBUTES ObjectAttributes
;
92 InitializeObjectAttributes(&ObjectAttributes
,
95 Status
= NtCreateEvent(&EventHandle
,
100 if (!NT_SUCCESS(Status
))
102 printf("NtCreateEvent() failed\n");
106 Status
= NtReadFile(FileHandle
,
115 if (Status
== STATUS_PENDING
)
117 NtWaitForSingleObject(EventHandle
, FALSE
, NULL
);
118 Status
= IoStatusBlock
.Status
;
121 NtClose(EventHandle
);
123 if (Status
!= STATUS_PENDING
&& BytesRead
!= NULL
)
125 *BytesRead
= IoStatusBlock
.Information
;
127 if (!NT_SUCCESS(Status
) && Status
!= STATUS_END_OF_FILE
)
129 printf("ReadBlock() failed (Status: %lx)\n", Status
);
138 int main (int argc
, char *argv
[])
145 LARGE_INTEGER FilePosition
;
149 printf("Usage: isotest [Drive:]\n");
153 strcpy(Filename
, "\\\\.\\");
154 strcat(Filename
, argv
[1]);
156 hDisk
= CreateFile(Filename
,
158 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
163 if (hDisk
== INVALID_HANDLE_VALUE
)
165 printf("CreateFile(): Invalid disk handle!\n");
169 Buffer
= (char*)malloc(2048);
173 printf("Out of memory!\n");
176 memset(Buffer
, 0, 2048);
179 FilePosition
.QuadPart
= 16 * 2048;
181 SetLastError(NO_ERROR
);
182 SetFilePointer(hDisk
,
183 FilePosition
.u
.LowPart
,
184 &FilePosition
.u
.HighPart
,
186 if (GetLastError() != NO_ERROR
)
190 printf("SetFilePointer() failed!\n");
202 printf("ReadFile() failed!\n");
216 printf("ReadBlock() failed!\n");
221 HexDump(Buffer
, 128);