(SIGAR-168) always fallback to wmi when peb fails for proc_args
This commit is contained in:
		
							parent
							
								
									0b335d9025
								
							
						
					
					
						commit
						c88b49abe2
					
				@ -171,15 +171,16 @@ int sigar_proc_args_peb_get(sigar_t *sigar, HANDLE proc,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    size = rtl_bufsize(buf, rtl.CommandLine);
 | 
					    size = rtl_bufsize(buf, rtl.CommandLine);
 | 
				
			||||||
 | 
					    if (size <= 0) {
 | 
				
			||||||
 | 
					        return ERROR_DATATYPE_MISMATCH; /* fallback to wmi */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    memset(buf, '\0', sizeof(buf));
 | 
					    memset(buf, '\0', sizeof(buf));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((size > 0) &&
 | 
					    if (ReadProcessMemory(proc, rtl.CommandLine.Buffer, buf, size, NULL)) {
 | 
				
			||||||
        ReadProcessMemory(proc, rtl.CommandLine.Buffer, buf, size, NULL))
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return sigar_parse_proc_args(sigar, buf, procargs);
 | 
					        return sigar_parse_proc_args(sigar, buf, procargs);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
        return SIGAR_OK;
 | 
					        return GetLastError();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1434,20 +1434,18 @@ static int sigar_remote_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
 | 
				
			|||||||
    char cmdline[SIGAR_CMDLINE_MAX], *ptr = cmdline, *arg;
 | 
					    char cmdline[SIGAR_CMDLINE_MAX], *ptr = cmdline, *arg;
 | 
				
			||||||
    HANDLE proc = open_process(pid);
 | 
					    HANDLE proc = open_process(pid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!proc) {
 | 
					    if (proc) {
 | 
				
			||||||
        return GetLastError();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        status = sigar_proc_args_peb_get(sigar, proc, procargs);
 | 
					        status = sigar_proc_args_peb_get(sigar, proc, procargs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CloseHandle(proc);
 | 
					        CloseHandle(proc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (status == ERROR_DATATYPE_MISMATCH) {
 | 
					        if (status == SIGAR_OK) {
 | 
				
			||||||
        /* we are 32-bit, pid process is 64-bit */
 | 
					            return status;
 | 
				
			||||||
        status = sigar_proc_args_wmi_get(sigar, pid, procargs);
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return status;
 | 
					    /* likely we are 32-bit, pid process is 64-bit */
 | 
				
			||||||
 | 
					    return sigar_proc_args_wmi_get(sigar, pid, procargs);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
 | 
					int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user