@@ -147,7 +147,6 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
147
147
_In_ PPH_STRING FileName
148
148
)
149
149
{
150
- ULONG status ;
151
150
PPH_STRING lxssCommandLine = NULL ;
152
151
PPH_STRING lxssPackageName = NULL ;
153
152
PPH_STRING lxssDistroName ;
@@ -165,32 +164,29 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
165
164
return FALSE;
166
165
}
167
166
168
- if (PhIsNullOrEmptyString (lxssDistroName ) || PhIsNullOrEmptyString (lxssDistroPath ) || PhIsNullOrEmptyString (lxssFileName ))
167
+ if (
168
+ PhIsNullOrEmptyString (lxssDistroName ) ||
169
+ PhIsNullOrEmptyString (lxssDistroPath ) ||
170
+ PhIsNullOrEmptyString (lxssFileName )
171
+ )
169
172
{
170
173
if (lxssDistroName ) PhDereferenceObject (lxssDistroName );
171
174
if (lxssDistroPath ) PhDereferenceObject (lxssDistroPath );
172
175
if (lxssFileName ) PhDereferenceObject (lxssFileName );
173
176
return FALSE;
174
177
}
175
178
176
- if (PhEqualString2 (lxssFileName , L"/init" , FALSE))
177
- {
178
- PhMoveReference (& lxssFileName , PhCreateString (L"init" ));
179
- }
180
-
181
179
PhMoveReference (& lxssCommandLine , PhFormatString (
182
180
L"rpm -qf %s --queryformat \"%%{VERSION}|%%{VENDOR}|%%{SUMMARY}\"" ,
183
181
lxssFileName -> Buffer
184
182
));
185
183
186
- status = PhCreateProcessLxss (
184
+ if ( PhCreateProcessLxss (
187
185
lxssDistroName -> Buffer ,
188
186
lxssCommandLine -> Buffer ,
189
187
NULL ,
190
188
& result
191
- );
192
-
193
- if (status == 0 )
189
+ ))
194
190
{
195
191
goto ParseResult ;
196
192
}
@@ -200,14 +196,12 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
200
196
lxssFileName -> Buffer
201
197
));
202
198
203
- status = PhCreateProcessLxss (
199
+ if (! PhCreateProcessLxss (
204
200
lxssDistroName -> Buffer ,
205
201
lxssCommandLine -> Buffer ,
206
202
NULL ,
207
203
& result
208
- );
209
-
210
- if (status != 0 )
204
+ ))
211
205
{
212
206
PhDereferenceObject (lxssCommandLine );
213
207
PhDereferenceObject (lxssDistroName );
@@ -242,14 +236,12 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
242
236
lxssPackageName -> Buffer
243
237
));
244
238
245
- status = PhCreateProcessLxss (
239
+ if (! PhCreateProcessLxss (
246
240
lxssDistroName -> Buffer ,
247
241
lxssCommandLine -> Buffer ,
248
242
NULL ,
249
243
& result
250
- );
251
-
252
- if (status != 0 )
244
+ ))
253
245
{
254
246
PhDereferenceObject (lxssCommandLine );
255
247
PhDereferenceObject (lxssDistroName );
@@ -293,7 +285,8 @@ BOOLEAN PhInitializeLxssImageVersionInfo(
293
285
return TRUE;
294
286
}
295
287
296
- ULONG PhCreateProcessLxss (
288
+ _Success_ (return )
289
+ BOOLEAN PhCreateProcessLxss (
297
290
_In_ PWSTR LxssDistribution ,
298
291
_In_ PWSTR LxssCommandLine ,
299
292
_In_opt_ PWSTR LxssCurrentDirectory ,
@@ -335,7 +328,7 @@ ULONG PhCreateProcessLxss(
335
328
);
336
329
337
330
if (!NT_SUCCESS (status ))
338
- return status ;
331
+ return FALSE ;
339
332
340
333
status = PhCreatePipeEx (
341
334
& inputReadHandle ,
@@ -348,7 +341,7 @@ ULONG PhCreateProcessLxss(
348
341
{
349
342
NtClose (outputWriteHandle );
350
343
NtClose (outputReadHandle );
351
- return status ;
344
+ return FALSE ;
352
345
}
353
346
354
347
memset (& startupInfo , 0 , sizeof (STARTUPINFO ));
@@ -378,7 +371,7 @@ ULONG PhCreateProcessLxss(
378
371
NtClose (outputReadHandle );
379
372
NtClose (inputReadHandle );
380
373
NtClose (inputWriteHandle );
381
- return status ;
374
+ return FALSE ;
382
375
}
383
376
384
377
// Note: Close the write handles or the child process
@@ -396,18 +389,22 @@ ULONG PhCreateProcessLxss(
396
389
}
397
390
398
391
// Note: Don't use NTSTATUS now that we have the lxss exit code. (dmex)
399
- if (Result && status == 0 )
392
+ if (status == 0 )
400
393
{
401
- * Result = lxssOutputString ;
394
+ if (Result ) * Result = lxssOutputString ;
395
+ if (processHandle ) NtClose (processHandle );
396
+ if (outputReadHandle ) NtClose (outputReadHandle );
397
+ if (inputWriteHandle ) NtClose (inputWriteHandle );
398
+
399
+ return TRUE;
402
400
}
403
401
else
404
402
{
405
- PhSetReference (& lxssOutputString , NULL );
406
- }
403
+ if (lxssOutputString ) PhDereferenceObject (lxssOutputString );
404
+ if (processHandle ) NtClose (processHandle );
405
+ if (outputReadHandle ) NtClose (outputReadHandle );
406
+ if (inputWriteHandle ) NtClose (inputWriteHandle );
407
407
408
- NtClose (processHandle );
409
- NtClose (outputReadHandle );
410
- NtClose (inputWriteHandle );
411
-
412
- return status ;
408
+ return FALSE;
409
+ }
413
410
}
0 commit comments