NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: pikeplan9 on June 08, 2013, 11:09:17 AM

Title: Windows ExitProcess call fail !
Post by: pikeplan9 on June 08, 2013, 11:09:17 AM
I have the following code
Code: [Select]
; ExitProcess(0)
push 0
call [ebp + 8]; exit process
is this related to stack alignment ?
it fails eax set to 2 and error code INVALID_PARAMETER_ID
screen shot
http://sdrv.ms/116dV5S (http://sdrv.ms/116dV5S)
Title: Re: Windows ExitProcess call fail !
Post by: shellc0de on June 08, 2013, 11:36:05 AM
Try this?
Code: [Select]
[BITS 32]
xor eax,eax
push eax
mov eax,0x7c81d20a
call eax
Sorry,0x7c81d20a this is address of ExitProces in kernel you must use dllexport to see what address is at your pc.
Title: Re: Windows ExitProcess call fail !
Post by: Frank Kotler on June 08, 2013, 06:05:04 PM
This seems a little weird to me. What would be an "invalid" parameter to ExitProcess? What reason do you have to think that ExitProcess is at [ebp + 8]? Did you put it there? I would suspect that the error is from some other API.

As far as using some specific address for ExitProcess, doesn't MS randomize this stuff every Tuesday? I don't know much Windows, but this seems spectacularly non-portable!

What's wrong with:
Code: [Select]
global start
extern ExitProcess
section .text
start:
push 0
call ExitProcess
?

As an experiment, can you get that error from ANY parameter to ExitProcess?

Baffled,
Frank