Author Topic: DLL load fails although instructions appear valid  (Read 9198 times)

Offline paml27

  • Jr. Member
  • *
  • Posts: 37
DLL load fails although instructions appear valid
« on: January 02, 2018, 07:44:54 PM »
I recently moved to 64-bit NASM from 32-bit MASM, and I have a simple addressing problem. 

I am writing a DLL in NASM.  The following two lines assemble and link with the NASM assembler / GoLink, but when I try to load the DLL, I get an OS error "invalid access to memory location."  RCX contains a pointer that is passed into the DLL: 

mov rax,254
mov [rcx+8],rax

When I try it this way, it also doesn't work: 
mov rax,254
mov [rcx+8],qword rax

The rest of the DLL is fine, just those two lines cause a load failure. 

Thanks for any ideas. 

Offline dreamCoder

  • Full Member
  • **
  • Posts: 107
Re: DLL load fails although instructions appear valid
« Reply #1 on: January 03, 2018, 09:08:59 AM »
Hard to tell from this snippet alone. Need more information. It could be that RCX is by itself not a valid pointer. It could be something else, like stack alignment, register corruptions and stuff. 64-bit is a different beast.