I know it's been done a million times. This started (today) because I found a feature which I wanted to implement. This is the only documentation avaliable so far, apart from an uncommented test program :wink
So far the following functions are provided:
Reger_Init - Prepares data structures/critical sections
Reger_Free - Frees return values (allocated on a heap)
Reger_UnInit - Destroys data structures
Reger_Read - Reads a value from the registry
And the exciting one:
Reger_ReadVolatile - Reads a value from the registry, and if the value changes it will automatically be read again
Reger_StartVolatile - Call before using the returned pointer - basically starts a critical section
Reger_EndVolatile - Call after using the returned pointer - exits the critical section
Critical sections are only used if bMultithreaded (in Reger_Init call) is non-zero - however, multiple threads (one for each volatile read) are used regardless. I think this is probably wrong, which is why I'm posting now to get feedback from people who have done this stuff before :bg
The Reger_Read function returns the value in EAX, the length in ECX and the type in EDX. If the type is not REG_DWORD (4), EAX contains a pointer to a buffer. This buffer is guaranteed to be null-terminated and ECX may be up to 4 characters longer than the actual string.
The Reger_ReadVolatile function returns a pointer in EAX. DWORD PTR [EAX] contains either the value or the pointer as above, DWORD PTR [EAX+4] contains the type.
Full source code is included. ASM Runtime (http://www.masmforum.com/simple/index.php?topic=3148.30) required to build the test program. Test1.exe is when the first section of code (Reger_Read) is enabled. Test2.exe is when the second section (Reger_ReadVolatile) is enabled.
Enjoy :U
Reger.zip (15.3kb) (http://www.freewebtown.com/zooba/Reger.zip)