Jump to content
Tuts 4 You
Sign in to follow this  
DrPepUr

Winasm Question

Recommended Posts

DrPepUr

I am playing around a little with Masm @ Winasm trying to get the computername

I tried this

.data?

ComputerName db 255 dup(?)

lSize db 255 dup(?)

.Code

invoke GetComputerName,addr ComputerName,addr lSize

It compiles and runs but no return, what am I doing wrong?

Edited by dustyh1981 (see edit history)

Share this post


Link to post
HVC
.data?
ComputerName db 255 dup(?)
lSize dd ?.code
invoke RtlZeroMemory, OFFSET ComputerName, SIZEOF ComputerName
mov lSize, SIZEOF ComputerName
invoke GetComputerName,addr ComputerName,addr lSize

A. iSize needs to be of DWORD size.

B. Before calling GetComputerName, iSize needs to hold the size of the buffer pointed by the 1st parameter of the GetComputerName API (in this case, the size of ComputerName buffer).

C. After calling GetComputerName, iSize holds the length of the Computer name.

Edited by HVC (see edit history)

Share this post


Link to post
DrPepUr

You are a life saver thanks

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×
×
  • Create New...