Document of c-modernization-kit (funcman) 1.0.0
Loading...
Searching...
No Matches
dllmain.h File Reference

汎用 DLL ロード・アンロードフックヘッダー。 More...

#include <syslog.h>
Include dependency graph for dllmain.h:

Go to the source code of this file.

Macros

#define DLLMAIN_INFO_MSG(msg)
 DllMain / constructor / destructor コンテキストで安全に 情報メッセージを出力するマクロ。

Functions

static void onLoad (void)
 ライブラリのロード時に呼び出されるフック関数。
static void onUnload (void)
 ライブラリのアンロード時に呼び出されるフック関数。
 __attribute__ ((constructor)) static void dllmain_on_load__(void)
 共有ライブラリロード時のコンストラクタ (Linux 専用)。
 __attribute__ ((destructor)) static void dllmain_on_unload__(void)
 共有ライブラリアンロード時のデストラクタ (Linux 専用)。

Detailed Description

汎用 DLL ロード・アンロードフックヘッダー。

Author
c-modenization-kit sample team
Date
2026/02/23
Version
1.0.0

このヘッダーをインクルードした .c ファイルに対して、プラットフォームごとの DLL ロード・アンロードフックを提供します。

インクルード元の .c ファイルは以下の関数を定義する必要があります。

  • onLoad() : ライブラリロード時に呼び出される関数
  • onUnload(): ライブラリアンロード時に呼び出される関数

Linux : attribute((constructor/destructor)) により onLoad / onUnload が 自動的に呼び出されます。

Windows: DllMain の DLL_PROCESS_ATTACH / DLL_PROCESS_DETACH により onLoad / onUnload が呼び出されます。

Definition in file dllmain.h.

Macro Definition Documentation

◆ DLLMAIN_INFO_MSG

#define DLLMAIN_INFO_MSG ( msg)
Value:
syslog(LOG_INFO, (msg))

DllMain / constructor / destructor コンテキストで安全に 情報メッセージを出力するマクロ。

DllMain コンテキストおよび constructor / destructor コンテキストでは 呼び出し可能な API に制限があります。
Linux では syslog(LOG_INFO, ...) を、Windows では OutputDebugStringA を使用することで制約を回避します。

Parameters
[in]msg出力するメッセージ文字列リテラル。

Definition at line 47 of file dllmain.h.

Function Documentation

◆ onLoad()

void onLoad ( void )
static

ライブラリのロード時に呼び出されるフック関数。

このヘッダーをインクルードする .c ファイルで定義する必要があります。
Linux では dlopen() またはプロセス起動時に、 Windows では LoadLibrary() またはプロセス起動時に呼び出されます。

Referenced by __attribute__().

Here is the caller graph for this function:

◆ onUnload()

void onUnload ( void )
static

ライブラリのアンロード時に呼び出されるフック関数。

このヘッダーをインクルードする .c ファイルで定義する必要があります。
Linux では dlclose() またはプロセス正常終了時に、 Windows では FreeLibrary() またはプロセス正常終了時に呼び出されます。

Referenced by __attribute__().

Here is the caller graph for this function:

◆ __attribute__() [1/2]

__attribute__ ( (constructor) )

共有ライブラリロード時のコンストラクタ (Linux 専用)。

attribute((constructor)) により、dlopen() または プロセス起動時に自動的に呼び出されます。

Definition at line 75 of file dllmain.h.

References onLoad().

Here is the call graph for this function:

◆ __attribute__() [2/2]

__attribute__ ( (destructor) )

共有ライブラリアンロード時のデストラクタ (Linux 専用)。

attribute((destructor)) により、dlclose() または プロセス正常終了時に自動的に呼び出されます。

Definition at line 85 of file dllmain.h.

References onUnload().

Here is the call graph for this function: