PDA

View Full Version : مخفی کردن برنامه در task manager (در لیست prosess ها)؟؟؟؟؟



keyvan 200
سه شنبه 09 آذر 1389, 02:45 صبح
سلام دوستان عزیز امیدوارم هرجا که هستید موفق باشید
ببخشید می خواستم ببینم چطور میشه یه برنامه رو به طور کامل کامل مخفی کرد
با این دستورات که می شه
me.hide
me.opacity = 0
me.visable = false
me.showintaskbar = false
کاملا عالی عمل می کنه ولی فقط در تاسک منیجر و فقط در لیست prosses ها می مونه به چه روشی می شه حذف کرد؟ تا اونجایی که من می دونم با استفاده از API می شه نه؟
بسیار ممنون و متشکر.:لبخندساده:

Alirezanet
سه شنبه 09 آذر 1389, 13:09 عصر
بله با API ها میشه ولی یکم سخته ...
من قبلا این کارو کرده بودم ... ولی دقیق یادم نیست ... تا اونجایی که یادمه از روی این کد تونستم به نتیجه برسم .
موفق باشی


Public Class Form1
Const WM_COMMAND As Int32 = &H111
Const MF_ENABLED As Int32 = &H0
Const MF_GRAYED As Int32 = &H1
Const LVM_FIRST As Int32 = &H1000
Const LVM_DELETEITEM As Int32 = (LVM_FIRST + 8)
Const LVM_SORTITEMS As Int32 = (LVM_FIRST + 48)
Private Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function apiFindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
Private Declare Function apiEnableWindow Lib "user32" Alias "EnableWindow" (ByVal hwnd As Int32, ByVal fEnable As Int32) As Boolean
Private Declare Function apiGetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Int32) As Int32
Private Declare Function apiGetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Int32, ByVal nPos As Int32) As Int32
Private Declare Function apiGetMenuItemID Lib "user32" Alias "GetMenuItemID" (ByVal hMenu As Int32, ByVal nPos As Int32) As Int32
Private Declare Function apiEnableMenuItem Lib "user32" Alias "EnableMenuItem" (ByVal hMenu As Int32, ByVal wIDEnableItem As Int32, ByVal wEnable As Int32) As Int32
Private Declare Function apiSendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As String) As Int32
Private Declare Function apiGetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Int32
Private Declare Function apiLockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Int32) As Int32

Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Me.Text = pName 'Set form name to match process name given
Me.ShowInTaskbar = False 'hide application from taskbar
Timer1.Interval = 700 'Set to start fast
Timer1.Enabled = True 'Actually start the timer
ListView1.View = View.Details
ListView1.Columns.Add("Process name", -2, HorizontalAlignment.Left)
ListView1.Sorting = SortOrder.Ascending 'So that the list view automatically sorts the entries for us.
'Me.Hide() 'uncomment when ready to terminate this program elsehow.
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
HideProcess("", False)
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
HideProcess("explorer", True)
End Sub


Private Function HideProcess(ByVal pName As String, Optional ByVal pHide As Boolean = True)
On Error Resume Next
Dim lhWndParent As Int32 = apiFindWindow(Nothing, "Windows Task Manager") 'get handle to the task manager
Dim lhWndDialog As Int32 = 0
Dim lhWndProcessList As Int32 = 0
Dim lhWndProcessHeader As Int32 = 0
Dim hMenu As Int32 = apiGetMenu(lhWndParent) 'get it's menu handle
Dim hSubMenu As Int32 = apiGetSubMenu(hMenu, 2) 'get it's submenu handle for "View"
Dim hSubSubMenu As Int32 = apiGetSubMenu(hSubMenu, 1) 'get it;s subsub menu handle for "update speed"
Dim hId1 As Int32 = apiGetMenuItemID(hSubMenu, 0) 'Get id for "refresh now" item
Dim hId2 As Int32 = apiGetMenuItemID(hSubSubMenu, 0) 'Get id for "high update speed" item
Dim hId3 As Int32 = apiGetMenuItemID(hSubSubMenu, 1) 'Get id for "normal update speed" item
Dim hId4 As Int32 = apiGetMenuItemID(hSubSubMenu, 2) 'Get id for "low update speed" item
Dim hId5 As Int32 = apiGetMenuItemID(hSubSubMenu, 3) 'Get id for "paused update speed" item
If pHide = True Then
Dim ProcessItemCount, ProcessItemIndex As Int32
Dim itemString As String, p As New Process, Processes() As Process

For i As Int32 = 1 To 7 'Loop through all seven child windows, for handles to the listviews, buttons, and header
lhWndDialog = apiFindWindowEx(lhWndParent, lhWndDialog, Nothing, Nothing)
If lhWndProcessList = 0 Then lhWndProcessList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Processes")
If lhWndProcessHeader = 0 Then lhWndProcessHeader = apiFindWindowEx(lhWndProcessList, 0, "SysHeader32", Nothing)
Next

apiSendMessage(lhWndParent, WM_COMMAND, hId5, 0) 'Click "paused update speed", so we can do it for the taskmgr

apiEnableMenuItem(hMenu, hId1, MF_GRAYED) 'disable refresh now item
apiEnableMenuItem(hMenu, hId2, MF_GRAYED) 'disable high update speed
apiEnableMenuItem(hMenu, hId3, MF_GRAYED) 'disable normal update speed
apiEnableMenuItem(hMenu, hId4, MF_GRAYED) 'disable low update speed
apiEnableMenuItem(hMenu, hId5, MF_GRAYED) 'disable paused update speed

apiEnableWindow(lhWndProcessHeader, 0) 'Disable process header, so it cannot be resorted by user

If Me.ListView1.Items.Count > 0 Then Me.ListView1.Items.Clear() 'clear any old data that was on the list

Processes = Process.GetProcesses() 'Get processes

For Each p In Processes 'Count processes, and add them to the listview.
ProcessItemCount += 1
If p.ProcessName.ToString = "Idle" Then
With Me.ListView1.Items.Add("System Idle Process")
End With
Else
With Me.ListView1.Items.Add(p.ProcessName.ToString)
End With
End If
Next p

'Look for, the index of the process matching the string name of our caption then
For z As Int32 = 0 To ProcessItemCount - 1
itemString = ListView1.Items.Item(z).Text.ToString()
If itemString = pName Then ProcessItemIndex = z
Next

apiLockWindowUpdate(lhWndProcessList) 'Lock the window from updating, to reduce flashing.
apiSendMessage(lhWndParent, WM_COMMAND, hId1, 0) 'AutoClick refresh to update, then immediately sort and delete.
apiSendMessage(lhWndProcessList, LVM_SORTITEMS, 0, Nothing) ' Sort process items alphabetically
apiSendMessage(lhWndProcessList, LVM_DELETEITEM, ProcessItemIndex, 0) 'Delete the process,
apiLockWindowUpdate(False) 'unlock that window

If lhWndParent = 0 Then
If Timer1.Interval <> 800 Then Timer1.Interval = 800 'Set to react fast while task manager is closed.
Else
If Timer1.Interval <> 2500 Then Timer1.Interval = 2500 'Set to a normal looking update speed, while the task manager remains open.
End If
Else
Timer1.Enabled = False 'kill the timer
For i As Int32 = 1 To 7
lhWndDialog = apiFindWindowEx(lhWndParent, lhWndDialog, Nothing, Nothing)
If lhWndProcessList = 0 Then lhWndProcessList = apiFindWindowEx(lhWndDialog, 0, "SysListView32", "Processes")
If lhWndProcessHeader = 0 Then lhWndProcessHeader = apiFindWindowEx(lhWndProcessList, 0, "SysHeader32", Nothing)
Next
apiEnableMenuItem(hMenu, hId1, MF_ENABLED) 're-enable refresh now
apiEnableMenuItem(hMenu, hId2, MF_ENABLED) 're-enable high update speed
apiEnableMenuItem(hMenu, hId3, MF_ENABLED) 're-enable normal update speed
apiEnableMenuItem(hMenu, hId4, MF_ENABLED) 're-enable low update speed
apiEnableMenuItem(hMenu, hId5, MF_ENABLED) 're-enable paused update speed
apiSendMessage(lhWndParent, WM_COMMAND, hId3, 0) 'click normal update speed
apiSendMessage(lhWndParent, WM_COMMAND, hId1, 0) 'click refresh now
apiEnableWindow(lhWndProcessHeader, 1) 'Enable process header
End If
Return True
End Function



End Class

mahdi1373
چهارشنبه 10 آذر 1389, 13:18 عصر
با هوک بهتره. این کدشه. البته مال vb 6 است. باید یکم تغییرش بدی.

این کد هارو توی یه ماژول می گذاری:


Public Type bkh
flag As Long
psz As Long
lParam As Long
pt As Long
vkDirection As Long
End Type
Public Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Public Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As Long, ByRef lpdwProcessId As Long) As Long
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As Long, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function VirtualFreeEx Lib "kernel32.dll" (ByVal hProcess As Long, ByRef lpAddress As Any, ByRef dwSize As Long, ByVal dwFreeType As Long) As Long
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function GetCurrentProcessId Lib "kernel32.dll" () As Long
Public Declare Function KillTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long


Public Sub Hide_Process(Name As String)
Dim pName As Long
Dim pType As Long
Dim l As Long
Dim Tid As Long
Dim hTid As Long
Dim pid As Long
Dim h As Long
Dim i As Long
Dim hProcess As Long
Dim f As bkh
Dim s As String
Dim bkh() As Byte
h = FindWindow(vbNullString, "Windows Task Manager")
KillTimer h, 0
h = FindWindowEx(h, 0, "#32770", vbNullString)
h = FindWindowEx(h, 0, "SysListView32", vbNullString)
If h = 0 Then Exit Sub
f.flag = 8 Or &H20
Call GetWindowThreadProcessId(h, pid)
hProcess = OpenProcess(1082, 0, pid)
bkh = StrConv(Name, vbFromUnicode)
pName = VirtualAllocEx(hProcess, 0, Len(Name) + 1, &H1000, 4)
WriteProcessMemory hProcess, pName, VarPtr(bkh(0)), Len(Name), l
f.psz = pName
pType = VirtualAllocEx(hProcess, 0, Len(f), &H1000, 4)
WriteProcessMemory hProcess, pType, VarPtr(f.flag), Len(f), l
i = SendMessage(h, &H1000 + 13, 0, pType)
If i <> -1 Then SendMessage h, &H1000 + 8, i, 0
VirtualFreeEx hProcess, pType, Len(f), &H8000
VirtualFreeEx hProcess, pName, LenB(Name) + 1, &H8000
End Sub


برای استفاده یه تایمر با interval =1 می سازی و توش این کد رو وارد می کنی(برای مخفی کردن برنامه خودت):

Hide_Process (App.exeName & ".exe")

mansourii
چهارشنبه 10 آذر 1389, 14:28 عصر
انقدر خودكشي كردن نميخواد كه!!
همش يك خط كد ميخواد


Me.Text = ""
MyBase.ShowInTaskbar = False

؟؟؟ نميدونم مشكل كجاست؟؟؟

hero4000
چهارشنبه 10 آذر 1389, 15:34 عصر
مشکل از سرسري نگاه کردن جنابعالي دوست عزيز

Taskbar با TaskManager فرق ميکنه ديگه نه :چشمک: