Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

784 lines
20 KiB

  1. /* demfcb.c - SVC handlers for misc. FCB operations
  2. *
  3. * demCloseFCB
  4. * demCreateFCB
  5. * demDate16
  6. * demDeleteFCB
  7. * demFCBIO
  8. * demGetFileInfo
  9. * demOpenFCB
  10. * demRenameFCB
  11. *
  12. * Modification History:
  13. *
  14. * Sudeepb 09-Apr-1991 Created
  15. * Sudeepb 21-Nov-1991 Added FCB based IO functions
  16. * Jonle 30-Jun-1994 add wild card support for fcb rename
  17. */
  18. #include "dem.h"
  19. #include "demmsg.h"
  20. #include <softpc.h>
  21. #include <winbase.h>
  22. #include <mvdm.h>
  23. #include "dpmtbls.h"
  24. #define DOT '.'
  25. #define QMARK '?'
  26. /* demDeleteFCB - FCB based File Delete
  27. *
  28. *
  29. * Entry - Client (ES:DI) - Full File Path
  30. * Client (AL) - 0 if not extended FCB
  31. * Client (DL) - File Attr. to be deleted (valid only if Al !=0 )
  32. *
  33. * Exit
  34. * SUCCESS
  35. * Client (CF) = 0
  36. *
  37. * FAILURE
  38. * Client (CF) = 1
  39. * Client (AX) = system status code
  40. * HARD ERROR
  41. * Client (CF) = 1
  42. * Client (AX) = 0ffffh
  43. *
  44. * Notes: Following are the rules for FCB based delete:
  45. * 1. If normal FCB than dont allow delete on hidden,system files
  46. * 2. if extended FCB than search attributes should include hidden,
  47. * system or read-only if that kind of file is to be deleted.
  48. */
  49. VOID demDeleteFCB (VOID)
  50. {
  51. HANDLE hFind;
  52. LPSTR lpFileName;
  53. BYTE bClientAttr=0;
  54. BOOL fExtendedFCB=FALSE;
  55. WIN32_FIND_DATA wfBuffer;
  56. BOOL fSuccess = FALSE;
  57. DWORD dwAttr;
  58. USHORT uErr;
  59. CHAR szPath_buffer[_MAX_PATH];
  60. CHAR szDrive[_MAX_DRIVE];
  61. CHAR szDir[_MAX_DIR];
  62. CHAR szFname[_MAX_FNAME];
  63. CHAR szExt[_MAX_EXT];
  64. DWORD dwErrCode = 0, dwErrCodeKeep = 0;
  65. // Get the file name
  66. lpFileName = (LPSTR) GetVDMAddr (getES(),getDI());
  67. _splitpath( lpFileName, szDrive, szDir, szFname, szExt );
  68. // Check if handling extended FCB
  69. if(getAL() != 0){
  70. bClientAttr = getDL();
  71. /* Special case for delete volume label (INT 21 Func 13H, Attr = 8H */
  72. if((bClientAttr == ATTR_VOLUME_ID)) {
  73. if((uErr = demDeleteLabel(lpFileName[DRIVEBYTE]))) {
  74. setCF(1);
  75. setAX(uErr);
  76. return;
  77. }
  78. setAX(0);
  79. setCF(0);
  80. return;
  81. }
  82. bClientAttr &= (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM);
  83. fExtendedFCB = TRUE;
  84. }
  85. // Find the first instance of file
  86. if((hFind = FindFirstFileOem (lpFileName,&wfBuffer)) == (HANDLE)-1){
  87. demClientError(INVALID_HANDLE_VALUE, *lpFileName);
  88. return;
  89. }
  90. // loop for all files which match the name and attributes
  91. do {
  92. // Check if read_only,hidden or system file
  93. if((dwAttr= wfBuffer.dwFileAttributes & (FILE_ATTRIBUTE_READONLY |
  94. FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM))){
  95. // if so, try next file if normal FCB case. If extended fcb case
  96. // then check if right attributes are given by client.
  97. if(fExtendedFCB && ((dwAttr & (DWORD)bClientAttr) == dwAttr)){
  98. // Yes, right attributes are given. So if the file is read
  99. // only then change the modes to normal. Note NT will
  100. // delete hidden and system files anyway.
  101. if (dwAttr & FILE_ATTRIBUTE_READONLY){
  102. strcpy( szPath_buffer, szDrive);
  103. strcat( szPath_buffer, szDir);
  104. strncat( szPath_buffer, wfBuffer.cFileName,sizeof(szPath_buffer)-strlen(szPath_buffer));
  105. szPath_buffer[sizeof(szPath_buffer)-1] = 0;
  106. // if set attributes fail try next file
  107. if(SetFileAttributesOemSys (szPath_buffer,
  108. FILE_ATTRIBUTE_NORMAL, FALSE) == -1)
  109. continue;
  110. }
  111. }
  112. else {
  113. dwErrCodeKeep = ERROR_ACCESS_DENIED;
  114. continue;
  115. }
  116. }
  117. strcpy( szPath_buffer, szDrive);
  118. strcat( szPath_buffer, szDir);
  119. strncat( szPath_buffer, wfBuffer.cFileName,sizeof(szPath_buffer)-strlen(szPath_buffer));
  120. szPath_buffer[sizeof(szPath_buffer)-1] = 0;
  121. if(DeleteFileOem(szPath_buffer) == FALSE) {
  122. dwErrCode = GetLastError();
  123. SetLastError(dwErrCode);
  124. if (((dwErrCode >= ERROR_WRITE_PROTECT) &&
  125. (dwErrCode <= ERROR_GEN_FAILURE)) ||
  126. dwErrCode == ERROR_WRONG_DISK ) {
  127. demClientError(INVALID_HANDLE_VALUE, szPath_buffer[0]);
  128. return;
  129. }
  130. continue;
  131. }
  132. // We have deleted at least one file, so report success
  133. fSuccess = TRUE;
  134. } while (FindNextFileOem(hFind,&wfBuffer) == TRUE);
  135. if(DPM_FindClose(hFind) == FALSE)
  136. demPrintMsg (MSG_INVALID_HFIND);
  137. if (fSuccess == TRUE){
  138. setCF(0);
  139. return;
  140. }
  141. setCF(1);
  142. if(dwErrCodeKeep)
  143. setAX((SHORT) dwErrCodeKeep);
  144. else
  145. setAX(ERROR_FILE_NOT_FOUND);
  146. return;
  147. }
  148. /* demRenameFCB - FCB based Rename file
  149. *
  150. * Entry - Client (DS:SI) Sources file to be renamed
  151. * Client (ES:DI) Destination file to be renamed to
  152. *
  153. * Exit - SUCCESS
  154. * Client (CF) = 0
  155. *
  156. * FAILURE
  157. * Client(CF) = 1
  158. * Client(AX) = error code
  159. */
  160. VOID demRenameFCB (VOID)
  161. {
  162. LPSTR lpSrc,lpDst;
  163. DWORD dw;
  164. HANDLE hFind;
  165. PCHAR pNewDstFilePart;
  166. PCHAR pDstFilePart;
  167. PCHAR pCurrSrcFilePart;
  168. WIN32_FIND_DATA W32FindData;
  169. CHAR NewDst[MAX_PATH];
  170. CHAR CurrSrc[MAX_PATH];
  171. lpSrc = (LPSTR) GetVDMAddr (getDS(),getSI());
  172. lpDst = (LPSTR) GetVDMAddr (getES(),getDI());
  173. // Find the first instance of the source file
  174. hFind = FindFirstFileOem (lpSrc,&W32FindData);
  175. if (hFind == INVALID_HANDLE_VALUE) {
  176. dw = GetLastError();
  177. if (dw == ERROR_BAD_PATHNAME || dw == ERROR_DIRECTORY ) {
  178. SetLastError(ERROR_PATH_NOT_FOUND);
  179. }
  180. demClientError(INVALID_HANDLE_VALUE, *lpSrc);
  181. return;
  182. }
  183. //
  184. // Source string consists of the path taken from the original
  185. // source specified plus the filename part retrieved from the
  186. // FindFile call
  187. //
  188. strncpy(CurrSrc, lpSrc,sizeof(CurrSrc));
  189. CurrSrc[sizeof(CurrSrc)-1] = 0;
  190. pCurrSrcFilePart = strrchr(CurrSrc, '\\');
  191. pCurrSrcFilePart++;
  192. //
  193. // Destination string is template for meta character substitution
  194. //
  195. pDstFilePart = strrchr(lpDst, '\\');
  196. pDstFilePart++;
  197. //
  198. // NewDst string is constructed from template and the source string
  199. // when doing meta file character substitution.
  200. //
  201. strncpy(NewDst, lpDst, sizeof(NewDst));
  202. NewDst[sizeof(NewDst)-1] = 0;
  203. pNewDstFilePart = strrchr(NewDst, '\\');
  204. pNewDstFilePart++;
  205. do {
  206. PCHAR pNew;
  207. PCHAR pSrc;
  208. PCHAR pDst;
  209. strncpy(pCurrSrcFilePart,
  210. W32FindData.cAlternateFileName[0]
  211. ? W32FindData.cAlternateFileName
  212. : W32FindData.cFileName, //// ??? hpfs lfns ????
  213. sizeof(CurrSrc)+CurrSrc-pCurrSrcFilePart);
  214. CurrSrc[sizeof(CurrSrc)-1] = 0;
  215. pSrc = pCurrSrcFilePart; // source fname
  216. pNew = pNewDstFilePart; // dest fname to be constructed
  217. pDst = pDstFilePart; // raw dest fname template (with metas)
  218. while (*pDst) {
  219. //
  220. // If Found a '?' in Dest template, use character from src
  221. //
  222. if (*pDst == QMARK) {
  223. if (*pSrc != DOT && *pSrc)
  224. *pNew++ = *pSrc++;
  225. }
  226. //
  227. // if Found a DOT in Dest template, Align DOTS between Src\Dst
  228. //
  229. else if (*pDst == DOT) {
  230. while (*pSrc != DOT && *pSrc) { // mov src to one past DOT
  231. pSrc++;
  232. }
  233. if (*pSrc)
  234. pSrc++;
  235. *pNew++ = DOT;
  236. }
  237. //
  238. // Nothing special found, use character from Dest template
  239. //
  240. else {
  241. if (*pSrc != DOT && *pSrc)
  242. pSrc++;
  243. *pNew++ = *pDst;
  244. }
  245. pDst++;
  246. }
  247. *pNew = '\0';
  248. //
  249. // MoveFile does not return error if dst and src are the same,
  250. // but DOS does, so check first..
  251. //
  252. if (!_stricmp (CurrSrc, NewDst)) {
  253. setCF(1);
  254. setAX(0x5);
  255. DPM_FindClose(hFind);
  256. return;
  257. }
  258. if (!MoveFileOem(CurrSrc, NewDst)){
  259. demClientError(INVALID_HANDLE_VALUE, *lpSrc);
  260. DPM_FindClose(hFind);
  261. return;
  262. }
  263. } while (FindNextFileOem(hFind,&W32FindData));
  264. //
  265. // If the search on the source string for any reason besides
  266. // no more files, then its a genuine error.
  267. //
  268. dw = GetLastError();
  269. if (dw != ERROR_NO_MORE_FILES) {
  270. if (dw == ERROR_BAD_PATHNAME || dw == ERROR_DIRECTORY ) {
  271. SetLastError(ERROR_PATH_NOT_FOUND);
  272. }
  273. demClientError(INVALID_HANDLE_VALUE, *lpSrc);
  274. }
  275. else {
  276. setCF(0);
  277. }
  278. DPM_FindClose(hFind);
  279. return;
  280. }
  281. /* demCloseFCB - Close the NT handle associated with the FCB being closed.
  282. *
  283. * Entry - Client (AX:SI) DWORD NT handle
  284. *
  285. * Exit - SUCCESS
  286. * Client (CF) = 0
  287. *
  288. * FAILURE
  289. * Client(CF) = 1
  290. * Client(AX) = error code
  291. */
  292. VOID demCloseFCB (VOID)
  293. {
  294. HANDLE hFile;
  295. hFile = GETHANDLE (getAX(),getSI());
  296. if(hFile == 0) {
  297. setCF(0);
  298. return;
  299. }
  300. if (DPM_CloseHandle (hFile) == FALSE){
  301. demClientError(hFile, (CHAR)-1);
  302. return;
  303. }
  304. setCF(0);
  305. return;
  306. }
  307. /* demCreateFCB - An FCB is being created get the NT handle.
  308. *
  309. * Entry - Client (AL) Creation Mode
  310. * 00 - Normal File
  311. * 01 - Read-only file
  312. * 02 - Hidden File
  313. * 04 - System file
  314. * Client (DS:SI) Full path filename
  315. * Client (ES:DI) SFT address
  316. *
  317. * Exit - SUCCESS
  318. * Client (CF) = 0
  319. * Client (AX:BP) = NT Handle
  320. * Client (BX) = Time
  321. * Client (CX) = Date
  322. * Client (DX:SI) = Size
  323. *
  324. * FAILURE
  325. * Client(CF) = 1
  326. * Client(AX) = error code
  327. */
  328. VOID demCreateFCB (VOID)
  329. {
  330. demFCBCommon (CREATE_ALWAYS);
  331. return;
  332. }
  333. /* demDate16 - Get the current date/time in DOS FCB format.
  334. *
  335. * Entry - None
  336. *
  337. * Exit - Always Success
  338. * Client (AX) has date
  339. * Client (DX) has time
  340. * NOTES:
  341. *
  342. * DemDate16 returns the current date in AX, current time in DX in this format
  343. * AX - YYYYYYYMMMMDDDDD years months days
  344. * DX - HHHHHMMMMMMSSSSS hours minutes seconds/2
  345. */
  346. VOID demDate16 (VOID)
  347. {
  348. SYSTEMTIME TimeDate;
  349. GetLocalTime(&TimeDate);
  350. // date is stored in a packed word: ((year-1980)*512) + (month*32) + day
  351. setAX ( (USHORT) (((TimeDate.wYear-1980) << 9 ) |
  352. ((TimeDate.wMonth & 0xf) << 5 ) |
  353. (TimeDate.wDay & 0x1f))
  354. );
  355. setDX ( (USHORT) ((TimeDate.wHour << 11) |
  356. ((TimeDate.wMinute & 0x3f) << 5) |
  357. ((TimeDate.wSecond / 2) & 0x1f))
  358. );
  359. return;
  360. }
  361. /* demFCBIO - Carry out the FCB based IO operation.
  362. *
  363. * Entry - Client (BX) = 1 if read operation, 0 if write
  364. * Client (AX:BP) NT Handle
  365. * Client (DI:DX) offset to start the operation with
  366. * Client (CX) Count of bytes
  367. *
  368. * Exit - SUCCESS
  369. * Client (CF) = 0
  370. * Client (CX) = counts of bytes read/written
  371. * Client (AX:BX) = size
  372. *
  373. * FAILURE
  374. * Client(CF) = 1
  375. * Client(AX) = error code
  376. */
  377. VOID demFCBIO (VOID)
  378. {
  379. HANDLE hFile;
  380. ULONG CurOffset;
  381. PVOID pBuf;
  382. DWORD dwBytesIO=0;
  383. DWORD dwSize,dwSizeHigh;
  384. DWORD dwErrCode;
  385. hFile = GETHANDLE (getAX(),getBP());
  386. CurOffset = (((ULONG)getDI()) << 16) + (ULONG)getDX();
  387. if (DPM_SetFilePointer (hFile,
  388. (LONG)CurOffset,
  389. NULL,
  390. (DWORD)FILE_BEGIN) == -1L){
  391. demClientError(hFile, (CHAR)-1);
  392. return ;
  393. }
  394. pBuf = (PVOID)GetVDMAddr(*((PUSHORT)pulDTALocation + 1),
  395. *((PUSHORT)pulDTALocation));
  396. if(getBX()) { // Read Operation
  397. if (DPM_ReadFile (hFile,
  398. pBuf,
  399. (DWORD)getCX(),
  400. &dwBytesIO,
  401. NULL) == FALSE){
  402. Sim32FlushVDMPointer(*pulDTALocation, getCX(), pBuf, FALSE);
  403. Sim32FreeVDMPointer(*pulDTALocation, getCX(), pBuf, FALSE);
  404. demClientError(hFile, (CHAR)-1);
  405. return ;
  406. }
  407. Sim32FlushVDMPointer (*pulDTALocation, getCX(),pBuf, FALSE);
  408. Sim32FreeVDMPointer (*pulDTALocation, getCX(), pBuf, FALSE);
  409. }
  410. else {
  411. if (getCX() == 0) {
  412. //0 byte write, adjust file size
  413. if(!DPM_SetEndOfFile(hFile)) {
  414. dwErrCode = GetLastError();
  415. SetLastError(dwErrCode);
  416. demClientError(hFile,(CHAR)-1);
  417. return;
  418. }
  419. }
  420. else if (DPM_WriteFile (hFile,
  421. pBuf,
  422. (DWORD)getCX(),
  423. &dwBytesIO,
  424. NULL) == FALSE) {
  425. // If disk is full then we should return number of bytes written
  426. // AX = 1 and CF = 1
  427. dwErrCode = GetLastError();
  428. if(dwErrCode == ERROR_DISK_FULL) {
  429. setCX( (USHORT) dwBytesIO);
  430. setAX(1);
  431. setCF(1);
  432. return;
  433. }
  434. SetLastError(dwErrCode);
  435. demClientError(hFile, (CHAR)-1);
  436. return ;
  437. }
  438. }
  439. // Get File Size
  440. if((dwSize = DPM_GetFileSize(hFile,&dwSizeHigh)) == -1){
  441. demPrintMsg(MSG_FILEINFO);
  442. ASSERT(FALSE);
  443. demClientError(hFile, (CHAR)-1);
  444. return;
  445. }
  446. if(dwSizeHigh) {
  447. demPrintMsg(MSG_FILESIZE_TOOBIG);
  448. ASSERT(FALSE);
  449. demClientError(hFile, (CHAR)-1);
  450. return;
  451. }
  452. // Setup the exit registers
  453. setCX((USHORT)dwBytesIO);
  454. setBX((USHORT)dwSize);
  455. setAX((USHORT)(dwSize >> 16 ));
  456. setCF(0);
  457. return;
  458. }
  459. /* demGetFileInfo - Get Misc. file info in FCB format.
  460. *
  461. * Entry - Client (DS:SI) full path file name
  462. *
  463. * Exit - SUCCESS
  464. * Client (CF) = 0
  465. * Client (AX) = Attribute of file
  466. * Client (CX) = Time stamp of file
  467. * Client (DX = Date stamp of file
  468. * Client (BX:DI)= Size of file (32 bit)
  469. *
  470. * FAILURE
  471. * Client(CF) = 1
  472. * Client(AX) = error code
  473. */
  474. VOID demGetFileInfo (VOID)
  475. {
  476. HANDLE hFile;
  477. LPSTR lpFileName;
  478. WORD wDate,wTime;
  479. DWORD dwSize,dwAttr;
  480. lpFileName = (LPSTR) GetVDMAddr (getDS(),getSI());
  481. if ((hFile = CreateFileOem(lpFileName,
  482. GENERIC_READ,
  483. FILE_SHARE_READ,
  484. NULL,
  485. OPEN_EXISTING,
  486. 0,
  487. NULL)) == (HANDLE)-1){
  488. demClientError(INVALID_HANDLE_VALUE, *lpFileName);
  489. return;
  490. }
  491. // Get Misc. INfo
  492. if (demGetMiscInfo (hFile,&wTime, &wDate, &dwSize) == FALSE) {
  493. DPM_CloseHandle (hFile);
  494. return;
  495. }
  496. DPM_CloseHandle (hFile);
  497. if ((dwAttr = GetFileAttributesOemSys (lpFileName, FALSE)) == -1) {
  498. demClientError(INVALID_HANDLE_VALUE, *lpFileName);
  499. return;
  500. }
  501. if (dwAttr == FILE_ATTRIBUTE_NORMAL)
  502. dwAttr = 0;
  503. setAX((USHORT)dwAttr);
  504. setCX(wTime);
  505. setDX(wDate);
  506. setDI((USHORT)dwSize);
  507. setBX((USHORT)(dwSize >> 16));
  508. return;
  509. }
  510. /* demOpenFCB - An FCB is being opened get the NT handle.
  511. *
  512. * Entry - Client (AL) Open Mode
  513. * Client (DS:SI) Full path filename
  514. *
  515. * Exit - SUCCESS
  516. * Client (CF) = 0
  517. * Client (AX:BP) = NT Handle
  518. * Client (BX) = Time
  519. * Client (CX) = Date
  520. * Client (DX:SI) = Size
  521. *
  522. * FAILURE
  523. * Client(CF) = 1
  524. * Client(AX) = error code
  525. */
  526. VOID demOpenFCB (VOID)
  527. {
  528. demFCBCommon (OPEN_EXISTING);
  529. return;
  530. }
  531. /* demFCBCommon - FCB Open/Create.
  532. *
  533. * Entry - CreateDirective - Open/Create
  534. * Client (AL) Open Mode
  535. * Client (DS:SI) Full path filename
  536. *
  537. * Exit - SUCCESS
  538. * Client (CF) = 0
  539. * Client (AX:BP) = NT Handle
  540. * Client (BX) = Time
  541. * Client (CX) = Date
  542. * Client (DX:SI) = Size
  543. *
  544. * FAILURE
  545. * Client(CF) = 1
  546. * Client(AX) = error code
  547. */
  548. VOID demFCBCommon (ULONG CreateDirective)
  549. {
  550. HANDLE hFile;
  551. LPSTR lpFileName;
  552. UCHAR uchMode,uchAccess;
  553. DWORD dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
  554. DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
  555. WORD wDate,wTime;
  556. DWORD dwSize,dwAttr=0;
  557. USHORT uErr;
  558. SECURITY_ATTRIBUTES sa;
  559. lpFileName = (LPSTR) GetVDMAddr (getDS(),getSI());
  560. uchMode = getAL();
  561. /* Special case for delete volume label (INT 21 Func 13H, Attr = 8H */
  562. if((uchMode == ATTR_VOLUME_ID) && (CreateDirective == CREATE_ALWAYS)) {
  563. if((uErr = demCreateLabel(lpFileName[DRIVEBYTE],
  564. lpFileName+LABELOFF))) {
  565. setCF(1);
  566. setAX(uErr);
  567. return;
  568. }
  569. setAX(0);
  570. setBP(0);
  571. setCF(0);
  572. return;
  573. }
  574. // In create case AL has creation attributes. By default
  575. // Access is for read/write and sharing for both. In open
  576. // case AL has appropriate access and sharing information.
  577. if((CreateDirective == CREATE_ALWAYS) && ((uchMode &0xff) == 0)) {
  578. dwAttr = FILE_ATTRIBUTE_NORMAL;
  579. dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ;
  580. }
  581. else {
  582. uchAccess = uchMode & (UCHAR)ACCESS_MASK;
  583. if (uchAccess == OPEN_FOR_READ)
  584. dwDesiredAccess = GENERIC_READ;
  585. else if (uchAccess == OPEN_FOR_WRITE)
  586. dwDesiredAccess = GENERIC_WRITE;
  587. uchMode = uchMode & (UCHAR)SHARING_MASK;
  588. switch (uchMode) {
  589. case SHARING_DENY_BOTH:
  590. dwShareMode = 0;
  591. break;
  592. case SHARING_DENY_WRITE:
  593. dwShareMode = FILE_SHARE_READ;
  594. break;
  595. case SHARING_DENY_READ:
  596. dwShareMode = FILE_SHARE_WRITE;
  597. break;
  598. }
  599. }
  600. sa.nLength = sizeof (SECURITY_ATTRIBUTES);
  601. sa.lpSecurityDescriptor = NULL;
  602. sa.bInheritHandle = TRUE;
  603. if ((hFile = CreateFileOem(lpFileName,
  604. dwDesiredAccess,
  605. dwShareMode | FILE_SHARE_DELETE,
  606. &sa,
  607. CreateDirective,
  608. dwAttr,
  609. NULL)) == (HANDLE)-1){
  610. demClientError(INVALID_HANDLE_VALUE, *lpFileName);
  611. return;
  612. }
  613. // Get Misc. INfo
  614. if (demGetMiscInfo (hFile,&wTime, &wDate, &dwSize) == FALSE)
  615. return;
  616. // Setup the exit registers
  617. setBX(wTime);
  618. setCX(wDate);
  619. setBP((USHORT)hFile);
  620. setAX((USHORT)((ULONG)hFile >> 16));
  621. setSI((USHORT)dwSize);
  622. setDX((USHORT)(dwSize >> 16));
  623. setCF(0);
  624. return;
  625. }
  626. BOOL demGetMiscInfo (hFile, lpTime, lpDate, lpSize)
  627. HANDLE hFile;
  628. LPWORD lpTime;
  629. LPWORD lpDate;
  630. LPDWORD lpSize;
  631. {
  632. FILETIME LastWriteTime,ftLocal;
  633. DWORD dwSizeHigh=0;
  634. if(GetFileTime (hFile,NULL,NULL,&LastWriteTime) == -1){
  635. demPrintMsg(MSG_FILEINFO);
  636. ASSERT(FALSE);
  637. demClientError(hFile, (CHAR)-1);
  638. DPM_CloseHandle (hFile);
  639. return FALSE;
  640. }
  641. FileTimeToLocalFileTime (&LastWriteTime,&ftLocal);
  642. if(FileTimeToDosDateTime(&ftLocal,
  643. lpDate,
  644. lpTime) == FALSE){
  645. demPrintMsg(MSG_FILEINFO);
  646. ASSERT(FALSE);
  647. demClientError(hFile, (CHAR)-1);
  648. return FALSE;
  649. }
  650. if((*lpSize = DPM_GetFileSize(hFile,&dwSizeHigh)) == -1){
  651. demPrintMsg(MSG_FILEINFO);
  652. ASSERT(FALSE);
  653. demClientError(hFile, (CHAR)-1);
  654. return FALSE;
  655. }
  656. if(dwSizeHigh) {
  657. demPrintMsg(MSG_FILESIZE_TOOBIG);
  658. ASSERT(FALSE);
  659. demClientError(hFile, (CHAR)-1);
  660. return FALSE;
  661. }
  662. return TRUE;
  663. }