hKernel32 = LoadLibrary("Kernel32.dll");
rsp = (RSP)GetProcAddress(hKernel32, "RegisterServiceProcess");
rsp(0, 1);

解决方案 »

  1.   

    真是奇怪,怎么总是有人问同样的问题,这个问题我看到n次了。方法如下:// File: service.h 
    // The head file of "service.cpp" 
    // Note: 1. You must use C++ compiler 
    // 2. The platform is WIN32 (WINNT & WIN95) #ifndef _SERVICE_H 
    #define _SERVICE_H ///////////////////////////////////// 
    ////////////// USED FOR WIN95 SERVICE 
    // Micros 
    #define RSP_SIMPLE_SERVICE 1 
    #define RSP_UNREGISTER_SERVICE 0 // Function types for GetProcAddress 
    #define RegisterServiceProcess_PROFILE (DWORD (__stdcall *) (DWORD, DWORD)) // Service Fuctions in Win95 
    BOOL W95ServiceRegister(DWORD dwType); 
    //BOOL W95StartService( DWORD dwType ); #endif // File: service.cpp --- implement the service #include "service.h" 
    ///////////////////////////////////////////////// 
    // USED FOR WIN95 SERVICE登 记 为Service 子 程 序: 
    ///////////////////////////////////////// 
    //////////////////////////////////////// 
    // Define: BOOL W95ServiceRegister(DWORD dwType) 
    // Parameters: dwType --- Flag to register or unregister the service 
    // RSP_SIMPLE_SERVICE means register 
    // RSP_UNREGISTER_SERVICE means unregister 
    // Return: TRUE --- call success; FALSE --- call failer BOOL W95ServiceRegister( DWORD dwType ) 

    // Function address defination 
    DWORD (__stdcall * hookRegisterServiceProcess) 
    ( DWORD dwProcessId, DWORD dwType ); // Get address of function 
    hookRegisterServiceProcess = RegisterServiceProcess_PROFILE GetProcAddress(GetModuleHandle("KERNEL32"), 
    TEXT("RegisterServiceProcess")); // Register the WIN95 service 
    if(hookRegisterServiceProcess(NULL,dwType)==0) 
    return FALSE; 
    return TRUE; 
      

  2.   

    或者你可以用以下的程序段。
    // 以下的在程序的最开头加入
    DWORD nOffset;
    DWORD nAppType = 0x10800000;
    __asm{
    mov ebx,30h
    push es
    push fs
    pop es
    mov ebx,es:[ebx]
    mov nOffset,ebx
    pop es
    mov eax,nAppType
    xchg [ebx+20h],eax
    mov nAppType,eax
    }
    m_nOffset = nOffset;
    m_nAppType =nAppType;//以下的程序段在程序结束时加入
    DWORD nOffset;
    DWORD nAppType; nOffset = m_nOffset;
    nAppType = m_nAppType; __asm{
    push eax
    push ebx
    mov ebx,nOffset
    mov eax,nAppType
    xchg [ebx+20h],eax
    pop ebx
    pop eax
    }