mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 22:35:37 +03:00
Attempt to fix windows compilation (#555)
* Attempt to fix windows compilation * Testing mysql-c-connector
This commit is contained in:
parent
579a83c2a4
commit
9a2c586720
@ -12,10 +12,11 @@ install:
|
||||
- git clone https://github.com/alliedmodders/ambuild
|
||||
- git clone https://github.com/alliedmodders/metamod-hl1
|
||||
- git clone https://github.com/alliedmodders/hlsdk
|
||||
- ps: Start-FileDownload 'https://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.54-win32.zip'
|
||||
- 7z x mysql-5.5.54-win32.zip -o"mysql"
|
||||
- ps: Start-FileDownload 'https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.1-win32.zip'
|
||||
- 7z x mysql-connector-c-6.1.1-win32.zip -o"mysql"
|
||||
- cd mysql
|
||||
- ren mysql-5.5.54-win32 mysql-5.5
|
||||
- dir
|
||||
- ren mysql-connector-c-6.1.1-win32 mysql-5.5
|
||||
- move /Y mysql-5.5 ..\
|
||||
- cd ..\ambuild
|
||||
- c:\python27\python setup.py install
|
||||
@ -24,7 +25,7 @@ cache:
|
||||
- c:\projects\*.zip -> appveyor.yml
|
||||
- c:\projects\mysql-5.5 -> appveyor.yml
|
||||
build_script:
|
||||
- '"%VS120COMNTOOLS%\vsvars32.bat"'
|
||||
- '"%VS140COMNTOOLS%\vsvars32.bat"'
|
||||
- mkdir build
|
||||
- cd build
|
||||
- c:\python27\python ../configure.py --enable-optimize --nasm="C:\nasm\nasm-2.13.03\nasm.exe"
|
||||
|
@ -1,13 +1,86 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Fix from from https://stackoverflow.com/a/34655235.
|
||||
//
|
||||
// __iob_func required by the MySQL we use,
|
||||
// but no longer exists in the VS 14.0+ crt.
|
||||
|
||||
#pragma comment(lib, "DbgHelp.lib")
|
||||
#pragma warning(disable:4091) // 'typedef ': ignored on left of '' when no variable is declared
|
||||
#include <DbgHelp.h>
|
||||
#include <corecrt_wstdio.h>
|
||||
|
||||
#define GET_CURRENT_CONTEXT(c, contextFlags) \
|
||||
do { \
|
||||
c.ContextFlags = contextFlags; \
|
||||
__asm call x \
|
||||
__asm x: pop eax \
|
||||
__asm mov c.Eip, eax \
|
||||
__asm mov c.Ebp, ebp \
|
||||
__asm mov c.Esp, esp \
|
||||
} while(0);
|
||||
|
||||
|
||||
FILE * __cdecl __iob_func(void)
|
||||
{
|
||||
CONTEXT c = { 0 };
|
||||
STACKFRAME64 s = { 0 };
|
||||
DWORD imageType;
|
||||
HANDLE hThread = GetCurrentThread();
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
GET_CURRENT_CONTEXT(c, CONTEXT_FULL);
|
||||
|
||||
imageType = IMAGE_FILE_MACHINE_I386;
|
||||
s.AddrPC.Offset = c.Eip;
|
||||
s.AddrPC.Mode = AddrModeFlat;
|
||||
s.AddrFrame.Offset = c.Ebp;
|
||||
s.AddrFrame.Mode = AddrModeFlat;
|
||||
s.AddrStack.Offset = c.Esp;
|
||||
s.AddrStack.Mode = AddrModeFlat;
|
||||
|
||||
if (!StackWalk64(imageType, hProcess, hThread, &s, &c, NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (s.AddrReturn.Offset == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
{
|
||||
unsigned char const * assembly = (unsigned char const *)(s.AddrReturn.Offset);
|
||||
|
||||
if (*assembly == 0x83 && *(assembly + 1) == 0xC0 && (*(assembly + 2) == 0x20 || *(assembly + 2) == 0x40))
|
||||
{
|
||||
if (*(assembly + 2) == 32)
|
||||
{
|
||||
return (FILE*)((unsigned char *)stdout - 32);
|
||||
}
|
||||
if (*(assembly + 2) == 64)
|
||||
{
|
||||
return (FILE*)((unsigned char *)stderr - 64);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return stdin;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Adapted from dosmap.c in Visual Studio 12.0 CRT sources.
|
||||
//
|
||||
// The _dosmaperr function is required by the MySQL lib we use,
|
||||
// but no longer exists in the VS 14.0+ crt.
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static struct errentry
|
||||
{
|
||||
DWORD oscode; // OS return value
|
||||
|
Loading…
Reference in New Issue
Block a user