このライブラリは、Windows 11バージョン24H2では機能しなくなりました。新しいセキュリティの強化により、非機能的になります。私はまだ修正を見つけていません!

MemoryDLLユニットは、Win64環境のメモリから直接動的リンクライブラリ(DLL)をロードするための高度な機能を提供します。ファイルシステムからDLLのロードを含む従来のメソッドとは異なり、 MemoryDLLを使用すると、バイト配列またはメモリストリームからDLLをロードできますか?関数アドレスを取得し、すべてのメモリをアンロードできます。このライブラリは、ファイルシステムに依存せずにDLLを管理する必要があるDelphi/Freepascal開発者に最適であり、パフォーマンスとセキュリティの両方を強化します。
MemoryDLLは、プレースホルダーDLLとフックベースのロードを使用して、従来のファイルベースのDLLロードをバイパスすることにより、メモリ内DLLの読み込みとリダイレクトを有効にします。
advapi32res.dllなど)をロードする試みを監視することにより、特定のDLLをロードするための呼び出しをリダイレクトします。このDLLは、フックがインターセプトしてリダイレクトをインメモリDLLに処理するためのトリガーとして機能します。互換性? : MemoryDLLユニットは、標準のDLLインターフェイスと互換性があり、既存のアプリケーションと簡単に統合できます。メモリ内リダイレクト法は、コードインジェクションなどのセキュリティリスクも削減し、DLL管理の安全な代替品を提供します。
メモリ画像からモジュールをロードし、Windows API LoadLibrary関数の動作を模倣します。 PE形式を解析し、必要な再配置を実行し、インポートを解決し、モジュールを初期化します。
Data: Pointer - PE形式に準拠するメモリ画像へのポインター。0表すTHandle 。MemoryDLLをプロジェクトに正常に統合するには、次の手順に従ってください。
最新バージョンをダウンロードしますか?
パッケージを解凍します
プロジェクトにmemorydllを追加します
usesセクションにmemorydllを追加します。この包含により、 MemoryDLLユニットがアプリケーションで使用できるようになります。コンピレーションエラーを回避するために、 MemoryDLLソースファイルへのパスがプロジェクト設定で正しく構成されていることを確認してください。Windows API互換性とのシームレスな統合
MemoryLoadLibraryを提供することにより、簡単に統合できます。ロードされると、 FreeLibraryやGetProcAddressなどの標準的なWindows API呼び出しを使用して、ファイルシステムからロードされているかのようにメモリ内DLLを管理できます。この設計により、既存のコードの最小限の変更が保証され、Windows APIコンベンションとの互換性を維持しながら、効率的なインメモリDLL処理を可能にします。統合をテストします
MemoryDllをインスタンス化するには、ユニットの実装セクションの最後に次のコードを含めます。このコードは、埋め込みリソースとしてDLLをロードしようとします。
uses
Windows,
MemoryDLL;
...
implementation
{
This code is an example of using MemoryDLL to load an embedded a DLL directly
from an embedded resource in memory, ensuring that no filesystem access is
required. It includes methods for loading, initializing, and unloading the
DLL. The DLL is loaded from a resource with a GUID name, providing a measure
of security by obfuscating the resource’s identity.
Variables:
- DLLHandle: THandle
- A handle to the loaded DLL. Initialized to 0, indicating the DLL has
not been loaded. It is updated with the handle returned from
LoadLibrary when the DLL is successfullyloaded from memory.
Functions:
- LoadDLL: Boolean
- Loads the DLL from an embedded resource and initializes it by
retrieving necessary exported functions. Returns True if the DLL is
loaded successfully, otherwise False.
- b6eb28fd6ebe48359ef93aef774b78d1: string
- A GUID-named helper function that returns the resource name for the DLL.
This GUID-like name helps avoid easy detection of the resource.
- UnloadDLL: procedure
- Unloads the DLL by freeing the library associated with DLLHandle. Resets
DLLHandle to 0 to indicate the DLL is unloaded.
Initialization:
- The LoadDLL function is called during initialization, and the program will
terminate with code 1 if the DLL fails to load.
Finalization:
- The UnloadDLL procedure is called upon finalization, ensuring the DLL is
unloaded before program termination.
}
var
DLLHandle: THandle = 0 ; // Global handle to the loaded DLL, 0 when not loaded.
{
LoadDLL
--------
Attempts to load a DLL directly from a resource embedded within the executable
file. This DLL is expected to be stored as an RCDATA resource under a specific
GUID-like name.
Returns:
Boolean - True if the DLL is successfully loaded, False otherwise.
}
function LoadDLL (): Boolean;
var
LResStream: TResourceStream; // Stream to access the DLL data stored in the
resource.
{
b6eb28fd6ebe48359ef93aef774b78d1
---------------------------------
Returns the name of the embedded DLL resource. Uses a GUID-like name for
obfuscation.
Returns:
string - The name of the resource containing the DLL data.
}
function b6eb28fd6ebe48359ef93aef774b78d1 (): string;
const
// GUID-like resource name for the embedded DLL.
CValue = ' b87deef5bbfd43c3a07379e26f4dec9b ' ;
begin
Result := CValue;
end ;
begin
Result := False;
// Check if the DLL is already loaded.
if DLLHandle <> 0 then Exit;
// Ensure the DLL resource exists.
if not Boolean((FindResource(HInstance,
PChar(b6eb28fd6ebe48359ef93aef774b78d1()), RT_RCDATA) <> 0 )) then Exit;
// Create a stream for the DLL resource data.
LResStream := TResourceStream.Create(HInstance,
b6eb28fd6ebe48359ef93aef774b78d1(), RT_RCDATA);
try
// Attempt to load the DLL from the resource stream.
DLLHandle := MemoryLoadLibrary(LResStream.Memory);
if DLLHandle = 0 then Exit; // Loading failed.
// Retrieve and initialize any necessary function exports from the DLL.
GetExports(DLLHandle);
Result := True; // Successful load and initialization.
finally
LResStream.Free(); // Release the resource stream.
end ;
end ;
{
UnloadDLL
---------
Frees the loaded DLL, releasing any resources associated with DLLHandle,
and resets DLLHandle to 0.
}
procedure UnloadDLL ();
begin
if DLLHandle <> 0 then
begin
FreeLibrary(DLLHandle); // Unload the DLL.
DLLHandle := 0 ; // Reset DLLHandle to indicate the DLL is no longer loaded.
end ;
end ;
initialization
// Attempt to load the DLL upon program startup. Halt execution with error
// code 1 if it fails.
if not LoadDLL() then
begin
Halt( 1 );
end ;
finalization
// Ensure the DLL is unloaded upon program termination.
UnloadDLL();
このユニットは、A-Normal-Userによる元のMemoryDll-DlRedirectプロジェクトに基づいています。このユニットが構築する基礎的な仕事に感謝します。
このプロジェクトは、特定の条件が満たされていれば、修正の有無にかかわらず、ソースおよびバイナリ形式での再分配と使用を可能にするBSD-3-Clauseライセンスの下でライセンスされています。寛容性と貢献者の権利を保護することのバランスをとっています。
MemoryDllへの貢献は強く奨励されています。お気軽に問題を提出したり、新機能を提案したり、その機能と堅牢性を拡大するためのプルリクエストを作成してください。

Delphiで❤️で作られています