HDKEEPER.C
上传用户:haocheng
上传日期:2007-01-06
资源大小:24k
文件大小:14k
源码类别:

磁盘编程

开发平台:

Others

  1. #include<stdio.h>
  2. #include<dos.h>   
  3. #include<fcntl.h>
  4. #include<sysstat.h>
  5. #define MemSize *(unsigned far *)0x00400013
  6. unsigned char Sector1[512]=
  7.       { 0xEB,0x05,0x90,0x89,0xA1,0x00,0xF0,0xFA,0x8C,0xC8,0x8E,0xD8,
  8. 0x8E,0xC0,0x8E,0xD0,0xBC,0x00,0x7C,0x33,0xF6,0xFB,0xFF,0x0E,
  9. 0x13,0x04,0xFF,0x0E,0x13,0x04,0xA1,0x13,0x04,0xB1,0x06,0xD3,
  10. 0xE0,0x8E,0xC0,0xBF,0x00,0x00,0xBE,0x00,0x7C,0xB9,0x00,0x02,
  11. 0xF3,0xA4,0x06,0xB8,0x38,0x00,0x50,0xCB,0x33,0xC0,0x8E,0xD8,
  12. 0x8C,0x06,0xF0,0x03,0xFA,0xA1,0x4C,0x00,0x2E,0xA3,0x03,0x00,
  13. 0xA3,0x40,0x01,0xA1,0x4E,0x00,0x2E,0xA3,0x05,0x00,0xA3,0x42,
  14. 0x01,0xB8,0x2F,0x01,0xA3,0x4C,0x00,0x8C,0x0E,0x4E,0x00,0xA1,
  15. 0x24,0x00,0x2E,0xA3,0x0C,0x01,0xA1,0x26,0x00,0x2E,0xA3,0x0E,
  16. 0x01,0xB8,0xB4,0x01,0xA3,0x24,0x00,0x8C,0x0E,0x26,0x00,0xBE,
  17. 0x02,0x00,0xB8,0x01,0x02,0xBB,0x00,0x02,0xB9,0x01,0x00,0xBA,
  18. 0x80,0x00,0x9C,0x2E,0xFF,0x1E,0x03,0x00,0x73,0x03,0x4E,0x75,
  19. 0xE9,0x33,0xF6,0xBF,0x00,0x02,0x0E,0x1F,0xF3,0xA6,0x74,0x14,
  20. 0xBE,0x10,0x01,0x32,0xED,0xAC,0x8A,0xC8,0xB8,0x01,0x13,0xBB,
  21. 0x07,0x00,0x2B,0xD2,0x8B,0xEE,0xCD,0x10,0x8C,0xC8,0x8E,0xC0,
  22. 0x33,0xDB,0xB8,0x01,0x03,0xB9,0x01,0x00,0xBA,0x80,0x00,0x9C,
  23. 0x2E,0xFF,0x1E,0x03,0x00,0xBE,0x02,0x00,0xB8,0x03,0x02,0xBB,
  24. 0x00,0x02,0xB9,0x04,0x00,0xBA,0x80,0x00,0x9C,0x2E,0xFF,0x1E,
  25. 0x03,0x00,0x73,0x03,0x4E,0x75,0xE9,0xB8,0xE8,0x00,0x50,0xB8,
  26. 0x00,0x02,0x50,0xC3,0xFB,0x33,0xC0,0x8E,0xC0,0xBE,0x02,0x00,
  27. 0xB8,0x01,0x02,0xBB,0x00,0x7C,0xB9,0x03,0x00,0xBA,0x80,0x00,
  28. 0x9C,0x2E,0xFF,0x1E,0x03,0x00,0x73,0x03,0x4E,0x75,0xE9,0xEA,
  29. 0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x5B,0x56,0x69,
  30. 0x72,0x75,0x73,0x5D,0x20,0x53,0x65,0x6C,0x66,0x20,0x50,0x72,
  31. 0x6F,0x74,0x65,0x63,0x74,0x2E,0x2E,0x2E,0x0A,0x0D,0x00,0xFF,
  32. 0xFF,0x6B,0x02,0xFB,0x81,0xFA,0x80,0x00,0x75,0x08,0x83,0xF9,
  33. 0x01,0x75,0x03,0xB9,0x03,0x00,0x80,0xFC,0x03,0x74,0x28,0x80,
  34. 0xFC,0x05,0x74,0x23,0x80,0xFC,0x06,0x74,0x1E,0x80,0xFC,0x07,
  35. 0x74,0x19,0x80,0xFC,0x0B,0x74,0x14,0x80,0xFC,0x0F,0x74,0x0F,
  36. 0x80,0xFC,0x13,0x74,0x0A,0x80,0xFC,0x19,0x74,0x05,0x2E,0xFF,
  37. 0x2E,0x03,0x00,0x80,0xFA,0x80,0x75,0xF6,0x51,0x52,0x86,0xE9,
  38. 0x80,0xE5,0xC0,0x8B,0xD1,0xB1,0x06,0xD2,0xEE,0x2E,0x3B,0x16,
  39. 0x2D,0x01,0x5A,0x59,0x7D,0xE0,0x2E,0x80,0x3E,0x2A,0x01,0x00,
  40. 0x74,0x20,0x80,0xFE,0x00,0x75,0xD3,0x83,0xF9,0x01,0x74,0x16,
  41. 0x83,0xF9,0x02,0x74,0x11,0x83,0xF9,0x03,0x74,0x0C,0x83,0xF9,
  42. 0x07,0x74,0x07,0x83,0xF9,0x08,0x74,0x02,0xEB,0xB8,0xB4,0x00,
  43. 0xFD,0xCA,0x02,0x00,0xFB,0x50,0xE4,0x60,0x3C,0x01,0x74,0x06,
  44. 0x58,0x2E,0xFF,0x2E,0x0C,0x01,0xB4,0x02,0xCD,0x16,0x24,0x0F,
  45. 0x3C,0x0A,0x75,0xF0,0x9C,0x2E,0xFF,0x1E,0x0C,0x01,0x9C,0xB8,
  46. 0xDC,0x01,0x50,0xB8,0x00,0x06,0x50,0xC3,0x72,0x09,0x2E,0xC6,
  47. 0x06,0x2A,0x01,0xFF,0xEB,0x07,0x90,0x2E,0xC6,0x06,0x2A,0x01,
  48. 0x00,0x9D,0x58,0xCF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  49. 0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xAA};
  50. char Sector2[1536]=
  51.       { 0x0E,0x1F,0xBF,0xAB,0x02,0xE8,0x90,0x00,0xBF,0xF0,0x07,0xE8,
  52. 0x23,0x00,0xBE,0xF0,0x07,0xBF,0xE0,0x07,0x8A,0x0D,0x8A,0x2C,
  53. 0x3A,0xCD,0x75,0x06,0x32,0xED,0xF3,0xA6,0x74,0x08,0xBF,0xD1,
  54. 0x06,0xE8,0x70,0x00,0xEB,0xFE,0xBF,0xDC,0x02,0xE8,0x68,0x00,
  55. 0xC3,0x06,0x57,0x0E,0x07,0x47,0xC6,0x06,0xAA,0x02,0x00,0x90,
  56. 0x80,0x3E,0xAA,0x02,0x0F,0x7D,0x4D,0xB4,0x01,0xCD,0x16,0x74,
  57. 0xF3,0xB8,0x00,0x00,0xCD,0x16,0x3C,0x00,0x74,0xEA,0x3C,0x08,
  58. 0x74,0x18,0x3C,0x0D,0x74,0x36,0x2C,0x14,0x0C,0x80,0xAA,0xB0,
  59. 0x2A,0xBB,0x00,0x00,0xB4,0x0E,0xCD,0x10,0xFE,0x06,0xAA,0x02,
  60. 0xEB,0xCE,0x80,0x3E,0xAA,0x02,0x00,0x74,0xC7,0x4F,0xB0,0x00,
  61. 0xAA,0xB4,0x03,0xB7,0x00,0xCD,0x10,0xB0,0x20,0xB4,0x0E,0xCD,
  62. 0x10,0xB4,0x02,0xCD,0x10,0xFE,0x0E,0xAA,0x02,0x4F,0xEB,0xAC,
  63. 0x5F,0xA0,0xAA,0x02,0x88,0x05,0x07,0xC3,0x2E,0x8A,0x05,0x3C,
  64. 0x24,0x74,0x0A,0xB4,0x0E,0xBB,0x03,0x00,0xCD,0x10,0x47,0xEB,
  65. 0xEF,0xC3,0x00,0x57,0x61,0x6B,0x69,0x6E,0x67,0x20,0x75,0x70,
  66. 0x20,0x42,0x61,0x62,0x79,0x73,0x6F,0x66,0x74,0x2D,0x48,0x44,
  67. 0x4B,0x65,0x65,0x70,0x65,0x72,0x2E,0x2E,0x2E,0x20,0x6F,0x6B,
  68. 0x2E,0x0A,0x0D,0x0A,0x0D,0x50,0x61,0x73,0x73,0x77,0x6F,0x72,
  69. 0x64,0x3A,0x20,0x24,0x0A,0x0D,0x0A,0x0D,0x24,0x00,0x00,0x00,
  70. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  71. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  72. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  73. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  74. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  75. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  76. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  77. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  78. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  79. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  80. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  81. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  82. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  83. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  84. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  85. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  86. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  87. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  88. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  89. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  90. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  91. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  92. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  93. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  94. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  95. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  96. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  97. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  98. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  99. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  100. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  101. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  102. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  103. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  104. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  105. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  106. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  107. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  108. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  109. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  110. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  111. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  112. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  113. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  114. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  115. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  116. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  117. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  118. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  119. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  120. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  121. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  122. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  123. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  124. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  125. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  126. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  127. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  128. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  129. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  130. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  131. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  132. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  133. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  134. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  135. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  136. 0x00,0x00,0x00,0x00,0x50,0x51,0x1E,0x06,0x56,0x57,0x33,0xC0,
  137. 0x8E,0xD8,0xA1,0xF0,0x03,0x8E,0xD8,0x8E,0xC0,0xBF,0xF0,0x07,
  138. 0xE8,0x49,0x00,0xBE,0xF0,0x07,0xBF,0xE0,0x07,0x8A,0x0D,0x8A,
  139. 0x2C,0x3A,0xCD,0x75,0x0C,0x32,0xED,0xF3,0xA6,0xB8,0x33,0x04,
  140. 0xB9,0x05,0x00,0x74,0x16,0x05,0xC8,0x00,0xE8,0x74,0x00,0xE8,
  141. 0x8B,0x00,0xE2,0xF5,0xE8,0x7F,0x00,0x5F,0x5E,0x07,0x1F,0x59,
  142. 0x58,0xF9,0xC3,0xB8,0xE3,0x08,0x2D,0xC8,0x00,0xE8,0x5B,0x00,
  143. 0xE8,0x72,0x00,0xE2,0xF5,0xE8,0x66,0x00,0x5F,0x5E,0x07,0x1F,
  144. 0x59,0x58,0xF8,0xC3,0x06,0x57,0x47,0xC6,0x06,0xAA,0x02,0x00,
  145. 0x80,0x3E,0xAA,0x02,0x0F,0x7D,0x34,0xB4,0x01,0xCD,0x16,0x74,
  146. 0xF3,0xB8,0x00,0x00,0xCD,0x16,0x3C,0x00,0x74,0xEA,0x3C,0x08,
  147. 0x74,0x0F,0x3C,0x0D,0x74,0x1D,0x2C,0x14,0x0C,0x80,0xAA,0xFE,
  148. 0x06,0xAA,0x02,0xEB,0xD7,0x80,0x3E,0xAA,0x02,0x00,0x74,0xD0,
  149. 0x4F,0xB0,0x00,0xAA,0xFE,0x0E,0xAA,0x02,0x4F,0xEB,0xC5,0x5F,
  150. 0xA0,0xAA,0x02,0x88,0x05,0x07,0xC3,0x50,0xB0,0xB6,0xE6,0x43,
  151. 0x58,0xE6,0x42,0x8A,0xC4,0xE6,0x42,0xE4,0x61,0x0C,0x03,0xE6,
  152. 0x61,0xC3,0xE4,0x61,0x24,0xFC,0xE6,0x61,0xC3,0x56,0xBE,0x00,
  153. 0xA0,0x4E,0x83,0xFE,0x00,0x75,0xFA,0x5E,0xC3,0x07,0x0A,0x0D,
  154. 0x0A,0x0D,0x53,0x6F,0x72,0x72,0x79,0x21,0x20,0x59,0x6F,0x75,
  155. 0x20,0x61,0x72,0x65,0x20,0x55,0x6E,0x77,0x65,0x6C,0x63,0x6F,
  156. 0x6D,0x65,0x20,0x47,0x75,0x65,0x73,0x74,0x21,0x0A,0x0D,0x49,
  157. 0x20,0x63,0x61,0x6E,0x20,0x6E,0x6F,0x74,0x20,0x6C,0x65,0x74,
  158. 0x20,0x79,0x6F,0x75,0x20,0x69,0x6E,0x21,0x0A,0x0D,0x48,0x61,
  159. 0x21,0x48,0x61,0x21,0x48,0x61,0x21,0x2E,0x2E,0x2E,0x24,0x00,
  160. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  161. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  162. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  163. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  164. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  165. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  166. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  167. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  168. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  169. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  170. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  171. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  172. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  173. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  174. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  175. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  176. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  177. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
  178. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01};
  179. unsigned char buffer[512];
  180. void ReadStr(char *str)
  181. {
  182.  unsigned char Plength=1;
  183.  unsigned xx,yy,x;
  184.  union REGS r;
  185.  xx=wherex();
  186.  yy=wherey();
  187.  x=xx;
  188.  do{
  189.      gotoxy(xx,yy);
  190.      r.h.ah=0;
  191.      int86(0x16,&r,&r);
  192.      if((r.h.ah!=28)&&(r.h.ah!=14)&&(r.h.ah!=1))
  193.      {
  194.       *(str+Plength)=(r.h.al-20)|0x80;
  195.       gotoxy(xx,yy);
  196.       putch('*');
  197.       xx++;
  198.       Plength++;
  199.      }
  200.      else if(r.h.ah==14)
  201.           {
  202.            xx--;
  203.            if(xx<x)xx=x;
  204.            gotoxy(xx,yy);
  205.            putch(' ');
  206.            if(Plength>1)Plength--;
  207.           }
  208.           else if(r.h.ah==1)Plength=0;
  209.     }while((r.h.ah!=28)&&(r.h.ah!=1)&&(Plength<15));
  210.     *(str+0)=Plength-1;
  211. }
  212. int CheckPass(char *src,char *dest)
  213. {
  214.  unsigned char Plength,p2;
  215.  Plength=*(src+0);
  216.  p2=*(dest+0);
  217.  if(Plength!=p2)return -1;
  218.  while(Plength>0)
  219.  {
  220.   if(*(src+Plength)!=*(dest+Plength))return -1;
  221.   Plength--;
  222.  }
  223.  return 1;
  224. }
  225. int CopyPass(char *src,char *dest)
  226. {
  227.  char Plength;
  228.  Plength=*(src+0);
  229.  while(Plength>=0)
  230.  {
  231.   *(dest+Plength)=*(src+Plength);
  232.   Plength--;
  233.  }
  234.  return 0;
  235. }
  236. void reboot(void)
  237. {
  238.  void (far *reboot_ptr)(void);
  239.  unsigned int far *i_ptr;
  240.  clrscr();
  241.  i_ptr=MK_FP(0x0040,0x0072);
  242.  *i_ptr=0x1234;
  243.  reboot_ptr=MK_FP(0xF000,0xFFF0);
  244.  reboot_ptr();
  245. }
  246. void copyright()
  247. {
  248.  printf("n Babysoft  (R) Hard Disk Keeper version 1.0");
  249.  printf("n Copyright (C) 1997.12 LiuYaDing,Babysoft Corp.");
  250.  printf("n This Program can set password on Driver C: and make it Read-Only.n");
  251. }
  252. void main()
  253. {
  254.  char k,*pass;
  255.  char passwd1[16],passwd2[16];
  256.  char filename[20];
  257.  int fp;
  258.  if(MemSize!=0x280)
  259.  {
  260.   printf("na Hard Disk Keeper has been Installed or Virus infected!!!");
  261.   printf("n Please check your system......");
  262.   printf("n If you use AMI BIOS,don't reduce your RAM.n");
  263.   printf("n        (C) Copyright 1997.12 LiuYaDing,Babysoft Corp.n");
  264.   exit(1);
  265.  }
  266.  copyright();
  267.  printf("n Password: ");
  268.  ReadStr(passwd1);
  269.  printf("n Verify  : ");
  270.  ReadStr(passwd2);
  271.  if(CheckPass(passwd1,passwd2)!=1)
  272.  {
  273.   printf("na Password verify error!!! ");
  274.   exit(1);
  275.  }
  276.  pass=Sector2+0x600-32;
  277.  CopyPass(passwd1,pass);
  278.  printf("n Backup Filename[.MBG]:");
  279.  scanf("%s",filename);
  280.  fp=open(filename,O_CREAT|O_BINARY,S_IREAD|S_IWRITE);
  281.  if(fp==-1){printf("na Backup file open error!");}
  282.  else printf(" Saved Master Boot Sector to <%s> ok.",filename);
  283.  if((biosdisk(0x02,0x80,0,0,1,1,buffer))!=0)
  284.  {
  285.   printf("na Read Master Boot Sector error!");
  286.   exit(1);
  287.  }
  288.  if((biosdisk(0x03,0x80,0,0,3,1,buffer))!=0)
  289.  {
  290.   printf("na Installed Hard Disk Keeper error!");
  291.   exit(1);
  292.  }
  293.  if((biosdisk(0x03,0x80,0,0,7,1,buffer))!=0)
  294.  {
  295.   printf("na Installed Hard Disk Keeper error!");
  296.   exit(1);
  297.  }
  298.  Sector1[0x12D]=buffer[0x1C5];
  299.  Sector1[0x12E]=buffer[0x1C4]&192;
  300.  Sector1[0x12E]=Sector1[0x12E]>>6;
  301.  if((biosdisk(0x03,0x80,0,0,1,1,Sector1))!=0)
  302.  {
  303.   printf("na Install Hard Disk Keeper First Parts error!");
  304.   exit(1);
  305.  }
  306.  if((biosdisk(0x03,0x80,0,0,4,3,Sector2))!=0)
  307.  {
  308.   printf("na Install Hard Disk Keeper Other Parts error!");
  309.   exit(1);
  310.  }
  311.  write(fp,buffer,512);
  312.  close(fp);
  313.  printf("n Installed Hard Disk Keeper ok.");
  314.  printf("n Reboot system to enable the change?(Y/N)");
  315.  k=getch();k=k|0x20;
  316.  if(k=='y')reboot();
  317. }