Changeset 93126 in vbox
- Timestamp:
- Jan 5, 2022 1:04:16 AM (3 years ago)
- Location:
- trunk/src/VBox/Main/src-helper-apps/os2
- Files:
-
- 2 edited
-
Makefile.kmk (modified) (1 diff)
-
os2_util.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-helper-apps/os2/Makefile.kmk
r93123 r93126 42 42 OPTION STACK=8192 \ 43 43 OPTION HEAPSize=4096 \ 44 OPTION MANYAUTODATA \ 44 OPTION NEWFile \ 45 OPTION PROTmode \ 45 46 SEGMENT IOPL IOPL EXECUTEREAD 46 47 if 0 -
trunk/src/VBox/Main/src-helper-apps/os2/os2_util.c
r93120 r93126 57 57 *********************************************************************************************************************************/ 58 58 void __far VBoxBackdoorPrint(PSZ psz, unsigned cch); 59 static PSZ MyGetOptValue(PSZ psz, PSZ pszOption, PSZ *ppszValue); 59 60 60 61 … … 143 144 144 145 145 static voidMyApiErrorAndQuit(PSZ pszOperation, USHORT rc)146 static DECL_NO_RETURN(void) MyApiErrorAndQuit(PSZ pszOperation, USHORT rc) 146 147 { 147 148 MyOutStr("Os2Util: error: "); … … 154 155 155 156 156 static voidMyApiError3AndQuit(PSZ pszOperation, PSZ psz2, PSZ psz3, USHORT rc)157 static DECL_NO_RETURN(void) MyApiError3AndQuit(PSZ pszOperation, PSZ psz2, PSZ psz3, USHORT rc) 157 158 { 158 159 MyOutStr("Os2Util: error: "); … … 167 168 168 169 169 static voidMySyntaxErrorAndQuit(PSZ pszMsg)170 static DECL_NO_RETURN(void) MySyntaxErrorAndQuit(PSZ pszMsg) 170 171 { 171 172 MyOutStr("Os2Util: syntax error: "); … … 184 185 USHORT rc; 185 186 rc = DosOpen(pszTeeToFile, &hFile, &usAction, 0 /*cbInitial*/, 0 /*fFileAttribs*/, 186 OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,187 OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT | OPEN_FLAGS_SEQUENTIAL, 0 /*Reserved*/);187 OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 188 OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT | OPEN_FLAGS_SEQUENTIAL, 0 /*Reserved*/); 188 189 if (rc == NO_ERROR) 189 190 { … … 352 353 353 354 355 /** 356 * Handles --file-to-backdoor / -c. 357 */ 358 static void CopyFileToBackdoorAndQuit(PSZ psz, BOOL fLongOpt, PSZ pszBuf, USHORT cbBuf) 359 { 360 HFILE hFile = 0; 361 USHORT usAction = 0; 362 USHORT rc; 363 364 /* 365 * Get the filename and check that it is the last thing on the commandline. 366 */ 367 PSZ pszFilename = NULL; 368 CHAR ch; 369 psz = MyGetOptValue(psz, fLongOpt ? "--file-to-backdoor" : "-c", &pszFilename); 370 while ((ch = *psz) != '\0' && IS_BLANK(ch)) 371 psz++; 372 if (ch != '\0') 373 MySyntaxErrorAndQuit("No options allowed after -c/--file-to-backdoor"); 374 375 /* 376 * Open the file 377 */ 378 rc = DosOpen(pszFilename, &hFile, &usAction, 0 /*cbInitial*/, 0 /*fFileAttribs*/, 379 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 380 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT | OPEN_FLAGS_SEQUENTIAL, 0 /*Reserved*/); 381 if (rc != NO_ERROR) 382 MyApiError3AndQuit("Failed to open \"", pszFilename, "\" for reading", rc); 383 384 VBoxBackdoorPrint(RT_STR_TUPLE("--- BEGIN OF \"")); 385 VBoxBackdoorPrint(pszFilename, MyStrLen(pszFilename)); 386 VBoxBackdoorPrint(RT_STR_TUPLE("\" ---\n")); 387 388 for (;;) 389 { 390 USHORT cbRead = 0; 391 rc = DosRead(hFile, pszBuf, cbBuf, &cbRead); 392 if (rc == NO_ERROR) 393 { 394 if (cbRead == 0) 395 break; 396 VBoxBackdoorPrint(pszBuf, cbRead); 397 } 398 else if (rc != ERROR_INTERRUPT) 399 MyApiError3AndQuit("Reading \"", pszFilename, "\"", rc); 400 } 401 402 VBoxBackdoorPrint(RT_STR_TUPLE("--- END OF \"")); 403 VBoxBackdoorPrint(pszFilename, MyStrLen(pszFilename)); 404 VBoxBackdoorPrint(RT_STR_TUPLE("\" ---\n")); 405 406 DosClose(hFile); 407 DosExit(EXIT_PROCESS, 1); 408 } 409 410 354 411 /** Displays version string and quits. */ 355 static voidShowVersionAndQuit(void)412 static DECL_NO_RETURN(void) ShowVersionAndQuit(void) 356 413 { 357 414 CHAR szVer[] = "$Rev$\r\n"; … … 363 420 364 421 /** Displays usage info and quits. */ 365 static voidShowUsageAndQuit(void)422 static DECL_NO_RETURN(void) ShowUsageAndQuit(void) 366 423 { 367 424 static char s_szHelp[] = … … 377 434 " -- <prog> [args]\r\n" 378 435 " or Os2Util.exe <-w<msg>|--write-backdoor <msg>>\r\n" 436 " or Os2Util.exe <-c<file>|--file-to-backdoor <file>>\r\n" 379 437 "\r\n" 380 438 "Note! Does not supported any kind of quoting before the child arguments.\r\n" … … 419 477 static PSZ MyGetOptNum(PSZ psz, PSZ pszOption, PUSHORT puValue) 420 478 { 421 PSZ pszError = NULL; 422 PSZ pszValueStart = NULL; 423 PSZ pszValue; 424 CHAR ch; 425 USHORT uValue; 426 psz = MyGetOptValue(psz, pszOption, &pszValueStart); 427 428 pszValue = pszValueStart; 429 uValue = 0; 479 PSZ pszError = NULL; 480 PSZ pszValue = NULL; 481 PSZ const pszRet = MyGetOptValue(psz, pszOption, &pszValue); 482 PSZ const pszValueStart = pszValue; 483 USHORT uValue = 0; 484 CHAR ch; 430 485 if (pszValue[0] == '0' && ((ch = pszValue[1]) == 'x' || ch == 'X')) 431 486 { … … 487 542 488 543 *puValue = uValue; 489 return psz ;544 return pszRet; 490 545 } 491 546 … … 545 600 HQUEUE hQueue = ~(HQUEUE)0; 546 601 CHAR szQueueName[64]; 547 unsigned cAsZero ;602 unsigned cAsZero = 0; 548 603 USHORT auAsZero[16]; 549 604 … … 584 639 if (cAsZero > RT_ELEMENTS(auAsZero)) 585 640 MySyntaxErrorAndQuit("Too many --as-zero/-z options"); 586 psz = MyGetOptNum(psz + 1, "--as-zero", &auAsZero[cAsZero]);641 psz = MyGetOptNum(psz, "--as-zero", &auAsZero[cAsZero]); 587 642 cAsZero++; 588 643 } 644 else if (ch == 'f' && MyMatchLongOption(&psz, RT_STR_TUPLE("file-to-backdoor"))) 645 CopyFileToBackdoorAndQuit(psz, TRUE /*fLongOpt*/, szBuf, sizeof(szBuf)); 589 646 else if (ch == 'h' && MyMatchLongOption(&psz, RT_STR_TUPLE("help"))) 590 647 ShowUsageAndQuit(); … … 617 674 else if (ch == 'b') 618 675 g_fOutputToBackdoor = fTeeToBackdoor = TRUE; 676 else if (ch == 'c') 677 CopyFileToBackdoorAndQuit(psz + 1, FALSE /*fLongOpt*/, szBuf, sizeof(szBuf)); 619 678 else if (ch == 'f') 620 679 {
Note:
See TracChangeset
for help on using the changeset viewer.

