Hans Leidekker : wbemprox: Add helpers to retrieve the system directory and OS architecture.
Module: wine Branch: master Commit: 381d30ac17a8cf68099e8fa3e2d0bb7669327d64 URL: http://source.winehq.org/git/wine.git/?a=commit;h=381d30ac17a8cf68099e8fa3e2... Author: Hans Leidekker <hans(a)codeweavers.com> Date: Tue Sep 18 13:11:59 2012 +0200 wbemprox: Add helpers to retrieve the system directory and OS architecture. --- dlls/wbemprox/builtin.c | 42 ++++++++++++++++++++++++------------------ 1 files changed, 24 insertions(+), 18 deletions(-) diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 54992b3..4b6ff38 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -831,31 +831,37 @@ static void fill_processor( struct table *table ) table->num_rows = count; } -static void fill_os( struct table *table ) +static const WCHAR *get_osarchitecture(void) { - struct record_operatingsystem *rec; - WCHAR path[MAX_PATH]; SYSTEM_INFO info; + GetNativeSystemInfo( &info ); + if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW; + return os_32bitW; +} +static WCHAR *get_systemdirectory(void) +{ void *redir; + WCHAR *ret; - if (!(table->data = heap_alloc( sizeof(*rec) ))) return; - - rec = (struct record_operatingsystem *)table->data; - rec->caption = os_captionW; - rec->csdversion = os_csdversionW; + if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL; + Wow64DisableWow64FsRedirection( &redir ); + GetSystemDirectoryW( ret, MAX_PATH ); + Wow64RevertWow64FsRedirection( redir ); + return ret; +} - GetNativeSystemInfo( &info ); - if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) - rec->osarchitecture = os_64bitW; - else - rec->osarchitecture = os_32bitW; +static void fill_os( struct table *table ) +{ + struct record_operatingsystem *rec; - rec->oslanguage = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ); + if (!(table->data = heap_alloc( sizeof(*rec) ))) return; - Wow64DisableWow64FsRedirection( &redir ); - GetSystemDirectoryW( path, MAX_PATH ); - Wow64RevertWow64FsRedirection( redir ); - rec->systemdirectory = heap_strdupW( path ); + rec = (struct record_operatingsystem *)table->data; + rec->caption = os_captionW; + rec->csdversion = os_csdversionW; + rec->osarchitecture = get_osarchitecture(); + rec->oslanguage = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ); + rec->systemdirectory = get_systemdirectory(); TRACE("created 1 row\n"); table->num_rows = 1;
participants (1)
-
Alexandre Julliard