The MASM Forum

General => The Campus => Topic started by: Don57 on February 08, 2013, 03:19:13 AM

Title: Wait for API call ?
Post by: Don57 on February 08, 2013, 03:19:13 AM
I need to wait for an API call to fill return buffers. The only thing that comes to mind is CreateProcess and WaitForSingleObject which I don't thing will work with an API call.
Title: Re: Wait for API call ?
Post by: dedndave on February 08, 2013, 03:38:11 AM
which API call are you waiting for ?   :biggrin:
Title: Re: Wait for API call ?
Post by: Don57 on February 08, 2013, 03:50:53 AM
RegEnumValue - if I try to read the buffer right after the call the data is not correct. If I wait to read the data , the proper data is returned, it is almost as if the call takes time to write to the 5 buffers.
Title: Re: Wait for API call ?
Post by: dedndave on February 08, 2013, 03:55:45 AM
that seems very strange
it's not supposed to be an asyncronous function
i.e., when the function returns, the buffers should be filled, according to the return status

are you calling it in a thread or something ?
Title: Re: Wait for API call ?
Post by: dedndave on February 08, 2013, 03:57:10 AM
QuoteIf the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is a system error code.

ERROR_SUCCESS = 0

if it returns 0, the buffers should be valid
Title: Re: Wait for API call ?
Post by: dedndave on February 08, 2013, 04:02:38 AM
also important:
QuoteWhile using RegEnumValue, an application should not call any
registry functions that might change the key being queried.
Title: Re: Wait for API call ?
Post by: Don57 on February 08, 2013, 04:09:48 AM
The call is from the mainline. If I use the routines that I wrote for debugging and read all the returned buffers in orders the data is valid.
However when I try to read just lp_lp_RegValueName and lp_RegData the data becomes incorrect. For example DisplayName becomes SystemComponent. It is almost as if the buffers have not finished writting.
Title: Re: Wait for API call ?
Post by: dedndave on February 08, 2013, 04:13:37 AM
something is fishy
i guess i would take a closer look at the difference between the 2 programs
perhaps the second test piece is overwriting a buffer
you might also check to see that, if the buffer is on the stack, that ESP is below it   :P

disassembling the code may give you some insight
Title: Re: Wait for API call ?
Post by: dedndave on February 08, 2013, 04:16:06 AM
.....if not, plug it into Olly