![]() |
|
#1
|
|||
|
|||
How to enable Code section (Read / Write) in x64
Anyone have an example on how to enable Code section (Read / Write) in x64 please?
Thanks |
#2
|
|||
|
|||
Are you talking about the section headers? If so, then CFF explorer has this option to enable/disable the sections flags. Apologies if I misunderstand your question.
This might help you: https://github.com/OsandaMalith/PESecInfo Last edited by Stingered; 02-21-2023 at 01:12. |
#3
|
|||
|
|||
Quote:
I used the same way as below: PUSH ESP PUSH 40 // code writable PUSH 1000 // size of code to make writable PUSH 401000 // start address of code to make writable CALL VirtualProtect // xxxxxxxx is address of VirtualProtect I did this in several x32 app's and worked just fine but in x64 no way Last edited by New Tiger; 02-21-2023 at 05:12. |
#4
|
|||
|
|||
Based on the original question, there are two ways:
Based on your second post, the most promising answer would be:
|
#5
|
|||
|
|||
Quote:
Also, based on yor answer, Mr VIP, in particular the last line "Your problem definitely is not some write permission, but the basic understanding of the CPU architecture" can you teach me Mr professional these fundamentals. Understand the question before you show off your muscles. It's real useful for you to keep this advice for your own as when I was handling these x32 stuff you were still asking for suckle, I don't know how admins promoted you to VIP here??????? Just get away! you're really very rude Last edited by New Tiger; 02-21-2023 at 06:02. |
#6
|
|||
|
|||
@New Tiger
Take a look at this link and see if it helps: https://ethical.blue/textz/n/28 |
The Following User Says Thank You to Stingered For This Useful Post: | ||
New Tiger (02-21-2023) |
#7
|
|||
|
|||
Quote:
![]() @New Tiger The calling convention in 64-bit is different from that of 32-bit. The x64 Application Binary Interface (ABI) uses a four-register fast-call calling convention by default. Space is allocated on the call stack as a shadow store for callees to save those registers. Meaning that the parameters are passed to the function through registers as a default which differs significantly from the 32-bit manner where the stack can be wholly used for passing the parameters. Example: Quote:
![]() Please read these 2 pages for more info: Quote:
Then the VirtualProtect should work just fine in 64-bit also ![]() |
#8
|
|||
|
|||
@Stingered
Thanks mate for the provided link. @Rasmus Appreciated, really useful information mate. Last edited by New Tiger; 02-22-2023 at 04:26. |
#9
|
|||
|
|||
Problem is solved
Last edited by New Tiger; 02-22-2023 at 04:28. |
#10
|
|||
|
|||
I think this Tiger trying break brains.
But possible he banned in Google. |
#11
|
|||
|
|||
Quote:
Where are the admins? Isn't this a false accusation and defamation |
#12
|
||||
|
||||
Hi New_Tiger,
I think it would be easier for people to help you if you were to post the assembly code you were using in x64 to attempt to solve this. Since you only provided the code in 32 bit assembly, we are left only to speculate what the issue could be. Anyway, since you posted the screenshot of what you were doing, it is clear that you were using the wrong calling convention. In x64, parameters are not passed to the WINAPI using the STDCALL convention, but rather a FAST CALL convention. Your code show be something like the following: MOV ECX, ADDRESS_OF_SECTION MOV EDX, SIZE_OF_SECTION MOV r8d, NEW_PROTECT_CONSTANT MOV r9, Address of an empty dword where the old_protect is returned CALL VirtualProtect
__________________
"As the island of our knowledge grows, so does the shore of our ignorance." John Wheeler |
#13
|
|||
|
|||
Quote:
Once again, thanks and do apologize! |
#14
|
|||
|
|||
However if you are dealing with Linux and 64 bit ELF files, the advice is similar but the headers and format different. Instead of VirtualProtect there is mprotect, etc. Based on responses, it's clear everyone here still uses Windows, myself included.
Also at ring0 there exists possibility of modifying page tables and changing the protection directly without using the OS API wrappers for this purpose. The 32 bit calling conventions include fastcall, register, vectorcall and thiscall which do use registers. Sure cdecl and stdcall or Pascal conventions are common, but it's incorrect to say it doesn't use registers. Those conventions exist on a multitude of compilers. By 64 bit era there are so many registers added beyond there mere double bitwidth that for performance reasons there was no reason to keep stack only methods. |
#15
|
|||
|
|||
I was not aware of the calling convention in x64 but with the aid of the provided references I could solve the issue.
|
![]() |
Thread Tools | |
Display Modes | |
|
|