@@ -1647,6 +1647,11 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
16471647 bool t_success;
16481648 t_success = true ;
16491649
1650+ // Are we running deploy just for the purpose of changing the EXE icons?
1651+ bool t_icons_only = false ;
1652+ if (MCStringIsEmpty (p_params.stackfile ) && !MCStringIsEmpty (p_params.app_icon ))
1653+ t_icons_only = true ;
1654+
16501655 // First thing to do is to open the files.
16511656 MCDeployFileRef t_engine, t_output;
16521657 t_engine = t_output = NULL ;
@@ -1662,8 +1667,9 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
16621667 t_section_headers = NULL ;
16631668 if (t_success)
16641669 t_success = MCDeployToWindowsReadHeaders (t_engine, t_dos_header, t_nt_header, t_section_headers);
1665-
1670+
16661671 IMAGE_SECTION_HEADER *t_payload_section, *t_project_section, *t_resource_section;
1672+ t_payload_section = t_project_section = t_resource_section = nil;
16671673 uint32_t t_section_count;
16681674 if (t_success)
16691675 {
@@ -1672,7 +1678,10 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
16721678 t_payload_section = &t_section_headers[t_section_count - 3 ];
16731679 else
16741680 t_payload_section = nil;
1675- t_project_section = &t_section_headers[t_section_count - 2 ];
1681+
1682+ if (!t_icons_only)
1683+ t_project_section = &t_section_headers[t_section_count - 2 ];
1684+
16761685 t_resource_section = &t_section_headers[t_section_count - 1 ];
16771686 }
16781687
@@ -1684,7 +1693,7 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
16841693 t_success = MCDeployThrow (kMCDeployErrorWindowsMissingSections );
16851694 if (t_success && memcmp (t_resource_section -> Name, " .rsrc" , 6 ) != 0 )
16861695 t_success = MCDeployThrow (kMCDeployErrorWindowsNoResourceSection );
1687- if (t_success && memcmp (t_project_section -> Name, " .project" , 8 ) != 0 )
1696+ if (t_success && !t_icons_only && memcmp (t_project_section -> Name, " .project" , 8 ) != 0 )
16881697 t_success = MCDeployThrow (kMCDeployErrorWindowsNoProjectSection );
16891698 if (t_success && t_payload_section != nil && memcmp (t_payload_section -> Name, " .payload" , 8 ) != 0 )
16901699 t_success = MCDeployThrow (kMCDeployErrorWindowsNoPayloadSection );
@@ -1739,7 +1748,9 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
17391748 t_output_offset = 0 ;
17401749 if (t_success)
17411750 {
1742- if (t_payload_section == nil)
1751+ if (t_icons_only)
1752+ t_output_offset = t_resource_section -> PointerToRawData;
1753+ else if (t_payload_section == nil)
17431754 t_output_offset = t_project_section -> PointerToRawData;
17441755 else
17451756 t_output_offset = t_payload_section -> PointerToRawData;
@@ -1760,7 +1771,7 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
17601771 // Write out the project capsule struct
17611772 uint32_t t_project_size;
17621773 t_project_size = 0 ;
1763- if (t_success)
1774+ if (t_success && !t_icons_only )
17641775 t_success = MCDeployWriteProject (p_params, false , t_output, t_output_offset, t_project_size);
17651776
17661777 // Next use the project size to compute the updated header values we need.
@@ -1779,7 +1790,7 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
17791790
17801791 uint32_t t_project_section_size, t_project_section_delta;
17811792 t_project_section_size = (t_project_size + 4095 ) & ~4095 ;
1782- t_project_section_delta = t_project_section_size - t_project_section -> SizeOfRawData;
1793+ t_project_section_delta = t_project_section == nil ? 0 : t_project_section_size - t_project_section -> SizeOfRawData;
17831794
17841795 uint32_t t_resource_section_size;
17851796 t_resource_section_size = MCWindowsResourcesMeasure (t_resources);
@@ -1796,13 +1807,19 @@ Exec_stat MCDeployToWindows(const MCDeployParameters& p_params)
17961807 t_project_section -> PointerToRawData = t_payload_section -> PointerToRawData + t_payload_section_size;
17971808 }
17981809
1799- // Resize and shift up the project section
1800- t_project_section -> SizeOfRawData = t_project_section_size;
1801- t_project_section -> Misc . VirtualSize = t_project_section_size;
1810+ // Resize and shift up the project section (if present)
1811+ if (t_project_section != nil)
1812+ {
1813+ t_project_section -> SizeOfRawData = t_project_section_size;
1814+ t_project_section -> Misc . VirtualSize = t_project_section_size;
1815+ }
18021816
18031817 // Resize and shift up the resource section.
1804- t_resource_section -> VirtualAddress = t_project_section -> VirtualAddress + t_project_section_size;
1805- t_resource_section -> PointerToRawData = t_project_section -> PointerToRawData + t_project_section_size;
1818+ if (t_project_section != nil)
1819+ {
1820+ t_resource_section -> VirtualAddress = t_project_section -> VirtualAddress + t_project_section_size;
1821+ t_resource_section -> PointerToRawData = t_project_section -> PointerToRawData + t_project_section_size;
1822+ }
18061823 t_resource_section -> SizeOfRawData = t_resource_section_size;
18071824 t_resource_section -> Misc . VirtualSize = t_resource_section_size;
18081825
0 commit comments