MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2DefineDosDevicePipe

Function Ext2DefineDosDevicePipe

Ext2Mgr/Ext2Pipe.cpp:186–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185
186BOOL Ext2DefineDosDevicePipe(DWORD flags, CHAR *dos, CHAR *symlink)
187{
188 PPIPE_REQ p = NULL;
189 ULONG len = REQ_BODY_SIZE;
190 BOOL rc = 0;
191
192 p = (PPIPE_REQ) new CHAR[len];
193 if (NULL == p)
194 goto errorout;
195
196 if (flags & DDD_REMOVE_DEFINITION) {
197
198 /* do dismount */
199 PREQ_REMOVE_DRV q;
200 memset(p, 0, len);
201 p->magic = PIPE_REQ_MAGIC;
202 p->len = sizeof(PIPE_REQ) + sizeof(REQ_REMOVE_DRV);
203 p->cmd = CMD_REMOVE_DRV;
204 q = (PREQ_REMOVE_DRV)&p->data[0];
205 q->pid = GetCurrentProcessId();
206 q->drive = (UCHAR)toupper(dos[0]);
207 q->flags = flags;
208 strcpy(&q->name[0], symlink);
209 p->len += (int)strlen(symlink) + 1;
210
211 rc = Ext2PipeControl(&p, &len);
212 if (!rc) {
213 printf("pipe communication failed.\n");
214 goto errorout;
215 }
216
217 if (q->result) {
218 printf("%C: removed.\n", q->drive);
219 rc = TRUE;
220 } else {
221 printf("failed to remove %C:.\n", q->drive);
222 goto errorout;
223 }
224
225 } else {
226
227 /* do mount */
228 PREQ_DEFINE_DRV q;
229 memset(p, 0, len);
230 p->magic = PIPE_REQ_MAGIC;
231 p->len = sizeof(PIPE_REQ) + sizeof(REQ_DEFINE_DRV);
232 p->cmd = CMD_DEFINE_DRV;
233 q = (PREQ_DEFINE_DRV)&p->data[0];
234 q->pid = GetCurrentProcessId();
235 q->drive = (UCHAR)toupper(dos[0]);
236 q->flags = flags;
237 strcpy(&q->name[0], symlink);
238 p->len += (int)strlen(symlink) + 1;
239
240 rc = Ext2PipeControl(&p, &len);
241 if ( !rc) {
242 printf("pipe communication failed.\n");
243 goto errorout;

Callers 1

Ext2DefineDosDeviceFunction · 0.85

Calls 1

Ext2PipeControlFunction · 0.85

Tested by

no test coverage detected