ReactOS  0.4.13-dev-464-g6b95727
isotest.c File Reference
#include <windows.h>
#include <ndk/ntndk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <wchar.h>
Include dependency graph for isotest.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define EVENT_ALL_ACCESS   (0x1f0003L)
 

Functions

void HexDump (char *buffer, ULONG size)
 
BOOL ReadBlock (HANDLE FileHandle, PVOID Buffer, PLARGE_INTEGER Offset, ULONG Length, PULONG BytesRead)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ EVENT_ALL_ACCESS

#define EVENT_ALL_ACCESS   (0x1f0003L)

Definition at line 82 of file isotest.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 7 of file isotest.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 5 of file isotest.c.

Function Documentation

◆ HexDump()

void HexDump ( char buffer,
ULONG  size 
)

Definition at line 17 of file isotest.c.

18 {
19  ULONG offset = 0;
20  unsigned char *ptr;
21 
22  while (offset < (size & ~15))
23  {
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",
26  offset,
27  ptr[0],
28  ptr[1],
29  ptr[2],
30  ptr[3],
31  ptr[4],
32  ptr[5],
33  ptr[6],
34  ptr[7],
35  ptr[8],
36  ptr[9],
37  ptr[10],
38  ptr[11],
39  ptr[12],
40  ptr[13],
41  ptr[14],
42  ptr[15]);
43 
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]:'.');
61 
62  offset += 16;
63  }
64 
65  ptr = (unsigned char*)((ULONG_PTR)buffer + offset);
66  if (offset < size)
67  {
68  printf("%08lx ", offset);
69  while (offset < size)
70  {
71  printf(" %02hx", *ptr);
72  offset++;
73  ptr++;
74  }
75  }
76 
77  printf("\n\n");
78 }
GLintptr offset
Definition: glext.h:5920
GLuint buffer
Definition: glext.h:5915
uint32_t ULONG_PTR
Definition: typedefs.h:63
static PVOID ptr
Definition: dispmode.c:27
GLsizeiptr size
Definition: glext.h:5919
#define isprint(c)
Definition: acclib.h:73
unsigned int ULONG
Definition: retypes.h:1
#define printf
Definition: config.h:203

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 143 of file isotest.c.

144 {
145  HANDLE hDisk;
146  DWORD dwRead;
147  char *Buffer;
148  CHAR Filename[80];
149  LARGE_INTEGER FilePosition;
150 
151  if (argc != 2)
152  {
153  printf("Usage: isotest [Drive:]\n");
154  return 0;
155  }
156 
157  strcpy(Filename, "\\\\.\\");
158  strcat(Filename, argv[1]);
159 
160  hDisk = CreateFile(Filename,
161  GENERIC_READ,
163  NULL,
165  0,
166  NULL);
167  if (hDisk == INVALID_HANDLE_VALUE)
168  {
169  printf("CreateFile(): Invalid disk handle!\n");
170  return 0;
171  }
172 
173  Buffer = (char*)malloc(2048);
174  if (Buffer == NULL)
175  {
176  CloseHandle(hDisk);
177  printf("Out of memory!\n");
178  return 0;
179  }
180  memset(Buffer, 0, 2048);
181 
182 
183  FilePosition.QuadPart = 16 * 2048;
184 #if 0
186  SetFilePointer(hDisk,
187  FilePosition.u.LowPart,
188  &FilePosition.u.HighPart,
189  FILE_BEGIN);
190  if (GetLastError() != NO_ERROR)
191  {
192  CloseHandle(hDisk);
193  free(Buffer);
194  printf("SetFilePointer() failed!\n");
195  return 0;
196  }
197 
198  if (ReadFile(hDisk,
199  Buffer,
200  2048,
201  &dwRead,
202  NULL) == FALSE)
203  {
204  CloseHandle(hDisk);
205  free(Buffer);
206  printf("ReadFile() failed!\n");
207  return 0;
208  }
209 #endif
210 
211  if (ReadBlock(hDisk,
212  Buffer,
213  &FilePosition,
214  2048,
215  &dwRead) == FALSE)
216  {
217  CloseHandle(hDisk);
218  free(Buffer);
219 #if 0
220  printf("ReadBlock() failed!\n");
221 #endif
222  return 0;
223  }
224 
225  HexDump(Buffer, 128);
226 
227  CloseHandle(hDisk);
228 
229  free(Buffer);
230 
231  return 0;
232 }
static int argc
Definition: ServiceArgs.c:12
#define CloseHandle
Definition: compat.h:398
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char CHAR
Definition: xmlstorage.h:175
#define free
Definition: debug_ros.c:5
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define argv
Definition: mplay32.c:18
#define NO_ERROR
Definition: dderror.h:5
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:925
#define FILE_SHARE_READ
Definition: compat.h:125
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
BOOL ReadBlock(HANDLE FileHandle, PVOID Buffer, PLARGE_INTEGER Offset, ULONG Length, PULONG BytesRead)
Definition: isotest.c:86
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define OPEN_EXISTING
Definition: compat.h:426
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define GENERIC_READ
Definition: compat.h:124
#define FILE_BEGIN
Definition: winbase.h:112
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
struct _LARGE_INTEGER::@2196 u
void HexDump(char *buffer, ULONG size)
Definition: isotest.c:17
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define malloc
Definition: debug_ros.c:4
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define memset(x, y, z)
Definition: compat.h:39
LONGLONG QuadPart
Definition: typedefs.h:112
#define printf
Definition: config.h:203

◆ ReadBlock()

BOOL ReadBlock ( HANDLE  FileHandle,
PVOID  Buffer,
PLARGE_INTEGER  Offset,
ULONG  Length,
PULONG  BytesRead 
)

Definition at line 86 of file isotest.c.

91 {
96 
98  NULL, 0, NULL, NULL);
99 
103  TRUE,
104  FALSE);
105  if (!NT_SUCCESS(Status))
106  {
107  printf("NtCreateEvent() failed\n");
108  return(FALSE);
109  }
110 
112  EventHandle,
113  NULL,
114  NULL,
115  &IoStatusBlock,
116  Buffer,
117  Length,
118  Offset,
119  NULL);
120  if (Status == STATUS_PENDING)
121  {
124  }
125 
127 
128  if (Status != STATUS_PENDING && BytesRead != NULL)
129  {
131  }
133  {
134  printf("ReadBlock() failed (Status: %lx)\n", Status);
135  return(FALSE);
136  }
137 
138  return(TRUE);
139 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:100
#define STATUS_END_OF_FILE
Definition: shellext.h:62
HANDLE FileHandle
Definition: stats.c:38
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
#define printf
Definition: config.h:203
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:855
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by main().