لم تعد هذه المكتبة تعمل في Windows 11 الإصدار 24H2. تحسينات الأمان الجديدة تجعلها غير وظيفية. لم أجد إصلاحًا بعد!

توفر وحدة MemoryDLL وظائف متقدمة لتحميل مكتبات الارتباط الديناميكي (DLLS) مباشرة من الذاكرة في بيئات Win64. على عكس الطرق التقليدية التي تتضمن تحميل DLLs من نظام الملفات ، يتيح لك MemoryDLL تحميل DLLs من صفائف البايت أو تدفقات الذاكرة؟ واسترداد عناوين الوظائف وتفريغها-كل ذلك في الذاكرة. تعتبر هذه المكتبة مثالية لمطوري Delphi/Freepascal الذين يحتاجون إلى إدارة DLLs دون الاعتماد على نظام الملفات ، وتعزيز كل من الأداء والأمان.
تتيح MemoryDLL تحميل DLL في الذاكرة باستخدام DLLs من العناصر النائبة والتحميل المستند إلى الخطاف لتجاوز تحميل DLL التقليدي المستند إلى الملف:
advapi32res.dll ). يعمل DLL هذا كمشغل للخطاف لاعتراض ومعالجة إعادة التوجيه إلى DLL في الذاكرة. التوافق؟ : وحدة MemoryDLL متوافقة مع واجهات DLL القياسية ، مما يسمح بسهولة التكامل مع التطبيقات الموجودة. كما أن طريقة إعادة التوجيه في الذاكرة تقلل أيضًا من مخاطر الأمان ، مثل حقن الكود؟ ، مما يوفر بديلاً آمنًا لإدارة DLL.
يقوم بتحميل الوحدة النمطية من صورة الذاكرة ، ويحاكي سلوك دالة LoadLibrary Windows API. إنه يوسع تنسيق PE ، ويقوم بإجراء عمليات نقل ضرورية ، ويحل الواردات ، ويهيئ الوحدة النمطية.
Data: Pointer - مؤشر لصورة الذاكرة تتوافق مع تنسيق PE.THandle تمثل الوحدة المحملة أو 0 عند الفشل.لدمج الذاكرة بنجاح في مشروعك ، يرجى اتباع هذه الخطوات:
قم بتنزيل أحدث إصدار؟
فك ضغط الحزمة
أضف الذاكرة إلى مشروعك ➕
uses مشروعك. سيجعل هذا التضمين وحدة MemoryDLL للاستخدام في التطبيق الخاص بك. تأكد من تكوين المسار إلى ملف مصدر الذاكرة بشكل صحيح في إعدادات المشروع الخاصة بك لتجنب أخطاء التجميع.تكامل سلس مع توافق Windows API
MemoryLoadLibrary لتحميل DLLs مباشرة من الذاكرة. بمجرد التحميل ، يمكن استخدام مكالمات Windows API القياسية مثل FreeLibrary و GetProcAddress لإدارة 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();
تعتمد هذه الوحدة على مشروع MemoryDll-dlleRdirect الأصلي بواسطة المستخدم الطبيعي. نعترف بامتنان العمل الأساسي الذي تبنيه هذه الوحدة.
تم ترخيص هذا المشروع بموجب ترخيص BSD-3-Cause ؟ ، والذي يسمح بإعادة التوزيع والاستخدام في النماذج المصدر والثنائية ، مع أو بدون تعديل ، شريطة استيفاء شروط معينة. إنه يلفت التوازن بين التساهل وحماية حقوق المساهمين.
يتم تشجيع المساهمات في MemoryDLL للغاية. لا تتردد في تقديم المشكلات ، أو اقتراح ميزات جديدة ، أو إنشاء طلبات سحب لتوسيع قدراتها والقوة.

مصنوع من ❤ في دلفي