Original Post
#define RSP_SIMPLE_SERVICE 0x00000001 // Registers the process as a simple service process
#define RSP_UNREGISTER_SERVICE 0x00000000 // Unregisters the process as a service process.
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
typedef DWORD ( *RSPPROC) (DWORD, DWORD);
For some reason GetProcAddress() isn''t working in the code below... I would appreciate it if anyone could tell me what I am doing wrong.
RSPPROC RegisterServiceProcess;
HANDLE g_hSvcDll = NULL;
g_hSvcDll = LoadLibrary ("kernel32.dll");
if (!g_hSvcDll)
{
MessageBox(0,"Function: LoadLibrary() Failed",0,0);
}
RegisterServiceProcess = (RSPPROC) GetProcAddress ((HINSTANCE) g_hSvcDll,"RegisterServiceProcess");
if(!RegisterServiceProcess)
{
int error = GetLastError();
char message[100];
sprintf(message,"Error: GetProcAddress Failed: Error Number: %d",error);
MessageBox(0,message,0,0);
FreeLibrary ((HINSTANCE) g_hSvcDll);
}
else
{
if (!RegisterServiceProcess (GetCurrentProcessId (),1))
{
MessageBox(0,"Function: RegisterServiceProcess() Failed",0,0);
}
}
return 0;
}