Skip to content

Commit 9e0f461

Browse files
committed
update adjusting scr
making the source more readable
1 parent c34a34d commit 9e0f461

File tree

8 files changed

+640
-609
lines changed

8 files changed

+640
-609
lines changed

PyInstaller-C++.vcxproj

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
<Platform>x64</Platform>
1919
</ProjectConfiguration>
2020
</ItemGroup>
21+
<ItemGroup>
22+
<ClInclude Include="include\PyInstArchive.h" />
23+
<ClInclude Include="include\zconf.h" />
24+
<ClInclude Include="include\zlib.h" />
25+
</ItemGroup>
26+
<ItemGroup>
27+
<ClCompile Include="src\Pyinstaller.cpp" />
28+
</ItemGroup>
2129
<PropertyGroup Label="Globals">
2230
<VCProjectVersion>17.0</VCProjectVersion>
2331
<Keyword>Win32Proj</Keyword>
@@ -47,7 +55,7 @@
4755
<CharacterSet>Unicode</CharacterSet>
4856
</PropertyGroup>
4957
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
50-
<ConfigurationType>StaticLibrary</ConfigurationType>
58+
<ConfigurationType>Application</ConfigurationType>
5159
<UseDebugLibraries>false</UseDebugLibraries>
5260
<PlatformToolset>v143</PlatformToolset>
5361
<WholeProgramOptimization>true</WholeProgramOptimization>
@@ -72,7 +80,10 @@
7280
</ImportGroup>
7381
<PropertyGroup Label="UserMacros" />
7482
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
75-
<OutDir>$(SolutionDir)ConsoleApplication2</OutDir>
83+
<OutDir>$(SolutionDir)build\Debug</OutDir>
84+
</PropertyGroup>
85+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
86+
<OutDir>$(SolutionDir)build\Release</OutDir>
7687
</PropertyGroup>
7788
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7889
<ClCompile>
@@ -123,7 +134,7 @@
123134
<SubSystem>
124135
</SubSystem>
125136
<GenerateDebugInformation>true</GenerateDebugInformation>
126-
<AdditionalDependencies>libz-static.lib;%(AdditionalDependencies)</AdditionalDependencies>
137+
<AdditionalDependencies>lib/libz-static.lib;%(AdditionalDependencies)</AdditionalDependencies>
127138
</Link>
128139
</ItemDefinitionGroup>
129140
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -134,30 +145,20 @@
134145
<SDLCheck>true</SDLCheck>
135146
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
136147
<ConformanceMode>true</ConformanceMode>
137-
<PrecompiledHeader>Use</PrecompiledHeader>
138-
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
148+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
149+
<PrecompiledHeaderFile>
150+
</PrecompiledHeaderFile>
151+
<LanguageStandard>stdcpp17</LanguageStandard>
139152
</ClCompile>
140153
<Link>
141154
<SubSystem>
142155
</SubSystem>
143156
<EnableCOMDATFolding>true</EnableCOMDATFolding>
144157
<OptimizeReferences>true</OptimizeReferences>
145158
<GenerateDebugInformation>true</GenerateDebugInformation>
159+
<AdditionalDependencies>lib/libz-static.lib;%(AdditionalDependencies)</AdditionalDependencies>
146160
</Link>
147161
</ItemDefinitionGroup>
148-
<ItemGroup>
149-
<ClInclude Include="framework.h" />
150-
<ClInclude Include="PyInstArchive.h" />
151-
</ItemGroup>
152-
<ItemGroup>
153-
<ClCompile Include="pch.cpp">
154-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
155-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
156-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
157-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
158-
</ClCompile>
159-
<ClCompile Include="Pyinstaller.cpp" />
160-
</ItemGroup>
161162
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
162163
<ImportGroup Label="ExtensionTargets">
163164
</ImportGroup>

PyInstaller-C++.vcxproj.filters

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="framework.h">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
<ClInclude Include="PyInstArchive.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
</ItemGroup>
25+
<ItemGroup>
26+
<ClCompile Include="Pyinstaller.cpp">
27+
<Filter>Source Files</Filter>
28+
</ClCompile>
29+
<ClCompile Include="pch.cpp">
30+
<Filter>Source Files</Filter>
31+
</ClCompile>
32+
</ItemGroup>
33+
</Project>

framework.h

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1-
#ifndef PYINSTARCHIVE_H
2-
#define PYINSTARCHIVE_H
3-
4-
#include <iostream>
5-
#include <fstream>
6-
#include <vector>
7-
#include <string>
8-
#include <cstring>
9-
#include <cstdint>
10-
#include <mutex>
11-
12-
// Structure for Table of Contents Entry
13-
struct CTOCEntry {
14-
uint32_t position; // Position of the entry
15-
uint32_t cmprsdDataSize; // Compressed data size
16-
uint32_t uncmprsdDataSize; // Uncompressed data size
17-
uint8_t cmprsFlag; // Compression flag
18-
char typeCmprsData; // Type of compressed data
19-
std::string name; // Name of the entry
20-
21-
// Constructor
22-
CTOCEntry(uint32_t pos, uint32_t cmprsdSize, uint32_t uncmprsdSize, uint8_t flag, char type, const std::string& n)
23-
: position(pos), cmprsdDataSize(cmprsdSize), uncmprsdDataSize(uncmprsdSize), cmprsFlag(flag), typeCmprsData(type), name(n) {}
24-
25-
// Getters for entry details
26-
uint32_t getCompressedDataSize() const {
27-
return cmprsdDataSize;
28-
}
29-
30-
const std::string& getName() const {
31-
return name;
32-
}
33-
34-
bool isCompressed() const {
35-
return cmprsFlag != 0;
36-
}
37-
};
38-
39-
// Class for handling the PyInstaller Archive
40-
class PyInstArchive {
41-
public:
42-
// Constructor
43-
PyInstArchive(const std::string& path);
44-
45-
// Member functions
46-
bool open();
47-
void close();
48-
bool checkFile();
49-
bool getCArchiveInfo();
50-
void parseTOC();
51-
void timeExtractionProcess(const std::string& outputDir);
52-
void decompressAndExtractFile(const CTOCEntry& tocEntry, const std::string& outputDir);
53-
void displayInfo();
54-
void decompressData(const std::vector<char>& compressedData, std::vector<char>& decompressedData);
55-
56-
private:
57-
std::mutex mtx;
58-
std::mutex printMtx; // Mutex for synchronizing print statements
59-
std::string filePath; // Path to the archive file
60-
std::ifstream fPtr; // File stream for reading the archive
61-
uint64_t fileSize; // Size of the file
62-
uint64_t cookiePos; // Position of the cookie
63-
uint64_t overlayPos; // Position of the overlay
64-
uint64_t overlaySize; // Size of the overlay
65-
uint64_t tableOfContentsPos; // Position of the TOC
66-
uint64_t tableOfContentsSize; // Size of the TOC
67-
uint8_t pyinstVer; // PyInstaller version
68-
uint8_t pymaj; // Python major version
69-
uint8_t pymin; // Python minor version
70-
std::vector<CTOCEntry> tocList; // List of TOC entries
71-
uint32_t lengthofPackage; // Length of the package
72-
uint32_t toc; // Table of contents
73-
uint32_t tocLen; // Length of the table of contents
74-
75-
// Constants for PyInstaller cookie sizes
76-
static const uint8_t PYINST20_COOKIE_SIZE = 24;
77-
static const uint8_t PYINST21_COOKIE_SIZE = 24 + 64;
78-
static const std::string MAGIC;
79-
};
80-
81-
#endif // PYINSTARCHIVE_H
1+
#ifndef PYINSTARCHIVE_H
2+
#define PYINSTARCHIVE_H
3+
4+
#include <iostream>
5+
#include <fstream>
6+
#include <vector>
7+
#include <string>
8+
#include <cstring>
9+
#include <cstdint>
10+
#include <mutex>
11+
12+
// Structure for Table of Contents Entry
13+
struct CTOCEntry {
14+
uint32_t position; // Position of the entry
15+
uint32_t cmprsdDataSize; // Compressed data size
16+
uint32_t uncmprsdDataSize; // Uncompressed data size
17+
uint8_t cmprsFlag; // Compression flag
18+
char typeCmprsData; // Type of compressed data
19+
std::string name; // Name of the entry
20+
21+
// Constructor
22+
CTOCEntry(uint32_t pos, uint32_t cmprsdSize, uint32_t uncmprsdSize, uint8_t flag, char type, const std::string& n)
23+
: position(pos), cmprsdDataSize(cmprsdSize), uncmprsdDataSize(uncmprsdSize), cmprsFlag(flag), typeCmprsData(type), name(n) {}
24+
25+
// Getters for entry details
26+
uint32_t getCompressedDataSize() const {
27+
return cmprsdDataSize;
28+
}
29+
30+
const std::string& getName() const {
31+
return name;
32+
}
33+
34+
bool isCompressed() const {
35+
return cmprsFlag != 0;
36+
}
37+
};
38+
39+
// Class for handling the PyInstaller Archive
40+
class PyInstArchive {
41+
public:
42+
// Constructor
43+
PyInstArchive(const std::string& path);
44+
45+
// Member functions
46+
bool open();
47+
void close();
48+
bool checkFile();
49+
bool getCArchiveInfo();
50+
void parseTOC();
51+
void timeExtractionProcess(const std::string& outputDir);
52+
void decompressAndExtractFile(const CTOCEntry& tocEntry, const std::string& outputDir);
53+
void displayInfo();
54+
void decompressData(const std::vector<char>& compressedData, std::vector<char>& decompressedData);
55+
56+
private:
57+
std::mutex mtx;
58+
std::mutex printMtx; // Mutex for synchronizing print statements
59+
std::string filePath; // Path to the archive file
60+
std::ifstream fPtr; // File stream for reading the archive
61+
uint64_t fileSize; // Size of the file
62+
uint64_t cookiePos; // Position of the cookie
63+
uint64_t overlayPos; // Position of the overlay
64+
uint64_t overlaySize; // Size of the overlay
65+
uint64_t tableOfContentsPos; // Position of the TOC
66+
uint64_t tableOfContentsSize; // Size of the TOC
67+
uint8_t pyinstVer; // PyInstaller version
68+
uint8_t pymaj; // Python major version
69+
uint8_t pymin; // Python minor version
70+
std::vector<CTOCEntry> tocList; // List of TOC entries
71+
uint32_t lengthofPackage; // Length of the package
72+
uint32_t toc; // Table of contents
73+
uint32_t tocLen; // Length of the table of contents
74+
75+
// Constants for PyInstaller cookie sizes
76+
static const uint8_t PYINST20_COOKIE_SIZE = 24;
77+
static const uint8_t PYINST21_COOKIE_SIZE = 24 + 64;
78+
static const std::string MAGIC;
79+
};
80+
81+
#endif // PYINSTARCHIVE_H
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)