![]() |
ZenWINX Architecture - Reference Manual - Guides |
|
00001 /* 00002 * ZenWINX - WIndows Native eXtended library. 00003 * Copyright (c) 2007-2010 by Dmitri Arkhangelski (dmitriar@gmail.com). 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00027 #include "ntndk.h" 00028 #include "zenwinx.h" 00029 00038 int __stdcall winx_query_env_variable(short *name, short *buffer, int length) 00039 { 00040 UNICODE_STRING n, v; 00041 NTSTATUS Status; 00042 00043 DbgCheck3(name,buffer,(length > 0),"winx_query_env_variable",-1); 00044 00045 RtlInitUnicodeString(&n,name); 00046 v.Buffer = buffer; 00047 v.Length = 0; 00048 v.MaximumLength = length * sizeof(short); 00049 Status = RtlQueryEnvironmentVariable_U(NULL,&n,&v); 00050 if(!NT_SUCCESS(Status)){ 00051 DebugPrintEx(Status,"Cannot query %ws environment variable",name); 00052 return (-1); 00053 } 00054 return 0; 00055 } 00056 00064 int __stdcall winx_set_env_variable(short *name, short *value) 00065 { 00066 UNICODE_STRING n, v; 00067 NTSTATUS status; 00068 00069 DbgCheck1(name,"winx_set_env_variable",-1); 00070 00071 RtlInitUnicodeString(&n,name); 00072 if(value){ 00073 RtlInitUnicodeString(&v,value); 00074 status = RtlSetEnvironmentVariable(NULL,&n,&v); 00075 } else { 00076 status = RtlSetEnvironmentVariable(NULL,&n,NULL); 00077 } 00078 if(!NT_SUCCESS(status)){ 00079 DebugPrintEx(status,"Cannot set %ws environment variable",name); 00080 return (-1); 00081 } 00082 return 0; 00083 } 00084