Happy New Year to all my assembly friends.
I am having much trouble with the NetUserEnum Function.
My code is as follows:
Ok, so it gets through the error checks ok, but when I invoke the MessageBox, it does not display the user name correctly, only some squares. It iterates through the loop the correct number of times.
What am I missing here?
Wongdai
I am having much trouble with the NetUserEnum Function.
My code is as follows:
entriesread dd ?
totalentries dd ?
user_name LPWSTR ?
invoke NetUserEnum,NULL,0,FILTER_NORMAL_ACCOUNT,addr user_name,
MAX_PREFERRED_LENGTH, addr entriesread,
addr totalentries,NULL
.IF eax==ERROR_ACCESS_DENIED
invoke ShellAbout,hWin,addr AccessDenied,addr AboutMsg,NULL
.elseif eax==NERR_InvalidComputer
invoke ShellAbout,hWin,addr InvalidComputer,addr AboutMsg,NULL
.elseif eax==NERR_GroupNotFound
invoke ShellAbout,hWin,addr GroupNotFound,addr AboutMsg,NULL
.elseif eax==ERROR_MORE_DATA
invoke ShellAbout,hWin,addr MoreData,addr AboutMsg,NULL
.else
push ebx
xor ebx,ebx
push esi
mov esi,user_name
cmp ebx,entriesread
jae skip
shownext:
invoke MessageBoxW,0,addr user_name,0,0
add ebx,1
add esi,4
cmp ebx,entriesread
jb shownext
skip:
pop esi
pop ebx
Ok, so it gets through the error checks ok, but when I invoke the MessageBox, it does not display the user name correctly, only some squares. It iterates through the loop the correct number of times.
What am I missing here?
Wongdai
Try changing user_name LPWSTR ? to user_name USER_INFO_0 <>
PS: Wish U all a happy new year :D
PS: Wish U all a happy new year :D
Thanks - but no cigar. ;-)
Exactly the same result.
Wongdai
Exactly the same result.
Wongdai
If no-one can see the problem, does anyone have any code that uses this function (NetUserEnum) that they could lend me?
Wongdai
Wongdai
invoke MessageBoxW,0,addr user_name,0,0
bufptr, On return a pointer to the return information structure is returned in the address pointed to by bufptr.
You need to dereference the returned pointer first.
Regards, P1 8)
Thanks, but...
I'm sorry, I am very newb at this.
How do I achieve this dereferencing of the pointer?
Wongdai
I'm sorry, I am very newb at this.
How do I achieve this dereferencing of the pointer?
Wongdai
invoke MessageBoxW,0,user_name,0,0
If I remove the addr (i.e. invoke MessageBoxW,0,user_name,0,0) I get an error on compile "INVOKE argument type mismatch : argument : 2".
I image this is because user_name is defined as:
user_name USER_INFO_0 <>
Yes?
So I tried before calling MessageBoxW to
mov esi,user_name
and then
invoke MessageBoxW,0,esi,0,0)
but I still get pretty much the same results as when I started, i.e. the message that it displays is just boxes.
I am obviously not good at this, but am determined not to give up.
Any other ideas please?
Wongdai
I image this is because user_name is defined as:
user_name USER_INFO_0 <>
Yes?
So I tried before calling MessageBoxW to
mov esi,user_name
and then
invoke MessageBoxW,0,esi,0,0)
but I still get pretty much the same results as when I started, i.e. the message that it displays is just boxes.
I am obviously not good at this, but am determined not to give up.
Any other ideas please?
Wongdai
BTW, user_name is a pointer to an array of pointers to USER_INFO_0 structures.
This will fix your code.
When you get into COM interfaces, you will need to know how and when to dereference your data.
Regards, P1 8)
shownext:
mov eax,
invoke MessageBoxW,0,eax,0,0
This will fix your code.
When you get into COM interfaces, you will need to know how and when to dereference your data.
Regards, P1 8)
invoke MessageBoxW,0,user_name,0,0
Regards, P1 8)
Thanks P1
I will try that when I get home tonight. Sounds like I was on the right track? (....but would never have actually got there. ;0( )
Wongdai
I will try that when I get home tonight. Sounds like I was on the right track? (....but would never have actually got there. ;0( )
Wongdai
P1
You are a bliddy genius! It works!
Now I just have to work out why.
;-)
Thanks
wongdai
You are a bliddy genius! It works!
Now I just have to work out why.
;-)
Thanks
wongdai
P1, You are a bliddy genius! It works!
Then this board is full of geniuses. I was just the first one to answer.Remember to do this as well:
bufptr
Pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter. This buffer is allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the function fails with ERROR_MORE_DATA.
Pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter. This buffer is allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the function fails with ERROR_MORE_DATA.
Regards, P1 8)
Ah, ok thanks
I would probably have forgotten to do this.
Wongdai
I would probably have forgotten to do this.
Wongdai