elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  duda acerca de los servicios :P
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: duda acerca de los servicios :P  (Leído 4,978 veces)
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: duda acerca de los servicios :P
« Respuesta #10 en: 3 Septiembre 2011, 22:26 pm »

y si le metes un...

Código
  1.  
  2. do
  3. doevents
  4. loop
  5.  
  6.  

despues de...

Código
  1.  
  2.    If (Not StartServiceCtrlDispatcher(DispatchTable(0))) Then
  3.        OutputDebugString " [MY_SERVICE] StartServiceCtrlDispatcher " & GetLastError
  4.    End If
  5.  
  6.  

Dulces Lunas!¡.


En línea

The Dark Shadow is my passion.
x64core


Desconectado Desconectado

Mensajes: 1.908


Ver Perfil
Re: duda acerca de los servicios :P
« Respuesta #11 en: 3 Septiembre 2011, 22:40 pm »

tampoco : :-\
estos diaz e buscado, y buscado pero no hay mucha informacion :P al menos no como inciar un servicio propio y que funcione bien e encontrado esto pero al paracer no esta terminado creo :P y segun el autor funciona perfectamente y el preciso para eso :P

Código
  1.    Option Explicit
  2.    Public SS As SERVICE_STATUS
  3.    Public hSS As Long
  4.    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
  5.    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  6.    Public directory As String
  7.    Private Sub Main()
  8.  
  9.    If InStr(Command$, "SSTARTED") > 0 Then
  10.    'the service executed us,
  11.    'we are now a normal process, but with SYSTEM privileges.
  12.    Load Program 'Do what you want here, you CAN use GUI again.
  13.    Exit Sub
  14.    End If
  15.  
  16.    'YOU CANNOT CALL ANY GUI HERE!
  17.    'As service, you cannot have any graphical stuff.
  18.    Dim hnd As Long
  19.    Dim h(0 To 1) As Long
  20.    hStopEvent = CreateEvent(0, 1, 0, vbNullString)
  21.    hStopPendingEvent = CreateEvent(0, 1, 0, vbNullString)
  22.    hStartEvent = CreateEvent(0, 1, 0, vbNullString)
  23.    ServiceName = StrConv(Service_Name, vbFromUnicode)
  24.    ServiceNamePtr = VarPtr(ServiceName(LBound(ServiceName)))
  25.    hnd = StartAsService
  26.    h(0) = hnd
  27.    h(1) = hStartEvent
  28.    IsNTService = WaitForMultipleObjects(2&, h(0), 0&, -1&) = 1&
  29.  
  30.    If Not IsNTService Then
  31.    CloseHandle hnd
  32.    SetNTService
  33.    DoEvents
  34.    StartNTService
  35.    Exit Sub
  36.    End If
  37.  
  38.    If IsNTService Then
  39.    SetServiceState SERVICE_RUNNING
  40.    Do
  41.    'Okay, we're a service,
  42.    'Let's execute ourself again so that we can move on..
  43.    ShellExecute 0&, "open", App.Path & "\" & App.EXEName & ".exe", " SSTARTED", App.Path & "\", vbNormal
  44.    StopNTService
  45.    Exit Do
  46.  
  47.    Loop While WaitForSingleObject(hStopPendingEvent, 1000&) = 258&
  48.    SetServiceState SERVICE_STOPPED
  49.    SetEvent hStopEvent
  50.    WaitForSingleObject hnd, -1&
  51.    CloseHandle hnd
  52.    End
  53.    End If
  54.    CloseHandle hStopEvent
  55.    CloseHandle hStartEvent
  56.    CloseHandle hStopPendingEvent
  57.    End Sub
  58.    Private Sub ServiceThread(ByVal Dummy As Long)
  59.       Dim ServiceTableEntry As SERVICE_TABLE
  60.       ServiceTableEntry.lpServiceName = ServiceNamePtr
  61.       ServiceTableEntry.lpServiceProc = FncPtr(AddressOf ServiceMain)
  62.       StartServiceCtrlDispatcher ServiceTableEntry
  63.    End Sub
  64.    Function FncPtr(ByVal fnp As Long) As Long
  65.       FncPtr = fnp
  66.    End Function
  67.    Private Sub ServiceMain(ByVal dwArgc As Long, ByVal lpszArgv As Long)
  68.       SS.dwServiceType = SERVICE_WIN32_OWN_PROCESS
  69.       SS.dwControlsAccepted = SERVICE_ACCEPT_STOP _
  70.                                       Or SERVICE_ACCEPT_SHUTDOWN
  71.       SS.dwWin32ExitCode = 0&
  72.       SS.dwServiceSpecificExitCode = 0&
  73.       SS.dwCheckPoint = 0&
  74.       SS.dwWaitHint = 0&
  75.       hSS = RegisterServiceCtrlHandler(Service_Name, _
  76.                              AddressOf Handler)
  77.       SetServiceState SERVICE_START_PENDING
  78.       SetEvent hStartEvent
  79.       WaitForSingleObject hStopEvent, -1&
  80.    End Sub
  81.    Public Function StartAsService() As Long
  82.       Dim ThreadId As Long
  83.       StartAsService = CreateThread(0&, 0&, AddressOf ServiceThread, 0&, 0&, ThreadId)
  84.    End Function
  85.    Private Sub Handler(ByVal fdwControl As Long)
  86.       Select Case fdwControl
  87.           Case SERVICE_CONTROL_SHUTDOWN, SERVICE_CONTROL_STOP
  88.               SetServiceState SERVICE_STOP_PENDING
  89.               SetEvent hStopPendingEvent
  90.           Case Else
  91.               SetServiceState
  92.       End Select
  93.    End Sub
  94.    Public Sub SetServiceState(Optional ByVal NewState As SERVICE_STATE = 0&)
  95.       If NewState <> 0& Then SS.dwCurrentState = NewState
  96.       SetServiceStatus hSS, SS
  97.    End Sub
  98.    Public Function FileExists1(fName$) As Boolean
  99.    On Local Error Resume Next
  100.    Dim ff
  101.    ff = FreeFile
  102.    Open fName$ For Input As ff
  103.    If Err Then
  104.    FileExists1 = False
  105.    Else
  106.    FileExists1 = True
  107.    End If
  108.    Close ff
  109.    End Function
  110.    'This module is Coded by SqUeEzEr (Don't remove this line)
  111.  
  112.  

Código
  1.    Option Explicit
  2.    'Our service name!!! IMPORTANT!
  3.    Private Const Service_Display_Name As String = "SqUeEzEr"
  4.    Public Const Service_Name = "SqUeEzEr"
  5.    Public AppPath As String
  6.    Public IsNTService As Boolean
  7.    Public hStopEvent As Long, hStartEvent As Long, hStopPendingEvent
  8.    Public ServiceName() As Byte, ServiceNamePtr As Long
  9.    Public Declare Function CreateThread Lib "kernel32" (ByVal lpThreadAttributes As Long, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lpParameter As Long, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
  10.    Private Type SERVICE_STATUS
  11.       dwServiceType As Long
  12.       dwCurrentState As Long
  13.       dwControlsAccepted As Long
  14.       dwWin32ExitCode As Long
  15.       dwServiceSpecificExitCode As Long
  16.       dwCheckPoint As Long
  17.       dwWaitHint As Long
  18.    End Type
  19.    Private Type QUERY_SERVICE_CONFIG
  20.       dwServiceType As Long
  21.       dwStartType As Long
  22.       dwErrorControl As Long
  23.       lpBinaryPathName As Long
  24.       lpLoadOrderGroup As Long
  25.       dwTagId As Long
  26.       lpDependencies As Long
  27.       lpServiceStartName As Long
  28.       lpDisplayName As Long
  29.    End Type
  30.    Public Enum SERVICE_STATE
  31.       SERVICE_STOPPED = &H1
  32.       SERVICE_START_PENDING = &H2
  33.       SERVICE_STOP_PENDING = &H3
  34.       SERVICE_RUNNING = &H4
  35.       SERVICE_CONTINUE_PENDING = &H5
  36.       SERVICE_PAUSE_PENDING = &H6
  37.       SERVICE_PAUSED = &H7
  38.    End Enum
  39.    Private Enum SERVICE_CONTROL
  40.       SERVICE_CONTROL_STOP = 1&
  41.       SERVICE_CONTROL_PAUSE = 2&
  42.       SERVICE_CONTROL_CONTINUE = 3&
  43.       SERVICE_CONTROL_INTERROGATE = 4&
  44.       SERVICE_CONTROL_SHUTDOWN = 5&
  45.    End Enum
  46.    Private Const SERVICE_ALL_ACCESS = (&HF0000 Or &H1& Or &H2& Or &H4& Or &H8& Or &H10& Or &H20& Or &H40& Or &H80& Or &H100&)
  47.    Private Declare Function OpenService _
  48.         Lib "advapi32" Alias "OpenServiceA" _
  49.         (ByVal hSCManager As Long, ByVal lpServiceName As String, _
  50.         ByVal dwDesiredAccess As Long) As Long   '** Change SERVICE_NAME as needed
  51.    Private Declare Function CreateService _
  52.         Lib "advapi32" Alias "CreateServiceA" _
  53.         (ByVal hSCManager As Long, ByVal lpServiceName As String, _
  54.         ByVal lpDisplayName As String, ByVal dwDesiredAccess As Long, _
  55.         ByVal dwServiceType As Long, ByVal dwStartType As Long, _
  56.         ByVal dwErrorControl As Long, ByVal lpBinaryPathName As String, _
  57.         ByVal lpLoadOrderGroup As String, ByVal lpdwTagId As String, _
  58.         ByVal lpDependencies As String, ByVal lp As String, _
  59.         ByVal lpPassword As String) As Long
  60.    Private Declare Function QueryServiceConfig Lib "advapi32" _
  61.         Alias "QueryServiceConfigA" (ByVal hService As Long, _
  62.         lpServiceConfig As QUERY_SERVICE_CONFIG, _
  63.         ByVal cbBufSize As Long, pcbBytesNeeded As Long) As Long
  64.    Private Declare Function QueryServiceStatus Lib "advapi32" _
  65.       (ByVal hService As Long, lpServiceStatus As SERVICE_STATUS) As Long
  66.    Private Declare Function ControlService Lib "advapi32" _
  67.           (ByVal hService As Long, ByVal dwControl As SERVICE_CONTROL, _
  68.           lpServiceStatus As SERVICE_STATUS) As Long
  69.    Private Declare Function StartService Lib "advapi32" _
  70.           Alias "StartServiceA" (ByVal hService As Long, _
  71.           ByVal dwNumServiceArgs As Long, ByVal lpServiceArgVectors As Long) As Long
  72.    Private Declare Function OpenSCManager _
  73.         Lib "advapi32" Alias "OpenSCManagerA" _
  74.         (ByVal lpMachineName As String, ByVal lpDatabaseName As String, _
  75.         ByVal dwDesiredAccess As Long) As Long
  76.    Private Declare Function DeleteService _
  77.         Lib "advapi32" (ByVal hService As Long) As Long
  78.    Private Declare Function CloseServiceHandle _
  79.         Lib "advapi32" (ByVal hSCObject As Long) As Long
  80.    Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
  81.    Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Any) As Long
  82.    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
  83.    Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
  84.    Public Function SetNTService() As Long
  85.    Dim hSCManager As Long
  86.    Dim hService As Long, DomainName As String
  87.    hSCManager = OpenSCManager(vbNullString, vbNullString, _
  88.                          &H2&)
  89.    If hSCManager <> 0 Then
  90.       hService = CreateService(hSCManager, Service_Name, _
  91.                          Service_Display_Name, SERVICE_ALL_ACCESS, _
  92.                          &H10&, _
  93.                          2, 1, _
  94.                          App.Path & "\" & App.EXEName & ".exe", vbNullString, _
  95.                          vbNullString, vbNullString, "LocalSystem", _
  96.                          vbNullString)
  97.       If hService <> 0 Then
  98.           CloseServiceHandle hService
  99.       Else
  100.           SetNTService = Err.LastDllError
  101.       End If
  102.       CloseServiceHandle hSCManager
  103.    Else
  104.       SetNTService = Err.LastDllError
  105.    End If
  106.    End Function
  107.    Public Function StopNTService() As Long
  108.    Dim hSCManager As Long, hService As Long, Status As SERVICE_STATUS
  109.    hSCManager = OpenSCManager(vbNullString, vbNullString, _
  110.                          &H1&)
  111.    If hSCManager <> 0 Then
  112.       hService = OpenService(hSCManager, Service_Name, &H20&)
  113.       If hService <> 0 Then
  114.           If ControlService(hService, SERVICE_CONTROL_STOP, Status) = 0 Then
  115.               StopNTService = Err.LastDllError
  116.           End If
  117.       CloseServiceHandle hService
  118.       Else
  119.           StopNTService = Err.LastDllError
  120.       End If
  121.    CloseServiceHandle hSCManager
  122.    Else
  123.       StopNTService = Err.LastDllError
  124.    End If
  125.    End Function
  126.    Public Function StartNTService() As Long
  127.    Dim hSCManager As Long, hService As Long
  128.    hSCManager = OpenSCManager(vbNullString, vbNullString, _
  129.                          &H1&)
  130.    If hSCManager <> 0 Then
  131.       hService = OpenService(hSCManager, Service_Name, &H10&)
  132.       If hService <> 0 Then
  133.           If StartService(hService, 0, 0) = 0 Then
  134.               StartNTService = Err.LastDllError
  135.           End If
  136.       CloseServiceHandle hService
  137.       Else
  138.           StartNTService = Err.LastDllError
  139.       End If
  140.    CloseServiceHandle hSCManager
  141.    Else
  142.       StartNTService = Err.LastDllError
  143.    End If
  144.    End Function
  145.    'This module is Coded by SqUeEzEr (Don't remove this line)
  146.  
  147.  

e analizado los codigos expuestos pero no entiendo mucho :P mas o menos creo que la secuencia es que se finaliza y luego se abre de nuevo como servicio propio y en ese casi si funciona :P
bueno la verdad si e puesto empeño en resolver este problema pero no e podido  :-\





En línea

Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
acerca de ...denegacion de servicios localmente( o algo asi)
Programación Visual Basic
..::[ thekingkid ]::.. 0 1,488 Último mensaje 31 Diciembre 2005, 04:41 am
por ..::[ thekingkid ]::..
Duda acerca de DLL
Programación Visual Basic
Krnl64 1 1,948 Último mensaje 30 Mayo 2006, 07:43 am
por byebye
Rumores acerca de Windows 8: nuevos servicios al descubierto
Noticias
wolfbcn 2 2,171 Último mensaje 9 Mayo 2011, 17:56 pm
por Randomize
Duda sobre servicios VPN
Seguridad
megabity 2 2,095 Último mensaje 28 Enero 2015, 00:16 am
por megabity
Duda diseño para servicios/productos.
Bases de Datos
1304654 0 2,364 Último mensaje 26 Agosto 2015, 17:32 pm
por 1304654
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines