- Timestamp:
- Feb 19, 2001, 6:25:14 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/oslibdos.cpp
r5016 r5193 1 /* $Id: oslibdos.cpp,v 1.5 6 2001-01-23 11:59:45 sandervlExp $ */1 /* $Id: oslibdos.cpp,v 1.57 2001-02-19 17:25:14 bird Exp $ */ 2 2 /* 3 3 * Wrappers for OS/2 Dos* API … … 31 31 #include "oslibdos.h" 32 32 #include "dosqss.h" 33 #include "win32k.h" 33 34 34 35 #define DBG_LOCALLOG DBG_oslibdos … … 293 294 //NT returns addresses aligned at 64k, so we do too. 294 295 //****************************************************************************** 295 DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD size, DWORD flags) 296 { 297 LPVOID memaddr; 298 DWORD offset; 299 APIRET rc; 300 301 rc = DosAllocMem(&memaddr, size, PAG_READ | flAllocMem); 302 if(rc) { 296 DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD cb, DWORD flFlags) 297 { 298 PVOID pvMemAddr; 299 DWORD offset; 300 APIRET rc; 301 302 /* 303 * Let's try use the exteneded DosAllocMem API of Win32k.sys. 304 */ 305 if (libWin32kInstalled()) 306 { 307 rc = DosAllocMemEx(&pvMemAddr, cb, flFlags | flAllocMem | OBJ_ALIGN64K); 308 if (rc != ERROR_NOT_SUPPORTED) /* This call was stubbed until recently. */ 309 return rc; 310 } 311 312 /* 313 * If no or old Win32k fall back to old method. 314 */ 315 rc = DosAllocMem(&pvMemAddr, cb, PAG_READ | flAllocMem); 316 if (rc) 317 { 303 318 return rc; 304 } 305 DosEnterCritSec(); 306 DosFreeMem(memaddr); 307 offset = (DWORD)memaddr & 0xFFFF; 308 if(offset) { 309 DosAllocMem(&memaddr, 64*1024 - offset, PAG_READ | flAllocMem); 310 } 311 rc = DosAllocMem(lplpMemAddr, size, flags | flAllocMem); 312 DosExitCritSec(); 313 if((DWORD)*lplpMemAddr & 0xFFFF) {//still not at 64k boundary? 319 } 320 DosEnterCritSec(); 321 DosFreeMem(pvMemAddr); 322 offset = (DWORD)pvMemAddr & 0xFFFF; 323 if (offset) 324 { 325 DosAllocMem(&pvMemAddr, 64*1024 - offset, PAG_READ | flAllocMem); 326 } 327 rc = DosAllocMem(lplpMemAddr, cb, flFlags | flAllocMem); 328 DosExitCritSec(); 329 if ((DWORD)*lplpMemAddr & 0xFFFF) 330 { //still not at 64k boundary? 314 331 DosFreeMem(*lplpMemAddr); 315 rc = OSLibDosAllocMem(lplpMemAddr, size, flags); 316 } 317 if(offset) { 318 DosFreeMem(memaddr); 319 } 320 321 return rc; 332 rc = OSLibDosAllocMem(lplpMemAddr, cb, flFlags); 333 } 334 if (offset) 335 { 336 DosFreeMem(pvMemAddr); 337 } 338 339 340 return rc; 322 341 } 323 342 //****************************************************************************** … … 591 610 dosTime = *(USHORT*)pTime; 592 611 dosDate = *(USHORT*)pDate; 593 612 594 613 // PH: probably replace with faster implementation than calling Open32 595 614 // through the external interface! … … 1700 1719 return; 1701 1720 } 1702 1721 1703 1722 if (longName[1] == '.' && longName[2] == 0) // ".." 1704 1723 { … … 1716 1735 return; 1717 1736 } 1718 1737 1719 1738 INT x; 1720 1739 CHAR *source = longName; … … 1723 1742 // the filename. 1724 1743 BOOL flag83 = TRUE; 1725 1744 1726 1745 // verify forbidden characters 1727 for (x = 0; 1728 (x < 8) && 1746 for (x = 0; 1747 (x < 8) && 1729 1748 (flag83 == TRUE); 1730 1749 x++) … … 1735 1754 x=1000; 1736 1755 break; 1737 1756 1738 1757 case '/': case '?': 1739 1758 case '*': case ':': … … 1747 1766 } 1748 1767 } 1749 1768 1750 1769 // verify we're on a period now 1751 1770 if (flag83 == TRUE) … … 1753 1772 flag83 = FALSE; 1754 1773 else source++; 1755 1774 1756 1775 // verify extension 1757 1776 if (flag83 == TRUE) … … 1771 1790 source++; 1772 1791 } 1773 1792 1774 1793 // verify we're at the end of the string now 1775 1794 if (flag83 == TRUE) 1776 1795 if (*source != 0) 1777 1796 flag83 = FALSE; 1778 1797 1779 1798 // OK, done 1780 1799 if (flag83 == TRUE) … … 1784 1803 // would surely fail. 1785 1804 strcpy(shortName, longName); 1786 1805 1787 1806 return; // Done 1788 1807 } 1789 1790 1808 1809 1791 1810 // @@@PH 1792 1811 shortName[0] = 0; // this function is disabled anyway ... 1793 1812 return; 1794 1813 1795 1814 CHAR *dest = shortName; 1796 1815 CHAR *ext = strrchr(longName,'.'); 1797 1816 1798 1817 //CB: quick and dirty, real FILE~12.EXT is too slow 1799 1818 //PH: We'd have to count the number of non-8:3-compliant files … … 1859 1878 name++; 1860 1879 strcpy(pFind->cFileName,name); 1861 } 1862 else 1880 } 1881 else 1863 1882 pFind->cFileName[0] = 0; 1864 1883 1865 1884 long2ShortName(pFind->cFileName,pFind->cAlternateFileName); 1866 1885 } … … 1922 1941 DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION); 1923 1942 1924 if(rc) 1943 if(rc) 1925 1944 { 1926 1945 DosFindClose(hDir);
Note:
See TracChangeset
for help on using the changeset viewer.