Ignore:
Timestamp:
Oct 21, 2000, 4:30:47 PM (25 years ago)
Author:
sandervl
Message:

registry api fixes + version keys added

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:33 sandervl Exp $ */
     1/* $Id: registry.cpp,v 1.6 2000-10-21 14:30:47 sandervl Exp $ */
    22
    33/*
     
    3030#include "unicode.h"
    3131#include <winreg.h>
    32 
    33 #define DBG_LOCALLOG    DBG_registry
     32#include <heapstring.h>
     33
     34#define DBG_LOCALLOG    DBG_registry
    3435#include "dbglocal.h"
    3536
     
    644645  LONG  rc;
    645646
    646   rc = CALL_ODINFUNC(RegOpenKeyExA)(ConvertKey(arg1),
     647  rc = CALL_ODINFUNC(RegOpenKeyExA)(arg1,
    647648                                    astring,
    648649                                    arg3,
     
    741742  if(rc == ERROR_SUCCESS)
    742743  {
    743         if(*arg3) {
    744                 astring = (char *)malloc(*arg3);
    745                 strcpy(astring, (char *)arg2);
    746                 AsciiToUnicode(astring, arg2);
    747                 free(astring);
    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;
    750751  }
    751752  return(rc);
     
    800801  LONG  rc;
    801802
    802   rc = CALL_ODINFUNC(RegQueryValueA)(ConvertKey(hkey),
     803  rc = CALL_ODINFUNC(RegQueryValueA)(hkey,
    803804                                     astring1,
    804805                                     (char *)lpszValue,
     
    806807  if(rc == ERROR_SUCCESS)
    807808  {
    808         if(pcbValue) {
    809                 astring2 = (char *)malloc(*pcbValue);
    810                 strcpy(astring2, (char *)lpszValue);
    811                 AsciiToUnicode(astring2, lpszValue);
    812                 free(astring2);
    813         }
     809    if(pcbValue) {
     810            astring2 = (char *)malloc(*pcbValue);
     811            strcpy(astring2, (char *)lpszValue);
     812            AsciiToUnicode(astring2, lpszValue);
     813            free(astring2);
     814    }
    814815  }
    815816  FreeAsciiString(astring1);
     
    830831 *****************************************************************************/
    831832
    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);
     833ODINFUNCTION6(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);
    847848}
    848849
     
    860861 *****************************************************************************/
    861862
    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);
     863ODINFUNCTION6(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;
    870872  LONG  rc;
    871873
    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,
    873881                                       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  }
    878909  FreeAsciiString(astring);
     910  if(akeydata) {
     911    free(akeydata);
     912  }
    879913  return(rc);
    880914}
     
    910944                         lpData,
    911945                         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)
    913947  {
    914948    char regdata = 0;
    915         //SvL: Netscape sets an empty string key this way; Open32 doesn't like it
    916         rc = O32_RegSetValue(ConvertKey(hkey),
     949    //SvL: Netscape sets an empty string key this way; Open32 doesn't like it
     950    rc = O32_RegSetValue(ConvertKey(hkey),
    917951                         lpSubKey,
    918952                         dwType,
     
    946980  LONG  rc;
    947981
    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);
    957987
    958988  FreeAsciiString(astring1);
     
    9741004 *****************************************************************************/
    9751005
    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);
     1006ODINFUNCTION6(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);
    9891038}
    9901039
     
    10021051 *****************************************************************************/
    10031052
    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);
     1053ODINFUNCTION6(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;
    10121062  LONG  rc;
    10131063
    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
    10281084  FreeAsciiString(astring);
    10291085  return(rc);
Note: See TracChangeset for help on using the changeset viewer.