@@ -388,36 +388,30 @@ unsafe fn init_state() -> *mut bt::backtrace_state {
388
388
}
389
389
let ptrQueryFullProcessImageNameA =
390
390
GetProcAddress ( dll, b"QueryFullProcessImageNameA\0 " . as_ptr( ) as * const _) as usize ;
391
- let mut len: u32 ;
392
391
if ptrQueryFullProcessImageNameA == 0
393
392
{
394
- len = GetModuleFileNameA ( 0 as HMODULE , buf. as_mut_ptr( ) , buf. len( ) as u32 ) ;
395
- }
396
- else
397
- {
398
- use core:: mem;
399
- let p1 = OpenProcess ( PROCESS_QUERY_INFORMATION , FALSE , GetCurrentProcessId ( ) ) ;
400
- len = buf. len( ) as u32 ;
401
- let pfnQueryFullProcessImageNameA : extern "system" fn (
402
- hProcess: HANDLE ,
403
- dwFlags: DWORD ,
404
- lpExeName: LPSTR ,
405
- lpdwSize: PDWORD ,
406
- ) -> BOOL = mem:: transmute( ptrQueryFullProcessImageNameA) ;
407
-
408
- let rc = pfnQueryFullProcessImageNameA( p1, 0 , buf. as_mut_ptr( ) , & mut len) ;
409
- CloseHandle ( p1) ;
410
- if rc == 0 {
411
- return Err ( ( ) )
412
- }
393
+ return Err ( ( ) ) ;
413
394
}
395
+ use core:: mem;
396
+ let p1 = OpenProcess ( PROCESS_QUERY_INFORMATION , FALSE , GetCurrentProcessId ( ) ) ;
397
+ let mut len = buf. len( ) as u32 ;
398
+ let pfnQueryFullProcessImageNameA : extern "system" fn (
399
+ hProcess: HANDLE ,
400
+ dwFlags: DWORD ,
401
+ lpExeName: LPSTR ,
402
+ lpdwSize: PDWORD ,
403
+ ) -> BOOL = mem:: transmute( ptrQueryFullProcessImageNameA) ;
404
+
405
+ let rc = pfnQueryFullProcessImageNameA( p1, 0 , buf. as_mut_ptr( ) , & mut len) ;
406
+ CloseHandle ( p1) ;
407
+
414
408
// We want to return a slice that is nul-terminated, so if
415
409
// everything was filled in and it equals the total length
416
410
// then equate that to failure.
417
411
//
418
412
// Otherwise when returning success make sure the nul byte is
419
413
// included in the slice.
420
- if len == buf. len( ) as u32 {
414
+ if rc == 0 || len == buf. len( ) as u32 {
421
415
Err ( ( ) )
422
416
} else {
423
417
assert_eq!( buf[ len as usize ] , 0 ) ;
0 commit comments