2 * isotest - display cdrom information
6 //#include <winioctl.h>
11 void HexDump(char *buffer
, ULONG size
)
16 while (offset
< (size
& ~15))
18 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
19 printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
38 printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
39 isprint(ptr
[0])?ptr
[0]:'.',
40 isprint(ptr
[1])?ptr
[1]:'.',
41 isprint(ptr
[2])?ptr
[2]:'.',
42 isprint(ptr
[3])?ptr
[3]:'.',
43 isprint(ptr
[4])?ptr
[4]:'.',
44 isprint(ptr
[5])?ptr
[5]:'.',
45 isprint(ptr
[6])?ptr
[6]:'.',
46 isprint(ptr
[7])?ptr
[7]:'.',
47 isprint(ptr
[8])?ptr
[8]:'.',
48 isprint(ptr
[9])?ptr
[9]:'.',
49 isprint(ptr
[10])?ptr
[10]:'.',
50 isprint(ptr
[11])?ptr
[11]:'.',
51 isprint(ptr
[12])?ptr
[12]:'.',
52 isprint(ptr
[13])?ptr
[13]:'.',
53 isprint(ptr
[14])?ptr
[14]:'.',
54 isprint(ptr
[15])?ptr
[15]:'.');
59 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
62 printf("%08lx ", offset
);
65 printf(" %02hx", *ptr
);
75 #ifndef EVENT_ALL_ACCESS
76 #define EVENT_ALL_ACCESS (0x1f0003L)
80 ReadBlock(HANDLE FileHandle
,
82 PLARGE_INTEGER Offset
,
86 IO_STATUS_BLOCK IoStatusBlock
;
87 OBJECT_ATTRIBUTES ObjectAttributes
;
91 InitializeObjectAttributes(&ObjectAttributes
,
94 Status
= NtCreateEvent(&EventHandle
,
99 if (!NT_SUCCESS(Status
))
101 printf("NtCreateEvent() failed\n");
105 Status
= NtReadFile(FileHandle
,
114 if (Status
== STATUS_PENDING
)
116 printf("STATUS_PENDING\n");
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
)
137 int main (int argc
, char *argv
[])
144 LARGE_INTEGER FilePosition
;
148 printf("Usage: isotest [Drive:]\n");
152 strcpy(Filename
, "\\\\.\\");
153 strcat(Filename
, argv
[1]);
155 hDisk
= CreateFile(Filename
,
157 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
162 if (hDisk
== INVALID_HANDLE_VALUE
)
164 printf("CreateFile(): Invalid disk handle!");
168 Buffer
= (char*)malloc(2048);
172 printf("Out of memory!");
175 memset(Buffer
, 0, 2048);
178 FilePosition
.QuadPart
= 16 * 2048;
180 SetLastError(NO_ERROR
);
181 SetFilePointer(hDisk
,
182 FilePosition
.u
.LowPart
,
183 &FilePosition
.u
.HighPart
,
185 if (GetLastError() != NO_ERROR
)
189 printf("SetFilePointer() failed!");
201 printf("ReadFile() failed!");
214 printf("ReadBlock() failed!");
218 HexDump(Buffer
, 128);