So, i want create service. My program need work as service, but not process. I finded in Internet and edited this code :
#define rootkitname "myrootkit"
SC_HANDLE hSCManager;
hSCManager=OpenSCManager(NULL, NULL,SC_MANAGER_CREATE_SERVICE);
LPVTSTR rootkpath;
rootkpath="C:\Users\Admin\Desktop\Blocker\Project1.exe";
SC_HANDLE hManager,hService; hService=CreateService(hManager,rootkitname,rootkitname,SERVICE_ALL_ACCESS,SER VICE_KERNEL_DRIVER, SERVICE_BOOT_START,SERVICE_ERROR_NORMAL, \rootkpath,NULL,NULL,NULL, NULL,NULL,NULL);
StartService(hService,NULL,NULL);
This code create service, but it have mistake. In Builder6 i have this mistake:
[C++ Error] Unit1.cpp(60): E2451 Undefined symbol 'LPVTSTR'
[C++ Error] Unit1.cpp(60): E2379 Statement missing ;
[C++ Error] Unit1.cpp(61): E2451 Undefined symbol 'rootkpath'
[C++ Error] Unit1.cpp(63): E2206 Illegal character '\' (0x5c)
[C++ Error] Unit1.cpp(63): E2227 Extra parameter in call to __stdcall CreateServiceA(void *,const char *,const char *,unsigned long,unsigned long,unsigned long,unsigned long,const char *,const char *,unsigned long *,const char *,const char *,const char *)
Please, help me. Target my application is : user don't can closed my program from Task Manager.
LPVTSTR is not a thing, google suggests LPCTSTR (no idea if that is correct). Backslashes in C strings have to be doubled, so rootkpath="C:\\Users\\Admin\\...
In the call to CreateService - \rootkpath should be just rootkpath and remove one of the NULLs at the end, you have one too many.
Related
I am writing a java application. It is an mp3 player. I want to use the pulseaudio server because my bluetooth speaker is accessible with pulseaudio.
I have written a shared library using the simple pulseaudio interface.
Now i get the error
/home/rainer/NetBeansProjects/audioserver/src/main/native/audioserver.so: undefined symbol: pa_simple_new
which library i have to add to my java program to get access to the symbol pa_simple_new ?
After searching around, i found the library libpulse-simple.so contains the functions. There were shown when executing
nm -D libpulse-simple.so
I wasn't able to call the functions directly, because i call this functions in a JNI environment.
I had to use the functions dlopen and dlsym for accessing the functions:
void* h = dlopen("libpulse-simple.so", RTLD_LAZY|RTLD_GLOBAL);
and
ptr_pa_simple_new = (pa_simple* (*)(const char *,const char *,pa_stream_direction_t,const char *,const char *,const pa_sample_spec *,const pa_channel_map *,const pa_buffer_attr *,int *))dlsym(h,"pa_simple_new");
ptr_pa_simple_free = (void (*)(pa_simple *))dlsym(h,"pa_simple_free");
ptr_pa_simple_write = (int (*)(pa_simple *, const void *, size_t, int *))dlsym(h,"pa_simple_write");
I'm experimenting the next error when including muiload.h and linking with muiload.lib and calling LoadMUILibrary in Visual Studio 2015:
Muiload.lib(muiload.obj) : error LNK2019: unresolved external symbol
__vsnwprintf referenced in function "long __stdcall StringVPrintfWorkerW(unsigned short *,unsigned int,unsigned int
*,unsigned short const *,char *)" (?StringVPrintfWorkerW##YGJPAGIPAIPBGPAD#Z)
Maybe something wrong in muiload.lib?
Solved adding the additional library legacy_stdio_definitions.lib to the linker input as explained in https://social.msdn.microsoft.com/Forums/en-US/5150eeec-4427-440f-ab19-aecb26113d31/updated-to-vs-2015-and-now-get-unresolved-external-errors?forum=vcgeneral
An alternative to linking against legacy_stdio_definitions.lib is to redefine these function signatures to match their deprecated style:
int (WINAPIV * __vsnprintf)(char *, size_t, const char*, va_list) = _vsnprintf;
int (WINAPIV * __vsnwprintf)(wchar_t *, size_t, const wchar_t*, va_list) = _vsnwprintf;
One benefit of this is that it avoids other possible linker definition issues caused by including the legacy library.
Note that this should be defined in a compiler unit (.cpp) rather than in a header file.
I use Multi-thread method in vs2008 ,use c++ language. when I use _beginthreadex function, I got the follow error:
error C2664: '_beginthreadex' : cannot convert parameter 3 from 'unsigned int
(__stdcall *)(void *)' to 'unsigned int (__stdcall *)(void *)'
ps: I use the template on the threadFunc like this:
template<class T>
unsigned int WINAPI closingReconstruction_ThreadFunc(void* pvPara)
{...}
,and then i creat the thread
_beginthreadex(NULL,0,closingReconstruction_ThreadFunc<T>,(PVOID)(tPara+i),0,NULL)
so i get this error , of course , if I remove the template ,it can be work,but i need to use template, are there any methods to solve this.
You forgot to mention the immediately preceding error message,
error C2065: 'T' : undeclared identifier
Let me just state that looking at the first error message first, is generally a good idea.
Cheers & hth.,
I hook a function with windows detours in C++.
I get an error in following code:
void (*asmFunction)(const char *text);
void hookFunction(const char *text) {
__asm nop;
asmFunction(text);
}
asmFunction = (void (__cdecl *)(const char *))DetourFunction((PBYTE)0x433A90, (PBYTE)&hookFunction);
The compiler (MSVC++ 2008) says:
error C4430: Missing type specifier - int assumed. Hint: "default-int" is not supported in C++. Yadda yadda …
error C2373: 'asmFunction': redefinition with different specifiers
error C2440: 'in initialization': 'void (__cdecl *)(const char *)' cannot be converted to 'int'. There is no context in which this conversion is valid.
The code worked yesterday. What's wrong with it? How can I fix it without destructing the hook?
This expression needs to be within a function, e.g.
int main() {
asmFunction = (void (__cdecl *)(const char *))DetourFunction(
(PBYTE)0x433A90, (PBYTE)&hookFunction
);
// ...
}
Go read a book on C++.
I have a class SoundManager which contains a function called 'recordLoop'. In the constructor of the SoundManager, I am using this code:
recordHandle = (HANDLE)_beginthreadex(NULL,0,recordLoop,
(void*)exinfo->length,CREATE_SUSPENDED,0);
It is giving me the following errors:
error C3867: 'SoundManager::recordLoop': function call missing argument list; use '&SoundManager::recordLoop' to create a pointer to member
IntelliSense: argument of type "unsigned int (__stdcall SoundManager::*)(void *params)" is incompatible with parameter of type "unsigned int (__stdcall *)(void *)"
So I've tried using the &SoundManager::recordLoop as suggested, but it gives me this:
error C2664: '_beginthreadex' : cannot convert parameter 3 from 'unsigned int (__stdcall SoundManager::* )(void *)' to 'unsigned int (__stdcall *)(void *)'
IntelliSense: argument of type "unsigned int (__stdcall SoundManager::*)(void *params)" is incompatible with parameter of type "unsigned int (__stdcall *)(void *)"
Is it illegal to start a thread on a class method or did I do something wrong?
Thanks in advance
EDIT: Sorry forgot to add the recordLoop >.< here it is:
public:
unsigned __stdcall recordLoop(void* params);
It's illegal to start a thread on a non-static class member since there is no way for the created thread to know what this is.
What is the definition of recordLoop?
I had the same problem with casting.
Ignoring all other problems like one mentioned in the answer above, function pointer must be cast to (unsigned(__stdcall*)(void*)) in _beginthreadex, no matter what type the function is or what is its parameter list.