Source code of Windows XP (NT5)
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.

62 lines
1.1 KiB

  1. /* demlock.c - SVC handler for file file locking calls
  2. *
  3. * demLockOper
  4. *
  5. * Modification History:
  6. *
  7. * Sudeepb 07-Aug-1992 Created
  8. */
  9. #include "dem.h"
  10. #include "demmsg.h"
  11. #include <softpc.h>
  12. /* demLockOper - Lock or Unlock the file data
  13. *
  14. * Entry Client(AX) : Lock = 0 Unlock = 1
  15. * Client(BX:BP) : NT Handle
  16. * Client(CX:DX) : offset in the file
  17. * Client(SI:DI) : Data Length to be locked
  18. * Exit
  19. * SUCCESS: Client CF = 0
  20. * FAILURE: Client CF = 1
  21. */
  22. VOID demLockOper (VOID)
  23. {
  24. HANDLE hFile;
  25. DWORD dwFileOffset,cbLock;
  26. // Collect all the parameters
  27. hFile = GETHANDLE(getBX(),getBP());
  28. dwFileOffset = GETULONG (getCX(),getDX());
  29. cbLock = GETULONG (getSI(),getDI());
  30. if(getAL() == 0){ // Locking case
  31. if (LockFile (hFile,
  32. dwFileOffset,
  33. 0,
  34. cbLock,
  35. 0
  36. ) == TRUE) {
  37. setCF (0);
  38. return;
  39. }
  40. }
  41. else {
  42. if (UnlockFile (hFile,
  43. dwFileOffset,
  44. 0,
  45. cbLock,
  46. 0
  47. ) == TRUE) {
  48. setCF (0);
  49. return;
  50. }
  51. }
  52. // Operation failed
  53. demClientError(hFile, (CHAR)-1);
  54. return;
  55. }