Hi... this probably seems like a simple question to most of you, but it's got me stumped. I'm trying to use the GetComputerName api call to put the name of the local computer into a buffer. I've got:

MiscBuffer db 256 dup (?)

And then I run:

invoke GetComputerName, addr MiscBuffer, sizeof MiscBuffer

...and when the code runs it crashes when it gets to this point.

I've tried using:

lea esi,MiscBuffer
invoke GetComputerName, esi, sizeof MiscBuffer

etc etc and it still crashs.
The same happens when I try to use GetUserName. I have a feeling it's to do with pointers, or something like that I seem to have missed.

Can anyone help me?

- Fourfty
Posted on 2001-09-11 13:24:24 by Fourfty
MSDN says argument 2 is of type LPDWORD, which is a pointer to a DWORD.

This API returns a DWORD value via its arguments. You need to create a "return argument".
MiscBuffer db 256 dup (?) 

MiscBufferSize dd ?

mov MiscBufferSize, sizeof MiscBuffer
invoke GetComputerName, addr MiscBuffer, addr MiscBufferSize
; if success, MiscBufferSize has value of lstrlen(MiscBuffer)
Posted on 2001-09-11 14:44:37 by tank