Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How reliable/secure are getenv('User') & WScript.Network
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00953302
Message ID:
00954675
Views:
10
That's an interesting discussion, mind if I join :)

I just tried a simple code. It shows that at the very beginning a FoxPro app reads environmental variables to its internal variables. Whenever you call GETENV(), it does not invoke GetEnvironmentVariable API call.

Here is the code:
CLEAR
CLEAR ALL

DECLARE INTEGER SetEnvironmentVariable IN kernel32 STRING lpName, STRING lpValue

DECLARE INTEGER GetEnvironmentVariable IN kernel32;
	STRING lpName, STRING @lpBuffer, INTEGER nSize

? "Before:"
? GETENV("username")
? gv("username")

? SetEnvironmentVariable("username", "Homer Simpson")

? "After:"
? gv("username")
? GETENV("username")

FUNCTION gv(cName)
	LOCAL cBuffer, nBufsize
	nBufsize=4096
	cBuffer= REPLICATE(CHR(0), nBufsize)
	nBufsize = GetEnvironmentVariable(cName, @cBuffer, nBufsize)
RETURN SUBSTR(cBuffer, 1, nBufsize)
Probably C/C++ debugger may reveal even more interesting details.

Technically, though very much unlikely, someone with sufficient tools and knowledge may start another process that can reach the heap of Visual FoxPro application and change those internal variables.

What was the initial question :) Am I out of topic?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform