vb6
- Static BeUsed As Boolean
- If BeUsed = False Then
- Dim hProcess As Long
- hProcess = OpenProcessAPI(PROCESS_ALL_ACCESS, 0, GetCurrentProcessId)
- If hProcess = 0 Then Exit Function
- Dim sLenth As Long
- Dim BaseAddress As Long
- sLenth = LenB(lpImagePath) + 1 + 26
- BaseAddress = VirtualAllocEx(hProcess, ByVal 0&, ByVal sLenth, MEM_COMMIT, PAGE_READWRITE)
- If BaseAddress = 0 Then Exit Function
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 0, ByVal VarPtr(&H30058B64), 4, False
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 4, ByVal VarPtr(&H8B000000), 4, False
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 8, ByVal VarPtr(&HC0831040), 4, False
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 12, ByVal VarPtr(&H245C8B3C), 4, False
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 16, ByVal VarPtr(&H89188904), 4, False
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 20, ByVal VarPtr(&HC2042444), 4, False
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 24, ByVal VarPtr(&H10), 2, False
- WriteProcessMemoryAPI hProcess, ByVal BaseAddress + 26, ByVal StrPtr(lpImagePath), sLenth, False
- CloseHandleAPI hProcess
- CallWindowProc BaseAddress, BaseAddress + 26, 0, 0, 0
- BeUsed = True
- ChangeImagePath = BaseAddress
- End If
複製代碼 vb2008
- Static BeUsed As Boolean
- If BeUsed = False Then
- Dim hProcess As Long
- hProcess = OpenProcessAPI(PROCESS_ALL_ACCESS, 0, GetCurrentProcessId)
- If hProcess = 0 Then Exit Function
- Dim sLenth As Long
- Dim BaseAddress As Long
- sLenth = lpImagePath.Length + 1 + 26
- BaseAddress = VirtualAllocEx(hProcess, 0, sLenth, MEM_COMMIT, PAGE_READWRITE)
- If BaseAddress = 0 Then Exit Function
- WriteProcessMemoryAPI(hProcess, BaseAddress + 0, VarPtr(&H30058B64), 4, False)
- WriteProcessMemoryAPI(hProcess, BaseAddress + 4, VarPtr(&H8B000000), 4, False)
- WriteProcessMemoryAPI(hProcess, BaseAddress + 8, VarPtr(&HC0831040), 4, False)
- WriteProcessMemoryAPI(hProcess, BaseAddress + 12, VarPtr(&H245C8B3C), 4, False)
- WriteProcessMemoryAPI(hProcess, BaseAddress + 16, VarPtr(&H89188904), 4, False)
- WriteProcessMemoryAPI(hProcess, BaseAddress + 20, VarPtr(&HC2042444), 4, False)
- WriteProcessMemoryAPI(hProcess, BaseAddress + 24, VarPtr(&H10), 2, False)
- WriteProcessMemoryAPI(hProcess, BaseAddress + 26, StrPtr(lpImagePath), sLenth, False)
- CloseHandleAPI(hProcess)
- CallWindowProc(BaseAddress, BaseAddress + 26, 0, 0, 0)
- BeUsed = True
- ChangeImagePath = BaseAddress
- End If
複製代碼 vb6
- Dim pe32 As PROCESSENTRY32
- Dim hSnapshot As Long
- Dim bProcFound As Boolean
- Dim bFoundGame As Boolean
-
- hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
- pe32.dwSize = Len(pe32)
-
- bProcFound = Process32First(hSnapshot, pe32)
- Do While bProcFound
- If Right$(LCase$(Left$(pe32.szExeFile, InStr(1, pe32.szExeFile, Chr(0)) - 1)), Len(strGameName)) = LCase$(strGameName) Then
- dwProcId = pe32.th32ProcessID
- bFoundGame = True
- End If
- bProcFound = Process32Next(hSnapshot, pe32)
- Loop
- CloseHandle hSnapshot
- FindGame = bFoundGame
複製代碼 vb2008
- Dim PE32 As processentry32
- Dim hSnapshot As Long
- Dim bProcFound As Boolean
- Dim bFoundGame As Boolean
- hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
- PE32.dwsize = Len(PE32)
- bProcFound = Process32First(hSnapshot, PE32)
- Do While bProcFound
- ?????
- bFoundGame = True
- End If
- bProcFound = Process32Next(hSnapshot, PE32)
- Loop
- FindGame = bFoundGame
複製代碼 中間這段不太會寫,求指教...
... |