Browse Source

Windows: build fixes and it is now a 64 bit application.

See https://bugs.unrealircd.org/view.php?id=5320
Expect several more major fixes/changes to follow...
pull/1/head
Bram Matthys 3 years ago
parent
commit
bcceea9065
No known key found for this signature in database
GPG Key ID: BF8116B163EAAE98
  1. 12
      Makefile.windows
  2. 7
      include/windows/setup.h
  3. 4
      src/windows/UnrealIRCd.exe.manifest
  4. 2
      src/windows/editor.c
  5. 8
      src/windows/gui.c
  6. 29
      src/windows/unrealinst.iss
  7. 108
      src/windows/windebug.c

12
Makefile.windows

@ -127,16 +127,16 @@ MODDBGCFLAG=/LDd /MD /Zi
FD_SETSIZE=/D FD_SETSIZE=16384
CFLAGS=$(DBGCFLAG) $(PCRE2_INC) $(ARGON2_INC) $(CARES_INC) $(LIBCURL_INC) $(LIBRESSL_INC) /J /I ./INCLUDE /Fosrc/ /nologo \
$(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) /D NOSPOOF=1 /c /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
$(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) /D NOSPOOF=1 /c /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
CFLAGSST=$(DBGCFLAGST) $(PCRE2_INC) $(ARGON2_INC) $(CARES_INC) $(LIBCURL_INC) $(LIBRESSL_INC) /J /I ./INCLUDE /Fosrc/ /nologo \
$(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) /D NOSPOOF=1 /c /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
$(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) /D NOSPOOF=1 /c /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
LFLAGS=kernel32.lib user32.lib gdi32.lib shell32.lib ws2_32.lib advapi32.lib \
dbghelp.lib oldnames.lib comctl32.lib comdlg32.lib $(CARES_LIB) $(CARESLIB) \
$(PCRE2_LIB) $(PCRE2LIB) $(ARGON2_LIB) $(ARGON2LIB) $(LIBRESSL_LIB) $(SSLLIB) $(LIBCURL_LIB) $(CURLLIB) /def:UnrealIRCd.def /implib:UnrealIRCd.lib \
/nologo $(DBGLFLAG) /out:UnrealIRCd.exe
MODCFLAGS=$(MODDBGCFLAG) $(SSLCFLAGS) $(CURLCFLAGS) /J /Fesrc/modules/ \
/Fosrc/modules/ /nologo $(PCRE2_INC) $(ARGON2_INC) $(CARES_INC) $(LIBCURL_INC) $(LIBRESSL_INC) /I ./INCLUDE /D \
DYNAMIC_LINKING /D NOSPOOF /D MODULE_COMPILE /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
DYNAMIC_LINKING /D NOSPOOF /D MODULE_COMPILE /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
MODLFLAGS=/link /def:src/modules/module.def UnrealIRCd.lib ws2_32.lib \
$(PCRE2_LIB) $(PCRE2LIB) $(ARGON2_LIB) $(ARGON2LIB) $(CARES_LIB) $(LIBRESSL_LIB) $(SSLLIB) \
$(LIBCURL_LIB) $(CURLLIB)
@ -282,7 +282,8 @@ DLL_FILES=SRC/MODULES/CHGHOST.DLL SRC/MODULES/SDESC.DLL SRC/MODULES/SETIDENT.DLL
SRC/MODULES/HISTORY_BACKEND_MEM.DLL \
SRC/MODULES/HISTORY_BACKEND_NULL.DLL \
SRC/MODULES/RESTRICT-COMMANDS.DLL \
SRC/MODULES/RMTKL.DLL
SRC/MODULES/RMTKL.DLL \
SRC/MODULES/ECHO-MESSAGE.DLL
ALL: CONF UNREALSVC.EXE UnrealIRCd.exe MODULES
@ -1053,4 +1054,7 @@ src/modules/restrict-commands.dll: src/modules/restrict-commands.c $(INCLUDES)
src/modules/rmtkl.dll: src/modules/rmtkl.c $(INCLUDES)
$(CC) $(MODCFLAGS) /Fosrc/modules/ /Fesrc/modules/ src/modules/rmtkl.c $(MODLFLAGS)
src/modules/echo-message.dll: src/modules/echo-message.c $(INCLUDES)
$(CC) $(MODCFLAGS) /Fosrc/modules/ /Fesrc/modules/ src/modules/echo-message.c $(MODLFLAGS)
dummy:

7
include/windows/setup.h

@ -71,13 +71,6 @@
#define mode_t int
#endif
/*
make up for win32 (and win64?) users not being able to run ./configure.
*/
#ifndef intptr_t
#define intptr_t long
#endif
/* Generation version number (e.g.: 3 for Unreal3*) */
#define UNREAL_VERSION_GENERATION 5

4
src/windows/UnrealIRCd.exe.manifest

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
processorArchitecture="X86"
processorArchitecture="amd64"
name="UnrealIRCd.UnrealIRCd.5"
version="5.0.0.0"
type="win32"
@ -13,7 +13,7 @@
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
processorArchitecture="amd64"
publicKeyToken="6595b64144ccf1df"
language="*"
/>

2
src/windows/editor.c

@ -342,7 +342,7 @@ LRESULT CALLBACK FromFileDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
else
strcpy(szText, "UnrealIRCd Editor - New File");
SetWindowText(hDlg, szText);
lpfnOldWndProc = (FARPROC)SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)RESubClassFunc);
lpfnOldWndProc = (FARPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)RESubClassFunc);
hTool = DrawToolbar(hInst, hDlg);
hStatus = DrawStatusbar(hInst, hDlg, IDC_STATUS);
SendMessage(hWnd, EM_SETEVENTMASK, 0, (LPARAM)ENM_SELCHANGE);

8
src/windows/gui.c

@ -682,7 +682,7 @@ LRESULT CALLBACK FromVarDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPara
EDITSTREAM edit;
SetWindowText(hDlg, title);
bzero(String, sizeof(String));
lpfnOldWndProc = (FARPROC)SetWindowLong(GetDlgItem(hDlg, IDC_TEXT), GWL_WNDPROC, (DWORD)RESubClassFunc);
lpfnOldWndProc = (FARPROC)SetWindowLongPtr(GetDlgItem(hDlg, IDC_TEXT), GWLP_WNDPROC, (LONG_PTR)RESubClassFunc);
while (*s)
{
strcat(String, *s++);
@ -766,7 +766,7 @@ LRESULT CALLBACK FromFileReadDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM
HWND hWnd = GetDlgItem(hDlg, IDC_TEXT), hTip;
StringCbPrintf(szText, sizeof(szText), "UnrealIRCd Viewer - %s", (unsigned char *)lParam);
SetWindowText(hDlg, szText);
lpfnOldWndProc = (FARPROC)SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)RESubClassFunc);
lpfnOldWndProc = (FARPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)RESubClassFunc);
if ((fd = open((unsigned char *)lParam, _O_RDONLY|_O_BINARY)) != -1)
{
fstat(fd,&sb);
@ -851,8 +851,8 @@ LRESULT CALLBACK HelpDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
hFont = CreateFont(8,0,0,0,0,0,1,0,ANSI_CHARSET,0,0,PROOF_QUALITY,0,"MS Sans Serif");
SendMessage(GetDlgItem(hDlg, IDC_EMAIL), WM_SETFONT, (WPARAM)hFont,TRUE);
SendMessage(GetDlgItem(hDlg, IDC_URL), WM_SETFONT, (WPARAM)hFont,TRUE);
lpfnOldWndProc = (FARPROC)SetWindowLong(GetDlgItem(hDlg, IDC_EMAIL), GWL_WNDPROC, (DWORD)LinkSubClassFunc);
SetWindowLong(GetDlgItem(hDlg, IDC_URL), GWL_WNDPROC, (DWORD)LinkSubClassFunc);
lpfnOldWndProc = (FARPROC)SetWindowLongPtr(GetDlgItem(hDlg, IDC_EMAIL), GWLP_WNDPROC, (LONG_PTR)LinkSubClassFunc);
SetWindowLongPtr(GetDlgItem(hDlg, IDC_URL), GWLP_WNDPROC, (LONG_PTR)LinkSubClassFunc);
return TRUE;
case WM_DRAWITEM:

29
src/windows/unrealinst.iss

@ -13,7 +13,7 @@ AppSupportURL=https://www.unrealircd.org
AppUpdatesURL=https://www.unrealircd.org
AppMutex=UnrealMutex,Global\UnrealMutex
DefaultDirName={pf}\UnrealIRCd 5
DefaultGroupName=UnrealIRCd
DefaultGroupName=UnrealIRCd 5
AllowNoIcons=yes
LicenseFile=src\windows\gplplusssl.rtf
Compression=lzma
@ -23,6 +23,8 @@ OutputDir=.
SourceDir=../../
UninstallDisplayIcon={app}\UnrealIRCd.exe
DisableWelcomePage=no
ArchitecturesInstallIn64BitMode=x64
ArchitecturesAllowed=x64
; !!! Make sure to update SSL/TLS validation (WizardForm.TasksList.Checked[9]) if tasks are added/removed !!!
[Tasks]
@ -67,16 +69,15 @@ Source: "src\modules\usermodes\*.dll"; DestDir: "{app}\modules\usermodes"; Flags
Source: "src\modules\snomasks\*.dll"; DestDir: "{app}\modules\snomasks"; Flags: ignoreversion
Source: "src\modules\extbans\*.dll"; DestDir: "{app}\modules\extbans"; Flags: ignoreversion
Source: "c:\dev\pcre2\bin\pcre*.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\argon2\vs2015\build\*.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\c-ares\msvc\cares\dll-release\cares.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\libressl\bin\openssl.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\libressl\bin\*.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\setacl.exe"; DestDir: "{app}\tmp"; Flags: ignoreversion
Source: "c:\dev\unrealircd-5-libs\pcre2\bin\pcre*.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\unrealircd-5-libs\argon2\vs2015\build\*.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\unrealircd-5-libs\c-ares\msvc\cares\dll-release\cares.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\unrealircd-5-libs\libressl\bin\openssl.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\unrealircd-5-libs\libressl\bin\*.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\unrealircd-5-libs\setacl.exe"; DestDir: "{app}\tmp"; Flags: ignoreversion
#ifdef USE_CURL
; curl with SSL/TLS support
Source: "C:\dev\curl-ssl\builds\libcurl-vc-x86-release-dll-ssl-dll-ipv6-sspi-obj-lib\libcurl.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\dev\unrealircd-5-libs\curl\builds\libcurl-vc-x64-release-dll-ssl-dll-cares-dll-ipv6-obj-lib\libcurl.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "doc\conf\tls\curl-ca-bundle.crt"; DestDir: "{app}\conf\tls"; Flags: ignoreversion
#endif
@ -105,16 +106,16 @@ var
major: Cardinal;
begin
Result := true;
if Not RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Major', major) then
if Not RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\16.0\VC\Runtimes\x64', 'Major', major) then
begin
MsgBox('UnrealIRCd requires the Microsoft Visual C++ Redistributable for Visual Studio 2017 to be installed.' #13 +
MsgBox('UnrealIRCd requires the Microsoft Visual C++ Redistributable for Visual Studio 2019 to be installed.' #13 +
'After you click OK you will be taken to a download page from Microsoft:' #13 +
'1) Scroll down to the "Visual Studio 2017" section' #13 +
'2) Click on the x86 "vc_redist.x86.exe" to download the installer' #13 +
'1) Scroll down to the section "Visual Studio 2015, 2017 and 2019"' #13 +
'2) Click on the x64 "vc_redist.x64.exe" to download the 64 bit installer' #13 +
'3) Run the installer.' #13 + #13 +
'If you are already absolutely sure that you have this package installed then you can skip this step.', mbInformation, MB_OK);
ShellExec('open', 'https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads', '', '', SW_SHOWNORMAL,ewNoWait,ErrorCode);
MsgBox('Your browser was launched. After you have installed the Microsoft Visual C++ Redistributable for Visual Studio 2017 (vc_redist.x86.exe), click OK below to continue the UnrealIRCd installer', mbInformation, MB_OK);
MsgBox('Your browser was launched. After you have installed the Microsoft Visual C++ Redistributable for Visual Studio 2019 (vc_redist.x64.exe), click OK below to continue the UnrealIRCd installer', mbInformation, MB_OK);
end;
end;

108
src/windows/windebug.c

@ -57,39 +57,39 @@ __inline char *StackTrace(EXCEPTION_POINTERS *e)
{
static char buffer[5000];
char curmodule[256];
DWORD symOptions, dwDisp, frame;
DWORD symOptions;
DWORD64 dwDisp;
DWORD dwDisp32;
int frame;
HANDLE hProcess = GetCurrentProcess();
IMAGEHLP_SYMBOL *pSym = MyMallocEx(sizeof(IMAGEHLP_SYMBOL)+500);
IMAGEHLP_LINE pLine;
IMAGEHLP_MODULE pMod;
STACKFRAME Stack;
IMAGEHLP_SYMBOL64 *pSym = MyMallocEx(sizeof(IMAGEHLP_SYMBOL64)+500);
IMAGEHLP_LINE64 pLine;
IMAGEHLP_MODULE64 pMod;
STACKFRAME64 Stack;
CONTEXT context;
memcpy(&context, e->ContextRecord, sizeof(CONTEXT));
/* Load the stack information */
memset(&Stack, 0, sizeof(Stack));
Stack.AddrPC.Offset = e->ContextRecord->Eip;
Stack.AddrPC.Offset = e->ContextRecord->Rip;
Stack.AddrPC.Mode = AddrModeFlat;
Stack.AddrFrame.Offset = e->ContextRecord->Ebp;
Stack.AddrFrame.Offset = e->ContextRecord->Rbp;
Stack.AddrFrame.Mode = AddrModeFlat;
Stack.AddrStack.Offset = e->ContextRecord->Esp;
Stack.AddrStack.Offset = e->ContextRecord->Rsp;
Stack.AddrStack.Mode = AddrModeFlat;
if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
hProcess = (HANDLE)GetCurrentProcessId();
else
hProcess = GetCurrentProcess();
hProcess = GetCurrentProcess();
/* Initialize symbol retrieval system */
SymInitialize(hProcess, NULL, TRUE);
SymSetOptions(SYMOPT_LOAD_LINES|SYMOPT_UNDNAME);
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
pSym->MaxNameLength = 500;
/* Retrieve the first module name */
bzero(&pMod, sizeof(IMAGEHLP_MODULE));
pMod.SizeOfStruct = sizeof(IMAGEHLP_MODULE);
SymGetModuleInfo(hProcess, Stack.AddrPC.Offset, &pMod);
bzero(&pMod, sizeof(IMAGEHLP_MODULE64));
pMod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
SymGetModuleInfo64(hProcess, Stack.AddrPC.Offset, &pMod);
strcpy(curmodule, pMod.ModuleName);
sprintf(buffer, "\tModule: %s\n", pMod.ModuleName);
@ -97,13 +97,13 @@ __inline char *StackTrace(EXCEPTION_POINTERS *e)
for (frame = 0; ; frame++)
{
char buf[500];
if (!StackWalk(IMAGE_FILE_MACHINE_I386, GetCurrentProcess(), GetCurrentThread(),
&Stack, &context, NULL, SymFunctionTableAccess, SymGetModuleBase, NULL))
if (!StackWalk64(IMAGE_FILE_MACHINE_AMD64, GetCurrentProcess(), GetCurrentThread(),
&Stack, &context, NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL))
break;
bzero(&pMod, sizeof(IMAGEHLP_MODULE));
pMod.SizeOfStruct = sizeof(IMAGEHLP_MODULE);
SymGetModuleInfo(hProcess, Stack.AddrPC.Offset, &pMod);
bzero(&pMod, sizeof(IMAGEHLP_MODULE64));
pMod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
SymGetModuleInfo64(hProcess, Stack.AddrPC.Offset, &pMod);
if (strcmp(curmodule, pMod.ModuleName))
{
strcpy(curmodule, pMod.ModuleName);
@ -111,10 +111,10 @@ __inline char *StackTrace(EXCEPTION_POINTERS *e)
strcat(buffer, buf);
}
bzero(&pLine, sizeof(IMAGEHLP_LINE));
pLine.SizeOfStruct = sizeof(IMAGEHLP_LINE);
SymGetLineFromAddr(hProcess, Stack.AddrPC.Offset, &dwDisp, &pLine);
SymGetSymFromAddr(hProcess, Stack.AddrPC.Offset, &dwDisp, pSym);
bzero(&pLine, sizeof(IMAGEHLP_LINE64));
pLine.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
SymGetLineFromAddr64(hProcess, Stack.AddrPC.Offset, &dwDisp32, &pLine);
SymGetSymFromAddr64(hProcess, Stack.AddrPC.Offset, &dwDisp, pSym);
sprintf(buf, "\t\t#%d %s:%d: %s\n", frame, pLine.FileName, pLine.LineNumber,
pSym->Name);
strcat(buffer, buf);
@ -128,18 +128,48 @@ __inline char *StackTrace(EXCEPTION_POINTERS *e)
* Parameters:
* context - The CPU context
* Returns:
* The values of the EAX/EBX/ECX/EDX/ESI/EDI/EIP/EBP/ESP registers
* The values of the registers as a string.
*/
__inline char *GetRegisters(CONTEXT *context)
{
static char buffer[1024];
sprintf(buffer, "\tEAX=0x%08x EBX=0x%08x ECX=0x%08x\n"
"\tEDX=0x%08x ESI=0x%08x EDI=0x%08x\n"
"\tEIP=0x%08x EBP=0x%08x ESP=0x%08x\n",
context->Eax, context->Ebx, context->Ecx, context->Edx,
context->Esi, context->Edi, context->Eip, context->Ebp,
context->Esp);
sprintf(buffer,
"\tRAX=%p"
"\tRBX=%p"
"\tRCX=%p"
"\tRDX=%p\n"
"\tRSI=%p"
"\tRDI=%p"
"\tRBP=%p"
"\tRSP=%p\n"
"\tR8=%p"
"\tR9=%p"
"\tR10=%p"
"\tR11=%p\n"
"\tR12=%p"
"\tR13=%p"
"\tR14=%p"
"\tR15=%p\n"
"\tRIP=%p\n",
(void *)context->Rax,
(void *)context->Rbx,
(void *)context->Rcx,
(void *)context->Rdx,
(void *)context->Rsi,
(void *)context->Rdi,
(void *)context->Rbp,
(void *)context->Rsp,
(void *)context->R8,
(void *)context->R9,
(void *)context->R10,
(void *)context->R11,
(void *)context->R12,
(void *)context->R13,
(void *)context->R14,
(void *)context->R15,
(void *)context->Rip);
return buffer;
}
@ -240,7 +270,7 @@ void StartUnrealAgain(void)
*/
LONG __stdcall ExceptionFilter(EXCEPTION_POINTERS *e)
{
MEMORYSTATUS memStats;
MEMORYSTATUSEX memStats;
char file[512], text[1024], minidumpf[512];
FILE *fd;
time_t timet = time(NULL);
@ -251,20 +281,20 @@ LONG __stdcall ExceptionFilter(EXCEPTION_POINTERS *e)
sprintf(file, "unrealircd.%d.core", getpid());
fd = fopen(file, "w");
GlobalMemoryStatus(&memStats);
GlobalMemoryStatusEx(&memStats);
fprintf(fd, "Generated at %s\n%s (%d.%d.%d)\n%s[%s%s%s] (%s) on %s\n"
"-----------------\nMemory Information:\n"
"\tPhysical: (Available:%ldMB/Total:%ldMB)\n"
"\tVirtual: (Available:%ldMB/Total:%ldMB)\n"
"\tPhysical: (Available:%lluMB/Total:%lluMB)\n"
"\tVirtual: (Available:%lluMB/Total:%lluMB)\n"
"-----------------\nException:\n\t%s\n-----------------\n"
"Backup Buffer:\n\t%s\n-----------------\nRegisters:\n"
"%s-----------------\nStack Trace:\n%s",
asctime(gmtime(&timet)), OSName, VerInfo.dwMajorVersion,
VerInfo.dwMinorVersion, VerInfo.dwBuildNumber, IRCDTOTALVERSION,
serveropts, extraflags ? extraflags : "", tainted ? "3" : "",
buildid, me.name, memStats.dwAvailPhys/1048576, memStats.dwTotalPhys/1048576,
memStats.dwAvailVirtual/1048576, memStats.dwTotalVirtual/1048576,
GetException(e->ExceptionRecord->ExceptionCode), backupbuf,
buildid, me.name, memStats.ullAvailPhys/1048576, memStats.ullTotalPhys/1048576,
memStats.ullAvailVirtual/1048576, memStats.ullTotalVirtual/1048576,
GetException(e->ExceptionRecord->ExceptionCode), backupbuf,
GetRegisters(e->ContextRecord), StackTrace(e));
sprintf(text, "UnrealIRCd has encountered a fatal error. Debugging information has been dumped to %s.", file);

Loading…
Cancel
Save