File build-with-mingw-on-Linux.patch of Package mingw32-cross-nsis-plugin-uac

From e1178aec4453b9c8dee4fe8ccfd70d67352689a7 Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <daniel@molkentin.de>
Date: Wed, 11 Mar 2015 01:09:00 +0000
Subject: [PATCH] Build with mingw on Linux

---
 Makefile               | 21 +++++++++++++++++++++
 NSIS_CUSTOMPISDK.h     |  2 +-
 RunAs.cpp              |  8 +++++---
 merge_rdata_and_text.x |  7 +++++++
 platform.h             |  6 +++---
 uac.cpp                |  2 +-
 uac.h                  |  4 ++--
 7 files changed, 40 insertions(+), 10 deletions(-)
 create mode 100644 Makefile
 create mode 100644 merge_rdata_and_text.x

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..489324c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,21 @@
+CXX = i686-w64-mingw32-g++
+WINDRES = i686-w64-mingw32-windres
+OBJ = RunAs.o uac.o util.o resource.o
+LIBS = -lkernel32 -luser32 -lole32 -ladvapi32 -lshell32 -lmsvcrt
+LDFLAGS = -v -nostdlib -Wl,--subsystem,windows -Wl,merge_rdata_and_text.x -Wl,-Bsymbolic-functions -Wl,-S -mdll -Wl,-entry=__DllMainCRTStartup@12
+#LDFLAGS = -Wl,--export-all-symbols -nodefaultlibs -Wl,--subsystem,windows -Wl,-Bsymbolic-functions -Wl,--export-all-symbols
+#uncomment for unicode build
+CXXFLAGS = -fno-exceptions -fno-rtti #-DUNICODE -D_UNICODE
+
+UAC.dll: $(OBJ)
+	$(CXX) -o $@ $(OBJ) $(LIBS) $(LDFLAGS)
+
+%.o: %.cpp
+	$(CXX) $(CXXFLAGS) -Os -mwindows -c $<
+
+%.o: %.rc
+	$(WINDRES) $< $@
+
+
+clean:
+	rm -f *.o *.dll
diff --git a/NSIS_CUSTOMPISDK.h b/NSIS_CUSTOMPISDK.h
index 9d11c86..2a44144 100644
--- a/NSIS_CUSTOMPISDK.h
+++ b/NSIS_CUSTOMPISDK.h
@@ -1,7 +1,7 @@
 // Copyright (C) Anders Kjersem. Licensed under the zlib/libpng license, see License.txt for details.
 
 #pragma once
-#include <TChar.h>
+#include <tchar.h>
 
 
 typedef TCHAR NSISCH;
diff --git a/RunAs.cpp b/RunAs.cpp
index 99f73fd..99c28ab 100644
--- a/RunAs.cpp
+++ b/RunAs.cpp
@@ -11,10 +11,12 @@ extern GETUSERNAMEEX			_GetUserNameEx;
 extern CREATEPROCESSWITHLOGONW	_CreateProcessWithLogonW;
 
 
-#include <Lmcons.h>//UNLEN && GNLEN && PWLEN
-#include <WindowsX.h>
+#include <lmcons.h>//UNLEN && GNLEN && PWLEN
+#include <windowsx.h>
 #include "resource.h"
+
 using namespace NSIS;
+#define max(a,b) (((a) > (b)) ? (a) : (b))
 
 #define ERRAPP_TRYAGAIN (0x20000000|1)
 #define MYMAX_DOMAIN (2+max(GNLEN,MAX_COMPUTERNAME_LENGTH)+1)
@@ -313,4 +315,4 @@ extern "C" void __declspec(dllexport) __cdecl DBGRDMyRunAs(HWND hwnd,HINSTANCE h
 	VERIFY(!DelayLoadFunctions());
 	TRACEF("ec=%d\n",MyRunAs(GetModuleHandle(_T("UAC.dLl")),sei));
 }
-#endif
\ No newline at end of file
+#endif
diff --git a/merge_rdata_and_text.x b/merge_rdata_and_text.x
new file mode 100644
index 0000000..f8bf2b6
--- /dev/null
+++ b/merge_rdata_and_text.x
@@ -0,0 +1,7 @@
+SECTIONS {
+ .text : {
+  *(.text)
+  *(.rdata)
+  *(SORT(.rdata$*))
+}
+}
diff --git a/platform.h b/platform.h
index d54a86f..884d8a3 100644
--- a/platform.h
+++ b/platform.h
@@ -7,9 +7,9 @@
 #define _WIN32_WINNT 0x0501
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <ShellAPI.h>
-#include <TChar.h>
-#include <WindowsX.h>
+#include <shellapi.h>
+#include <tchar.h>
+#include <windowsx.h>
 
 #ifndef FORCEINLINE
 #define FORCEINLINE __forceinline
diff --git a/uac.cpp b/uac.cpp
index 76a8b74..f4ad8a2 100644
--- a/uac.cpp
+++ b/uac.cpp
@@ -215,7 +215,7 @@ void MSRunAsDlgMod_Init()
 
 FORCEINLINE void* DelayLoadFunction(HMODULE hLib,LPCSTR Export) 
 {
-	return GetProcAddress(hLib,Export);
+	return (void*) GetProcAddress(hLib,Export);
 }
 
 DWORD DelayLoadFunctions() 
diff --git a/uac.h b/uac.h
index 3a3b82b..2f32933 100644
--- a/uac.h
+++ b/uac.h
@@ -52,7 +52,7 @@ typedef BOOL	(WINAPI*CHANGEWINDOWMESSAGEFILTER)(UINT message,DWORD dwFlag);
 typedef BOOL	(WINAPI*GETUSERNAME)(LPTSTR lpBuffer,LPDWORD nSize);
 typedef BOOL	(WINAPI*CREATEPROCESSWITHLOGONW)(LPCWSTR lpUsername,LPCWSTR lpDomain,LPCWSTR lpPassword,DWORD dwLogonFlags,LPCWSTR lpApplicationName,LPWSTR lpCommandLine,DWORD dwCreationFlags,LPVOID pEnv,LPCWSTR WorkDir,LPSTARTUPINFOW pSI,LPPROCESS_INFORMATION pPI);
 #define SECURITY_WIN32
-#include <Security.h> //NameSamCompatible
+#include <security.h> //NameSamCompatible
 typedef BOOLEAN	(WINAPI*GETUSERNAMEEX)(EXTENDED_NAME_FORMAT NameFormat,LPTSTR lpNameBuffer,PULONG nSize);
 typedef DWORD	(WINAPI*SHGETVALUEA)(HKEY hKey,LPCSTR pszSubKey,LPCSTR pszValue,DWORD*pdwType,void*pvData,DWORD*pcbData);
 #endif
@@ -172,4 +172,4 @@ typedef struct {
 	WNDPROC OrgMainWndProc;
 	HWND hwndNSIS;
 #endif
-} UAC_GLOBALS;
\ No newline at end of file
+} UAC_GLOBALS;
-- 
2.1.2

openSUSE Build Service is sponsored by