flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 24 Apr 2020, 00:43
To read a memory value just do this:
Code: mov ecx,[rdx] Code: mov [rdx],ecx |
|||
![]() |
|
jmurray 24 Apr 2020, 19:22
The program which uses this has already allocated a memory location. The value forwarded in rdx is an Intptr of this memory location.
I have made the following changes to the code, but it now crashes on write: Code: proc ReadMemory uses rcx, rdx ;Read uint32 from rdx, return in rcx mov rbx,[rdx];set rbx to memory location at rdx mov eax,dword [rbx];move the first 4 bytes at rbx into eax mov [rcx],eax;move eax into rcx mov rax,rcx ret endp proc WriteMemory uses rcx, rdx ;Write int32/uint32 from rcx to first 4 bytes of rdx mov rbx,[rdx];set rbx to memory location at rdx mov eax,dword [rcx];Write value into eax mov [rbx],eax;Write value from eax into rbx ret endp I may be overthinking this, but am very grateful for the help. |
|||
![]() |
|
revolution 24 Apr 2020, 20:33
It looks like you want to do a memory-to-memory move, and your registers are pointers to the locations.
Code: proc MoveMemory ;Move uint32 from [rdx], to [rcx] mov eax,[rdx] moc [rcx],eax ret endp |
|||
![]() |
|
jmurray 24 Apr 2020, 22:26
I'm not sure what you think I'm trying to do.
My external program uses these dll procedures to store and read from a memory address at pointer rdx. It does this by either passing a uint32 to write to memory in rcx for write, or passes a uint32 for the procedure to write the contents of memory into in the case of read. The issue i'm having is that when writing in "123" for example, when it is read from the same pointer, returns a different number. Because I am now directly feeding the procedures the rdx pointer from my program, I am now using my initial code example again. But the problem persists. This is under the assumption that a called DLL has access to the calling programs memory space however. |
|||
![]() |
|
revolution 24 Apr 2020, 23:14
What is your external program? Does it use the Windows fastcall convention? If it does then it will expect a return value in RAX.
Code: proc ReadMemory ;Read uint32 from rdx, return in rax mov eax,[rdx] ;read memory ret endp Code: proc ReadMemory ;Read uint32 from [rdx], return in rax mov rax,[rdx] ;read pointer mov eax,[rax] ;read memory ret endp |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.