السلام عليكم ورحمة الله
وكيف حالكم جميعا وارجوا ان يكون الجميع بخير
اردت ان يقوم برنامجي بتغيير بايتات معينة في جسمه ولكن تظهر رسالة ان الملف مشغول ولا يمكن اجراء العملية
اي ما كانت الطريقة لابد وان تكون قد تطرق لها احد ما هنا او هناك او لها مكونات او حلول احترافية مرت بكم
وشكرا
وعليكم السلام ورحمة الله وبركاته
احد الطرق:
ينسخ البرنامج نفسه باسم مخلتلف/مجلد اخر
ينفذ النسخة الجديدة وينهي مهامه
النسخة الجديدة تقوم بتعديل النسخة الاصلية
تنفذ النسخة الجديدة النسخة القديمة وتنهي مهامها
وعليكم السلام ورحمة الله وبركاته
عند البرمجة صمم برنامجين ، برنامج إسمه Luncher يقوم بتشغيل البرنامج و هو الذي يقوم بالفحص أو التغيير ، والثاني ينفذ من طرف Luncher حيث لا يمكن تنفيذه مباشرة
كود :
والثاني ينفذ من طرف Luncher حيث لا يمكن تنفيذه مباشرة
هل يوجد ملفات تنفيذية لا تعمل الا عند الطلب
على العموم الذكاء الصناعي طلبت منه كود لتغيير بايتات لملف تنفيذي يعمل بالذاكرة فاعطاني هذا الكود ولم افهم منه شئ
كود :
uses
Windows, SysUtils;
const
PAGE_READWRITE = $04;
PROCESS_ALL_ACCESS = $001F0FFF;
var
hProcess: THandle; // Handle to the process we want to modify.
pBaseAddress: Pointer; // Base address of the executable in memory.
pBuffer: array[0..255] of Byte; // Buffer containing the bytes we want to write.
begin
// Get a handle to the process we want to modify.
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, GetCurrentProcessId);
// Get the base address of the executable in memory.
pBaseAddress := VirtualAllocEx(hProcess, nil, SizeOf(pBuffer), MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE);
// Write our buffer of bytes to the executable in memory.
WriteProcessMemory(hProcess, pBaseAddress, @pBuffer[0], SizeOf(pBuffer), nil);
// Free up resources and close handles.
VirtualFreeEx(hProcess, pBaseAddress, 0, MEM_RELEASE); CloseHandle(hProcess); end.
فهل فيه شئ ينفع لما نتحدث عنه
او شئ اخر
كود :
// This code will modify the hex values at a specific address in an executable.
// It assumes that the executable is already loaded into memory.
uses Windows; // for the VirtualProtect function
const
// The address of the hex values to be modified:
HexAddress = $12345678;
// The new hex values to be written:
NewHexValues: array[0..3] of Byte = ($01, $02, $03, $04);
var
OldProtection: DWORD; // used by VirtualProtect function
begin
// Change the memory protection at HexAddress so we can write to it:
VirtualProtect(Pointer(HexAddress), 4, PAGE_EXECUTE_READWRITE, @OldProtection);
// Write the new hex values to HexAddress:
Move(NewHexValues[0], Pointer(HexAddress)^, 4);
// Restore the original memory protection at HexAddress:
VirtualProtect(Pointer(HexAddress), 4, OldProtection, @OldProtection);
end.
(13-01-2023, 03:27 AM)Delphi4Us كتب : [ -> ]الذكاء الصناعي طلبت منه كود لتغيير بايتات لملف تنفيذي يعمل بالذاكرة فاعطاني هذا الكود ولم افهم منه شئ
ذلك مثال للتعديل على البرنامج بالذاكرة وليس الملف التنفيذي بالقرص.