Changeset 3678 for trunk/src


Ignore:
Timestamp:
Jun 8, 2000, 8:08:58 PM (25 years ago)
Author:
sandervl
Message:

RegQueryValueW, OpenFile and LoadLibrary fixes

Location:
trunk/src/kernel32
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/HandleManager.cpp

    r3642 r3678  
    1 /* $Id: HandleManager.cpp,v 1.40 2000-06-01 11:28:42 sandervl Exp $ */
     1/* $Id: HandleManager.cpp,v 1.41 2000-06-08 18:08:54 sandervl Exp $ */
    22
    33/*
     
    10161016  {
    10171017        TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
    1018         SetLastError(rc);          /* Hehe, OS/2 and NT are pretty compatible :) */
     1018        SetLastError(pOFStruct->nErrCode);
    10191019        return (INVALID_HANDLE_VALUE);                           /* signal error */
    10201020  }
  • trunk/src/kernel32/hmfile.cpp

    r3642 r3678  
    1 /* $Id: hmfile.cpp,v 1.1 2000-06-01 11:28:46 sandervl Exp $ */
     1/* $Id: hmfile.cpp,v 1.2 2000-06-08 18:08:56 sandervl Exp $ */
    22
    33/*
     
    137137  SetLastError(ERROR_SUCCESS);
    138138
    139   dprintf(("KERNEL32: HMDeviceFileClass::OpenFile %s(%s,%08x,%08x,%08x) - stub?\n",
     139  dprintf(("KERNEL32: HMDeviceFileClass::OpenFile %s(%s,%08x,%08x,%08x)",
    140140           lpHMDeviceName,
    141141           lpFileName,
     
    165165
    166166        if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0
    167            && !(fuMode & OF_CREATE) ) {
     167           && !(fuMode & OF_CREATE) )
     168        {
     169                pOFStruct->nErrCode = ERROR_FILE_NOT_FOUND;
    168170                SetLastError(ERROR_FILE_NOT_FOUND);
    169171                return HFILE_ERROR;
  • trunk/src/kernel32/registry.cpp

    r2984 r3678  
    1 /* $Id: registry.cpp,v 1.1 2000-03-03 11:15:59 sandervl Exp $ */
     1/* $Id: registry.cpp,v 1.2 2000-06-08 18:08:56 sandervl Exp $ */
    22
    33/*
     
    3030#include "unicode.h"
    3131#include <winreg.h>
     32
     33#define DBG_LOCALLOG    DBG_registry
     34#include "dbglocal.h"
    3235
    3336
     
    789792
    790793ODINFUNCTION4(LONG,RegQueryValueW,HKEY,   hkey,
    791                                    LPCWSTR,lpszSubKey,
    792                                    LPWSTR, lpszValue,
    793                                    PLONG,  pcbValue)
     794                                  LPCWSTR,lpszSubKey,
     795                                  LPWSTR, lpszValue,
     796                                  PLONG,  pcbValue)
    794797{
    795798  char *astring1 = UnicodeToAsciiString((LPWSTR)lpszSubKey);
     
    803806  if(rc == ERROR_SUCCESS)
    804807  {
    805     astring2 = (char *)malloc(*pcbValue);
    806     strcpy(astring2, (char *)lpszValue);
    807     AsciiToUnicode(astring2, lpszValue);
    808     free(astring2);
     808        if(pcbValue) {
     809                astring2 = (char *)malloc(*pcbValue);
     810                strcpy(astring2, (char *)lpszValue);
     811                AsciiToUnicode(astring2, lpszValue);
     812                free(astring2);
     813        }
    809814  }
     815  FreeAsciiString(astring1);
    810816  return(rc);
    811817}
     
    918924
    919925ODINFUNCTION5(LONG,RegSetValueW,HKEY,   hkey,
    920                                  LPCWSTR,lpSubKey,
    921                                  DWORD,  dwType,
    922                                  LPCWSTR,lpData,
    923                                  DWORD,  cbData)
     926                                LPCWSTR,lpSubKey,
     927                                DWORD,  dwType,
     928                                LPCWSTR,lpData,
     929                                DWORD,  cbData)
    924930{
    925931  char *astring1 = UnicodeToAsciiString((LPWSTR)lpSubKey);
     
    956962
    957963ODINFUNCTION6(LONG,RegSetValueExA,HKEY,  arg1,
    958                                    LPSTR, arg2,
    959                                    DWORD, arg3,
    960                                    DWORD, arg4,
    961                                    BYTE*, arg5,
    962                                    DWORD, arg6)
     964                                  LPSTR, arg2,
     965                                  DWORD, arg3,
     966                                  DWORD, arg4,
     967                                  BYTE*, arg5,
     968                                  DWORD, arg6)
    963969{
    964970  return _O32_RegSetValueEx(ConvertKey(arg1),
  • trunk/src/kernel32/winimagebase.cpp

    r3625 r3678  
    1 /* $Id: winimagebase.cpp,v 1.21 2000-05-28 16:45:12 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.22 2000-06-08 18:08:56 sandervl Exp $ */
    22
    33/*
     
    3737#include "directory.h"
    3838#include <win\virtual.h>
     39#include <winconst.h>
    3940
    4041#define DBG_LOCALLOG    DBG_winimagebase
     
    200201}
    201202//******************************************************************************
    202 //******************************************************************************
    203 BOOL Win32ImageBase::isPEImage(char *szFileName)
     203//returns ERROR_SUCCESS or error code
     204//******************************************************************************
     205ULONG Win32ImageBase::isPEImage(char *szFileName)
    204206{
    205207 char   filename[CCHMAXPATH];
     
    219221        dprintf(("KERNEL32:Win32ImageBase::isPEImage(%s) findDll failed to find the file.\n",
    220222                 szFileName, rc));
    221         return FALSE;
     223        return ERROR_FILE_NOT_FOUND_W;
    222224  }
    223225  rc = DosOpen(filename,                       /* File path name */
     
    237239        dprintf(("KERNEL32:Win32ImageBase::isPEImage(%s) failed with %u\n",
    238240                  szFileName, rc));
    239         return(FALSE);
     241        return ERROR_FILE_NOT_FOUND_W;
    240242  }
    241243
     
    246248  if(pdoshdr == NULL)   {
    247249        DosClose(win32handle);                /* Close the file */
    248         return(FALSE);
     250        return ERROR_INVALID_EXE_SIGNATURE_W;
    249251  }
    250252  rc = DosRead(win32handle, pdoshdr, sizeof(IMAGE_DOS_HEADER), &ulRead);
    251253  if(rc != NO_ERROR) {
    252254        DosClose(win32handle);                /* Close the file */
    253         return(FALSE);
     255        return ERROR_INVALID_EXE_SIGNATURE_W;
    254256  }
    255257  ULONG hdrsize = pdoshdr->e_lfanew + SIZE_OF_NT_SIGNATURE + sizeof(IMAGE_FILE_HEADER);
     
    262264  if(win32file == NULL) {
    263265        DosClose(win32handle);                /* Close the file */
    264         return(FALSE);
     266        return ERROR_NOT_ENOUGH_MEMORY_W;
    265267  }
    266268  rc = DosRead(win32handle, win32file, hdrsize, &ulRead);
     
    284286  }
    285287  DosClose(win32handle);
    286   return(TRUE);
     288  return ERROR_SUCCESS_W;
    287289
    288290failure:
    289291  free(win32file);
    290292  DosClose(win32handle);
    291   return(FALSE);
     293  return ERROR_INVALID_EXE_SIGNATURE_W;
    292294}
    293295//******************************************************************************
  • trunk/src/kernel32/winimagebase.h

    r3625 r3678  
    1 /* $Id: winimagebase.h,v 1.10 2000-05-28 16:45:12 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.11 2000-06-08 18:08:57 sandervl Exp $ */
    22
    33/*
     
    8787        ULONG getResourceSize(HRSRC hResource);
    8888
    89 static  BOOL  isPEImage(char *szFileName);
     89        //returns ERROR_SUCCESS or error code
     90static  ULONG isPEImage(char *szFileName);
    9091static  BOOL  findDll(const char *pszFileName, char *pszFullName,
    9192                      int cchFullName, const char *pszAltPath = NULL);
  • trunk/src/kernel32/winimagepeldr.cpp

    r3642 r3678  
    1 /* $Id: winimagepeldr.cpp,v 1.46 2000-06-01 11:28:48 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.47 2000-06-08 18:08:57 sandervl Exp $ */
    22
    33/*
     
    13431343        Win32DllBase::renameDll(modname);
    13441344
    1345         if(isPEImage(modname) == FALSE)
     1345        if(isPEImage(modname) != ERROR_SUCCESS_W)
    13461346        {//LX image, so let OS/2 do all the work for us
    13471347                APIRET rc;
  • trunk/src/kernel32/wprocess.cpp

    r3588 r3678  
    1 /* $Id: wprocess.cpp,v 1.81 2000-05-22 19:08:01 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.82 2000-06-08 18:08:58 sandervl Exp $ */
    22
    33/*
     
    661661    BOOL            fPath;              /* Flags which is set if the    */
    662662                                        /* lpszLibFile contains a path. */
    663     BOOL            fPE;                /* isPEImage return value. */
     663    ULONG           fPE;                /* isPEImage return value. */
    664664
    665665    /** @sketch
     
    802802     */
    803803    fPE = Win32ImageBase::isPEImage(szModname);
    804     if (fPE)
     804    if(fPE == ERROR_SUCCESS)
    805805    {
    806806        Win32PeLdrDll * peldrDll;
     
    887887    else
    888888    {
    889         dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x) library were found (%s) but it's not loadable!",
    890                  lpszLibFile, hFile, dwFlags, szModname));
    891         SetLastError(ERROR_INVALID_EXE_SIGNATURE);
     889        dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x) library wasn't found (%s) or isn't loadable; err %x",
     890                 lpszLibFile, hFile, dwFlags, szModname, fPE));
     891        SetLastError(fPE);
    892892    }
    893893
     
    13701370        if(winimage == NULL)
    13711371        {
    1372      char modname[CCHMAXPATH];
     1372        char modname[CCHMAXPATH];
    13731373
    13741374        strcpy(modname, lpszModName);
     
    13761376        Win32DllBase::renameDll(modname);
    13771377
    1378         if(Win32ImageBase::isPEImage(modname) == FALSE)
    1379                 {
     1378        if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
     1379        {
    13801380         HINSTANCE hInstance;
    13811381
     
    14311431        Win32DllBase::renameDll(modname);
    14321432
    1433         if(Win32ImageBase::isPEImage(modname) == FALSE)
    1434                 {
     1433        if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
     1434        {
    14351435         HINSTANCE hInstance;
    14361436
Note: See TracChangeset for help on using the changeset viewer.