14#if !defined(__CYGWIN__) && !defined(WINELIB)
18#if defined(BI_MULTI_THREAD_RTL)
22#if defined(__BORLANDC__)
68#if defined(BI_MULTI_THREAD_RTL)
86 static TWindow*& GetInstance();
89TWindow*& TCreationWindow::GetInstance()
91#if defined(BI_MULTI_THREAD_RTL)
130 return TCreationWindow::GetInstance();
148 _T(
"), New(") << (
void*)
w <<
_T(
')'));
149 TCreationWindow::GetInstance() =
w;
170# define DEFWINDOWPROC "DefWindowProcW"
172# define DEFWINDOWPROC "DefWindowProcA"
175#define DEFWINDOWPROC_MODULE _T("USER32")
177 HMODULE module = GetModuleHandle(DEFWINDOWPROC_MODULE);
209 w->SubclassWindowFunction();
222#if defined(BI_NOTHUNK)
233TWindow::CreateInstanceProc()
246 WARNX(
OwlThunk, !
hObj, 0,
_T(
"CommonWndProc: Handle lookup failed! GetLastError: ") << ::GetLastError());
255 return &TLocal::CommonWndProc;
262TWindow::InitInstanceProc()
266 WARNX(
OwlThunk, !
r, 0,
_T(
"InitInstanceProc: Handle registration failed! GetLastError: ") << ::GetLastError());
274TWindow::FreeInstanceProc()
277 WARNX(
OwlThunk, !
h, 0,
_T(
"FreeInstanceProc: Handle removal failed! GetLastError: ") << ::GetLastError());
290#define THUNK_ALLOCATOR_DIAGNOSTICS_VARIABLES\
294#define THUNK_ALLOCATOR_DIAGNOSTICS_INITIALIZATION\
295 , Count(0), Maximum(0)
297#define THUNK_ALLOCATOR_DIAGNOSTICS_UPDATE(i)\
299 if ((Count += i) > Maximum)\
302 WARNX(OwlThunk, true, 2, _T("New thunk count record: ") << Maximum);\
304 CHECKX(Count >= 0, _T("Negative thunk count!"));\
309#define THUNK_ALLOCATOR_DIAGNOSTICS_VARIABLES
310#define THUNK_ALLOCATOR_DIAGNOSTICS_INITIALIZATION
311#define THUNK_ALLOCATOR_DIAGNOSTICS_UPDATE(i)
326 static TThunkAllocator& GetInstance()
350 const auto ok = Handle !=
nullptr;
351 WARN(!
ok,
_T(
"TThunkAllocator::~TThunkAllocator: Terminating due to failed precondition."));
352 if (!
ok) std::terminate();
355 WARNX(
OwlThunk, !
r, 0,
_T(
"HeapDestroy failed! GetLastError: ") << ::GetLastError());
362 LPVOID Allocate(
size_t size)
367 if (!p) TXOutOfMemory().Throw();
379 WARNX(
OwlThunk, !
r, 0,
_T(
"HeapFree failed! GetLastError: ") << ::GetLastError());
404 WARNX(
OwlThunk, !Handle, 0,
_T(
"HeapCreate failed! GetLastError: ") << ::GetLastError());
405 if (!Handle) TXOutOfMemory().Throw();
412 TThunkAllocator(
const TThunkAllocator&);
413 TThunkAllocator& operator=(
const TThunkAllocator&);
437 struct TCode {
uint8 bytes[Size];};
448 typename TFactory::TCode Code;
449 static const TFactory Factory;
455 : Code(Factory.CodeTemplate)
461 void*
operator new(
size_t n)
463 LPVOID p = TThunkAllocator::GetInstance().Allocate (
n);
472 void operator delete(
void* p,
size_t)
474 WARNX(
OwlThunk, !p, 0,
_T(
"TThunk::delete called with null pointer."));
476 TThunkAllocator::GetInstance().Free(p);
484template <const u
int8* i,
size_t s,
void* (*gpa)(),
int dai,
int iai>
485const typename TThunkT<i, s, gpa, dai, iai>::TFactory
486TThunkT<i, s, gpa, dai, iai>::Factory;
500 0xB8, 0x00, 0x00, 0x00, 0x00,
501 0x89, 0x44, 0x24, 0x04,
502 0x68, 0x00, 0x00, 0x00, 0x00,
531 0xB9, 0x00, 0x00, 0x00, 0x00,
532 0x68, 0x00, 0x00, 0x00, 0x00,
547 return *
reinterpret_cast<void**
>(&f);
569 0x48, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571 0x48, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
588#elif defined(_M_IX86)
593#error OWLNext: Unable to generate thunks for this platform.
599#if defined(__BORLANDC__)
601#elif defined(_MSC_VER)
603#elif defined(__GNUC__)
606#error OWLNext: Unable to generate thunks for this compiler.
613TWindow::CreateInstanceProc()
615 return reinterpret_cast<WNDPROC>(
new TThunk(
this));
622TWindow::InitInstanceProc()
630TWindow::FreeInstanceProc()
632 delete reinterpret_cast<TThunk*
>(GetInstanceProc());
#define WARNX(group, condition, level, message)
#define WARN(condition, message)
#define PRECONDITION(condition)
#define DIAG_DECLARE_GROUP(group)
#define TRACEX(group, level, message)
#define DIAG_DEFINE_GROUP_INIT(f, g, e, l)
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
static LRESULT CALLBACK InitWndProc(HWND, UINT msg, WPARAM, LPARAM)
Callback process for hooking TWindow to native window.
HWND GetHandle() const
Returns the handle of the window.
#define OWLInternalVersion
Reliable platform independent header for common memory and string functions.
Object Windows Library (OWLNext Core)
TModule & OWLGetModule()
Returns a reference to the global OWL module object. When linking dynamically to OWLNext,...
UINT TMsgId
Message ID type.
WNDPROC GetDefWindowProc()
void * GetDispatchHelper()
TThunkT< ThunkInitializerForMicrosoft32Bit, sizeof ThunkInitializerForMicrosoft32Bit, &GetMessageReceiverMemberFunctionAddress, 6, 1 > TThunkForMicrosoft32Bit
void SetCreationWindow(TWindow *w)
const uint8 ThunkInitializerForMicrosoft32Bit[]
LPARAM TParam2
Second parameter type.
WPARAM TParam1
First parameter type.
LRESULT TResult
Result type.
TThunkT< ThunkInitializerForBorland32Bit, sizeof ThunkInitializerForBorland32Bit, &GetDispatchHelper, 10, 1 > TThunkForBorland32Bit
TModule & GetGlobalModule()
TResult CALLBACK DispatchWindowMessage(TWindow *w, TMsgId msg, TParam1 param1, TParam2 param2)
uint32 OWLGetVersion()
Get version of OWL at runtime.
const uint8 ThunkInitializerForMicrosoft64Bit[]
const uint8 ThunkInitializerForBorland32Bit[]
void * GetMessageReceiverMemberFunctionAddress()
TThunkT< ThunkInitializerForMicrosoft64Bit, sizeof ThunkInitializerForMicrosoft64Bit, &GetDispatchHelper, 2, 13 > TThunkForMicrosoft64Bit
TWindow * GetCreationWindow()
#define THUNK_ALLOCATOR_DIAGNOSTICS_UPDATE(i)
#define THUNK_ALLOCATOR_DIAGNOSTICS_INITIALIZATION
#define THUNK_ALLOCATOR_DIAGNOSTICS_VARIABLES
Base window class TWindow definition, including HWND encapsulation.