|
发表于 2024-3-20 16:04:56
|
显示全部楼层
浙江省嘉兴市
那你直接删掉模块里的 进程_取用户名 复制我给你的 火山精易模块奇葩BUG太多 这个我修复了好了 顺便同时支持了32/64
<火山程序 类型 = "通常" 版本 = 1 />
方法 进程_取用户名 <公开 静态 类型 = 文本型 注释 = "获取指定进程的用户名" @禁止流程检查 = 真 "//@视窗.需求目标平台" = @"32位平台">
参数 进程ID <类型 = 整数>
{
变量 szName <类型 = 文本型>
@ typedef enum _SYSTEM_INFORMATION_CLASS
@ {
@ SystemBasicInformation = 0,
@ SystemPerformanceInformation = 2,
@ SystemTimeOfDayInformation = 3,
@ SystemProcessInformation = 5,
@ SystemProcessorPerformanceInformation = 8,
@ SystemInterruptInformation = 23,
@ SystemExceptionInformation = 33,
@ SystemRegistryQuotaInformation = 37,
@ SystemLookasideInformation = 45,
@ SystemCodeIntegrityInformation = 103,
@ SystemPolicyInformation = 134,
@ } SYSTEM_INFORMATION_CLASS;
@ typedef struct _UNICODE_STRING
@ {
@ USHORT Length;
@ USHORT MaximumLength;
@ PWSTR Buffer;
@ } UNICODE_STRING, * PUNICODE_STRING;
@ typedef struct _SYSTEM_PROCESS_INFORMATION
@ {
@ ULONG NextEntryOffset;
@ ULONG NumberOfThreads;
@ LARGE_INTEGER qSpareLi1;
@ LARGE_INTEGER qSpareLi2;
@ LARGE_INTEGER qSpareLi3;
@ LARGE_INTEGER qCreateTime;
@ LARGE_INTEGER qUserTime;
@ LARGE_INTEGER qKernelTime;
@ UNICODE_STRING ImageName;
@ int nBasePriority;
@ HANDLE dwProcessId;
@ PVOID dwInheritedFromUniqueProcessId;
@ ULONG dwHandleCount;
@ ULONG dwSessionId;
@ PVOID dwSpareUl3;
@ SIZE_T tPeakVirtualSize;
@ SIZE_T tVirtualSize;
@ ULONG dwPageFaultCount;
@ SIZE_T dwPeakWorkingSetSize;
@ SIZE_T dwWorkingSetSize;
@ PVOID tQuotaPeakPagedPoolUsage;
@ SIZE_T tQuotaPagedPoolUsage;
@ SIZE_T tQuotaPeakNonPagedPoolUsage;
@ SIZE_T tQuotaNonPagedPoolUsage;
@ SIZE_T tPagefileUsage;
@ SIZE_T tPeakPagefileUsage;
@ SIZE_T tPrivatePageCount;
@ LARGE_INTEGER qReadOperationCount;
@ LARGE_INTEGER qWriteOperationCount;
@ LARGE_INTEGER qOtherOperationCount;
@ LARGE_INTEGER qReadTransferCount;
@ LARGE_INTEGER qWriteTransferCount;
@ LARGE_INTEGER qOtherTransferCount;
@ } SYSTEM_PROCESS_INFORMATION;
@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
@ typedef NTSTATUS(WINAPI* NtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength);
@ typedef BYTE(WINAPI* WinStationGetProcessSid)(HANDLE hServer, DWORD ProcessId, FILETIME ProcessStartTime, PBYTE pProcessUserSid, PDWORD dwSidSize);
@ HMODULE hModule[2];
@ hModule[0] = LoadLibraryW(L"ntdll.dll");
@ hModule[1] = LoadLibraryW(L"winsta.dll");
@ NtQuerySystemInformation pfnNtQuerySystemInformation;
@ WinStationGetProcessSid pfnWinStationGetProcessSid;
@ if (hModule[0]) pfnNtQuerySystemInformation = (NtQuerySystemInformation)GetProcAddress(hModule[0], "NtQuerySystemInformation");
@ if (hModule[1]) pfnWinStationGetProcessSid = (WinStationGetProcessSid)GetProcAddress(hModule[1], "WinStationGetProcessSid");
@ if (pfnNtQuerySystemInformation && pfnWinStationGetProcessSid)
@ {
@ DWORD dwSize = 0;
@ pfnNtQuerySystemInformation(SystemProcessInformation, NULL, 0, &dwSize);
@ NTSTATUS lRetVal;
@ SYSTEM_PROCESS_INFORMATION* pSystemInformation, * pCurSystemInformation;
@ pSystemInformation = (SYSTEM_PROCESS_INFORMATION*)malloc(dwSize);
@ ZeroMemory(pSystemInformation, dwSize);
@ lRetVal = pfnNtQuerySystemInformation(SystemProcessInformation, pSystemInformation, dwSize, &dwSize);
@ if (lRetVal == STATUS_WAIT_0)
@ {
@ pCurSystemInformation = pSystemInformation;
@ while (pCurSystemInformation->dwProcessId != (HANDLE)@<进程ID>)
@ {
@ if (pCurSystemInformation->NextEntryOffset == 0) break;
@ pCurSystemInformation = (SYSTEM_PROCESS_INFORMATION*)((BYTE*)pCurSystemInformation + pCurSystemInformation->NextEntryOffset);
@ }
@ if (pCurSystemInformation->dwProcessId == (HANDLE)@<进程ID>)
@ {
@ FILETIME qCreateTime;
@ memcpy(&qCreateTime, &pCurSystemInformation->qCreateTime, sizeof(qCreateTime));
@ DWORD dwSize = 0;
@ pfnWinStationGetProcessSid(NULL, (DWORD)pCurSystemInformation->dwProcessId, qCreateTime, NULL, &dwSize);
@ BYTE* pSid = new BYTE[dwSize]();
@ pfnWinStationGetProcessSid(NULL, (DWORD)pCurSystemInformation->dwProcessId, qCreateTime, pSid, &dwSize);
@ DWORD dwNameLen = 0, dwDomainLen = 0;
@ SID_NAME_USE snu;
@ LookupAccountSidW(NULL, pSid, NULL, &dwNameLen, NULL, &dwDomainLen, &snu);
@ TCHAR* szName = new TCHAR[dwNameLen](), * szDomain = new TCHAR[dwDomainLen]();
@ LookupAccountSidW(NULL, pSid, szName, &dwNameLen, szDomain, &dwDomainLen, &snu);
@ @<szName>.SetValueText(szName);
@ delete[] szName;
@ delete[] szDomain;
@ delete[] pSid;
@ }
@ }
@ free(pSystemInformation);
@ }
@ if (hModule[0]) FreeLibrary(hModule[0]);
@ if (hModule[1]) FreeLibrary(hModule[1]);
@ return @<szName>.GetText();
}
|
评分
-
参与人数 1 | 荣誉 +3 |
收起
理由
|
笨潴
| + 3 |
热心帮助他人,荣誉+3,希望继续努力(*^__^*) 嘻嘻! |
查看全部评分
|