ReactOS 0.4.16-dev-205-g7b2bb7e
diskspeed.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <ndk/ntndk.h>
#include <ntddscsi.h>
#include <scsi.h>
Include dependency graph for diskspeed.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define _NTSCSI_USER_MODE_
 

Functions

BOOL GetInquiryData (HANDLE hDevice, PINQUIRYDATA InquiryData)
 
int main (void)
 

Macro Definition Documentation

◆ _NTSCSI_USER_MODE_

#define _NTSCSI_USER_MODE_

Definition at line 18 of file diskspeed.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 15 of file diskspeed.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 13 of file diskspeed.c.

Function Documentation

◆ GetInquiryData()

BOOL GetInquiryData ( HANDLE  hDevice,
PINQUIRYDATA  InquiryData 
)

Definition at line 22 of file diskspeed.c.

23{
25 DWORD dwReturned;
26 SCSI_ADDRESS ScsiAddress;
27 PSCSI_ADAPTER_BUS_INFO AdapterInfo;
28 PSCSI_INQUIRY_DATA InquiryBuffer;
29 BYTE Buffer[4096];
30 int i;
31
32 Result = DeviceIoControl(hDevice,
34 NULL,
35 0,
36 &ScsiAddress,
37 sizeof(ScsiAddress),
38 &dwReturned,
39 FALSE);
40 if (Result == FALSE)
41 {
42 return FALSE;
43 }
44 Result = DeviceIoControl(hDevice,
46 NULL,
47 0,
48 Buffer,
49 sizeof(Buffer),
50 &dwReturned,
51 FALSE);
52 if (Result)
53 {
54 AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)Buffer;
55 for (i = 0; i < AdapterInfo->NumberOfBuses; i++)
56 {
57 InquiryBuffer = (PSCSI_INQUIRY_DATA) (Buffer + AdapterInfo->BusData[i].InquiryDataOffset);
58 if (AdapterInfo->BusData[i].InquiryDataOffset)
59 {
60 while (1)
61 {
62 if (InquiryBuffer->PathId == ScsiAddress.PathId &&
63 InquiryBuffer->TargetId == ScsiAddress.TargetId &&
64 InquiryBuffer->Lun == ScsiAddress.Lun)
65 {
66 memcpy(InquiryData, InquiryBuffer->InquiryData, sizeof(INQUIRYDATA));
67 return TRUE;
68 }
69 if (InquiryBuffer->NextInquiryDataOffset == 0)
70 {
71 break;
72 }
73 InquiryBuffer = (PSCSI_INQUIRY_DATA) (Buffer + InquiryBuffer->NextInquiryDataOffset);
74 }
75 }
76 }
77 }
78 return FALSE;
79}
Definition: bufpool.h:45
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define IOCTL_SCSI_GET_ADDRESS
Definition: scsi_port.h:52
struct _SCSI_INQUIRY_DATA * PSCSI_INQUIRY_DATA
#define IOCTL_SCSI_GET_INQUIRY_DATA
Definition: scsi_port.h:49
struct _SCSI_ADAPTER_BUS_INFO * PSCSI_ADAPTER_BUS_INFO
SCSI_BUS_DATA BusData[1]
Definition: scsi_port.h:106
UCHAR PathId
Definition: scsi_port.h:149
UCHAR TargetId
Definition: scsi_port.h:150
ULONG InquiryDataOffset
Definition: scsi_port.h:98
UCHAR InquiryData[1]
Definition: scsi_port.h:119
ULONG NextInquiryDataOffset
Definition: scsi_port.h:118
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
unsigned char BYTE
Definition: xxhash.c:193

Referenced by main().

◆ main()

int main ( void  )

Definition at line 83 of file diskspeed.c.

84{
85 HANDLE hDevice;
86 OVERLAPPED ov;
87
88 PBYTE Buffer = NULL ;
90 DWORD dwReturned;
91 DWORD dwReadTotal;
92 DWORD Size;
95 CHAR Name[20];
96
97 INQUIRYDATA InquiryData;
98
99
100 Drive = 0;
101 while (1)
102 {
103 sprintf(Name, "\\\\.\\PHYSICALDRIVE%ld", Drive);
104 hDevice = CreateFile(Name,
107 NULL,
109 0,
110 NULL);
111 if (hDevice == INVALID_HANDLE_VALUE)
112 {
113 if (Drive > 0)
114 {
115 VirtualFree(Buffer, 512 * 1024, MEM_RELEASE);
116 }
117 else
118 {
119 printf("Cannot open '%s'\n", Name);
120 }
121 break;
122 }
123 if (Drive == 0)
124 {
125 printf("Transfer Size (kB) 1 2 4 8 16 32 64 128 256\n");
126 printf("Transfer Rate (MB/s)\n");
127 printf("-------------------------------------------------------------------------------\n");
128
130 }
131 Result = GetInquiryData(hDevice, &InquiryData);
132 if (Result)
133 {
134 printf("%.24s ", InquiryData.VendorId);
135 }
136 else
137 {
138 printf("Disk %ld ", Drive + 1);
139 }
140 Size = 1024;
141 memset(&ov, 0, sizeof(OVERLAPPED));
142 while (Size <= 256 * 1024)
143 {
144 memset(Buffer, 0, Size);
145 dwReadTotal = 0;
146
147 Start = GetTickCount() + 2000;
148 while (Start > GetTickCount())
149 {
150 Result = ReadFile(hDevice, Buffer, Size, &dwReturned, &ov);
151 if (Result)
152 {
153 dwReadTotal += dwReturned;
154 ov.Offset += dwReturned;
155 }
156 }
157 dwReadTotal /= 2048;
158 printf("%3ld.%ld ", dwReadTotal / 1024, (dwReadTotal % 1024) * 10 / 1024);
159 Size *= 2;
160 }
161 printf("\n");
162 CloseHandle(hDevice);
163 Drive++;
164 }
165 printf("\n");
166
167
168 return 0;
169}
PWCHAR Drive
Definition: chkdsk.c:73
BOOL GetInquiryData(HANDLE hDevice, PINQUIRYDATA InquiryData)
Definition: diskspeed.c:22
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define printf
Definition: freeldr.h:97
return pTarget Start()
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MEM_COMMIT
Definition: nt_native.h:1313
BYTE * PBYTE
Definition: pedump.c:66
#define memset(x, y, z)
Definition: compat.h:39
UCHAR VendorId[8]
Definition: cdrw_hw.h:1132
DWORD Offset
Definition: winbase.h:839
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:119
#define CreateFile
Definition: winbase.h:3773
char CHAR
Definition: xmlstorage.h:175