win32sup.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*++
  2. Copyright (c) 2014 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. win32sup.h
  9. Abstract:
  10. This header contains isolated definitions for Windows support functions in
  11. the setup application. This is needed because windows.h defines don't
  12. gel nicely with Minoca OS defines.
  13. Author:
  14. Evan Green 8-Oct-2014
  15. --*/
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. //
  20. // ---------------------------------------------------------------- Definitions
  21. //
  22. //
  23. // ------------------------------------------------------ Data Type Definitions
  24. //
  25. /*++
  26. Structure Description:
  27. This structure describes a partition.
  28. Members:
  29. Partition - Stores the partition information.
  30. DiskNumber - Stores the disk number.
  31. PartitionNumber - Stores the partition number.
  32. DevicePath - Stores a pointer to the device path.
  33. --*/
  34. typedef struct _SETUP_WIN32_PARTITION_DESCRIPTION {
  35. PARTITION_DEVICE_INFORMATION Partition;
  36. ULONG DiskNumber;
  37. ULONG PartitionNumber;
  38. PSTR DevicePath;
  39. } SETUP_WIN32_PARTITION_DESCRIPTION, *PSETUP_WIN32_PARTITION_DESCRIPTION;
  40. //
  41. // -------------------------------------------------------------------- Globals
  42. //
  43. //
  44. // -------------------------------------------------------- Function Prototypes
  45. //
  46. INT
  47. SetupWin32EnumerateDevices (
  48. PSETUP_WIN32_PARTITION_DESCRIPTION *Devices,
  49. PULONG DeviceCount
  50. );
  51. /*++
  52. Routine Description:
  53. This routine enumerates all devices and partitions in the system.
  54. Arguments:
  55. Devices - Supplies a pointer where an array of partition descriptions will
  56. be returned on success. The caller is responsible for freeing this
  57. array when finished (it's just a single free plus each device path).
  58. DeviceCount - Supplies a pointer where the number of elements in the
  59. array will be returned.
  60. Return Value:
  61. 0 on success.
  62. Non-zero on failure.
  63. --*/
  64. VOID
  65. SetupWin32PrintLastError (
  66. VOID
  67. );
  68. /*++
  69. Routine Description:
  70. This routine prints a description of GetLastError to standard error and
  71. also prints a newline.
  72. Arguments:
  73. None.
  74. Return Value:
  75. None.
  76. --*/
  77. PVOID
  78. SetupWin32OpenDeviceId (
  79. ULONGLONG DeviceId
  80. );
  81. /*++
  82. Routine Description:
  83. This routine opens a handle to a disk or partition ID.
  84. Arguments:
  85. DeviceId - Supplies the device ID to open.
  86. Return Value:
  87. Returns the open handle on success.
  88. NULL or (PVOID)-1 on failure.
  89. --*/
  90. VOID
  91. SetupWin32Close (
  92. PVOID Handle
  93. );
  94. /*++
  95. Routine Description:
  96. This routine closes a handle.
  97. Arguments:
  98. Handle - Supplies a pointer to the destination to open.
  99. Return Value:
  100. None.
  101. --*/
  102. ssize_t
  103. SetupWin32Read (
  104. PVOID Handle,
  105. void *Buffer,
  106. size_t ByteCount
  107. );
  108. /*++
  109. Routine Description:
  110. This routine reads from an open handle.
  111. Arguments:
  112. Handle - Supplies the handle.
  113. Buffer - Supplies a pointer where the read bytes will be returned.
  114. ByteCount - Supplies the number of bytes to read.
  115. Return Value:
  116. Returns the number of bytes read.
  117. -1 on failure.
  118. --*/
  119. ssize_t
  120. SetupWin32Write (
  121. PVOID Handle,
  122. void *Buffer,
  123. size_t ByteCount
  124. );
  125. /*++
  126. Routine Description:
  127. This routine writes data to an open handle.
  128. Arguments:
  129. Handle - Supplies the handle.
  130. Buffer - Supplies a pointer to the bytes to write.
  131. ByteCount - Supplies the number of bytes to read.
  132. Return Value:
  133. Returns the number of bytes written.
  134. -1 on failure.
  135. --*/
  136. LONGLONG
  137. SetupWin32Seek (
  138. PVOID Handle,
  139. LONGLONG Offset
  140. );
  141. /*++
  142. Routine Description:
  143. This routine seeks in the current file or device.
  144. Arguments:
  145. Handle - Supplies the handle.
  146. Offset - Supplies the new offset to set.
  147. Return Value:
  148. Returns the resulting file offset after the operation.
  149. -1 on failure, and errno will contain more information. The file offset
  150. will remain unchanged.
  151. --*/
  152. LONGLONG
  153. SetupWin32Tell (
  154. PVOID Handle
  155. );
  156. /*++
  157. Routine Description:
  158. This routine returns the current file pointer.
  159. Arguments:
  160. Handle - Supplies the handle.
  161. Return Value:
  162. Returns the file offset on success.
  163. -1 on failure, and errno will contain more information. The file offset
  164. will remain unchanged.
  165. --*/
  166. INT
  167. SetupWin32FileStat (
  168. PVOID Handle,
  169. PULONGLONG FileSize
  170. );
  171. /*++
  172. Routine Description:
  173. This routine gets details for the given open file.
  174. Arguments:
  175. Handle - Supplies the handle.
  176. FileSize - Supplies an optional pointer where the file size will be
  177. returned on success.
  178. Return Value:
  179. 0 on success.
  180. Non-zero on failure.
  181. --*/