Jump to content
Tuts 4 You

Winasm Question


DrPepUr

Recommended Posts

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
Link to comment
.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
Link to comment

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
×
×
  • Create New...