-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported from svn tag fireworkz__2021_09_10__2_31_00
- Loading branch information
Showing
56 changed files
with
1,720 additions
and
910 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ Priority: Optional | |
Licence: Free | ||
Maintainer: Colton Software <[email protected]> | ||
Standards-Version: 0.4.0 | ||
Version: 20200611 | ||
Version: 20210910 | ||
Recommends: Fireworkz | ||
Description: Example files for Fireworkz | ||
Example files to demonstrate, and help with using, various Fireworkz facilities. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
// CreateCFBF.cpp | ||
|
||
#include <windows.h> | ||
|
||
#include <stdio.h> | ||
|
||
#define SS_NORMAL 512 // As created by StgCreateDocfile() | ||
#define SS_LARGE 4096 // Needs v4 DLL (Windows 2000) | ||
|
||
static void | ||
byteswap( | ||
unsigned char * a, | ||
unsigned char * b, | ||
size_t n) | ||
{ | ||
while(n != 0) | ||
{ | ||
unsigned char tmp = *b; | ||
*b++ = *a; | ||
*a++ = tmp; | ||
--n; | ||
} | ||
} | ||
|
||
/* | ||
StgCreateDocfile() creates a file containing: | ||
File Sector Zero: Structured Storage Header | ||
File Sector One (Data Sector[0]): Sector Allocation Table | ||
File Sector Two (Data Sector[1]): Directory | ||
It's more convenient to store the SAT sectors contiguously | ||
for extension, so reorder a copy to contain: | ||
File Sector Zero: Structured Storage Header | ||
File Sector One (Data Sector[0]): Directory | ||
File Sector Two (Data Sector[1]): Sector Allocation Table | ||
*/ | ||
|
||
static int | ||
create_storage_512(void) | ||
{ | ||
int ok = EXIT_FAILURE; | ||
static const WCHAR filename[MAX_PATH] = L"cfbf-512,ffd"; | ||
DWORD grfMode = STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE; | ||
IStorage * pstgOpen = NULL; | ||
HRESULT hr = StgCreateDocfile(filename, grfMode, 0 /*reserved*/, &pstgOpen); | ||
if(SUCCEEDED(hr)) | ||
{ | ||
pstgOpen->Release(); | ||
ok = EXIT_SUCCESS; | ||
} | ||
return(ok); | ||
} | ||
|
||
static int | ||
reorder_storage_512(void) | ||
{ | ||
int ok = EXIT_FAILURE; | ||
const char * infile = "cfbf-512,ffd"; | ||
const char * outfile = "cfbf-512ro,ffd"; | ||
const unsigned int sector_size = SS_NORMAL; | ||
unsigned char buffer[sector_size*3]; | ||
FILE * fin; | ||
FILE * fout; | ||
|
||
if(0 == fopen_s(&fin, infile, "rb")) | ||
{ | ||
if(0 == fopen_s(&fout, outfile, "wb")) | ||
{ | ||
if (3 != fread_s(buffer, sizeof(buffer), sector_size, 3, fin)) | ||
{ | ||
fprintf_s(stderr, "Failed to read three sectors from %s\n", infile); | ||
goto barf; | ||
} | ||
|
||
/* Sector Zero: Structured Storage Header */ | ||
/* Swap sector ids of SAT and Directory for reorder */ | ||
byteswap(&buffer[0*sector_size + 0x4C /*_sectFat[0]*/ /*[04CH,436]*/ /*76d..511d*/ /* the SECTs of the first 109 FAT sectors */], | ||
&buffer[0*sector_size + 0x30 /*_sectDirStart*/ /*[030H,04]*/ /*48d*/ /* first SECT in the Directory chain */], | ||
4); | ||
|
||
/* Sector One: SAT */ | ||
/* Swap sector ids of SAT and Directory for reorder */ | ||
byteswap(&buffer[1*sector_size + 0], | ||
&buffer[1*sector_size + 4], | ||
4); | ||
|
||
/* Sector Two: Directory */ | ||
|
||
/* Write out, reordered as Header, Directory, SAT */ | ||
if(1 != fwrite(&buffer[0*sector_size], sector_size, 1, fout)) | ||
{ | ||
fprintf_s(stderr, "Failed to write sector zero to %s\n", outfile); | ||
goto barf; | ||
} | ||
if(1 != fwrite(&buffer[2*sector_size], sector_size, 1, fout)) | ||
{ | ||
fprintf_s(stderr, "Failed to write sector one to %s\n", outfile); | ||
goto barf; | ||
} | ||
if(1 != fwrite(&buffer[1*sector_size], sector_size, 1, fout)) | ||
{ | ||
fprintf_s(stderr, "Failed to write sector two to %s\n", outfile); | ||
goto barf; | ||
} | ||
|
||
ok = EXIT_SUCCESS; | ||
|
||
barf:; | ||
|
||
(void) fclose(fout); | ||
} | ||
(void) fclose(fin); | ||
} | ||
|
||
return(ok); | ||
} | ||
|
||
static int | ||
create_storage_4096(void) | ||
{ | ||
int ok = EXIT_FAILURE; | ||
static const WCHAR filename[MAX_PATH] = L"cfbf-4096,ffd"; | ||
DWORD grfMode = STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE; | ||
STGFMT stgfmt = STGFMT_DOCFILE; | ||
DWORD grfAttrs = 0; | ||
STGOPTIONS stgoptions = { 1 /*usVersion*/, 0 /*usPadding*/, SS_LARGE /*ulSectorSize*/ }; | ||
IStorage * pstgOpen = NULL; | ||
HRESULT hr = StgCreateStorageEx(filename, grfMode, stgfmt, grfAttrs, &stgoptions, NULL /*pSecurityDescriptor*/, IID_IStorage, reinterpret_cast<void**>(&pstgOpen)); | ||
if(SUCCEEDED(hr)) | ||
{ | ||
pstgOpen->Release(); | ||
ok = EXIT_SUCCESS; | ||
} | ||
return(ok); | ||
} | ||
|
||
static int | ||
reorder_storage_4096(void) | ||
{ | ||
int ok = EXIT_FAILURE; | ||
const char * infile = "cfbf-4096,ffd"; | ||
const char * outfile = "cfbf-4096ro,ffd"; | ||
const unsigned int sector_size = SS_LARGE; | ||
unsigned char buffer[sector_size*3]; | ||
FILE * fin; | ||
FILE * fout; | ||
|
||
if(0 == fopen_s(&fin, infile, "rb")) | ||
{ | ||
if(0 == fopen_s(&fout, outfile, "wb")) | ||
{ | ||
if (3 != fread_s(buffer, sizeof(buffer), sector_size, 3, fin)) | ||
{ | ||
fprintf_s(stderr, "Failed to read three sectors from %s\n", infile); | ||
goto barf; | ||
} | ||
|
||
/* Sector Zero: Structured Storage Header */ | ||
/* Swap sector ids of SAT and Directory for reorder */ | ||
byteswap(&buffer[0*sector_size + 0x4C /*_sectFat[0]*/ /*[04CH,436]*/ /*76d..511d*/ /* the SECTs of the first 109 FAT sectors */], | ||
&buffer[0*sector_size + 0x30 /*_sectDirStart*/ /*[030H,04]*/ /*48d*/ /* first SECT in the Directory chain */], | ||
4); | ||
|
||
/* Sector One: SAT */ | ||
/* Swap sector ids of SAT and Directory for reorder */ | ||
byteswap(&buffer[1*sector_size + 0], | ||
&buffer[1*sector_size + 4], | ||
4); | ||
|
||
/* Sector Two: Directory */ | ||
|
||
/* Write out, reordered as Header, Directory, SAT */ | ||
if(1 != fwrite(&buffer[0*sector_size], sector_size, 1, fout)) | ||
{ | ||
fprintf_s(stderr, "Failed to write sector zero to %s\n", outfile); | ||
goto barf; | ||
} | ||
if(1 != fwrite(&buffer[2*sector_size], sector_size, 1, fout)) | ||
{ | ||
fprintf_s(stderr, "Failed to write sector one to %s\n", outfile); | ||
goto barf; | ||
} | ||
if(1 != fwrite(&buffer[1*sector_size], sector_size, 1, fout)) | ||
{ | ||
fprintf_s(stderr, "Failed to write sector two to %s\n", outfile); | ||
goto barf; | ||
} | ||
|
||
ok = EXIT_SUCCESS; | ||
|
||
barf:; | ||
|
||
(void) fclose(fout); | ||
} | ||
(void) fclose(fin); | ||
} | ||
|
||
return(ok); | ||
} | ||
|
||
int main() | ||
{ | ||
int ok; | ||
|
||
if(EXIT_SUCCESS != (ok = create_storage_512())) return(ok); | ||
if(EXIT_SUCCESS != (ok = reorder_storage_512())) return(ok); | ||
|
||
if(EXIT_SUCCESS != (ok = create_storage_4096())) return(ok); | ||
if(EXIT_SUCCESS != (ok = reorder_storage_4096())) return(ok); | ||
|
||
return(EXIT_SUCCESS); | ||
} | ||
|
||
// end of CreateCFBF.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.1622 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateCFBF", "CreateCFBF.vcxproj", "{6994EFAE-7999-4963-8037-86EAF6657CE4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Debug|x64.ActiveCfg = Debug|x64 | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Debug|x64.Build.0 = Debug|x64 | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Debug|x86.ActiveCfg = Debug|Win32 | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Debug|x86.Build.0 = Debug|Win32 | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Release|x64.ActiveCfg = Release|x64 | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Release|x64.Build.0 = Release|x64 | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Release|x86.ActiveCfg = Release|Win32 | ||
{6994EFAE-7999-4963-8037-86EAF6657CE4}.Release|x86.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {2B833A1C-D5BF-4C5F-91BE-ADC7106939A8} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.