mireado

starting commit

1 +cmake_minimum_required(VERSION 2.8)
2 +
3 +set(CMAKE_CONFIGURATION_TYPES Debug Release)
4 +
5 +project(vnr)
6 +
7 +set(WDK_HOME "C:\\WinDDK\\7600.16385.1" CACHE FILEPATH "path to the Windows DDK directory")
8 +
9 +add_definitions(
10 + -DUNICODE
11 + -D_UNICODE
12 +)
13 +
14 +include_directories(${PROJECT_SOURCE_DIR})
15 +
16 +set(common_src
17 + ${PROJECT_SOURCE_DIR}/ith/common/const.h
18 + ${PROJECT_SOURCE_DIR}/ith/common/defs.h
19 + ${PROJECT_SOURCE_DIR}/ith/common/except.h
20 + ${PROJECT_SOURCE_DIR}/ith/common/growl.h
21 + ${PROJECT_SOURCE_DIR}/ith/common/memory.h
22 + ${PROJECT_SOURCE_DIR}/ith/common/types.h
23 +)
24 +
25 +set(import_src
26 + ${PROJECT_SOURCE_DIR}/ith/import/mono/funcinfo.h
27 + ${PROJECT_SOURCE_DIR}/ith/import/mono/types.h
28 + ${PROJECT_SOURCE_DIR}/ith/import/ppsspp/funcinfo.h
29 +)
30 +
31 +add_subdirectory(ith/hook)
32 +add_subdirectory(ith/host)
33 +add_subdirectory(ith/sys)
1 +#ifndef CCMACRO_H
2 +#define CCMACRO_H
3 +
4 +// ccmacro.h
5 +// 12/9/2011 jichi
6 +
7 +#define CC_UNUSED(_var) (void)(_var)
8 +#define CC_NOP CC_UNUSED(0)
9 +
10 +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
11 +# define CC_LIKELY(expr) __builtin_expect(!!(expr), true)
12 +# define CC_UNLIKELY(expr) __builtin_expect(!!(expr), false)
13 +#else
14 +# define CC_LIKELY(x) (x)
15 +# define CC_UNLIKELY(x) (x)
16 +#endif
17 +
18 +#define CC_MIN(x, y) ((x) < (y) ? (x) : (y))
19 +#define CC_MAX(x, y) ((x) < (y) ? (y) : (x))
20 +
21 +#endif // CCMACRO_H
1 +# ccutil.pri
2 +# 1/31/2012 jichi
3 +
4 +DEFINES += WITH_LIB_CCUTIL
5 +
6 +DEPENDPATH += $$PWD
7 +
8 +HEADERS += \
9 + $$PWD/ccmacro.h
10 +
11 +# EOF
1 +# config.pri
2 +# 9/3/2011 jichi
3 +
4 +## Locations
5 +
6 +ROOTDIR = $$PWD
7 +BUILDDIR = $$ROOTDIR/build
8 +
9 +SRCDIR = $$ROOTDIR/cpp
10 +CONFDIR = $$SRCDIR/conf
11 +LIBDIR = $$SRCDIR/libs
12 +COMDIR = $$SRCDIR/coms
13 +PLUGINDIR = $$SRCDIR/plugins
14 +#SERVICEDIR = $$SRCDIR/services
15 +
16 +DESTDIR = $$BUILDDIR
17 +#win32: DESTDIR_TARGET = $$BUILDDIR/release.win
18 +#unix: DESTDIR_TARGET = $$BUILDDIR/release.unix
19 +#mac: DESTDIR_TARGET = $$BUILDDIR/release.mac
20 +
21 +LIBS += -L$$DESTDIR
22 +mac: LIBS += -F$$DESTDIR
23 +
24 +INCLUDEPATH += \
25 + $$SRCDIR \
26 + $$LIBDIR \
27 + $$COMDIR \
28 + $$PLUGINDIR \
29 + $$SERVICEDIR
30 +
31 +## Qt Translation
32 +
33 +CODECFORTR = UTF-8
34 +#CODECFORSRC = UTF-8 # there are sources in SJIS encoding
35 +
36 +## Compiling options
37 +
38 +# Windows
39 +win32: DEFINES += UNICODE # force using UNICODE interface by default
40 +
41 +# Mac
42 +#CONFIG += x86 x86_64 ppc64
43 +mac: CONFIG -= ppc ppc64 # disable compiling fat architectures
44 +
45 +# Enable C++11
46 +win32: QMAKE_CXXFLAGS += -Zc:auto
47 +unix: QMAKE_CXXFLAGS += -std=c++11
48 +mac {
49 + # Enable TR1 such as tuple
50 + # Clang is required to take place of llvm gcc, which uses /usr/lib/libstdc++.dylib
51 + QMAKE_CXXFLAGS += -stdlib=libc++
52 + QMAKE_LFLAGS += -stdlib=libc++
53 +}
54 +
55 +# MSVC warnings
56 +win32 {
57 + # Disable checked iterator and compiler warning.
58 + # SCL: http://msdn.microsoft.com/en-us/library/aa985896.aspx
59 + # SCL Warning: http://msdn.microsoft.com/en-us/library/aa985974.aspx
60 + # Performance comparison: http://askldjd.wordpress.com/2009/09/13/stl-performance-comparison-vc71-vc90-and-stlport/
61 + DEFINES += _SECURE_SCL=0 _SCL_SECURE_NO_WARNINGS
62 +
63 + # Disable CRT string function warnings
64 + DEFINES += _CRT_SECURE_NO_WARNINGS
65 +
66 + # Disable CRT posix warnings
67 + #DEFINES += _CRT_NONSTDC_NO_DEPRECATE
68 +
69 + QMAKE_CXXFLAGS += -wd4819 # ignore the warning on Japanese characters
70 +}
71 +
72 +## External Libraries
73 +
74 +win32 {
75 + D3D_HOME = "$$PROGRAMFILES/Microsoft DirectX SDK"
76 + DETOURS_HOME = "$$PROGRAMFILES/Microsoft Research/Detours Express 3.0"
77 + #DEV_HOME = c:/dev
78 + DEV_HOME = z:/local/windows/developer
79 + BOOST_HOME = $$DEV_HOME/boost/build
80 + #ITH_HOME = $$DEV_HOME/ith
81 + MSIME_HOME = $$DEV_HOME/msime
82 + #PYTHON_HOME = $$ROOTDIR/../Python
83 + #PYTHON_HOME = C:/Python
84 + PYTHON_HOME = Z:/Local/Windows/Developer/Python
85 + PYSIDE_HOME = $$PYTHON_HOME/Lib/site-packages/PySide
86 + QT_HOME = c:/qt/4
87 + QT_SRC = c:/qt
88 + SAPI_HOME = "$$PROGRAMFILES/Microsoft Speech SDK 5.1"
89 + #WMSDK_HOME = c:/wmsdk/wmpsdk9
90 + WDK7_HOME = c:/winddk/7600.16385.1
91 + WDK8_HOME = "$$PROGRAMFILES/Windows Kits/8.1"
92 + UTF8_HOME = z:/users/jichi/opt/utf8
93 +}
94 +mac {
95 + MACPORTS_HOME = /opt/local
96 + BOOST_HOME = $$MACPORTS_HOME
97 + DEV_HOME = ${HOME}/opt
98 + #ITH_HOME = ${HOME}/opt/ith
99 + MSIME_HOME = $$DEV_HOME/msime
100 + PYSIDE_HOME = $$MACPORTS_HOME
101 + PYTHON_HOME = $$MACPORTS_HOME/Library/Frameworks/Python.framework/Versions/Current
102 + #QT_HOME = ${HOME}/opt/qt
103 + QT_HOME = $$MACPORTS_HOME
104 + QT_SRC = ${HOME}/src
105 + UTF8_HOME = $$DEV_HOME/utf8
106 +}
107 +
108 +INCLUDEPATH += $$BOOST_HOME $$BOOST_HOME/include
109 +LIBS += -L$$BOOST_HOME/lib
110 +
111 +# Disable automatically linking with boost silently
112 +# See: http://www.boost.org/doc/libs/1_56_0/boost/config/user.hpp
113 +DEFINES += BOOST_ALL_NO_LIB
114 +mac: BOOST_VARIANT = -mt
115 +
116 +## Config
117 +
118 +CONFIG(release) {
119 + message(CONFIG release)
120 + #DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT
121 +}
122 +
123 +CONFIG(noqt) {
124 + message(CONFIG noqt)
125 + CONFIG += noqtcore noqtgui
126 + CONFIG -= qt
127 +}
128 +CONFIG(noqtcore) {
129 + message(CONFIG noqtcore)
130 + QT -= core
131 + LIBS -= -lQtCore
132 +}
133 +CONFIG(noqtgui) {
134 + message(CONFIG noqtgui)
135 + QT -= gui
136 + LIBS -= -lQtGui
137 + mac: CONFIG -= app_bundle
138 +}
139 +
140 +win32 {
141 + CONFIG(nocrt) { # No runtime CRT. Use -MT for static linking.
142 + message(CONFIG nocrt)
143 + QMAKE_CFLAGS -= -MD -MDd
144 + QMAKE_CFLAGS_DEBUG -= -MD -MDd
145 + QMAKE_CFLAGS_RELEASE -= -MD -MDd
146 + QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -MD -MDd
147 + QMAKE_CXXFLAGS -= -MD -MDd
148 + QMAKE_CXXFLAGS_DEBUG -= -MD -MDd
149 + QMAKE_CXXFLAGS_RELEASE -= -MD -MDd
150 + QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -MD -MDd
151 + #QMAKE_LFLAGS += -NODEFAULTLIB:msvcrt.lib \
152 + # -NODEFAULTLIB:msvcrtd.lib
153 + }
154 +
155 + # http://social.msdn.microsoft.com/Forums/vstudio/en-US/96c906d9-de1d-4ace-af37-71169617b6ff/destructors-and-seh
156 + CONFIG(eha) { # Catch all exceptions
157 + message(CONFIG eha)
158 + QMAKE_CXXFLAGS_STL_ON -= -EHsc
159 + QMAKE_CXXFLAGS_EXCEPTIONS_ON -= -EHsc
160 + QMAKE_CXXFLAGS_STL_ON += -EHa
161 + QMAKE_CXXFLAGS_EXCEPTIONS_ON += -EHa
162 + }
163 +
164 + CONFIG(noeh) { # No Exception handler
165 + message(CONFIG noeh)
166 + #CONFIG -= rtti #-exceptions -stl
167 + QMAKE_CXXFLAGS += /GR-
168 + QMAKE_CXXFLAGS_RTTI_ON -= -GR
169 +
170 + QMAKE_CXXFLAGS_STL_ON -= -EHsc
171 + QMAKE_CXXFLAGS_EXCEPTIONS_ON -= -EHsc
172 +
173 + CONFIG(dll) {
174 + QMAKE_LFLAGS += /ENTRY:"DllMain"
175 + }
176 + }
177 +
178 + CONFIG(nosafeseh) { # No Exception handler
179 + message(CONFIG nosafeseh)
180 +
181 + # Disable SafeSEH table
182 + # http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c/20344222
183 + # Alternative way: Register handler using MASM
184 + # http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh
185 + QMAKE_LFLAGS += -safeseh:no
186 + }
187 +}
188 +
189 +CONFIG(gdb) {
190 + message(CONFIG gdb)
191 + QMAKE_CXXFLAGS += -g -ggdb
192 +}
193 +
194 +CONFIG(lldb) {
195 + message(CONFIG lldb)
196 + QMAKE_CXXFLAGS += -g #-glldb
197 +}
198 +
199 +CONFIG(qmlplugin) {
200 + message(CONFIG qmlplugin)
201 + QT += core declarative
202 + win32: CONFIG += dll
203 +}
204 +
205 +CONFIG(pysideplugin) {
206 + message(CONFIG pysideplugin)
207 + CONFIG += pyplugin shiboken
208 + QT += core
209 +
210 + LIBS += -L$$PYSIDE_HOME -lpyside-python2.7
211 + INCLUDEPATH += \
212 + $$PYSIDE_HOME/include/PySide \
213 + $$PYSIDE_HOME/include/PySide-2.7 \
214 + $$PYSIDE_HOME/include \
215 + $$PYSIDE_HOME/include/PySide/QtCore \
216 + $$PYSIDE_HOME/include/PySide/QtGui \
217 + $$QT_HOME/include/QtGui # needed by pyside qtcore
218 +}
219 +
220 +CONFIG(shiboken) {
221 + message(CONFIG shiboken)
222 +
223 + LIBS += -L$$PYSIDE_HOME -lshiboken-python2.7
224 + INCLUDEPATH += \
225 + $$PYSIDE_HOME/include/shiboken \
226 + $$PYSIDE_HOME/include/shiboken-2.7
227 +
228 + # Ignore warnings from Shiboken and PySide
229 + mac {
230 + QMAKE_CXXFLAGS_WARN_ON += \
231 + -Wno-header-guard \
232 + -Wno-mismatched-tags \
233 + -Wno-missing-field-initializers \
234 + -Wno-unused-parameter
235 + }
236 + win32 {
237 + # QMAKE_CXXFLAGS_WARN_ON does not work on windows
238 + #
239 + #ifdef _MSC_VER
240 + # pragma warning (disable:4099) // C4099: mix class and struct
241 + # pragma warning (disable:4100) // C4100: unreferenced parametter
242 + # pragma warning (disable:4244) // C4244: conversion lost of data
243 + # pragma warning (disable:4390) // C4390: empty controlled statement
244 + # pragma warning (disable:4522) // C4522: multiple assignment operators
245 + # pragma warning (disable:4800) // C4800: forcing value to bool
246 + #endif // _MSC_VER
247 + QMAKE_CXXFLAGS += -wd4099 -wd4100 -wd4244 -wd4390 -wd4522 -wd4800
248 + }
249 +}
250 +
251 +CONFIG(pyplugin) {
252 + message(CONFIG pyplugin)
253 + INCLUDEPATH += $$PYTHON_HOME/include/python2.7 $$PYTHON_HOME/include
254 +
255 + unix: LIBS += -L$$PYTHON_HOME/lib -lpython2.7
256 + win32: LIBS += -L$$PYTHON_HOME/libs -lpython27
257 +
258 + unix: QMAKE_EXTENSION_SHLIB = so
259 + win32: QMAKE_EXTENSION_SHLIB = pyd
260 + win32: CONFIG += dll
261 +}
262 +
263 +CONFIG(qt) {
264 + message(CONFIG qt)
265 + INCLUDEPATH += $$QT_SRC $$QT_SRC/qt # always allow access to Qt source code
266 +
267 + # Clang: Disable warning while processing Qt library headers
268 + # http://stackoverflow.com/questions/17846909/how-can-i-stop-warnings-about-unused-private-fields
269 + mac {
270 + QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-register # register storage class specifier is deprecated
271 + QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-private-field # private field 'type' is not used in qmime.h
272 + }
273 +}
274 +
275 +# EOF
276 +
277 +## Debug
278 +
279 +#include($$ROOTDIR/lib/debug/debug.pri)
280 +
281 +## Deploy
282 +
283 +#DEFINES += VERSION=\\\"$$VERSION\\\"
284 +
285 +## IDs
286 +
287 +# Azure Market Key: https://datamarket.azure.com/account/datasets
288 +#DEFINES += CONFIG_AZURE_ID=\\\"tuSmXew4CSnnGaX0vZyYdNLCrlInvAUepCX6p5l5THc=\\\"
289 +
290 +# Yahoo!JAPAN AppID: https://e.developer.yahoo.co.jp/dashboard/
291 +#DEFINES += CONFIG_YAHOO_ID=\\\"mRr.UCWxg65ZTZTR_Mz0OTtj3sJ7xa5K66ZOGp55cgJsIDDeaB6e1LDY1NpEZ_AfZA--\\\"
292 +
293 +## Deploy
294 +# See: http://wiki.maemo.org/Packaging_a_Qt_application
295 +# See: http://www.developer.nokia.com/Community/Wiki/Creating_Debian_packages_for_Maemo_5_Qt_applications_and_showing_in_the_application_menu
296 +# See: https://wiki.kubuntu.org/PackagingGuide/QtApplication
297 +
298 +#QMLDIR=$$DESTDIR/qml
299 +#LUADIR=$$DESTDIR/lua
300 +#DOCDIR=$$DESTDIR/doc
301 +#TABLEDIR=$$DESTDIR/table
302 +#IMAGEDIR=$$DESTDIR/images
303 +#JSFDIR=$$DESTDIR/jsf
304 +#AVATARDIR=$$DESTDIR/avatars
305 +
306 +#unix:!mac {
307 +# isEmpty(PREFIX): PREFIX = /usr
308 +# BINDIR = $$PREFIX/bin
309 +# DATADIR = $$PREFIX/share
310 +#}
311 +#mac {
312 +# isEmpty(PREFIX): PREFIX = /opt/annot
313 +# BINDIR = $$PREFIX/bin
314 +# DATADIR = $$PREFIX/share
315 +#}
316 +#
317 +#!win32 {
318 +# DEFINES += \
319 +# BINDIR=\\\"$$BINDIR\\\" \
320 +# DATADIR=\\\"$$DATADIR\\\"
321 +#}
322 +#DEFINES += \
323 +# AVATARDIR=\\\"$$AVATARDIR\\\" \
324 +# DOCDIR=\\\"$$DOCDIR\\\" \
325 +# TABLEDIR=\\\"$$TABLEDIR\\\" \
326 +# IMAGEDIR=\\\"$$IMAGDIR\\\" \
327 +# LUADIR=\\\"$$LUADIR\\\" \
328 +# JSFDIR=\\\"$$JSFDIR\\\"
329 +
330 +## External libraries
331 +
332 +#win32 {
333 +# DEV_HOME = c:/dev
334 +# #DEV_HOME = B:/Developer
335 +# QT_HOME = c:/qt/qt4
336 +# QT_SRC = c:/qt
337 +# QT5_HOME = c:/qt/qt5
338 +# QT5_SRC = c:/qt
339 +# #VLC_HOME = "c:/Program Files/VideoLAN/VLC/sdk"
340 +# VLC_HOME = $$DEV_HOME/vlc
341 +# VLC_SRC = $$VLC_HOME/src
342 +# #WSF_HOME = $$DEV_HOME/wso2
343 +# #CDIO_HOME = $$DEV_HOME/cdio
344 +# #FFMPEG_HOME = $$DEV_HOME/ffmpeg
345 +# GPAC_HOME = $$DEV_HOME/gpac
346 +# MP4V2_HOME = $$DEV_HOME/mp4v2
347 +# LIVE_HOME = $$DEV_HOME/live
348 +# POPPLER_HOME = $$DEV_HOME/poppler
349 +# BOOST_HOME = $$DEV_HOME/boost
350 +# GSOAP_HOME = $$DEV_HOME/gsoap
351 +# GSOAP_SRC = $$DEV_HOME/gsoap/src
352 +# ZDEV_HOME = $$DEV_HOME/zlib
353 +# LUA_HOME = $$DEV_HOME/lua
354 +# FREETYPE_HOME = $$DEV_HOME/freetype
355 +# FONTCONFIG_HOME = $$DEV_HOME/fontconfig
356 +# MECAB_HOME = $$DEV_HOME/mecab
357 +# #LUA_VERSION = 52
358 +# #LUA_VERSION = 5.1
359 +# LUA_VERSION =
360 +#
361 +# ITH_HOME = $$DEV_HOME/ith
362 +#
363 +# WDK_HOME = c:/winddk/current
364 +#
365 +# INCLUDEPATH += $$DEV_HOME/inttypes/include
366 +#
367 +# INCLUDEPATH += $$ITH_HOME/include
368 +# LIBS += -L$$ITH_HOME/lib
369 +#
370 +# # wdk/inc/api/sal.h MUST be removed.
371 +# # See: http://stackoverflow.com/questions/1356653/multiple-compiling-errors-with-basic-c-application-on-vs2010-beta-1
372 +# # Select WinXP x86
373 +# INCLUDEPATH += $$WDK_HOME/inc
374 +# LIBS += -L$$WDK_HOME/lib/wxp/i386
375 +#}
376 +#
377 +#unix {
378 +# X11_HOME = /usr/X11
379 +# QT_HOME = /usr/share/qt4
380 +# QT_SRC =
381 +# VLC_HOME = /usr
382 +# VLC_SRC = ${HOME}/opt/src
383 +# #WSF_HOME = ${HOME}/opt/wso2/wsf
384 +# #CDIO_HOME = /usr
385 +# #FFMPEG_HOME = /usr
386 +# MECAB_HOME = /usr
387 +# GPAC_HOME = /usr
388 +# MP4V2_HOME = /usr
389 +# LIVE_HOME = /usr
390 +# POPPLER_HOME = ${HOME}/opt/poppler
391 +# BOOST_HOME = /usr
392 +# GSOAP_HOME = ${HOME}/opt/gsoap
393 +# GSOAP_SRC = ${HOME}/opt/src/gsoap
394 +# LUA_HOME = /usr
395 +# ZDEV_HOME = /usr
396 +# FREETYPE_HOME = $$X11_HOME
397 +# FONTCONFIG_HOME = $$X11_HOME
398 +# LUA_VERSION = 5.1
399 +#}
400 +#
401 +#mac {
402 +# SDK_HOME = /Developer/SDKs/MacOSX10.7.sdk
403 +# X11_HOME = $$SDK_HOME/usr/X11
404 +# MACPORTS_HOME = /opt/local
405 +# QT_HOME = ${HOME}/opt/qt
406 +# QT_SRC = ${HOME}/opt/src
407 +# QT5_HOME = ${HOME}/opt/qt5
408 +# QT5_SRC = ${HOME}/opt/src
409 +# #VLC_HOME = ${HOME}/opt/vlc
410 +# VLC_HOME = /Applications/VLC.app/Contents/MacOS
411 +# VLC_SRC = ${HOME}/opt/src
412 +# #WSF_HOME = ${HOME}/opt/wso2/wsf
413 +# #CDIO_HOME = ${HOME}/opt/libcdio
414 +# #FFMPEG_HOME = $$MACPORTS_HOME
415 +# GPAC_HOME = ${HOME}/opt/gpac
416 +# MP4V2_HOME = $$MACPORTS_HOME
417 +# MECAB_HOME = $$MACPORTS_HOME
418 +# LIVE_HOME = ${HOME}/opt/live
419 +# POPPLER_HOME = ${HOME}/opt/poppler
420 +# BOOST_HOME = $$MACPORTS_HOME
421 +# GSOAP_HOME = ${HOME}/opt/gsoap
422 +# GSOAP_SRC = ${HOME}/opt/src/gsoap
423 +# ZDEV_HOME = $$SDK_HOME/usr
424 +# FREETYPE_HOME = $$X11_HOME
425 +# FONTCONFIG_HOME = $$X11_HOME
426 +# #LUA_HOME = ${HOME}/opt/lua
427 +# LUA_HOME = $$MACPORTS_HOME
428 +# #LUA_VERSION = 52
429 +# LUA_VERSION =
430 +#}
431 +#
432 +#INCLUDEPATH += $$QT_SRC/qt/src
433 +##INCLUDEPATH += $$QT5_SRC/qt/src
434 +#
435 +#INCLUDEPATH += $$VLC_HOME/include
436 +#INCLUDEPATH += $$VLC_HOME/include/vlc/plugins
437 +##INCLUDEPATH += $$VLC_SRC/include
438 +#LIBS += -L$$VLC_HOME/lib
439 +##INCLUDEPATH += $$WSF_HOME/include
440 +##LIBS += -L$$WSF_HOME/lib
441 +##INCLUDEPATH += $$CDIO_HOME/include
442 +##LIBS += -L$$CDIO_HOME/lib
443 +##INCLUDEPATH += $$POPPLER_HOME/include/poppler/qt4
444 +##LIBS += -L$$POPPLER_HOME/lib
445 +#INCLUDEPATH += $$BOOST_HOME/include
446 +#LIBS += -L$$BOOST_HOME/lib
447 +#INCLUDEPATH += $$GSOAP_HOME/include
448 +##LIBS += -L$$GSOAP_HOME/lib
449 +#INCLUDEPATH += $$ZDEV_HOME/include
450 +#LIBS += -L$$ZDEV_HOME/lib
451 +#INCLUDEPATH += $$MECAB_HOME/include
452 +#LIBS += -L$$MECAB_HOME/lib
453 +#INCLUDEPATH += $$FREETYPE_HOME/include \
454 +# $$FREETYPE_HOME/include/freetype2
455 +#LIBS += -L$$FREETYPE_HOME/lib
456 +#INCLUDEPATH += $$FONTCONFIG_HOME/include
457 +#LIBS += -L$$FONTCONFIG_HOME/lib
458 +#INCLUDEPATH += $$LUA_HOME/include \
459 +# $$LUA_HOME/include/lua$$LUA_VERSION
460 +#LIBS += -L$$LUA_HOME/lib
461 +##INCLUDEPATH += $$FFMPEG_HOME/include
462 +##LIBS += -L$$FFMPEG_HOME/lib
463 +##INCLUDEPATH += $$GPAC_HOME/include
464 +##LIBS += -L$$GPAC_HOME/lib
465 +##INCLUDEPATH += $$MP4V2_HOME/include
466 +##LIBS += -L$$MP4V2_HOME/lib
467 +##INCLUDEPATH += \
468 +## $$LIVE_HOME/BasicUsageEnvironment/include \
469 +## $$LIVE_HOME/UsageEnvironment/include \
470 +## $$LIVE_HOME/groupsock/include \
471 +## $$LIVE_HOME/liveMedia/include
472 +# #$$LIVE_HOME/BasicUsageEnvironment $$LIVE_HOME/BasicUsageEnvironment/include \
473 +# #$$LIVE_HOME/UsageEnvironment $$LIVE_HOME/UsageEnvironment/include \
474 +# #$$LIVE_HOME/groupsock $$LIVE_HOME/groupsock/include \
475 +# #$$LIVE_HOME/liveMedia $$LIVE_HOME/liveMedia/include
476 +##LIBS += \
477 +## -L$$LIVE_HOME/BasicUsageEnvironment \
478 +## -L$$LIVE_HOME/UsageEnvironment \
479 +## -L$$LIVE_HOME/groupsock \
480 +## -L$$LIVE_HOME/liveMedia
481 +#
482 +#mac: INCLUDEPATH += $$SDK_HOME/usr/include
483 +
484 +#
485 +# assistant.pro - Qt 4.7.3
486 +#
487 +#include(../../../shared/fontpanel/fontpanel.pri)
488 +#TEMPLATE = app
489 +#LANGUAGE = C++
490 +#TARGET = assistant
491 +#contains(QT_CONFIG, webkit):QT += webkit
492 +#CONFIG += qt \
493 +# warn_on \
494 +# help
495 +#QT += network
496 +#PROJECTNAME = Assistant
497 +#DESTDIR = ../../../../bin
498 +#target.path = $$[QT_INSTALL_BINS]
499 +#INSTALLS += target
500 +#DEPENDPATH += ../shared
501 +#
502 +## ## Work around a qmake issue when statically linking to
503 +## ## not-yet-installed plugins
504 +#QMAKE_LIBDIR += $$QT_BUILD_TREE/plugins/sqldrivers
505 +#HEADERS += aboutdialog.h \
506 +# bookmarkdialog.h \
507 +# bookmarkfiltermodel.h \
508 +# bookmarkitem.h \
509 +# bookmarkmanager.h \
510 +# bookmarkmanagerwidget.h \
511 +# bookmarkmodel.h \
512 +# centralwidget.h \
513 +# cmdlineparser.h \
514 +# contentwindow.h \
515 +# findwidget.h \
516 +# filternamedialog.h \
517 +# helpenginewrapper.h \
518 +# helpviewer.h \
519 +# indexwindow.h \
520 +# installdialog.h \
521 +# mainwindow.h \
522 +# preferencesdialog.h \
523 +# qtdocinstaller.h \
524 +# remotecontrol.h \
525 +# searchwidget.h \
526 +# topicchooser.h \
527 +# tracer.h \
528 +# xbelsupport.h \
529 +# ../shared/collectionconfiguration.h
530 +#contains(QT_CONFIG, webkit) {
531 +# HEADERS += helpviewer_qwv.h
532 +#} else {
533 +# HEADERS += helpviewer_qtb.h
534 +# }
535 +#win32:HEADERS += remotecontrol_win.h
536 +#
537 +#SOURCES += aboutdialog.cpp \
538 +# bookmarkdialog.cpp \
539 +# bookmarkfiltermodel.cpp \
540 +# bookmarkitem.cpp \
541 +# bookmarkmanager.cpp \
542 +# bookmarkmanagerwidget.cpp \
543 +# bookmarkmodel.cpp \
544 +# centralwidget.cpp \
545 +# cmdlineparser.cpp \
546 +# contentwindow.cpp \
547 +# findwidget.cpp \
548 +# filternamedialog.cpp \
549 +# helpenginewrapper.cpp \
550 +# helpviewer.cpp \
551 +# indexwindow.cpp \
552 +# installdialog.cpp \
553 +# main.cpp \
554 +# mainwindow.cpp \
555 +# preferencesdialog.cpp \
556 +# qtdocinstaller.cpp \
557 +# remotecontrol.cpp \
558 +# searchwidget.cpp \
559 +# topicchooser.cpp \
560 +# xbelsupport.cpp \
561 +# ../shared/collectionconfiguration.cpp
562 +# contains(QT_CONFIG, webkit) {
563 +# SOURCES += helpviewer_qwv.cpp
564 +#} else {
565 +# SOURCES += helpviewer_qtb.cpp
566 +#}
567 +#
568 +#FORMS += bookmarkdialog.ui \
569 +# bookmarkmanagerwidget.ui \
570 +# bookmarkwidget.ui \
571 +# filternamedialog.ui \
572 +# installdialog.ui \
573 +# preferencesdialog.ui \
574 +# topicchooser.ui
575 +#
576 +#RESOURCES += assistant.qrc \
577 +# assistant_images.qrc
578 +#
579 +#win32 {
580 +# !wince*:LIBS += -lshell32
581 +# RC_FILE = assistant.rc
582 +#}
583 +#
584 +#mac {
585 +# ICON = assistant.icns
586 +# TARGET = Assistant
587 +# QMAKE_INFO_PLIST = Info_mac.plist
588 +#}
589 +#
590 +#contains(CONFIG, static): {
591 +# SQLPLUGINS = $$unique(sql-plugins)
592 +# contains(SQLPLUGINS, sqlite): {
593 +# QTPLUGIN += qsqlite
594 +# DEFINES += USE_STATIC_SQLITE_PLUGIN
595 +# }
596 +#}
1 +@echo off
2 +setlocal
3 +if [%1] == [] (
4 + echo usage: copy_vnr <path-to-Sakura-directory>
5 + goto :EOF
6 +)
7 +xcopy %1\config.pri . /S /Y /I
8 +xcopy %1\cpp\libs\ccutil ccutil /S /Y /I
9 +xcopy %1\cpp\libs\cpputil cpputil /S /Y /I
10 +xcopy %1\cpp\libs\disasm disasm /S /Y /I /EXCLUDE:exclude.txt
11 +xcopy %1\cpp\plugins\ith ith /S /Y /I
12 +xcopy %1\cpp\libs\memdbg memdbg /S /Y /I
13 +xcopy %1\cpp\libs\ntdll ntdll /S /Y /I
14 +xcopy %1\cpp\libs\ntinspect ntinspect /S /Y /I
15 +xcopy %1\cpp\libs\winmaker winmaker /S /Y /I
16 +xcopy %1\cpp\libs\winmutex winmutex /S /Y /I
17 +xcopy %1\cpp\libs\winversion winversion /S /Y /I
18 +xcopy %1\cpp\libs\winseh winseh /S /Y /I
19 +
20 +endlocal
1 +#pragma once
2 +#include "winmutex/winmutex.h"
1 +#pragma once
2 +// winmutex.h
3 +// 12/11/2011 jichi
4 +
5 +#include <windows.h>
6 +
7 +#ifdef _MSC_VER
8 +# pragma warning(disable:4800) // C4800: forcing value to bool
9 +#endif // _MSC_VER
10 +
11 +// Mutex lock
12 +// The interface of this class is consistent with the mutex class
13 +
14 +template <typename _Mutex>
15 + class win_mutex_lock
16 + {
17 + typedef win_mutex_lock<_Mutex> _Self;
18 + win_mutex_lock(const _Self&);
19 + _Self &operator=(const _Self&);
20 +
21 + _Mutex &_M_mutex;
22 + bool _M_locked;
23 + public:
24 + typedef _Mutex mutex_type;
25 + typedef typename _Mutex::native_handle_type native_handle_type;
26 + explicit win_mutex_lock(mutex_type &mutex)
27 + : _M_mutex(mutex), _M_locked(false) { lock(); }
28 + ~win_mutex_lock() { if (_M_locked) _M_mutex.unlock(); }
29 + mutex_type &mutex() { return _M_mutex; }
30 + //bool isLock() const { return _M_locked; }
31 + native_handle_type native_handle() { return _M_mutex.native_handle(); }
32 + void unlock() { _M_mutex.unlock(); _M_locked = false; }
33 + void lock() { _M_mutex.lock(); _M_locked = true; }
34 + bool tryLock() { return _M_locked = _M_mutex.tryLock(); }
35 + };
36 +
37 +// Mutex
38 +
39 +template <typename _Mutex, size_t _Irql = 0>
40 + class win_mutex
41 + {
42 + typedef win_mutex<_Mutex> _Self;
43 + typedef _Mutex __native_type;
44 + enum { __minimal_irql = _Irql };
45 + __native_type _M_mutex;
46 +
47 + win_mutex(const _Self&);
48 + _Self &operator=(const _Self&);
49 + private:
50 + win_mutex() {}
51 + typedef __native_type *native_handle_type;
52 + native_handle_type native_handle() { return &_M_mutex; }
53 + static size_t minimal_irql() { return __minimal_irql; }
54 +
55 + void unlock() {}
56 + void lock() {}
57 + bool try_lock() {}
58 + };
59 +
60 +template <>
61 + class IHFSERVICE win_mutex<CRITICAL_SECTION>
62 + {
63 + typedef win_mutex<CRITICAL_SECTION> _Self;
64 + typedef CRITICAL_SECTION __native_type;
65 + enum { __minimal_irql = 0 };
66 + win_mutex(const _Self&);
67 + _Self &operator=(const _Self&);
68 +
69 + __native_type _M_mutex;
70 + public:
71 + typedef __native_type *native_handle_type;
72 + native_handle_type native_handle() { return &_M_mutex; }
73 + static size_t minimal_irql() { return __minimal_irql; }
74 +
75 + win_mutex() { ::InitializeCriticalSection(&_M_mutex); }
76 + ~win_mutex() { ::DeleteCriticalSection(&_M_mutex); }
77 + void lock() { ::EnterCriticalSection(&_M_mutex); }
78 + void unlock() { ::LeaveCriticalSection(&_M_mutex); }
79 + bool try_lock() { return ::TryEnterCriticalSection(&_M_mutex); }
80 + };
81 +
82 +// Conditional variable
83 +
84 +template <typename _Cond>
85 + class win_mutex_cond
86 + {
87 + typedef win_mutex_cond<_Cond> _Self;
88 + typedef _Cond __native_type;
89 + win_mutex_cond(const _Self&);
90 + _Self &operator=(const _Self&);
91 +
92 + __native_type _M_cond;
93 + public:
94 + enum wait_status { no_timeout = 0, timeout };
95 + typedef __native_type *native_handle_type;
96 +
97 + win_mutex_cond() {}
98 + native_handle_type native_handle() { return &_M_cond; }
99 +
100 + void notify_one() {}
101 + void notify_all() {}
102 +
103 + template <typename _Mutex>
104 + void wait(_Mutex &mutex) {}
105 +
106 + template <typename _Mutex, typename _Pred>
107 + void wait(_Mutex &mutex, _Pred pred) {}
108 +
109 + template <typename _Mutex>
110 + wait_status wait_for(_Mutex &mutex, int msecs) {}
111 +
112 + template <typename _Mutex, typename _Pred>
113 + wait_status wait_for(_Mutex &mutex, int msecs, _Pred pred) {}
114 + };
115 +
116 +// Note: Conditional variables are NOT availabe on Windows XP/2003
117 +// See: http://en.cppreference.com/w/cpp/thread/condition_variable
118 +// See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686903%28v=vs.85%29.aspx
119 +template <>
120 + class win_mutex_cond<CONDITION_VARIABLE>
121 + {
122 + typedef win_mutex_cond<CONDITION_VARIABLE> _Self;
123 + typedef CONDITION_VARIABLE __native_type;
124 + win_mutex_cond(const _Self&);
125 + _Self &operator=(const _Self&);
126 +
127 + __native_type _M_cond;
128 + public:
129 + enum wait_status { no_timeout = 0, timeout };
130 + typedef __native_type *native_handle_type;
131 + native_handle_type native_handle() { return &_M_cond; }
132 +
133 + win_mutex_cond() { ::InitializeConditionVariable(&_M_cond); }
134 +
135 + void notify_one() { ::WakeConditionVariable(&_M_cond); }
136 + void notify_all() { ::WakeAllConditionVariable(&_M_cond); }
137 +
138 + template <typename _Mutex>
139 + void wait(_Mutex &mutex)
140 + { ::SleepConditionVariableCS(&_M_cond, mutex.native_handle(), INFINITE); }
141 +
142 + template <typename _Mutex, typename _Pred>
143 + void wait(_Mutex &mutex, _Pred pred)
144 + { while (!pred()) wait(mutex); }
145 +
146 + template <typename _Mutex>
147 + wait_status wait_for(_Mutex &mutex, int msecs)
148 + { return ::SleepConditionVariableCS(&_M_cond, mutex.native_handle(), msecs) ? no_timeout : timeout; }
149 +
150 + template <typename _Mutex, typename _Pred>
151 + wait_status wait_for(_Mutex &mutex, int msecs, _Pred pred)
152 + {
153 + auto start = ::GetTickCount();
154 + while (!pred()) {
155 + auto now = ::GetTickCount();
156 + msecs -= now - start;
157 + if (msecs <= 0)
158 + return timeout;
159 + start = now;
160 + wait_for(mutex, msecs);
161 + }
162 + return no_timeout;
163 + }
164 + };
165 +
166 +// EOF
1 +# winmutex.pri
2 +# 3/8/2013 jichi
3 +
4 +DEFINES += WITH_LIB_WINMUTEX
5 +
6 +DEPENDPATH += $$PWD
7 +#LIBS += -lkernel32 -luser32
8 +
9 +HEADERS += \
10 + $$PWD/winmutex \
11 + $$PWD/winmutex.h
12 +
13 +# EOF
1 +# Makefile
2 +# 12/13/2013 jichi
3 +# This file is for Windows only.
4 +# Compile SAFESEH table from the ASM file.
5 +# See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c
6 +# See: ::http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh
7 +# See: http://msdn.microsoft.com/en-us/library/16aexws6.aspx
8 +
9 +BUILDDIR = ../../../build
10 +OBJ = $(BUILDDIR)/safeseh.obj
11 +
12 +ML = ml
13 +CFLAGS =
14 +
15 +.PHONY: all compile clean
16 +
17 +all: compile
18 +
19 +compile: $(OBJ)
20 +
21 +$(OBJ): safeseh.asm
22 + $(ML) $(CFLAGS) -Fo $@ -c -safeseh $^
23 +
24 +clean:
25 +
26 +# EOF
1 +; safeseh.asm
2 +; 12/13/2013 jichi
3 +; see: http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh
4 +; see: http://code.metager.de/source/xref/WebKit/Source/WebCore/platform/win/makesafeseh.asm
5 +; see: http://jpassing.com/2008/05/20/fun-with-low-level-seh/
6 +.386
7 +.model flat, stdcall
8 +option casemap :none
9 +
10 +; The symbol name can be found out using: dumpbin /symbols winseh.obj
11 +extern _seh_handler:near ; defined in winseh.cc
12 +
13 +_seh_asm_handler proto
14 +.safeseh _seh_asm_handler
15 +
16 +.code
17 +_seh_asm_handler proc
18 +jmp _seh_handler
19 +_seh_asm_handler endp
20 +
21 +end
1 +// winseh.cc
2 +// 12/13/2013 jichi
3 +
4 +#include "winseh/winseh.h"
5 +#include "ntdll/ntdll.h"
6 +//#include <cstdio>
7 +
8 +// - Global variables -
9 +
10 +seh_dword_t seh_esp[seh_capacity],
11 + seh_eip[seh_capacity],
12 + seh_eh[seh_capacity];
13 +seh_dword_t seh_count;
14 +
15 +// - Exception handlers -
16 +
17 +// VC 2013: http://msdn.microsoft.com/en-us/library/b6sf5kbd.aspx
18 +// typedef EXCEPTION_DISPOSITION (*PEXCEPTION_ROUTINE) (
19 +// _In_ PEXCEPTION_RECORD ExceptionRecord,
20 +// _In_ ULONG64 EstablisherFrame,
21 +// _Inout_ PCONTEXT ContextRecord,
22 +// _Inout_ PDISPATCHER_CONTEXT DispatcherContext
23 +// );
24 +//
25 +// winnt.h: http://www.codemachine.com/downloads/win81/ntdef.h
26 +// typedef
27 +// __drv_sameIRQL
28 +// __drv_functionClass(EXCEPTION_ROUTINE)
29 +// EXCEPTION_DISPOSITION
30 +// NTAPI
31 +// EXCEPTION_ROUTINE (
32 +// _Inout_ struct _EXCEPTION_RECORD *ExceptionRecord,
33 +// _In_ PVOID EstablisherFrame,
34 +// _In_ struct _CONTEXT *ContextRecord,
35 +// _In_ PVOID DispatcherContext
36 +// );
37 +extern "C" EXCEPTION_DISPOSITION _seh_handler( // extern C is needed to avoid name hashing in C++
38 + _In_ PEXCEPTION_RECORD ExceptionRecord,
39 + _In_ PVOID EstablisherFrame, // does not work if I use ULONG64
40 + _Inout_ PCONTEXT ContextRecord,
41 + _In_ PVOID DispatcherContext) // PDISPATCHER_CONTEXT is not declared in windows.h
42 +{
43 + //assert(::seh_count > 0);
44 + ContextRecord->Esp = ::seh_esp[::seh_count - 1];
45 + ContextRecord->Eip = ::seh_eip[::seh_count - 1];
46 + //printf("seh_handler:%i,%x,%x\n", ::seh_count, ContextRecord->Esp, ContextRecord->Eip);
47 + return ::seh_eh[::seh_count - 1] ?
48 + reinterpret_cast<PEXCEPTION_ROUTINE>(::seh_eh[::seh_count - 1])(ExceptionRecord, EstablisherFrame, ContextRecord, DispatcherContext) :
49 + ExceptionContinueExecution;
50 +}
51 +
52 +// EOF
1 +#pragma once
2 +
3 +// winseh.h
4 +// 12/13/2013 jichi
5 +// See: http://code.metager.de/source/xref/WebKit/Source/WebCore/platform/win/makesafeseh.asm
6 +// See: http://jpassing.com/2008/05/20/fun-with-low-level-seh/
7 +
8 +#ifdef _MSC_VER
9 +# pragma warning (disable:4733) // C4733: Inline asm assigning to 'FS:0' : handler not registered as safe handler
10 +#endif // _MSC_VER
11 +
12 +#define SEH_RAISE (*(int*)0 = 0) // raise C000005, for debugging only
13 +
14 +// Maximum number of nested SEH
15 +// Default nested function count is 100, see: http://stackoverflow.com/questions/8656089/solution-for-fatal-error-maximum-function-nesting-level-of-100-reached-abor
16 +#ifndef SEH_CAPACITY
17 +# define SEH_CAPACITY 100
18 +#endif // SEH_CAPACITY
19 +
20 +enum { seh_capacity = SEH_CAPACITY };
21 +
22 +typedef unsigned long seh_dword_t; // DWORD in <windows.h>
23 +
24 +// 12/13/2013 jichi
25 +// The list implementation is not thread-safe
26 +extern seh_dword_t seh_esp[seh_capacity], // LPVOID, current stack
27 + seh_eip[seh_capacity], // LPVOID, current IP address
28 + seh_eh[seh_capacity]; // EXCEPTION_ROUTINE, current exception handler function address
29 +extern seh_dword_t seh_count; // current number of exception handlers
30 +extern seh_dword_t seh_handler; //extern PEXCEPTION_ROUTINE seh_handler;
31 +
32 +/**
33 + * Push SEH handler
34 + * @param _label exception recover label which should be the same as seh_pop_
35 + * @param _eh EXCEPTION_ROUTINE or 0
36 + * @param _r1 scalar register name, such as eax
37 + * @param _r2 counter register name, such as ecx
38 + *
39 + * Note: __asm prefix is needed to allow inlining macro
40 + * I didn't pushad and popad which seems to be not needed
41 + *
42 + * For SEH, see:
43 + * http://www.codeproject.com/Articles/82701/Win32-Exceptions-OS-Level-Point-of-View
44 + * http://sploitfun.blogspot.com/2012/08/seh-exploit-part1.html
45 + * http://sploitfun.blogspot.com/2012/08/seh-exploit-part2.html
46 + *
47 + * fs:0x0 on Windows is the pointer to ExceptionList
48 + * http://stackoverflow.com/questions/4657661/what-lies-at-fs0x0-on-windows
49 + *
50 + * EPB and ESP
51 + * http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point
52 + */
53 +#define seh_push_(_label, _eh, _r1, _r2) \
54 + { \
55 + __asm mov _r1, _eh /* move new handler address */ \
56 + __asm mov _r2, seh_count /* get current seh counter */ \
57 + __asm mov dword ptr seh_eh[_r2*4], _r1 /* set recover exception hander */ \
58 + __asm mov _r1, _label /* move jump label address */ \
59 + __asm mov dword ptr seh_eip[_r2*4], _r1 /* set recover eip as the jump label */ \
60 + __asm push seh_handler /* push new safe seh handler */ \
61 + __asm push fs:[0] /* push old fs:0 */ \
62 + __asm mov dword ptr seh_esp[_r2*4], esp /* safe current stack address */ \
63 + __asm mov fs:[0], esp /* change fs:0 to the current stack */ \
64 + __asm inc seh_count /* increase number of seh */ \
65 + }
66 + //TODO: get sizeof dword instead of hardcode 4
67 +
68 +/**
69 + * Restore old SEH handler
70 + * @param _label exception recover label which should be the same as seh_push_
71 + */
72 +#define seh_pop_(_label) \
73 + { \
74 + __asm _label: /* the exception recover label */ \
75 + __asm pop dword ptr fs:[0] /* restore old fs:0 */ \
76 + __asm add esp, 4 /* pop seh_handler */ \
77 + __asm dec seh_count /* decrease number of seh */ \
78 + }
79 +
80 +#define seh_pop() seh_pop_(seh_exit)
81 +#define seh_push() seh_push_(seh_exit, 0, eax, ecx) // use ecx as counter better than ebx
82 +
83 +/**
84 + * @param _eh EXCEPTION_ROUTINE or 0
85 + */
86 +#define seh_push_eh(_eh) seh_push_(seh_exit, _eh, eax, ecx)
87 +
88 +/**
89 + * Wrap the code block with SEH handler
90 + * @param* any code block. The colon for the last expression is optional.
91 + */
92 +#define seh_with(...) \
93 + { \
94 + seh_push() \
95 + __VA_ARGS__ \
96 + ; \
97 + seh_pop() \
98 + }
99 +
100 +/**
101 + * Wrap the code block with SEH handler
102 + * @param _eh EXCEPTION_ROUTINE or 0
103 + * @param* any code block. The colon for the last expression is optional.
104 + */
105 +#define seh_with_eh(_eh, ...) \
106 + { \
107 + seh_push_eh(_eh) \
108 + __VA_ARGS__ \
109 + ; \
110 + seh_pop() \
111 + }
112 +
113 +// EOF
114 +
115 +//#define seh_push_front() \
116 +// { \
117 +// __asm mov eax, seh_exit \
118 +// __asm mov seh_eip, eax \
119 +// __asm push seh_handler \
120 +// __asm push fs:[0] \
121 +// __asm mov seh_esp, esp \
122 +// __asm mov fs:[0], esp \
123 +// }
124 +//
125 +//#define seh_pop_front() \
126 +// { \
127 +// __asm seh_exit: \
128 +// __asm mov eax, [esp] \
129 +// __asm mov fs:[0], eax \
130 +// __asm add esp, 8 \
131 +// }
132 +//
133 +//#define seh_push_back() \
134 +// { \
135 +// __asm mov eax, seh_exit \
136 +// __asm mov ecx, seh_capacity - 1 \
137 +// __asm mov DWORD PTR seh_eip[ecx*4], eax \
138 +// __asm push seh_handler \
139 +// __asm push fs:[0] \
140 +// __asm mov DWORD PTR seh_esp[ecx*4], esp \
141 +// __asm mov fs:[0], esp \
142 +// }
143 +//
144 +//#define seh_pop_back() \
145 +// { \
146 +// __asm seh_exit: \
147 +// __asm mov eax, [esp] \
148 +// __asm mov fs:[0], eax \
149 +// __asm add esp, 8 \
150 +// }
1 +// winseh_safe.cc
2 +// 12/13/2013 jichi
3 +// See: http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh
4 +
5 +#include "winseh/winseh.h"
6 +
7 +extern "C" int __stdcall _seh_asm_handler();
8 +seh_dword_t seh_handler = reinterpret_cast<seh_dword_t>(_seh_asm_handler);
9 +
10 +// EOF
1 +# winseh_safe.pri
2 +# 12/13/2013 jichi
3 +#
4 +# Need link with with SEH assembly
5 +# See: http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh
6 +# See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c
7 +win32 {
8 +#include(../../../config.pri)
9 +
10 +# Disable buffer security check: http://msdn.microsoft.com/en-us/library/8dbf701c.aspx
11 +#QMAKE_CXXFLAGS += /GS-
12 +
13 +LIBS += safeseh.obj # compiled from safeseh.asm using ml -safeseh
14 +
15 +DEFINES += WITH_LIB_WINSEH
16 +
17 +DEPENDPATH += $$PWD
18 +
19 +HEADERS += $$PWD/winseh.h
20 +SOURCES += \
21 + $$PWD/winseh.cc \
22 + $$PWD/winseh_safe.cc
23 +
24 +OTHER_FILES += \
25 + $$PWD/safeseh.asm \
26 + $$PWD/Makefile
27 +}
28 +
29 +# EOF
1 +// winseh_unsafe.cc
2 +// 12/13/2013 jichi
3 +// See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c
4 +
5 +#include "winseh/winseh.h"
6 +#include <windows.h>
7 +
8 +extern "C" EXCEPTION_DISPOSITION _seh_handler(PEXCEPTION_RECORD, PVOID, PCONTEXT, PVOID);
9 +seh_dword_t seh_handler = reinterpret_cast<seh_dword_t>(_seh_handler);
10 +
11 +// EOF