#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include "install.h"
#include "volume.h"
#include "fat.h"
#include "fat32.h"
Go to the source code of this file.
◆ BackupBootSector()
Definition at line 61 of file install.c.
62{
66 BYTE BootSectorBuffer[512];
67 DWORD dwNumberOfBytesWritten;
69
70
71
72
74 {
75
76
77
79
80
81
82
84
85
86
87
89 {
90 break;
91 }
92
93
94
95
96
98 {
102 }
103 }
104
105
106
107
109 {
112 }
113
114
115
116
117 bRetVal =
WriteFile(hBackupFile, BootSectorBuffer, 512, &dwNumberOfBytesWritten,
NULL);
118 if (!bRetVal || (dwNumberOfBytesWritten != 512))
119 {
124 }
125
126 _tprintf(
_T(
"Boot sector backed up to file: %s\n"), szFileName);
127
129
131}
BOOL ReadVolumeSector(ULONG SectorNumber, PVOID SectorBuffer)
#define INVALID_HANDLE_VALUE
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
#define ERROR_ALREADY_EXISTS
DWORD WINAPI GetLastError(void)
Referenced by FatSwapFat32BootSector(), InstallFat32BootCode(), and main().
◆ InstallBootSector()
Definition at line 133 of file install.c.
134{
135 BYTE BootSectorBuffer[512];
136
137
138
139
141 {
143 }
144
146 {
147
148
149
150 memcpy((fat_data+3), (BootSectorBuffer+3), 59 );
151
152
153
154
156 {
158 }
159 }
160 else if (
_tcsicmp(lpszVolumeType,
_T(
"fat32")) == 0)
161 {
162
163
164
165 memcpy((fat32_data+3), (BootSectorBuffer+3), 87 );
166
167
168
169
171 {
173 }
174
175
176
177
179 {
181 }
182 }
183 else
184 {
186 _tprintf(
_T(
"File system type %s unknown.\n"), lpszVolumeType);
188 }
189
190 _tprintf(
_T(
"%s boot sector installed.\n"), lpszVolumeType);
191
193}
BOOL WriteVolumeSector(ULONG SectorNumber, PVOID SectorBuffer)
#define memcpy(s1, s2, n)
Referenced by main().
◆ main()
Definition at line 37 of file install.c.
38{
40 {
41 _tprintf(
_T(
"syntax: install x: [fs_type]\nwhere fs_type is fat or fat32\n"));
42 return -1;
43 }
44
46 {
47 return -1;
48 }
49
51
53
54 _tprintf(
_T(
"You must now copy freeldr.sys & freeldr.ini to %s.\n"),
argv[1]);
55
57
58 return 0;
59}
HANDLE OpenVolume(const TCHAR *Volume, BOOLEAN AllowRemote, BOOLEAN NtfsOnly)
BOOL BackupBootSector(LPCTSTR lpszVolumeName)
BOOL InstallBootSector(LPCTSTR lpszVolumeType)