summaryrefslogtreecommitdiffstats
path: root/src/nsis-1-fixes.patch
blob: bd9d1360945f337e809e8e8ab6d36da1d27900ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
This file is part of MXE. See LICENSE.md for licensing information.

Contains ad hoc patches for cross building.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Sun, 12 Aug 2012 12:33:26 +0200
Subject: [PATCH] explicit mingw cross prefix

This patch has been taken from:
http://sourceforge.net/tracker/index.php?func=detail&aid=3305366&group_id=22049&atid=373085

diff --git a/SCons/Tools/crossmingw.py b/SCons/Tools/crossmingw.py
index 1111111..2222222 100755
--- a/SCons/Tools/crossmingw.py
+++ b/SCons/Tools/crossmingw.py
@@ -61,6 +61,9 @@ prefixes = SCons.Util.Split("""
 """)
 
 def find(env):
+    if env.has_key('MINGW_CROSS_PREFIX'):
+        return env['MINGW_CROSS_PREFIX']
+
     for prefix in prefixes:
         # First search in the SCons path and then the OS path:
         if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'):
diff --git a/SConstruct b/SConstruct
index 1111111..2222222 100755
--- a/SConstruct
+++ b/SConstruct
@@ -59,6 +59,7 @@ doc = [
 
 path = ARGUMENTS.get('PATH', '')
 toolset = ARGUMENTS.get('TOOLSET', '')
+mingw_cross_prefix = ARGUMENTS.get('MINGW_CROSS_PREFIX', '')
 
 if toolset and path:
 	defenv = Environment(ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip'])
@@ -69,6 +70,8 @@ else:
 		defenv = Environment(TOOLS = toolset.split(',') + ['zip'])
 if not toolset and not path:
 	defenv = Environment()
+if mingw_cross_prefix:
+	defenv['MINGW_CROSS_PREFIX'] = mingw_cross_prefix
 
 Export('defenv')
 

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: freeman <free.man.uu@gmail.com>
Date: Sun, 12 Aug 2012 12:36:39 +0200
Subject: [PATCH] add missing header


diff --git a/Source/util.h b/Source/util.h
index 1111111..2222222 100755
--- a/Source/util.h
+++ b/Source/util.h
@@ -25,6 +25,7 @@
 #ifndef _WIN32
 #  include <iconv.h>
 #  include <stdio.h>
+#  include <unistd.h>
 #endif
 
 

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Boris Pek <tehnick-8@yandex.ru>
Date: Mon, 16 May 2016 14:26:59 +0300
Subject: [PATCH] Enable native 64-bit build

Taken from:
http://anonscm.debian.org/gitweb/?p=collab-maint/nsis.git;a=blob;f=debian/patches/makensis_native_64bit.patch;h=2256a0e193db894dd99507ac0de66f8ae060b46b;hb=HEAD

diff --git a/SCons/Config/gnu b/SCons/Config/gnu
index 1111111..2222222 100755
--- a/SCons/Config/gnu
+++ b/SCons/Config/gnu
@@ -95,8 +95,6 @@ makensis_env.Append(CXXFLAGS = ['-Wno-non-virtual-dtor']) # ignore virtual dtor
 makensis_env.Append(CXXFLAGS = ['-Wall'])                 # all warnings
 
 conf = FlagsConfigure(makensis_env)
-conf.CheckCompileFlag('-m32')                     #
-conf.CheckLinkFlag('-m32')                        #
 conf.CheckLinkFlag('$MAP_FLAG')                   # generate map file
 if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_CP']:
 	TestStrip(conf)                                 # strip
@@ -149,8 +147,6 @@ conf.Finish()
 ### cross-platform util environment adjustments
 
 conf = FlagsConfigure(cp_util_env)
-conf.CheckCompileFlag('-m32')
-conf.CheckLinkFlag('-m32')
 if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_CP']:
 	TestStrip(conf)                                 # strip
 conf.Finish()
@@ -160,8 +156,6 @@ conf.Finish()
 test_env = defenv.Clone()
 test_env.Append(CPPPATH = ['#$BUILD_CONFIG'])
 conf = FlagsConfigure(test_env)
-conf.CheckCompileFlag('-m32')
-conf.CheckLinkFlag('-m32')
 conf.Finish()
 
 ### weird GCC requirements
diff --git a/Source/DialogTemplate.cpp b/Source/DialogTemplate.cpp
index 1111111..2222222 100755
--- a/Source/DialogTemplate.cpp
+++ b/Source/DialogTemplate.cpp
@@ -74,7 +74,7 @@ void ReadVarLenArr(LPBYTE &seeker, WCHAR* &readInto, unsigned int uCodePage) {
     if (IS_INTRESOURCE(x)) { \
       *(WORD*)seeker = 0xFFFF; \
       seeker += sizeof(WORD); \
-      *(WORD*)seeker = ConvertEndianness(WORD(DWORD(x))); \
+      *(WORD*)seeker = ConvertEndianness(WORD((ULONG_PTR)(x))); \
       seeker += sizeof(WORD); \
     } \
     else { \
@@ -450,7 +450,7 @@ void CDialogTemplate::ConvertToRTL() {
       szClass = winchar_toansi(m_vItems[i]->szClass);
 
     // Button
-    if (long(m_vItems[i]->szClass) == 0x80) {
+    if ((ULONG_PTR)(m_vItems[i]->szClass) == 0x80) {
       m_vItems[i]->dwStyle ^= BS_LEFTTEXT;
       m_vItems[i]->dwStyle ^= BS_RIGHT;
       m_vItems[i]->dwStyle ^= BS_LEFT;
@@ -464,13 +464,13 @@ void CDialogTemplate::ConvertToRTL() {
       }
     }
     // Edit
-    else if (long(m_vItems[i]->szClass) == 0x81) {
+    else if ((ULONG_PTR)(m_vItems[i]->szClass) == 0x81) {
       if ((m_vItems[i]->dwStyle & ES_CENTER) == 0) {
         m_vItems[i]->dwStyle ^= ES_RIGHT;
       }
     }
     // Static
-    else if (long(m_vItems[i]->szClass) == 0x82) {
+    else if ((ULONG_PTR)(m_vItems[i]->szClass) == 0x82) {
       if ((m_vItems[i]->dwStyle & SS_TYPEMASK) == SS_LEFT || (m_vItems[i]->dwStyle & SS_TYPEMASK) == SS_LEFTNOWORDWRAP)
       {
         m_vItems[i]->dwStyle &= ~SS_TYPEMASK;
@@ -577,7 +577,7 @@ BYTE* CDialogTemplate::Save(DWORD& dwSize) {
   // Write all of the items
   for (unsigned int i = 0; i < m_vItems.size(); i++) {
     // DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundary
-    if (DWORD(seeker - pbDlg) % sizeof(DWORD))
+    if ((seeker - pbDlg) % sizeof(DWORD))
       seeker += sizeof(WORD);
 
     if (m_bExtended) {
@@ -628,7 +628,7 @@ BYTE* CDialogTemplate::Save(DWORD& dwSize) {
     }
   }
 
-  assert((DWORD) seeker - (DWORD) pbDlg == dwSize);
+  assert((DWORD)(seeker - pbDlg) == dwSize);
 
   // DONE!
   return pbDlg;
diff --git a/Source/Platform.h b/Source/Platform.h
index 1111111..2222222 100755
--- a/Source/Platform.h
+++ b/Source/Platform.h
@@ -53,6 +53,7 @@ typedef unsigned char UCHAR;
 typedef const char *LPCCH, *PCSTR, *LPCSTR;
 typedef unsigned short WCHAR, OLECHAR, *PWCHAR, *LPWCH, *PWCH, *NWPSTR, *LPWSTR, *PWSTR, *BSTR;
 typedef const unsigned short *LPCWCH, *PCWCH, *LPCWSTR, *PCWSTR, *LPCOLESTR;
+typedef int INT_PTR;
 typedef unsigned int UINT_PTR;
 // basic stuff
 typedef void * HANDLE;
@@ -60,8 +61,8 @@ typedef HANDLE HWND;
 typedef HANDLE HMODULE;
 typedef unsigned long HKEY;
 // some gdi
-typedef unsigned long COLORREF;
-typedef unsigned long HBRUSH;
+typedef DWORD COLORREF;
+typedef UINT32 HBRUSH;
 // bool
 #  define FALSE 0
 #  define TRUE 1
@@ -166,7 +167,7 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
 #    define MAKEINTRESOURCE MAKEINTRESOURCEA
 #  endif
 #  ifndef IMAGE_FIRST_SECTION
-#    define IMAGE_FIRST_SECTION(h) ( PIMAGE_SECTION_HEADER( (DWORD) h + \
+#    define IMAGE_FIRST_SECTION(h) ( PIMAGE_SECTION_HEADER( (ULONG_PTR) h + \
                                      FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) + \
                                      FIX_ENDIAN_INT16(PIMAGE_NT_HEADERS(h)->FileHeader.SizeOfOptionalHeader) ) )
 #  endif
@@ -174,7 +175,7 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
 #    define RGB(r,g,b) ((DWORD)(((BYTE)(r)|((WORD)(g)<<8))|(((DWORD)(BYTE)(b))<<16)))
 #  endif
 #  ifndef MAKELONG
-#    define MAKELONG(a,b) ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
+#    define MAKELONG(a,b) ((DWORD)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
 #  endif
 #endif
 #ifndef IS_INTRESOURCE
@@ -197,8 +198,10 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
 #  define FOF_NOERRORUI 0x0400
 #endif
 
-#ifndef ULONG_PTR
-#  define ULONG_PTR DWORD
+// mingw32 and w64-mingw32 do not define ULONG_PTR
+// but rather declare ULONG_PTR via typedef (see basetsd.h)
+#if !defined(__MINGW32__) && !defined(ULONG_PTR)
+#  define ULONG_PTR unsigned long
 #endif
 
 #ifndef IDC_HAND
@@ -238,7 +241,7 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
 #  undef INVALID_FILE_ATTRIBUTES
 #endif
 #ifndef INVALID_FILE_ATTRIBUTES
-#  define INVALID_FILE_ATTRIBUTES ((unsigned long) -1)
+#  define INVALID_FILE_ATTRIBUTES ((DWORD) -1)
 #endif
 
 // shell folders
diff --git a/Source/Plugins.cpp b/Source/Plugins.cpp
index 1111111..2222222 100755
--- a/Source/Plugins.cpp
+++ b/Source/Plugins.cpp
@@ -29,7 +29,7 @@
 #include "dirreader.h"
 
 #ifdef _WIN32
-#  include <WinNT.h>
+#  include <winnt.h>
 #else
 #  include <sys/stat.h>
 #endif
@@ -136,8 +136,8 @@ void Plugins::GetExports(const string &pathToDll, bool displayInfo)
         DWORD prd = FIX_ENDIAN_INT32(sections[i].PointerToRawData);
         PIMAGE_EXPORT_DIRECTORY exports = PIMAGE_EXPORT_DIRECTORY(&dlldata[0] + prd + ExportDirVA - va);
         DWORD na = FIX_ENDIAN_INT32(exports->AddressOfNames);
-        unsigned long *names = (unsigned long*)((unsigned long) exports + (char *) na - ExportDirVA);
-        for (unsigned long j = 0; j < FIX_ENDIAN_INT32(exports->NumberOfNames); j++)
+        LPDWORD names = (LPDWORD)((ULONG_PTR)exports + na - ExportDirVA);
+        for (DWORD j = 0; j < FIX_ENDIAN_INT32(exports->NumberOfNames); j++)
         {
           const string name = string((char*)exports + FIX_ENDIAN_INT32(names[j]) - ExportDirVA);
           const string signature = dllName + "::" + name;
diff --git a/Source/ResourceEditor.cpp b/Source/ResourceEditor.cpp
index 1111111..2222222 100755
--- a/Source/ResourceEditor.cpp
+++ b/Source/ResourceEditor.cpp
@@ -27,20 +27,10 @@ using namespace std;
 #define ALIGN(dwToAlign, dwAlignOn) dwToAlign = (dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn
 #define RALIGN(dwToAlign, dwAlignOn) ((dwToAlign%dwAlignOn == 0) ? dwToAlign : dwToAlign - (dwToAlign%dwAlignOn) + dwAlignOn)
 
-#ifndef _WIN32
-static inline ULONG ConvertEndianness(ULONG u) {
-  return FIX_ENDIAN_INT32(u);
-}
-#endif
-
 static inline DWORD ConvertEndianness(DWORD d) {
   return FIX_ENDIAN_INT32(d);
 }
 
-static inline LONG ConvertEndianness(LONG l) {
-  return FIX_ENDIAN_INT32(l);
-}
-
 static inline WORD ConvertEndianness(WORD w) {
   return FIX_ENDIAN_INT16(w);
 }
@@ -52,7 +42,7 @@ PIMAGE_NT_HEADERS CResourceEditor::GetNTHeaders(BYTE* pbPE) {
     throw runtime_error("PE file contains invalid DOS header");
 
   // Get NT headers
-  PIMAGE_NT_HEADERS ntHeaders = (PIMAGE_NT_HEADERS)(pbPE + ConvertEndianness(dosHeader->e_lfanew));
+  PIMAGE_NT_HEADERS ntHeaders = (PIMAGE_NT_HEADERS)(pbPE + ConvertEndianness((DWORD)dosHeader->e_lfanew));
   if (ntHeaders->Signature != IMAGE_NT_SIGNATURE)
     throw runtime_error("PE file missing NT signature");
 
@@ -684,7 +674,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
     rdDir.NumberOfIdEntries = ConvertEndianness(rdDir.NumberOfIdEntries);
 
     CopyMemory(seeker, &rdDir, sizeof(IMAGE_RESOURCE_DIRECTORY));
-    crd->m_dwWrittenAt = DWORD(seeker);
+    crd->m_ulWrittenAt = (ULONG_PTR)(seeker);
     seeker += sizeof(IMAGE_RESOURCE_DIRECTORY);
 
     for (int i = 0; i < crd->CountEntries(); i++) {
@@ -705,7 +695,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
       rDirE.UName.NameString.NameIsString = (crd->GetEntry(i)->HasName()) ? 1 : 0;
 
       CopyMemory(seeker, &rDirE, sizeof(MY_IMAGE_RESOURCE_DIRECTORY_ENTRY));
-      crd->GetEntry(i)->m_dwWrittenAt = DWORD(seeker);
+      crd->GetEntry(i)->m_ulWrittenAt = (ULONG_PTR)(seeker);
       seeker += sizeof(MY_IMAGE_RESOURCE_DIRECTORY_ENTRY);
     }
     qDirs.pop();
@@ -721,7 +711,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
     rDataE.Size = ConvertEndianness(cRDataE->GetSize());
 
     CopyMemory(seeker, &rDataE, sizeof(IMAGE_RESOURCE_DATA_ENTRY));
-    cRDataE->m_dwWrittenAt = DWORD(seeker);
+    cRDataE->m_ulWrittenAt = (ULONG_PTR)(seeker);
     seeker += sizeof(IMAGE_RESOURCE_DATA_ENTRY);
 
     qDataEntries.pop();
@@ -733,7 +723,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
   while (!qStrings.empty()) {
     CResourceDirectoryEntry* cRDirE = qStrings.front();
 
-    PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(cRDirE->m_dwWrittenAt)->UName.NameString.NameOffset = ConvertEndianness(DWORD(seeker) - DWORD(pbRsrcSec));
+    PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(cRDirE->m_ulWrittenAt)->UName.NameString.NameOffset = ConvertEndianness((DWORD) (seeker - pbRsrcSec));
 
     WCHAR* szName = cRDirE->GetName();
     WORD iLen = winchar_strlen(szName) + 1;
@@ -754,7 +744,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
   while (!qDataEntries2.empty()) {
     CResourceDataEntry* cRDataE = qDataEntries2.front();
     CopyMemory(seeker, cRDataE->GetData(), cRDataE->GetSize());
-    PIMAGE_RESOURCE_DATA_ENTRY(cRDataE->m_dwWrittenAt)->OffsetToData = ConvertEndianness(seeker - pbRsrcSec + m_dwResourceSectionVA);
+    PIMAGE_RESOURCE_DATA_ENTRY(cRDataE->m_ulWrittenAt)->OffsetToData = ConvertEndianness((DWORD)(seeker - pbRsrcSec) + m_dwResourceSectionVA);
 
     seeker += RALIGN(cRDataE->GetSize(), 8);
 
@@ -764,21 +754,21 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
   /*
    * Set all of the directory entries offsets.
    */
-  SetOffsets(m_cResDir, DWORD(pbRsrcSec));
+  SetOffsets(m_cResDir, (ULONG_PTR)(pbRsrcSec));
 }
 
 // Sets the offsets in directory entries
-void CResourceEditor::SetOffsets(CResourceDirectory* resDir, DWORD newResDirAt) {
+void CResourceEditor::SetOffsets(CResourceDirectory* resDir, ULONG_PTR newResDirAt) {
   for (int i = 0; i < resDir->CountEntries(); i++) {
-    PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY rde = PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(resDir->GetEntry(i)->m_dwWrittenAt);
+    PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY rde = PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(resDir->GetEntry(i)->m_ulWrittenAt);
     if (resDir->GetEntry(i)->IsDataDirectory()) {
       rde->UOffset.DirectoryOffset.DataIsDirectory = 1;
-      rde->UOffset.DirectoryOffset.OffsetToDirectory = resDir->GetEntry(i)->GetSubDirectory()->m_dwWrittenAt - newResDirAt;
+      rde->UOffset.DirectoryOffset.OffsetToDirectory = resDir->GetEntry(i)->GetSubDirectory()->m_ulWrittenAt - newResDirAt;
       rde->UOffset.OffsetToData = ConvertEndianness(rde->UOffset.OffsetToData);
       SetOffsets(resDir->GetEntry(i)->GetSubDirectory(), newResDirAt);
     }
     else {
-      rde->UOffset.OffsetToData = ConvertEndianness(resDir->GetEntry(i)->GetDataEntry()->m_dwWrittenAt - newResDirAt);
+      rde->UOffset.OffsetToData = ConvertEndianness((DWORD)(resDir->GetEntry(i)->GetDataEntry()->m_ulWrittenAt - newResDirAt));
     }
   }
 }
@@ -887,7 +877,7 @@ int CResourceDirectory::CountEntries() {
 // Returns -1 if can not be found
 int CResourceDirectory::Find(WCHAR* szName) {
   if (IS_INTRESOURCE(szName))
-    return Find((WORD) (DWORD) szName);
+    return Find((WORD) (ULONG_PTR) szName);
   else
     if (szName[0] == '#')
       return Find(WORD(winchar_stoi(szName + 1)));
@@ -965,7 +955,7 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(WCHAR* szName, CResourceDirecto
   if (IS_INTRESOURCE(szName)) {
     m_bHasName = false;
     m_szName = 0;
-    m_wId = (WORD) (DWORD) szName;
+    m_wId = (WORD) (ULONG_PTR) szName;
   }
   else {
     m_bHasName = true;
@@ -979,7 +969,7 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(WCHAR* szName, CResourceDataEnt
   if (IS_INTRESOURCE(szName)) {
     m_bHasName = false;
     m_szName = 0;
-    m_wId = (WORD) (DWORD) szName;
+    m_wId = (WORD) (ULONG_PTR) szName;
   }
   else {
     m_bHasName = true;
diff --git a/Source/ResourceEditor.h b/Source/ResourceEditor.h
index 1111111..2222222 100755
--- a/Source/ResourceEditor.h
+++ b/Source/ResourceEditor.h
@@ -27,7 +27,7 @@
 
 #include "Platform.h"
 #ifdef _WIN32
-#  include <WinNT.h>
+#  include <winnt.h>
 #else
 // all definitions for non Win32 platforms were taken from MinGW's free Win32 library
 #  define IMAGE_DIRECTORY_ENTRY_RESOURCE  2
@@ -156,7 +156,7 @@ private:
   CResourceDirectory* ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan);
 
   void WriteRsrcSec(BYTE* pbRsrcSec);
-  void SetOffsets(CResourceDirectory* resDir, DWORD newResDirAt);
+  void SetOffsets(CResourceDirectory* resDir, ULONG_PTR newResDirAt);
 
   DWORD AdjustVA(DWORD dwVirtualAddress, DWORD dwAdjustment);
   DWORD AlignVA(DWORD dwVirtualAddress);
@@ -180,7 +180,7 @@ public:
 
   void Destroy();
 
-  DWORD m_dwWrittenAt;
+  ULONG_PTR m_ulWrittenAt;
 
 private:
   IMAGE_RESOURCE_DIRECTORY m_rdDir;
@@ -204,7 +204,7 @@ public:
 
   CResourceDataEntry* GetDataEntry();
 
-  DWORD m_dwWrittenAt;
+  ULONG_PTR m_ulWrittenAt;
 
 private:
   bool m_bHasName;
@@ -232,7 +232,7 @@ public:
   DWORD GetCodePage();
   DWORD GetOffset();
 
-  DWORD m_dwWrittenAt;
+  ULONG_PTR m_ulWrittenAt;
 
 private:
   BYTE* m_pbData;
diff --git a/Source/ResourceVersionInfo.cpp b/Source/ResourceVersionInfo.cpp
index 1111111..2222222 100755
--- a/Source/ResourceVersionInfo.cpp
+++ b/Source/ResourceVersionInfo.cpp
@@ -146,7 +146,7 @@ int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType)
     p += sizeof(WORD);
     szKey = (WCHAR*)p;
     p += (winchar_strlen(szKey) + 1) * sizeof (WCHAR);
-    while ( ((long)p % 4) != 0 )
+    while ( ((ULONG_PTR)p % 4) != 0 )
         p++;
     return p - baseP;    
 }
diff --git a/Source/fileform.cpp b/Source/fileform.cpp
index 1111111..2222222 100755
--- a/Source/fileform.cpp
+++ b/Source/fileform.cpp
@@ -149,7 +149,7 @@ void ctlcolors_writer::write(const ctlcolors *data)
   m_sink->write_int(data->text);
   m_sink->write_int(data->bkc);
   m_sink->write_int(data->lbStyle);
-  m_sink->write_int((int) data->bkb);
+  m_sink->write_int((INT_PTR) data->bkb);
   m_sink->write_int(data->bkmode);
   m_sink->write_int(data->flags);
 }
diff --git a/Source/mmap.cpp b/Source/mmap.cpp
index 1111111..2222222 100755
--- a/Source/mmap.cpp
+++ b/Source/mmap.cpp
@@ -322,7 +322,7 @@ void MMapFile::release(void *pView, int size)
   if (!pView)
     return;
 
-  unsigned int alignment = ((unsigned int)pView) % m_iAllocationGranularity;
+  unsigned int alignment = ((ULONG_PTR)pView) % m_iAllocationGranularity;
   pView = (char *)pView - alignment;
   size += alignment;
 #ifdef _WIN32
diff --git a/Source/script.cpp b/Source/script.cpp
index 1111111..2222222 100755
--- a/Source/script.cpp
+++ b/Source/script.cpp
@@ -2129,7 +2129,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
         int k=line.gettoken_enum(1,rootkeys[0]);
         if (k == -1) k=line.gettoken_enum(1,rootkeys[1]);
         if (k == -1) PRINTHELP()
-        build_header.install_reg_rootkey=(int)rootkey_tab[k];
+        build_header.install_reg_rootkey=(INT_PTR)rootkey_tab[k];
         if (!build_header.install_reg_rootkey) PRINTHELP() // SHCTX is invalid here
         build_header.install_reg_key_ptr = add_string(line.gettoken_str(2),0);
         if (line.gettoken_str(2)[0] == '\\')
@@ -5184,7 +5184,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
         int k=line.gettoken_enum(2,rootkeys[0]);
         if (k == -1) k=line.gettoken_enum(2,rootkeys[1]);
         if (ent.offsets[0] == -1 || k == -1) PRINTHELP()
-        ent.offsets[1]=(int)rootkey_tab[k];
+        ent.offsets[1]=(INT_PTR)rootkey_tab[k];
         ent.offsets[2]=add_string(line.gettoken_str(3));
         ent.offsets[3]=add_string(line.gettoken_str(4));
         if (which_token == TOK_READREGDWORD) ent.offsets[4]=1;
@@ -5216,7 +5216,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
         if (k == -1) k=line.gettoken_enum(a,rootkeys[1]);
         if (k == -1) PRINTHELP()
         ent.which=EW_DELREG;
-        ent.offsets[1]=(int)rootkey_tab[k];
+        ent.offsets[1]=(INT_PTR)rootkey_tab[k];
         ent.offsets[2]=add_string(line.gettoken_str(a+1));
         ent.offsets[3]=(which_token==TOK_DELETEREGKEY)?0:add_string(line.gettoken_str(a+2));
         if (line.gettoken_str(a+1)[0] == '\\')
@@ -5236,7 +5236,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
         if (k == -1) k=line.gettoken_enum(1,rootkeys[1]);
         if (k == -1) PRINTHELP()
         ent.which=EW_WRITEREG;
-        ent.offsets[0]=(int)rootkey_tab[k];
+        ent.offsets[0]=(INT_PTR)rootkey_tab[k];
         ent.offsets[1]=add_string(line.gettoken_str(2));
         if (line.gettoken_str(2)[0] == '\\')
           warning_fl("%s: registry path name begins with \'\\\', may cause problems",line.gettoken_str(0));
@@ -5305,7 +5305,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
         int k=line.gettoken_enum(2,rootkeys[0]);
         if (k == -1) k=line.gettoken_enum(2,rootkeys[1]);
         if (ent.offsets[0] == -1 || k == -1) PRINTHELP()
-        ent.offsets[1]=(int)rootkey_tab[k];
+        ent.offsets[1]=(INT_PTR)rootkey_tab[k];
         ent.offsets[2]=add_string(line.gettoken_str(3));
         ent.offsets[3]=add_string(line.gettoken_str(4));
         ent.offsets[4]=which_token == TOK_ENUMREGKEY;
diff --git a/Source/util.cpp b/Source/util.cpp
index 1111111..2222222 100755
--- a/Source/util.cpp
+++ b/Source/util.cpp
@@ -77,9 +77,9 @@ int update_bitmap(CResourceEditor* re, WORD id, const char* filename, int width/
   }
 
   if (width != 0) {
-    LONG biWidth;
+    INT32 biWidth;
     fseek(f, 18, SEEK_SET); // Seek to the width member of the header
-    fread(&biWidth, sizeof(LONG), 1, f);
+    fread(&biWidth, sizeof(INT32), 1, f);
     FIX_ENDIAN_INT32_INPLACE(biWidth);
     if (width != biWidth) {
       fclose(f);
@@ -88,9 +88,9 @@ int update_bitmap(CResourceEditor* re, WORD id, const char* filename, int width/
   }
 
   if (height != 0) {
-    LONG biHeight;
+    INT32 biHeight;
     fseek(f, 22, SEEK_SET); // Seek to the height member of the header
-    fread(&biHeight, sizeof(LONG), 1, f);
+    fread(&biHeight, sizeof(INT32), 1, f);
     FIX_ENDIAN_INT32_INPLACE(biHeight);
     // Bitmap height can be negative too...
     if (height != abs(biHeight)) {
@@ -689,8 +689,8 @@ static BOOL GetVxdVersion( LPCSTR szFile, LPDWORD lpdwLen, LPVOID lpData )
   }
 
   // Find the beginning of the NT header at offset e_lfanew.
-  pNtExeHdr = (PIMAGE_NT_HEADERS) ( (DWORD) pView
-       + (DWORD) pDosExeHdr->e_lfanew );
+  pNtExeHdr = (PIMAGE_NT_HEADERS) ( (ULONG_PTR) pView
+       + pDosExeHdr->e_lfanew );
 
   // Check to make sure the file is a VxD.
   if ( (DWORD) pNtExeHdr->Signature != IMAGE_VXD_SIGNATURE ) 
@@ -728,8 +728,8 @@ static BOOL GetVxdVersion( LPCSTR szFile, LPDWORD lpdwLen, LPVOID lpData )
   }
 
   // e32_winresoff contains the offset of the resource in the VxD.
-  pVerRes = (VXD_VERSION_RESOURCE *) ( (DWORD) pView
-       + (DWORD) pLEHdr->e32_winresoff );
+  pVerRes = (VXD_VERSION_RESOURCE *) ( (ULONG_PTR) pView
+       + pLEHdr->e32_winresoff );
   dwSize = pVerRes->dwResSize;
   pRawRes = &(pVerRes->bVerData);
 

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tony Theodore <tonyt@logyst.com>
Date: Thu, 9 May 2013 13:08:59 +1000
Subject: [PATCH] i686-w64-mingw32 fixes


diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp
index 1111111..2222222 100755
--- a/Contrib/InstallOptions/InstallerOptions.cpp
+++ b/Contrib/InstallOptions/InstallerOptions.cpp
@@ -13,6 +13,7 @@
 #include <cderr.h>
 #include "resource.h"
 #include "shellapi.h"
+#include <algorithm>
 
 #include <nsis/pluginapi.h> // nsis plugin
 
@@ -759,7 +760,7 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
       DrawText(lpdis->hDC, pField->pszText, -1, &rc, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT);
 
       // Make some more room so the focus rect won't cut letters off
-      rc.right = min(rc.right + 2, lpdis->rcItem.right);
+      rc.right = std::min(rc.right + 2, lpdis->rcItem.right);
 
       // Move rect to right if in RTL mode
       if (bRTL)
diff --git a/Contrib/Makensisw/afxres.h b/Contrib/Makensisw/afxres.h
index 1111111..2222222 100755
--- a/Contrib/Makensisw/afxres.h
+++ b/Contrib/Makensisw/afxres.h
@@ -1,4 +1,4 @@
-#define _WIN32_IE 0x0400
+#define _WIN32_IE 0x0501
 #include <windows.h>
 
 #ifndef IDC_STATIC
diff --git a/Contrib/Makensisw/makensisw.h b/Contrib/Makensisw/makensisw.h
index 1111111..2222222 100755
--- a/Contrib/Makensisw/makensisw.h
+++ b/Contrib/Makensisw/makensisw.h
@@ -22,7 +22,7 @@
 #ifndef MAKENSIS_H
 #define MAKENSIS_H
 
-#define _WIN32_IE 0x0400
+#define _WIN32_IE 0x0501
 #include <windows.h>
 #include <commctrl.h>
 #include "utils.h"
diff --git a/Source/SConscript b/Source/SConscript
index 1111111..2222222 100755
--- a/Source/SConscript
+++ b/Source/SConscript
@@ -71,7 +71,7 @@ AddAvailableLibs(env, libs)
 
 ##### Defines
 
-env.Append(CPPDEFINES = ['_WIN32_IE=0x0500'])
+env.Append(CPPDEFINES = ['_WIN32_IE=0x0501'])
 
 ##### Set PCH
 
diff --git a/Source/exehead/SConscript b/Source/exehead/SConscript
index 1111111..2222222 100755
--- a/Source/exehead/SConscript
+++ b/Source/exehead/SConscript
@@ -52,7 +52,7 @@ Import('env compression solid_compression')
 
 env.Append(CPPDEFINES = ['EXEHEAD'])
 env.Append(CPPDEFINES = ['WIN32_LEAN_AND_MEAN'])
-env.Append(CPPDEFINES = ['_WIN32_IE=0x0500'])
+env.Append(CPPDEFINES = ['_WIN32_IE=0x0501'])
 
 ### Some other settings
 

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Boris Pek <tehnick-8@yandex.ru>
Date: Fri, 6 May 2016 15:56:21 +0300
Subject: [PATCH] fix build for x86_64-w64-mingw32 targets


diff --git a/Contrib/BgImage/BgImage.cpp b/Contrib/BgImage/BgImage.cpp
index 1111111..2222222 100755
--- a/Contrib/BgImage/BgImage.cpp
+++ b/Contrib/BgImage/BgImage.cpp
@@ -149,7 +149,7 @@ NSISFunc(SetBg) {
       return;
     }
 
-    oldProc = (void *)SetWindowLong(hwndParent, GWL_WNDPROC, (long)WndProc);
+    oldProc = (void *)SetWindowLongPtr(hwndParent, GWLP_WNDPROC, (long long)WndProc);
   }
 
   bgBitmap.bReady = FALSE;
@@ -345,7 +345,7 @@ NSISFunc(Clear) {
 NSISFunc(Destroy) {
   bgBitmap.bReady = FALSE;
   if (IsWindow(hwndParent) && oldProc)
-    SetWindowLong(hwndParent, GWL_WNDPROC, (long)oldProc);
+    SetWindowLongPtr(hwndParent, GWLP_WNDPROC, (long long)oldProc);
   if (IsWindow(hWndImage))
     SendMessage(hWndImage, WM_CLOSE, 0, 0);
   hWndImage = 0;
diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp
index 1111111..2222222 100755
--- a/Contrib/InstallOptions/InstallerOptions.cpp
+++ b/Contrib/InstallOptions/InstallerOptions.cpp
@@ -772,7 +772,7 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
       if (lpdis->itemAction & ODA_DRAWENTIRE)
       {
         // Get TxtColor unless the user has set another using SetCtlColors
-        if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA))
+        if (!GetWindowLongPtr(lpdis->hwndItem, GWLP_USERDATA))
           SetTextColor(lpdis->hDC, (COLORREF) pField->hImage);
 
         // Draw the text
@@ -1217,8 +1217,8 @@ int WINAPI createCfgDlg()
           mySendMessage(hwCtrl, EM_LIMITTEXT, (WPARAM)pField->nMaxLength, (LPARAM)0);
           if (dwStyle & ES_NUMBER)
           {
-            pField->wndProc = GetWindowLong(hwCtrl, GWL_WNDPROC);
-            SetWindowLong(hwCtrl, GWL_WNDPROC, (long) NumbersOnlyPasteWndProc);
+            pField->wndProc = GetWindowLongPtr(hwCtrl, GWLP_WNDPROC);
+            SetWindowLongPtr(hwCtrl, GWLP_WNDPROC, (long) NumbersOnlyPasteWndProc);
           }
           break;
 
@@ -1400,7 +1400,7 @@ int WINAPI createCfgDlg()
 
 #ifdef IO_ENABLE_LINK
         case FIELD_LINK:
-          pField->nParentIdx = SetWindowLong(hwCtrl, GWL_WNDPROC, (long)StaticLINKWindowProc);
+          pField->nParentIdx = SetWindowLongPtr(hwCtrl, GWLP_WNDPROC, (long)StaticLINKWindowProc);
           break;
 #endif
       }
@@ -1438,7 +1438,7 @@ int WINAPI createCfgDlg()
 
 void WINAPI showCfgDlg()
 {
-  lpWndProcOld = (void *) SetWindowLong(hMainWindow,DWL_DLGPROC,(long)ParentWndProc);
+  lpWndProcOld = (void *) SetWindowLongPtr(hMainWindow,DWLP_DLGPROC,(long)ParentWndProc);
 
   // Tell NSIS to remove old inner dialog and pass handle of the new inner dialog
   mySendMessage(hMainWindow, WM_NOTIFY_CUSTOM_READY, (WPARAM)hConfigWindow, 0);
@@ -1460,7 +1460,7 @@ void WINAPI showCfgDlg()
   // quit soon, which means the ini might get flushed late and cause crap. :) anwyay.
   if (!g_is_cancel) SaveSettings();
 
-  SetWindowLong(hMainWindow,DWL_DLGPROC,(long)lpWndProcOld);
+  SetWindowLongPtr(hMainWindow,DWLP_DLGPROC,(long)lpWndProcOld);
   DestroyWindow(hConfigWindow);
 
   // by ORTIM: 13-August-2002
diff --git a/Contrib/Makensisw/makensisw.cpp b/Contrib/Makensisw/makensisw.cpp
index 1111111..2222222 100755
--- a/Contrib/Makensisw/makensisw.cpp
+++ b/Contrib/Makensisw/makensisw.cpp
@@ -177,7 +177,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
     {
       g_sdata.hwnd=hwndDlg;
       HICON hIcon = LoadIcon(g_sdata.hInstance,MAKEINTRESOURCE(IDI_ICON));
-      SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
+      SetClassLongPtr(hwndDlg,GCLP_HICON,(long)hIcon);
       // Altered by Darren Owen (DrO) on 29/9/2003
       // Added in receiving of mouse and key events from the richedit control
       SendMessage(GetDlgItem(hwndDlg,IDC_LOGWIN),EM_SETEVENTMASK,(WPARAM)NULL,ENM_SELCHANGE|ENM_MOUSEEVENTS|ENM_KEYEVENTS);
@@ -272,7 +272,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
     case WM_ENTERSIZEMOVE:
     {
       GetClientRect(g_sdata.hwnd, &g_resize.resizeRect);
-      return TRUE;
+      return TRUE;
     }
     case WM_SIZE:
     {
diff --git a/Contrib/NSISdl/nsisdl.cpp b/Contrib/NSISdl/nsisdl.cpp
index 1111111..2222222 100755
--- a/Contrib/NSISdl/nsisdl.cpp
+++ b/Contrib/NSISdl/nsisdl.cpp
@@ -344,7 +344,7 @@ __declspec(dllexport) void download (HWND   parent,
     {
       uMsgCreate = RegisterWindowMessage("nsisdl create");
 
-      lpWndProcOld = (void *)SetWindowLong(parent,GWL_WNDPROC,(long)ParentWndProc);
+      lpWndProcOld = (void *)SetWindowLongPtr(parent,GWLP_WNDPROC,(long)ParentWndProc);
 
       SendMessage(parent, uMsgCreate, TRUE, (LPARAM) parent);
 
@@ -418,7 +418,7 @@ __declspec(dllexport) void download (HWND   parent,
           if (parent)
           {
             SendMessage(parent, uMsgCreate, FALSE, (LPARAM) parent);
-            SetWindowLong(parent, GWL_WNDPROC, (long)lpWndProcOld);
+            SetWindowLongPtr(parent, GWLP_WNDPROC, (long)lpWndProcOld);
           }
           break;
         }
diff --git a/Contrib/StartMenu/StartMenu.c b/Contrib/StartMenu/StartMenu.c
index 1111111..2222222 100755
--- a/Contrib/StartMenu/StartMenu.c
+++ b/Contrib/StartMenu/StartMenu.c
@@ -120,7 +120,7 @@ void __declspec(dllexport) Init(HWND hwndParent, int string_size, char *variable
     }
     else
     {
-      lpWndProcOld = (void *) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentWndProc);
+      lpWndProcOld = (void *) SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (long) ParentWndProc);
       wsprintf(buf, "%u", hwStartMenuSelect);
       pushstring(buf);
     }
@@ -145,7 +145,7 @@ void __declspec(dllexport) Show(HWND hwndParent, int string_size, char *variable
   }
   DestroyWindow(hwStartMenuSelect);
 
-  SetWindowLong(hwndParent, DWL_DLGPROC, (long) lpWndProcOld);
+  SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (long) lpWndProcOld);
 }
 
 void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c
index 1111111..2222222 100755
--- a/Contrib/nsDialogs/nsDialogs.c
+++ b/Contrib/nsDialogs/nsDialogs.c
@@ -194,7 +194,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
           xtraDrawStyle |= DT_HIDEPREFIX;
 
         // Use blue unless the user has set another using SetCtlColors
-        if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA))
+        if (!GetWindowLongPtr(lpdis->hwndItem, GWLP_USERDATA))
           SetTextColor(lpdis->hDC, RGB(0,0,255));
 
         // Draw the text
@@ -276,7 +276,7 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variab
     SWP_NOZORDER | SWP_NOACTIVATE
   );
 
-  g_dialog.parentOriginalWndproc = (WNDPROC) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentProc);
+  g_dialog.parentOriginalWndproc = (WNDPROC) SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (long) ParentProc);
 
   g_dialog.rtl = FALSE;
 
@@ -387,7 +387,7 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
   // set the WndProc for the link control
 
   if(g_dialog.controls[id].type == NSCTL_LINK)
-    g_dialog.controls[id].oldWndProc = (WNDPROC) SetWindowLong(hwItem, GWL_WNDPROC, (long) LinkWndProc);
+    g_dialog.controls[id].oldWndProc = (WNDPROC) SetWindowLongPtr(hwItem, GWLP_WNDPROC, (long) LinkWndProc);
 
   // push back result
 
@@ -588,7 +588,7 @@ void __declspec(dllexport) Show(HWND hwndParent, int string_size, char *variable
 
   // reset wndproc
 
-  SetWindowLong(hwndParent, DWL_DLGPROC, (long) g_dialog.parentOriginalWndproc);
+  SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (long) g_dialog.parentOriginalWndproc);
 }
 
 BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
diff --git a/Contrib/zip2exe/main.cpp b/Contrib/zip2exe/main.cpp
index 1111111..2222222 100755
--- a/Contrib/zip2exe/main.cpp
+++ b/Contrib/zip2exe/main.cpp
@@ -633,7 +633,7 @@ BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
       SetDlgItemText(hwndDlg,IDC_INSTPATH,gp_poi);
 
       hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON1));
-      SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
+      SetClassLongPtr(hwndDlg,GCLP_HICON,(long)hIcon);
 
       hFont=CreateFont(15,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,
               OUT_CHARACTER_PRECIS,
diff --git a/SCons/Config/gnu b/SCons/Config/gnu
index 1111111..2222222 100755
--- a/SCons/Config/gnu
+++ b/SCons/Config/gnu
@@ -73,6 +73,7 @@ if not defenv['DEBUG']:
 stub_env.Append(CCFLAGS = ['-Wall'])                # all warnings
 stub_env.Append(CCFLAGS = ['-xc'])                  # force compile as c
 stub_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing
+stub_env.Append(CCFLAGS = ['-fpermissive'])         # ignore invalid conversion errors (since C++11)
 
 if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_W32']:
 	stub_env.Append(LINKFLAGS = ['-s'])               # strip
@@ -109,6 +110,7 @@ if not defenv['DEBUG']:
 	plugin_env.Append(CCFLAGS = ['-Os'])              # optimize for size
 plugin_env.Append(CCFLAGS = ['-Wall'])              # level 3 warnings
 plugin_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing
+plugin_env.Append(CCFLAGS = ['-fpermissive'])         # ignore invalid conversion errors (since C++11)
 
 if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_W32']:
 	plugin_env.Append(LINKFLAGS = ['-s'])             # strip
@@ -126,6 +128,7 @@ if not defenv['DEBUG']:
 	cp_util_env.Append(CCFLAGS = ['-O2'])             # optimize
 cp_util_env.Append(CCFLAGS = ['-Wall'])             # all warnings
 cp_util_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing
+cp_util_env.Append(CCFLAGS = ['-fpermissive'])         # ignore invalid conversion errors (since C++11)
 
 conf = FlagsConfigure(cp_util_env)
 conf.CheckLinkFlag('$MAP_FLAG')                   # generate map file
diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c
index 1111111..2222222 100755
--- a/Source/exehead/Ui.c
+++ b/Source/exehead/Ui.c
@@ -121,7 +121,7 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara
 {
   if ((uMsg - WM_CTLCOLOREDIT) <= (WM_CTLCOLORSTATIC - WM_CTLCOLOREDIT))
   {
-    ctlcolors *c = (ctlcolors *)GetWindowLong((HWND)lParam, GWL_USERDATA);
+    ctlcolors *c = (ctlcolors *)GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
 
     if (c) {
       COLORREF text;
@@ -482,7 +482,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
       m_hwndOK=GetDlgItem(hwndDlg,IDOK);
       m_hwndCancel=GetDlgItem(hwndDlg,IDCANCEL);
       SetDlgItemTextFromLang(hwndDlg,IDC_VERSTR,LANG_BRANDING);
-      SetClassLong(hwndDlg,GCL_HICON,(long)g_hIcon);
+      SetClassLongPtr(hwndDlg,GCLP_HICON,(long)g_hIcon);
       // use the following line instead of the above, if .rdata needs shirking
       //SendMessage(hwndDlg,WM_SETICON,ICON_BIG,(LPARAM)g_hIcon);
 #if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
@@ -647,7 +647,7 @@ skipPage:
   }
   if (uMsg == WM_QUERYENDSESSION)
   {
-    SetWindowLong(hwndDlg, DWL_MSGRESULT, FALSE);
+    SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, FALSE);
     return TRUE;
   }
   if (uMsg == WM_COMMAND)
@@ -1290,7 +1290,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
     hBMcheck1=LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
 
     last_selected_tree_item=-1;
-    oldTreeWndProc=SetWindowLong(hwndTree1,GWL_WNDPROC,(long)newTreeWndProc);
+    oldTreeWndProc=SetWindowLongPtr(hwndTree1,GWLP_WNDPROC,(long)newTreeWndProc);
 
     hImageList = ImageList_Create(16,16, ILC_COLOR32|ILC_MASK, 6, 0);
     ImageList_AddMasked(hImageList,hBMcheck1,RGB(255,0,255));
diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c
index 1111111..2222222 100755
--- a/Source/exehead/exec.c
+++ b/Source/exehead/exec.c
@@ -788,7 +788,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
     case EW_SETCTLCOLORS:
     {
       ctlcolors *c = (ctlcolors *)(g_blocks[NB_CTLCOLORS].offset + parm1);
-      SetWindowLong((HWND) GetIntFromParm(0), GWL_USERDATA, (long) c);
+      SetWindowLongPtr((HWND) GetIntFromParm(0), GWLP_USERDATA, (long) c);
     }
     break;
     case EW_SETBRANDINGIMAGE:

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Boris Pek <tehnick-8@yandex.ru>
Date: Mon, 16 May 2016 15:12:58 +0300
Subject: [PATCH] Fix stdcall

Taken from:
http://anonscm.debian.org/gitweb/?p=collab-maint/nsis.git;a=blob;f=debian/patches/stdcall.patch;h=46b497e3a48a145afba97644390ac2e026225e89;hb=HEAD

diff --git a/SCons/Config/gnu b/SCons/Config/gnu
index 1111111..2222222 100755
--- a/SCons/Config/gnu
+++ b/SCons/Config/gnu
@@ -9,6 +9,14 @@ Import('FlagsConfigure')
 ### cross compiling
 
 def cross_env(env):
+	# Set stdcall calling convention for Win32 targets
+	if env.has_key('CPPDEFINES'):
+		for i in range(len(env['CPPDEFINES'])):
+			if 'NSISCALL' in env['CPPDEFINES'][i]:
+				env['CPPDEFINES'][i] = ('NSISCALL', '\'$STDCALL\'')
+				break
+	else:
+		env.Append(CPPDEFINES = [('NSISCALL', '$STDCALL')])
 	if env['PLATFORM'] != 'win32':
 		env.Tool('crossmingw', toolpath = [Dir('../Tools').rdir()])
 
@@ -35,7 +43,7 @@ defenv['STDCALL'] = '__attribute__((__stdcall__))'
 
 ### defines
 
-defenv.Append(CPPDEFINES = [('NSISCALL', '$STDCALL')])
+defenv.Append(CPPDEFINES = [('NSISCALL', '')])
 
 ### helper functions