2 * isotest - display cdrom information
6 //#include <winioctl.h>
14 void HexDump(char *buffer
, ULONG size
)
19 while (offset
< (size
& ~15))
21 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
22 printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
41 printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
42 isprint(ptr
[0])?ptr
[0]:'.',
43 isprint(ptr
[1])?ptr
[1]:'.',
44 isprint(ptr
[2])?ptr
[2]:'.',
45 isprint(ptr
[3])?ptr
[3]:'.',
46 isprint(ptr
[4])?ptr
[4]:'.',
47 isprint(ptr
[5])?ptr
[5]:'.',
48 isprint(ptr
[6])?ptr
[6]:'.',
49 isprint(ptr
[7])?ptr
[7]:'.',
50 isprint(ptr
[8])?ptr
[8]:'.',
51 isprint(ptr
[9])?ptr
[9]:'.',
52 isprint(ptr
[10])?ptr
[10]:'.',
53 isprint(ptr
[11])?ptr
[11]:'.',
54 isprint(ptr
[12])?ptr
[12]:'.',
55 isprint(ptr
[13])?ptr
[13]:'.',
56 isprint(ptr
[14])?ptr
[14]:'.',
57 isprint(ptr
[15])?ptr
[15]:'.');
62 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
65 printf("%08lx ", offset
);
68 printf(" %02hx", *ptr
);
78 #ifndef EVENT_ALL_ACCESS
79 #define EVENT_ALL_ACCESS (0x1f0003L)
83 ReadBlock(HANDLE FileHandle
,
85 PLARGE_INTEGER Offset
,
89 IO_STATUS_BLOCK IoStatusBlock
;
90 OBJECT_ATTRIBUTES ObjectAttributes
;
94 InitializeObjectAttributes(&ObjectAttributes
,
97 Status
= NtCreateEvent(&EventHandle
,
102 if (!NT_SUCCESS(Status
))
104 printf("NtCreateEvent() failed\n");
108 Status
= NtReadFile(FileHandle
,
117 if (Status
== STATUS_PENDING
)
119 NtWaitForSingleObject(EventHandle
, FALSE
, NULL
);
120 Status
= IoStatusBlock
.Status
;
123 NtClose(EventHandle
);
125 if (Status
!= STATUS_PENDING
&& BytesRead
!= NULL
)
127 *BytesRead
= IoStatusBlock
.Information
;
129 if (!NT_SUCCESS(Status
) && Status
!= STATUS_END_OF_FILE
)
131 printf("ReadBlock() failed (Status: %lx)\n", Status
);
140 int main (int argc
, char *argv
[])
146 LARGE_INTEGER FilePosition
;
150 printf("Usage: isotest [Drive:]\n");
154 strcpy(Filename
, "\\\\.\\");
155 strcat(Filename
, argv
[1]);
157 hDisk
= CreateFile(Filename
,
159 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
164 if (hDisk
== INVALID_HANDLE_VALUE
)
166 printf("CreateFile(): Invalid disk handle!\n");
170 Buffer
= (char*)malloc(2048);
174 printf("Out of memory!\n");
177 memset(Buffer
, 0, 2048);
180 FilePosition
.QuadPart
= 16 * 2048;
182 SetLastError(NO_ERROR
);
183 SetFilePointer(hDisk
,
184 FilePosition
.u
.LowPart
,
185 &FilePosition
.u
.HighPart
,
187 if (GetLastError() != NO_ERROR
)
191 printf("SetFilePointer() failed!\n");
203 printf("ReadFile() failed!\n");
217 printf("ReadBlock() failed!\n");
222 HexDump(Buffer
, 128);