- NSIS Discussion
- Structure definition
Archive: Structure definition
mantty
5th March 2004 09:25 UTC
Structure definition
Hi all!
I want to make change of a description of a service. And to do this i must call:
C++ code
SERVICE_DESCRIPTION sd;
sd.lpDescription = (char*)SvcDescription.c_str();
ChangeServiceConfig2( hService, SERVICE_CONFIG_DESCRIPTION, &sd)
NSIS:
System::Call 'advapi32::ChangeServiceConfig2( hService, SERVICE_CONFIG_DESCRIPTION, &sd)'
The problem that i have is how do i declare in NSIS sd structure?
kichik
5th March 2004 11:36 UTC
See http://nsis.sourceforge.net/index.ph...&tx_faq_faq=35
One of the links on this page is for the Service Library which uses System and some structures.
Other System.dll structure examples can be found in Contrib\System.
KirillKr
5th March 2004 12:37 UTC
When I can download nopey now?
kichik
5th March 2004 12:42 UTC
Contact the author. If you can get a copy, I or another archive admin will upload it so it won't get lost again.
KirillKr
5th March 2004 13:08 UTC
Who is author?
Nopey - system setting tool | | |
--------------------------------------------------------------------------------
Written by doberlec 2003-03-21 07:37:41 Last updated by joost 2003-10-08 13:03:52
kichik
5th March 2004 13:13 UTC
doberlec. I think he also has a forum user so you can use that to PM or e-mail.
evilO
5th March 2004 13:17 UTC
Hi :) !
I've got what you're looking for, altough I'm not the author...
I downloaded it a couple of months ago, and it is still on my HD.. :D
evilO/Olive
KirillKr
5th March 2004 13:21 UTC
evilO, thank you very much.
mantty
5th March 2004 13:26 UTC
Thanks guys for information.
I tried to make my own job, but i have some difficulties. Can some of you tell me what i did wrong?
this is what i have to do from c++:
typedef struct _SERVICE_DESCRIPTION {
LPTSTR lpDescription;
} SERVICE_DESCRIPTION, *LPSERVICE_DESCRIPTION;
BOOL ChangeServiceConfig2(
SC_HANDLE hService, // handle to service
DWORD dwInfoLevel, // information level
LPVOID lpInfo // new data
);
and i did this in script:
!define SERVICE_ALL_ACCESS 0xF01FF
!define SC_MANAGER_ALL_ACCESS 0x3F
!define stSERVICE_DESCRIPTION "(t)i"
System::Call 'advapi32::OpenSCManagerA(n, n, i ${SC_MANAGER_ALL_ACCESS}) i'
IntCmp $1 0 lbl_done
StrCpy $2 "0x10"
StrCpy $3 "0x3"
StrCpy $4 $ServiceName
StrCpy $5 $ProjectName
StrCpy $6 $MyPath
System::Call `advapi32::CreateServiceA(i r1, t r4, t r5, i ${SERVICE_ALL_ACCESS}, i r2, i r3, i 0, t r6, n, n, n, n, n) i.r7`
StrCmp $7 0 lbl_done lbl_good
lbl_good:
System::Call '${stSERVICE_DESCRIPTION}("My Description") .r8'
System::Call 'advapi32::ChangeServiceConfig2( i r7, i 1, i r8) i.r9'
StrCmp $9 0 0 +1
lbl_done:
System::Call 'advapi32::CloseServiceHandle(i r1) n'
The service it is installing ok, but the description it is not working.
kichik
5th March 2004 13:33 UTC
See this recent thread:
http://forums.winamp.com/showthread....hreadid=171553
You have the exact same problem in your code.
mantty
5th March 2004 14:23 UTC
kichik,
thank you very much for the info. I saw that post but i still don't get it working. Can you help me with the right code :-( ... thanks
deguix
6th March 2004 01:50 UTC
Try this (NOT TESTED), probably at least it will be closer to work correctly:
!define SERVICE_ALL_ACCESS 0xF01FF
>!define SC_MANAGER_ALL_ACCESS 0x3F
>!define SERVICE_CONFIG_DESCRIPTION 1
>!define stSERVICE_DESCRIPTION "(i)i"
>System::Call 'advapi32::OpenSCManagerA(n, n, \\
i ${SC_MANAGER_ALL_ACCESS}) i'
>IntCmp $1 0 lbl_done
StrCpy$2 "0x10"
>StrCpy $3 "0x3"
>StrCpy $4 $ServiceName
StrCpy$5 $ProjectName
StrCpy$6 $MyPath
System::Call `advapi32::CreateServiceA(i r1, t r4, t r5, \\
i${SERVICE_ALL_ACCESS}, i r2, i r3, i 0, t r6, n, n, n, \\
n, n) i.r7`
>StrCmp $7 "" 0 lbl_good
SetErrors
Goto lbl_end
lbl_good:
>System::Call '*${stSERVICE_DESCRIPTION} .r8'
>System::Call 'advapi32::ChangeServiceConfig2(i r7, \\
i ${SERVICE_CONFIG_DESCRIPTION}, i r8) i.r9'
>StrCmp $9 0 0 +2
SetErrors
lbl_done:
>System::Call 'advapi32::CloseServiceHandle(i r1) n'
>lbl_end:
It will set errors if the description wasn't put correctly or if it didn't found the service handle.
(I read all about these APIs, I think it's really gonna work now)
kichik
6th March 2004 10:40 UTC
Uploaded noepy.zip to archive:
http://nsis.sourceforge.net/archive/...file=nopey.zip
mantty
8th March 2004 09:25 UTC
thanks deguix for the code. I works almost perfect, but i still don't know how to set the value for the description in structure:
!define stSERVICE_DESCRIPTION "(i)i"
System::Call '*${stSERVICE_DESCRIPTION} .r8'
I want to have somethig like "My descripton there"
Thnaks
deguix
8th March 2004 10:06 UTC
Try this:
!define DESCRIPTION "My Description"
>!define SERVICE_ALL_ACCESS 0xF01FF
>!define SC_MANAGER_ALL_ACCESS 0x3F
>!define SERVICE_CONFIG_DESCRIPTION 1
>!define stSERVICE_DESCRIPTION "(t)i"
>System::Call 'advapi32::OpenSCManagerA(n, n, \\
i ${SC_MANAGER_ALL_ACCESS}) i'
>IntCmp $1 0 lbl_done
StrCpy$2 "0x10"
>StrCpy $3 "0x3"
>StrCpy $4 $ServiceName
StrCpy$5 $ProjectName
StrCpy$6 $MyPath
System::Call `advapi32::CreateServiceA(i r1, t r4, t r5, \\
i${SERVICE_ALL_ACCESS}, i r2, i r3, i 0, t r6, n, n, n, \\
n, n) i.r7`
>StrCmp $7 "" 0 lbl_good
SetErrors
Goto lbl_end
lbl_good:
>System::Call '*${stSERVICE_DESCRIPTION}("${DESCRIPTION}") .r8'
>System::Call 'advapi32::ChangeServiceConfig2(i r7, \\
i ${SERVICE_CONFIG_DESCRIPTION}, i r8) i.r9'
>StrCmp $9 0 0 +2
SetErrors
lbl_done:
>System::Call 'advapi32::CloseServiceHandle(i r1) n'
>lbl_end:
mantty
8th March 2004 10:49 UTC
thank you very, very much deguix.
evrything is working perfert!