Reactos

[MKHIVE] Return win32-like error codes for functions that expect to do so. Fix and comment out some unused ERROR_xxx/STATUS_xxx defines.

+51 -47
+6 -6
sdk/tools/mkhive/mkhive.h
··· 42 42 // We only want to include host headers, so we define them manually 43 43 #define STATUS_SUCCESS ((NTSTATUS)0x00000000) 44 44 #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001) 45 - #define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002) 46 - #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000D) 47 - #define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017) 48 - #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009A) 45 + // #define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002) 46 + // #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000D) 47 + // #define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017) 48 + // #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009A) 49 49 #define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS)0xC0000034) 50 - #define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0) 51 - #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005) 50 + // #define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0) 51 + // #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005) 52 52 53 53 unsigned char BitScanForward(ULONG * Index, unsigned long Mask); 54 54 unsigned char BitScanReverse(ULONG * const Index, unsigned long Mask);
+37 -37
sdk/tools/mkhive/registry.c
··· 30 30 #define NDEBUG 31 31 #include "mkhive.h" 32 32 33 - /* DEFINITIONS AND DATA *****************************************************/ 34 - 35 - #define STATUS_NO_LOG_SPACE ((NTSTATUS)0xC000017D) 36 - #define STATUS_CANNOT_DELETE ((NTSTATUS)0xC0000121) 33 + /* DATA *********************************************************************/ 37 34 38 35 typedef struct _REPARSE_POINT 39 36 { ··· 396 393 IN BOOL Volatile, 397 394 OUT PHKEY Key) 398 395 { 396 + NTSTATUS Status; 399 397 PWSTR LocalKeyName; 400 398 PWSTR End; 401 399 UNICODE_STRING KeyString; 402 - NTSTATUS Status; 403 400 PREPARSE_POINT CurrentReparsePoint; 404 401 PMEMKEY CurrentKey; 405 402 PCMHIVE ParentRegistryHive; ··· 450 447 451 448 ParentKeyCell = (PCM_KEY_NODE)HvGetCell(&ParentRegistryHive->Hive, ParentCellOffset); 452 449 if (!ParentKeyCell) 453 - return STATUS_UNSUCCESSFUL; 450 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 454 451 455 452 VERIFY_KEY_CELL(ParentKeyCell); 456 453 ··· 484 481 } 485 482 else // if (BlockOffset == HCELL_NIL) 486 483 { 487 - Status = STATUS_OBJECT_NAME_NOT_FOUND; // ERROR_PATH_NOT_FOUND; 484 + Status = STATUS_OBJECT_NAME_NOT_FOUND; 488 485 } 489 486 490 487 HvReleaseCell(&ParentRegistryHive->Hive, ParentCellOffset); 491 488 492 489 if (!NT_SUCCESS(Status)) 493 490 { 494 - DPRINT("RegpCreateOrOpenKey('%S'): Could not create or open subkey '%wZ'\n", KeyName, &KeyString); 495 - return ERROR_UNSUCCESSFUL; 491 + DPRINT("RegpCreateOrOpenKey('%S'): Could not create or open subkey '%wZ', Status 0x%08x\n", KeyName, &KeyString, Status); 492 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 496 493 } 497 494 498 495 ParentCellOffset = BlockOffset; ··· 504 501 505 502 CurrentKey = CreateInMemoryStructure(ParentRegistryHive, ParentCellOffset); 506 503 if (!CurrentKey) 507 - return ERROR_OUTOFMEMORY; 504 + return ERROR_NOT_ENOUGH_MEMORY; // STATUS_NO_MEMORY; 508 505 509 506 *Key = MEMKEY_TO_HKEY(CurrentKey); 510 507 ··· 557 554 IN LPCWSTR lpSubKey) 558 555 { 559 556 LONG rc; 557 + NTSTATUS Status; 560 558 HKEY hTargetKey; 561 559 PMEMKEY Key; // ParentKey 562 560 PHHIVE Hive; 563 561 PCM_KEY_NODE KeyNode; // ParentNode 564 562 PCM_KEY_NODE Parent; 565 563 HCELL_INDEX ParentCell; 566 - 567 - NTSTATUS Status; 568 564 569 565 if (lpSubKey) 570 566 { ··· 581 577 if (hTargetKey == RootKey) 582 578 { 583 579 /* Fail */ 584 - Status = STATUS_CANNOT_DELETE; 580 + rc = ERROR_ACCESS_DENIED; // STATUS_CANNOT_DELETE; 585 581 goto Quit; 586 582 } 587 583 ··· 593 589 KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); 594 590 if (!KeyNode) 595 591 { 596 - Status = ERROR_UNSUCCESSFUL; 592 + rc = ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 597 593 goto Quit; 598 594 } 599 595 ··· 621 617 /* Release the cell */ 622 618 HvReleaseCell(Hive, ParentCell); 623 619 } 620 + } 621 + else 622 + { 623 + /* Fail */ 624 + rc = ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 624 625 } 625 626 } 626 627 else 627 628 { 628 629 /* Fail */ 629 - Status = STATUS_CANNOT_DELETE; 630 + rc = ERROR_ACCESS_DENIED; // STATUS_CANNOT_DELETE; 630 631 } 631 632 632 633 /* Release the cell */ ··· 636 637 if (lpSubKey) 637 638 RegCloseKey(hTargetKey); 638 639 639 - return Status; 640 + return rc; 640 641 } 641 642 642 643 LONG WINAPI ··· 675 676 676 677 /* Special handling of registry links */ 677 678 if (cbData != sizeof(PVOID)) 678 - return STATUS_INVALID_PARAMETER; 679 + return ERROR_INVALID_PARAMETER; // STATUS_INVALID_PARAMETER; 679 680 680 681 DestKey = HKEY_TO_MEMKEY(*(PHKEY)lpData); 681 682 ··· 683 684 684 685 /* Create the link in registry hive (if applicable) */ 685 686 if (Key->RegistryHive != DestKey->RegistryHive) 686 - return STATUS_SUCCESS; 687 + return ERROR_SUCCESS; 687 688 688 689 DPRINT1("Save link to registry\n"); 689 - return STATUS_NOT_IMPLEMENTED; 690 + return ERROR_INVALID_FUNCTION; // STATUS_NOT_IMPLEMENTED; 690 691 } 691 692 692 693 if ((cbData & ~CM_KEY_VALUE_SPECIAL_SIZE) != cbData) 693 - return STATUS_UNSUCCESSFUL; 694 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 694 695 695 696 Hive = &Key->RegistryHive->Hive; 696 697 697 698 KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); 698 699 if (!KeyNode) 699 - return ERROR_UNSUCCESSFUL; 700 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 700 701 701 702 ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); 702 703 ··· 714 715 /* Sanity check */ 715 716 ASSERT(CellIndex == HCELL_NIL); 716 717 /* Fail */ 717 - // Status = STATUS_INSUFFICIENT_RESOURCES; 718 - return ERROR_UNSUCCESSFUL; 718 + Status = STATUS_INSUFFICIENT_RESOURCES; 719 719 } 720 720 if (CellIndex == HCELL_NIL) 721 721 { ··· 738 738 // /**/HvReleaseCell(Hive, CellIndex);/**/ 739 739 740 740 if (!NT_SUCCESS(Status)) 741 - return ERROR_UNSUCCESSFUL; 741 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 742 742 743 743 /* Get size of the allocated cell (if any) */ 744 744 if (!(ValueCell->DataLength & CM_KEY_VALUE_SPECIAL_SIZE) && ··· 746 746 { 747 747 DataCell = HvGetCell(Hive, ValueCell->Data); 748 748 if (!DataCell) 749 - return ERROR_UNSUCCESSFUL; 749 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 750 750 751 751 DataCellSize = (ULONG)(-HvGetCellSize(Hive, DataCell)); 752 752 } ··· 781 781 if (NewOffset == HCELL_NIL) 782 782 { 783 783 DPRINT("HvAllocateCell() has failed!\n"); 784 - return ERROR_UNSUCCESSFUL; 784 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 785 785 } 786 786 787 787 if (DataCell) ··· 873 873 874 874 KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, ParentKey->KeyCellOffset); 875 875 if (!KeyNode) 876 - return ERROR_UNSUCCESSFUL; 876 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 877 877 878 878 ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); 879 879 ··· 881 881 RtlInitUnicodeString(&ValueNameString, lpValueName); 882 882 CellIndex = CmpFindValueByName(Hive, KeyNode, &ValueNameString); 883 883 if (CellIndex == HCELL_NIL) 884 - return ERROR_FILE_NOT_FOUND; 884 + return ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; 885 885 886 886 /* Get the value cell */ 887 887 ValueCell = HvGetCell(Hive, CellIndex); ··· 899 899 IN HKEY hKey, 900 900 IN LPCWSTR lpValueName OPTIONAL) 901 901 { 902 + LONG rc; 903 + NTSTATUS Status; 902 904 PMEMKEY Key = HKEY_TO_MEMKEY(hKey); // ParentKey 903 905 PHHIVE Hive = &Key->RegistryHive->Hive; 904 906 PCM_KEY_NODE KeyNode; // ParentNode ··· 907 909 ULONG ChildIndex; 908 910 UNICODE_STRING ValueNameString; 909 911 910 - NTSTATUS Status; 911 - 912 912 KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Key->KeyCellOffset); 913 913 if (!KeyNode) 914 - return ERROR_UNSUCCESSFUL; 914 + return ERROR_GEN_FAILURE; // STATUS_UNSUCCESSFUL; 915 915 916 916 ASSERT(KeyNode->Signature == CM_KEY_NODE_SIGNATURE); 917 917 ··· 928 928 } 929 929 if (CellIndex == HCELL_NIL) 930 930 { 931 - Status = ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; 931 + rc = ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; 932 932 goto Quit; 933 933 } 934 934 ··· 945 945 if (!CmpMarkValueDataDirty(Hive, ValueCell)) 946 946 { 947 947 /* Not enough log space, fail */ 948 - Status = STATUS_NO_LOG_SPACE; 948 + rc = ERROR_NO_LOG_SPACE; // STATUS_NO_LOG_SPACE; 949 949 goto Quit; 950 950 } 951 951 ··· 958 958 if (!NT_SUCCESS(Status)) 959 959 { 960 960 /* Set known error */ 961 - Status = STATUS_INSUFFICIENT_RESOURCES; 961 + rc = ERROR_NO_SYSTEM_RESOURCES; // STATUS_INSUFFICIENT_RESOURCES; 962 962 goto Quit; 963 963 } 964 964 ··· 966 966 if (!CmpFreeValue(Hive, CellIndex)) 967 967 { 968 968 /* Failed to free the value, fail */ 969 - Status = STATUS_INSUFFICIENT_RESOURCES; 969 + rc = ERROR_NO_SYSTEM_RESOURCES; // STATUS_INSUFFICIENT_RESOURCES; 970 970 goto Quit; 971 971 } 972 972 ··· 985 985 } 986 986 987 987 /* Change default Status to success */ 988 - Status = STATUS_SUCCESS; 988 + rc = ERROR_SUCCESS; 989 989 990 990 Quit: 991 991 /* Check if we had a value */ ··· 1000 1000 if (KeyNode) 1001 1001 HvReleaseCell(Hive, Key->KeyCellOffset); 1002 1002 1003 - return Status; 1003 + return rc; 1004 1004 } 1005 1005 1006 1006
+8 -4
sdk/tools/mkhive/registry.h
··· 20 20 extern HIVE_LIST_ENTRY RegistryHives[]; 21 21 22 22 #define ERROR_SUCCESS 0L 23 - #define ERROR_UNSUCCESSFUL 1L 23 + #define ERROR_INVALID_FUNCTION 1L 24 24 #define ERROR_FILE_NOT_FOUND 2L 25 - #define ERROR_OUTOFMEMORY 14L 25 + #define ERROR_ACCESS_DENIED 5L 26 + #define ERROR_NOT_ENOUGH_MEMORY 8L 27 + #define ERROR_GEN_FAILURE 31L 26 28 #define ERROR_INVALID_PARAMETER 87L 27 - #define ERROR_MORE_DATA 234L 28 - #define ERROR_NO_MORE_ITEMS 259L 29 + // #define ERROR_MORE_DATA 234L 30 + // #define ERROR_NO_MORE_ITEMS 259L 31 + #define ERROR_NO_LOG_SPACE 1019L 32 + #define ERROR_NO_SYSTEM_RESOURCES 1450L 29 33 30 34 #define REG_NONE 0 31 35 #define REG_SZ 1