|
|
1.1 root 1: #include <stdio.h>
2: #include <string.h>
3: #include <windows.h>
4: #include "smpi.h"
5:
6: PCHAR string = "\\\\.\\Scsi0:";
7: PCHAR DbgString = "This string is in the data buffer area\n";
8: PCHAR UniqueString = "MyDrvr";
9:
10:
11: VOID main(VOID)
12: {
13: BOOLEAN bRc;
14: DWORD cbReturnedData;
15: HANDLE hDevice;
16: SHORT DbgStringLength = strlen(DbgString);
17: SHORT UniqueStringLength = strlen(UniqueString);
18: SRB_BUFFER smpi;
19:
20: //*************************************************************
21: //
22: // obtain a handle to the SCSI miniport driver
23: //
24: //*************************************************************
25:
26: printf("Attempting to get a handle for %s\n",string);
27:
28: hDevice = CreateFile(string,
29: GENERIC_READ,
30: FILE_SHARE_READ,
31: NULL,
32: OPEN_EXISTING,
33: 0,
34: NULL);
35:
36: if (hDevice == (HANDLE)-1)
37: {
38: printf("Attempt failed! Error number = %d\n",GetLastError());
39: return;
40: }
41:
42: printf("Attempt on %s succeeded\n\n",string);
43:
44: //*************************************************************
45: //
46: // fill in the SRB_IO_CONTROL structure
47: //
48: //*************************************************************
49:
50: smpi.sic.HeaderLength = sizeof(SRB_IO_CONTROL);
51: smpi.sic.Length = 0;
52:
53: _memccpy(&smpi.sic.Signature,UniqueString,0,UniqueStringLength);
54:
55: smpi.sic.Timeout = 10000;
56: smpi.sic.ControlCode = SMP_RETURN_3F;
57:
58: //*************************************************************
59: //
60: // call the driver
61: //
62: //*************************************************************
63:
64: bRc = DeviceIoControl(hDevice, // device handle
65: IOCTL_SCSI_MINIPORT, // io control code
66: &smpi, // input buffer
67: sizeof(SRB_IO_CONTROL), // input buffer length
68: &smpi, // output buffer
69: sizeof(SRB_IO_CONTROL), // output buffer length
70: &cbReturnedData, // # bytes returned
71: NULL); // synchronous call
72:
73: //*************************************************************
74: //
75: // check for errors
76: //
77: //*************************************************************
78:
79: if (!bRc)
80: printf("DeviceIoControl request for SMP_RETURN_3F failed : %d\n",
81: GetLastError());
82:
83: //*************************************************************
84: //
85: // verify the driver's access to the SRB_IO_CONTROL structure
86: //
87: //*************************************************************
88:
89: else {
90: printf("The SMP_RETURN_3F Return Code is 0x%08Xh\n",
91: smpi.sic.ReturnCode);
92: printf("The number of bytes returned by the driver is %d\n\n",
93: cbReturnedData);
94: }
95:
96: //*************************************************************
97: //
98: // fill in the SRB_IO_CONTROL structure
99: //
100: //*************************************************************
101:
102: smpi.sic.HeaderLength = sizeof(SRB_IO_CONTROL);
103: smpi.sic.Length = 100; // random large number
104:
105: _memccpy(&smpi.sic.Signature,UniqueString,0,UniqueStringLength);
106:
107: smpi.sic.Timeout = 0;
108: smpi.sic.ControlCode = SMP_PRINT_STRING;
109:
110: strcpy(smpi.ucDataBuffer,DbgString);
111:
112: //*************************************************************
113: //
114: // call the driver
115: //
116: //*************************************************************
117:
118: bRc = DeviceIoControl(hDevice, // device handle
119: IOCTL_SCSI_MINIPORT, // io control code
120: &smpi, // input buffer
121: sizeof(SRB_IO_CONTROL) + // input buffer length
122: DbgStringLength + 1,
123: &smpi, // output buffer
124: sizeof(SRB_IO_CONTROL) + // output buffer length
125: 100, // random large number
126: &cbReturnedData, // # bytes returned
127: NULL); // synchronous call
128:
129: //*************************************************************
130: //
131: // check for errors
132: //
133: //*************************************************************
134:
135: if (!bRc)
136: printf("DeviceIoControl request for SMP_PRINT_STRING failed : %d\n",
137: GetLastError());
138:
139: //*************************************************************
140: //
141: // verify the driver's access to the SRB_IO_CONTROL structure
142: //
143: //*************************************************************
144:
145: else {
146: printf("%s",smpi.ucDataBuffer);
147: printf("The number of bytes returned by the driver is %d\n\n",
148: cbReturnedData);
149: }
150:
151: //*************************************************************
152: //
153: // close the handle to the SCSI miniport driver
154: //
155: //*************************************************************
156:
157: CloseHandle(hDevice);
158: }
159:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.