Ignore:
Timestamp:
Jan 19, 2011, 10:56:46 PM (15 years ago)
Author:
dmik
Message:

kernel32: Implemented generating the high/low index values (using a CRC32 and a hash function on the fuill file name) and filling up the volume serial number in the BY_HANDLE_FILE_INFORMATION structure returned by GetFileInformationByHandle().

File:
1 edited

Legend:

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

    r21329 r21564  
    4242static void ParsePath(LPCSTR lpszFileName, LPSTR lpszParsedFileName, DWORD length);
    4343
     44
     45class HMFileInfo
     46{
     47public:
     48  HMFileInfo(HANDLE hFile, LPSTR lpszFileName, PVOID lpSecurityAttributes);
     49 ~HMFileInfo();
     50
     51  char *lpszFileName;
     52  PVOID lpSecurityAttributes;
     53  DWORD dwLXOffset;
     54};
     55
     56
    4457/*****************************************************************************
    4558 * Name      : DWORD HMDeviceFileClass::CreateFile
     
    5265 * Variables :
    5366 * Result    :
    54  * Remark    : 
     67 * Remark    :
    5568 * Status    : NO_ERROR - API succeeded
    5669 *             other    - what is to be set in SetLastError
     
    7487           lpSecurityAttributes,
    7588           pHMHandleDataTemplate));
    76  
     89
    7790  ParsePath(lpFileName, filepath, sizeof(filepath));
    7891
     
    120133 * Remark    : TODO: Check if this implementation is complete and 100% correct
    121134 *                           UTC Time or Localtime ?
    122  *                   GetFileTime is changed, Returns UTC-time yet !!!!! 
     135 *                   GetFileTime is changed, Returns UTC-time yet !!!!!
    123136 * Status    : NO_ERROR - API succeeded
    124137 *             other    - what is to be set in SetLastError
     
    187200        #if 1 /* Canonicalize the path should be the right thing to do I think... */
    188201        GetFullPathNameA(lpFileName, sizeof(filepath), filepath, NULL);
    189         #else                       
     202        #else
    190203        ParsePath(lpFileName, filepath, sizeof(filepath));
    191204        #endif
     
    201214    strncpy((char *)pOFStruct->szPathName, lpFileName, OFS_MAXPATHNAME);
    202215    pOFStruct->szPathName[OFS_MAXPATHNAME-1] = 0;
    203    
    204 
    205     /* 
     216
     217
     218    /*
    206219     * Do the parse stuff now and do a quick exit.
    207      * Based on testcase (5) and MSDN: 
     220     * Based on testcase (5) and MSDN:
    208221     *      "OF_PARSE   Fills the OFSTRUCT structure but carries out no other action."
    209222     */
     
    217230        return NO_ERROR;
    218231    }
    219    
     232
    220233
    221234    hFile = OSLibDosOpenFile((LPSTR)lpFileName, fuMode);
    222    
     235
    223236    if(hFile != INVALID_HANDLE_ERROR)
    224237    {
     
    229242                    NULL,
    230243                    &filetime );
    231    
    232         /* UTC Time or Localtime ? GetFileTime Returns UTC-time yet ? !!!!! */ 
     244
     245        /* UTC Time or Localtime ? GetFileTime Returns UTC-time yet ? !!!!! */
    233246        FileTimeToDosDateTime(&filetime,
    234247                              &filedatetime[0],
    235248                              &filedatetime[1] );
    236249        memcpy(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved));
    237    
     250
    238251        if(fuMode & OF_DELETE)
    239252        {
     
    247260            hFile = HFILE_ERROR;
    248261        }
    249    
     262
    250263        if((fuMode & OF_VERIFY))
    251264        {//TODO: what's this?? we copy the time above...
     
    257270            hFile = HFILE_ERROR;
    258271        }
    259    
     272
    260273        pOFStruct->nErrCode = GetLastError();
    261274        pHMHandleData->hHMHandle = hFile;
    262    
     275
    263276        if(hFile != HFILE_ERROR) {
    264277            pHMHandleData->dwUserData = (DWORD) new HMFileInfo(hFile, (LPSTR)lpFileName, NULL);
     
    268281    else {
    269282        DWORD rc = GetLastError();
    270    
     283
    271284        if(fuMode & OF_EXIST)
    272285        {
     
    393406 * Result    : TRUE / FALSE
    394407 * Remark    :
    395  * Status    : 
     408 * Status    :
    396409 *
    397410 * Author    : SvL
     
    617630       if((nNumberOfBytesToWrite+offset) & 0xfff)
    618631           nrpages++;
    619  
     632
    620633       map->commitRange((ULONG)lpBuffer, offset & ~0xfff, FALSE, nrpages);
    621634       map->Release();
     
    697710              lpHMDeviceName, pHMHandleData, pHFI));
    698711
    699     if(OSLibDosGetFileInformationByHandle(pHMHandleData->hHMHandle,
     712    HMFileInfo *fileInfo = (HMFileInfo *)pHMHandleData->dwUserData;
     713    if(OSLibDosGetFileInformationByHandle(fileInfo->lpszFileName,
     714                                          pHMHandleData->hHMHandle,
    700715                                          pHFI))
    701716    {
     
    853868  if(fileInfo && fileInfo->dwLXOffset)
    854869  {
    855       switch(dwMoveMethod) 
     870      switch(dwMoveMethod)
    856871      {
    857872      case FILE_BEGIN:
     
    11061121 * Variables :
    11071122 * Result    : BOOLEAN
    1108  * Remark    : 
     1123 * Remark    :
    11091124 * Status    :
    11101125 *
     
    11301145//
    11311146// When the application opens a file with CreateFile and 0 for desired access,
    1132 // then we need to create a handle with limited access. 
     1147// then we need to create a handle with limited access.
    11331148//
    11341149// MSDN:
    11351150//
    1136 // If this parameter is zero, the application can query file and device attributes 
    1137 // without accessing the device. This is useful if an application wants to determine 
     1151// If this parameter is zero, the application can query file and device attributes
     1152// without accessing the device. This is useful if an application wants to determine
    11381153// the size of a floppy disk drive and the formats it supports without requiring
    11391154// a floppy in the drive. It can also be used to test for the file's or directory's
     
    11531168 * Variables :
    11541169 * Result    :
    1155  * Remark    : 
     1170 * Remark    :
    11561171 * Status    : NO_ERROR - API succeeded
    11571172 *             other    - what is to be set in SetLastError
     
    11731188           lpSecurityAttributes,
    11741189           pHMHandleDataTemplate));
    1175  
     1190
    11761191  ParsePath(lpFileName, filepath, sizeof(filepath));
    11771192
     
    12421257  WIN32_FIND_DATAA finddata;
    12431258  HANDLE hFind;
    1244    
     1259
    12451260  hFind = FindFirstFileA(fileInfo->lpszFileName, &finddata);
    12461261  if(hFind == INVALID_HANDLE_VALUE) {
     
    12901305  WIN32_FIND_DATAA finddata;
    12911306  HANDLE hFind;
    1292    
     1307
    12931308  hFind = FindFirstFileA(fileInfo->lpszFileName, &finddata);
    12941309  if(hFind == INVALID_HANDLE_VALUE) {
     
    13001315  FindClose(hFind);
    13011316
    1302   if(fileInfo->dwLXOffset) 
     1317  if(fileInfo->dwLXOffset)
    13031318  {
    13041319      //subtract the LX header and magic qword from the file size
     
    13141329 * Variables :
    13151330 * Result    : BOOLEAN
    1316  * Remark    : 
     1331 * Remark    :
    13171332 * Status    :
    13181333 *
     
    13551370HMFileInfo::HMFileInfo(HANDLE hFile, LPSTR lpszFileName, PVOID lpSecurityAttributes)
    13561371{
     1372  // get the full path (this is necessary in particular for GetFileInformationByHandle)
     1373  char fullPath[260];
     1374  if (!OSLibDosQueryPathInfo(lpszFileName, FIL_QUERYFULLNAME, fullPath, sizeof(fullPath))) {
     1375      lpszFileName = fullPath;
     1376  }
     1377
    13571378  this->lpszFileName = (LPSTR)malloc(strlen(lpszFileName)+1);
    13581379  if(!this->lpszFileName) {
     
    13661387  //an LX header. We need to skip that to present the original file to the
    13671388  //caller
    1368   if(hFile && !stricmp(lpszFileName + strlen(lpszFileName) - 4, ".EXE")) 
     1389  if(hFile && !stricmp(lpszFileName + strlen(lpszFileName) - 4, ".EXE"))
    13691390  {
    13701391      ULONG action, ulRead, signature, ulFileSize;
     
    13851406
    13861407      //Make sure it's an LX executable before continueing
    1387       if(doshdr.e_magic != IMAGE_DOS_SIGNATURE || (WORD)signature != IMAGE_OS2_SIGNATURE_LX) 
     1408      if(doshdr.e_magic != IMAGE_DOS_SIGNATURE || (WORD)signature != IMAGE_OS2_SIGNATURE_LX)
    13881409      {
    13891410          goto failure;
Note: See TracChangeset for help on using the changeset viewer.