Changeset 4510 for trunk/src/kernel32/registry.cpp
- Timestamp:
- Oct 21, 2000, 4:30:47 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/registry.cpp
r4496 r4510 1 /* $Id: registry.cpp,v 1. 5 2000-10-18 17:09:33sandervl Exp $ */1 /* $Id: registry.cpp,v 1.6 2000-10-21 14:30:47 sandervl Exp $ */ 2 2 3 3 /* … … 30 30 #include "unicode.h" 31 31 #include <winreg.h> 32 33 #define DBG_LOCALLOG DBG_registry 32 #include <heapstring.h> 33 34 #define DBG_LOCALLOG DBG_registry 34 35 #include "dbglocal.h" 35 36 … … 644 645 LONG rc; 645 646 646 rc = CALL_ODINFUNC(RegOpenKeyExA)( ConvertKey(arg1),647 rc = CALL_ODINFUNC(RegOpenKeyExA)(arg1, 647 648 astring, 648 649 arg3, … … 741 742 if(rc == ERROR_SUCCESS) 742 743 { 743 744 745 746 747 748 749 else*arg2 = 0;744 if(*arg3) { 745 astring = (char *)malloc(*arg3); 746 strcpy(astring, (char *)arg2); 747 AsciiToUnicode(astring, arg2); 748 free(astring); 749 } 750 else *arg2 = 0; 750 751 } 751 752 return(rc); … … 800 801 LONG rc; 801 802 802 rc = CALL_ODINFUNC(RegQueryValueA)( ConvertKey(hkey),803 rc = CALL_ODINFUNC(RegQueryValueA)(hkey, 803 804 astring1, 804 805 (char *)lpszValue, … … 806 807 if(rc == ERROR_SUCCESS) 807 808 { 808 809 810 811 812 813 809 if(pcbValue) { 810 astring2 = (char *)malloc(*pcbValue); 811 strcpy(astring2, (char *)lpszValue); 812 AsciiToUnicode(astring2, lpszValue); 813 free(astring2); 814 } 814 815 } 815 816 FreeAsciiString(astring1); … … 830 831 *****************************************************************************/ 831 832 832 ODINFUNCTION6(LONG,RegQueryValueExA,HKEY, arg1,833 LPSTR, arg2,834 LPDWORD, arg3,835 LPDWORD, arg4,836 LPBYTE, arg5,837 LPDWORD, arg6)838 { 839 dprintf(("ADVAPI32:Registry key=%s", arg2));840 841 return O32_RegQueryValueEx(ConvertKey( arg1),842 arg2,843 arg3,844 arg4,845 arg5,846 arg6);833 ODINFUNCTION6(LONG,RegQueryValueExA,HKEY, hkey, 834 LPSTR, lpszValueName, 835 LPDWORD,lpdwType, 836 LPDWORD,lpdwReserved, 837 LPBYTE, lpbData, 838 LPDWORD,lpcbData) 839 { 840 dprintf(("ADVAPI32:Registry key=%s", lpszValueName)); 841 842 return O32_RegQueryValueEx(ConvertKey(hkey), 843 lpszValueName, 844 lpdwType, 845 lpdwReserved, 846 lpbData, 847 lpcbData); 847 848 } 848 849 … … 860 861 *****************************************************************************/ 861 862 862 ODINFUNCTION6(LONG,RegQueryValueExW,HKEY, arg1, 863 LPWSTR, arg2, 864 LPDWORD,arg3, 865 LPDWORD,arg4, 866 LPBYTE, arg5, 867 LPDWORD,arg6) 868 { 869 char *astring = UnicodeToAsciiString(arg2); 863 ODINFUNCTION6(LONG,RegQueryValueExW,HKEY, hkey, 864 LPWSTR, lpszValueName, 865 LPDWORD,lpdwType, 866 LPDWORD,lpdwReserved, 867 LPBYTE, lpbData, 868 LPDWORD,lpcbData) 869 { 870 char *astring = UnicodeToAsciiString(lpszValueName); 871 char *akeydata = NULL; 870 872 LONG rc; 871 873 872 rc = CALL_ODINFUNC(RegQueryValueExA)(ConvertKey(arg1), 874 if(lpbData && lpcbData) 875 { 876 akeydata = (char *)malloc(*lpcbData+1); 877 akeydata[*lpcbData] = 0; 878 } 879 880 rc = CALL_ODINFUNC(RegQueryValueExA)(hkey, 873 881 astring, 874 arg3, 875 arg4, 876 arg5, 877 arg6); 882 lpdwType, 883 lpdwReserved, 884 (LPBYTE)akeydata, 885 lpcbData); 886 //could also query key type (without returning data), call it again and only allocate translation 887 //buffer if string type 888 if(rc == ERROR_SUCCESS && lpbData && lpcbData) 889 { 890 if(lpdwType == NULL) {//NULL apparently means REG_SZ 891 lstrcpyAtoW((LPWSTR)lpcbData, akeydata); 892 } 893 else { 894 switch(*lpdwType) { 895 case REG_SZ: 896 case REG_EXPAND_SZ: 897 lstrcpyAtoW((LPWSTR)lpcbData, akeydata); 898 break; 899 case REG_MULTI_SZ: 900 case REG_LINK: //??? 901 dprintf(("ERROR: key data must be translated from Unicode to Ascii!!")); 902 break; 903 default: 904 memcpy(lpbData, akeydata, *lpcbData); 905 break; 906 } 907 } 908 } 878 909 FreeAsciiString(astring); 910 if(akeydata) { 911 free(akeydata); 912 } 879 913 return(rc); 880 914 } … … 910 944 lpData, 911 945 cbData); 912 if(rc == ERROR_NOT_ENOUGH_MEMORY && cbData == 0 && dwType == REG_SZ) 946 if(rc == ERROR_NOT_ENOUGH_MEMORY && cbData == 0 && dwType == REG_SZ) 913 947 { 914 948 char regdata = 0; 915 916 949 //SvL: Netscape sets an empty string key this way; Open32 doesn't like it 950 rc = O32_RegSetValue(ConvertKey(hkey), 917 951 lpSubKey, 918 952 dwType, … … 946 980 LONG rc; 947 981 948 //SvL: 8-11-'97: Bugfix: crash in pmwinx if size == 0 and string is large 949 if(cbData == 0) 950 cbData = strlen(astring2); 951 952 rc = O32_RegSetValue(ConvertKey(hkey), 953 astring1, 954 dwType, 955 astring2, 956 cbData); 982 rc = CALL_ODINFUNC(RegSetValueA)(hkey, 983 astring1, 984 dwType, 985 astring2, 986 cbData); 957 987 958 988 FreeAsciiString(astring1); … … 974 1004 *****************************************************************************/ 975 1005 976 ODINFUNCTION6(LONG,RegSetValueExA,HKEY, arg1, 977 LPSTR, arg2, 978 DWORD, arg3, 979 DWORD, arg4, 980 BYTE*, arg5, 981 DWORD, arg6) 982 { 983 return O32_RegSetValueEx(ConvertKey(arg1), 984 arg2, 985 arg3, 986 arg4, 987 arg5, 988 arg6); 1006 ODINFUNCTION6(LONG,RegSetValueExA,HKEY, hkey, 1007 LPSTR, lpszValueName, 1008 DWORD, dwReserved, 1009 DWORD, fdwType, 1010 BYTE*, lpbData, 1011 DWORD, cbData) 1012 { 1013 if(fdwType == REG_SZ) { 1014 dprintf(("ADVAPI32: RegSetValueExA)%08xh,%s,%08xh,%08xh,%s,%08xh)", 1015 hkey, 1016 lpszValueName, 1017 dwReserved, 1018 fdwType, 1019 lpbData, 1020 cbData)); 1021 } 1022 else { 1023 dprintf(("ADVAPI32: RegSetValueExA)%08xh,%s,%08xh,%08xh,%08xh,%08xh)", 1024 hkey, 1025 lpszValueName, 1026 dwReserved, 1027 fdwType, 1028 lpbData, 1029 cbData)); 1030 } 1031 1032 return O32_RegSetValueEx(ConvertKey(hkey), 1033 lpszValueName, 1034 dwReserved, 1035 fdwType, 1036 lpbData, 1037 cbData); 989 1038 } 990 1039 … … 1002 1051 *****************************************************************************/ 1003 1052 1004 ODINFUNCTION6(LONG,RegSetValueExW,HKEY, arg1, 1005 LPWSTR,arg2, 1006 DWORD, arg3, 1007 DWORD, arg4, 1008 BYTE*, arg5, 1009 DWORD, arg6) 1010 { 1011 char *astring = UnicodeToAsciiString(arg2); 1053 ODINFUNCTION6(LONG,RegSetValueExW,HKEY, hkey, 1054 LPWSTR,lpszValueName, 1055 DWORD, dwReserved, 1056 DWORD, fdwType, 1057 BYTE*, lpbData, 1058 DWORD, cbData) 1059 { 1060 char *astring = UnicodeToAsciiString(lpszValueName); 1061 char *akeydata = NULL; 1012 1062 LONG rc; 1013 1063 1014 dprintf(("ADVAPI32: RegSetValueExW(%08xh,%s,%08xh,%08xh,%08xh,%08xh)\n", 1015 arg1, 1016 astring, 1017 arg3, 1018 arg4, 1019 arg5, 1020 arg6)); 1021 1022 rc = O32_RegSetValueEx(ConvertKey(arg1), 1023 astring, 1024 arg3, 1025 arg4, 1026 arg5, 1027 arg6); 1064 switch(fdwType) { 1065 case REG_SZ: 1066 case REG_EXPAND_SZ: 1067 akeydata = UnicodeToAsciiString((LPWSTR)lpbData); 1068 lpbData = (BYTE *)akeydata; 1069 break; 1070 case REG_MULTI_SZ: 1071 case REG_LINK: //??? 1072 dprintf(("ERROR: key data must be translated from Unicode to Ascii!!")); 1073 break; 1074 } 1075 rc = CALL_ODINFUNC(RegSetValueExA)(hkey, 1076 astring, 1077 dwReserved, 1078 fdwType, 1079 lpbData, 1080 cbData); 1081 if(akeydata) 1082 FreeAsciiString(akeydata); 1083 1028 1084 FreeAsciiString(astring); 1029 1085 return(rc);
Note:
See TracChangeset
for help on using the changeset viewer.