ReactOS  0.4.13-dev-52-g0efcfec
process.c File Reference
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wbemcli.h"
#include "wine/debug.h"
#include "wbemprox_private.h"
Include dependency graph for process.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wbemprox)
 
static HRESULT get_owner (VARIANT *user, VARIANT *domain, VARIANT *retval)
 
HRESULT process_get_owner (IWbemClassObject *obj, IWbemClassObject *in, IWbemClassObject **out)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file process.c.

Function Documentation

◆ get_owner()

static HRESULT get_owner ( VARIANT user,
VARIANT domain,
VARIANT retval 
)
static

Definition at line 35 of file process.c.

36 {
37  DWORD len;
38  UINT error = 8;
39 
40  len = 0;
41  GetUserNameW( NULL, &len );
42  if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
43  if (!(V_BSTR( user ) = SysAllocStringLen( NULL, len - 1 ))) goto done;
44  if (!GetUserNameW( V_BSTR( user ), &len )) goto done;
45  V_VT( user ) = VT_BSTR;
46 
47  len = 0;
49  if (GetLastError() != ERROR_BUFFER_OVERFLOW) goto done;
50  if (!(V_BSTR( domain ) = SysAllocStringLen( NULL, len - 1 ))) goto done;
51  if (!GetComputerNameW( V_BSTR( domain ), &len )) goto done;
52  V_VT( domain ) = VT_BSTR;
53 
54  error = 0;
55 
56 done:
57  if (error)
58  {
59  VariantClear( user );
60  VariantClear( domain );
61  }
62  set_variant( VT_UI4, error, NULL, retval );
63  return S_OK;
64 }
#define error(str)
Definition: mkdosfs.c:1605
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:440
smooth NULL
Definition: ftsmooth.c:416
void set_variant(VARTYPE type, LONGLONG val, void *val_ptr, VARIANT *ret)
Definition: query.c:797
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
unsigned long DWORD
Definition: ntddk_ex.h:95
static JOBOBJECTINFOCLASS LPVOID DWORD len
Definition: process.c:79
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
#define V_VT(A)
Definition: oleauto.h:211
GLenum GLsizei len
Definition: glext.h:6722
#define V_BSTR(A)
Definition: oleauto.h:226
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by alloc_rootdir_entry(), check_file(), process_get_owner(), and test_file().

◆ process_get_owner()

HRESULT process_get_owner ( IWbemClassObject obj,
IWbemClassObject in,
IWbemClassObject **  out 
)

Definition at line 66 of file process.c.

67 {
68  VARIANT user, domain, retval;
70  HRESULT hr;
71 
72  TRACE("%p, %p, %p\n", obj, in, out);
73 
75  if (hr != S_OK) return hr;
76 
77  if (out)
78  {
79  hr = IWbemClassObject_SpawnInstance( sig, 0, &out_params );
80  if (hr != S_OK)
81  {
82  IWbemClassObject_Release( sig );
83  return hr;
84  }
85  }
86  VariantInit( &user );
87  VariantInit( &domain );
88  hr = get_owner( &user, &domain, &retval );
89  if (hr != S_OK) goto done;
90  if (out_params)
91  {
92  if (!V_UI4( &retval ))
93  {
94  hr = IWbemClassObject_Put( out_params, param_userW, 0, &user, CIM_STRING );
95  if (hr != S_OK) goto done;
96  hr = IWbemClassObject_Put( out_params, param_domainW, 0, &domain, CIM_STRING );
97  if (hr != S_OK) goto done;
98  }
99  hr = IWbemClassObject_Put( out_params, param_returnvalueW, 0, &retval, CIM_UINT32 );
100  }
101 
102 done:
103  VariantClear( &user );
104  VariantClear( &domain );
105  IWbemClassObject_Release( sig );
106  if (hr == S_OK && out)
107  {
108  *out = out_params;
109  IWbemClassObject_AddRef( out_params );
110  }
111  if (out_params) IWbemClassObject_Release( out_params );
112  return hr;
113 }
HRESULT hr
Definition: shlfolder.c:183
static HRESULT get_owner(VARIANT *user, VARIANT *domain, VARIANT *retval)
Definition: process.c:35
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static FILE * out
Definition: regtests2xml.c:44
static void out_params(void)
Definition: nanoxwin.c:1413
#define V_UI4(A)
Definition: oleauto.h:270
static const WCHAR method_getownerW[]
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
static const WCHAR param_userW[]
static const WCHAR class_processW[]
static const WCHAR param_domainW[]
#define S_OK
Definition: intsafe.h:59
GLuint in
Definition: glext.h:9616
HRESULT create_signature(const WCHAR *class, const WCHAR *method, enum param_direction dir, IWbemClassObject **sig)
Definition: class.c:818
static const WCHAR param_returnvalueW[]
void user(int argc, const char *argv[])
Definition: cmds.c:1350

Referenced by fill_process().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wbemprox  )