2 * isotest - display cdrom information
16 void HexDump(char *buffer
, ULONG size
)
21 while (offset
< (size
& ~15))
23 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
24 printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
43 printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
44 isprint(ptr
[0])?ptr
[0]:'.',
45 isprint(ptr
[1])?ptr
[1]:'.',
46 isprint(ptr
[2])?ptr
[2]:'.',
47 isprint(ptr
[3])?ptr
[3]:'.',
48 isprint(ptr
[4])?ptr
[4]:'.',
49 isprint(ptr
[5])?ptr
[5]:'.',
50 isprint(ptr
[6])?ptr
[6]:'.',
51 isprint(ptr
[7])?ptr
[7]:'.',
52 isprint(ptr
[8])?ptr
[8]:'.',
53 isprint(ptr
[9])?ptr
[9]:'.',
54 isprint(ptr
[10])?ptr
[10]:'.',
55 isprint(ptr
[11])?ptr
[11]:'.',
56 isprint(ptr
[12])?ptr
[12]:'.',
57 isprint(ptr
[13])?ptr
[13]:'.',
58 isprint(ptr
[14])?ptr
[14]:'.',
59 isprint(ptr
[15])?ptr
[15]:'.');
64 ptr
= (unsigned char*)((ULONG
)buffer
+ offset
);
67 printf("%08lx ", offset
);
70 printf(" %02hx", *ptr
);
80 #ifndef EVENT_ALL_ACCESS
81 #define EVENT_ALL_ACCESS (0x1f0003L)
85 ReadBlock(HANDLE FileHandle
,
87 PLARGE_INTEGER Offset
,
91 IO_STATUS_BLOCK IoStatusBlock
;
92 OBJECT_ATTRIBUTES ObjectAttributes
;
96 InitializeObjectAttributes(&ObjectAttributes
,
99 Status
= NtCreateEvent(&EventHandle
,
104 if (!NT_SUCCESS(Status
))
106 printf("NtCreateEvent() failed\n");
110 Status
= NtReadFile(FileHandle
,
119 if (Status
== STATUS_PENDING
)
121 NtWaitForSingleObject(EventHandle
, FALSE
, NULL
);
122 Status
= IoStatusBlock
.Status
;
125 NtClose(EventHandle
);
127 if (Status
!= STATUS_PENDING
&& BytesRead
!= NULL
)
129 *BytesRead
= IoStatusBlock
.Information
;
131 if (!NT_SUCCESS(Status
) && Status
!= STATUS_END_OF_FILE
)
133 printf("ReadBlock() failed (Status: %lx)\n", Status
);
142 int main (int argc
, char *argv
[])
148 LARGE_INTEGER FilePosition
;
152 printf("Usage: isotest [Drive:]\n");
156 strcpy(Filename
, "\\\\.\\");
157 strcat(Filename
, argv
[1]);
159 hDisk
= CreateFile(Filename
,
161 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
166 if (hDisk
== INVALID_HANDLE_VALUE
)
168 printf("CreateFile(): Invalid disk handle!\n");
172 Buffer
= (char*)malloc(2048);
176 printf("Out of memory!\n");
179 memset(Buffer
, 0, 2048);
182 FilePosition
.QuadPart
= 16 * 2048;
184 SetLastError(NO_ERROR
);
185 SetFilePointer(hDisk
,
186 FilePosition
.u
.LowPart
,
187 &FilePosition
.u
.HighPart
,
189 if (GetLastError() != NO_ERROR
)
193 printf("SetFilePointer() failed!\n");
205 printf("ReadFile() failed!\n");
219 printf("ReadBlock() failed!\n");
224 HexDump(Buffer
, 128);