mirror of
https://github.com/arehnman/yttrium-virtio-gpu.git
synced 2026-10-31 02:05:04 +00:00
Balloon: user-mode service app removed
There is no need of user-mode service anymore. Building scripts were fixed. Signed-off-by: Alexey V. Kostyushko <[email protected]> Signed-off-by: Denis V. Lunev <[email protected]>
This commit is contained in:
1 parent
11bbbe3b0b
commit
08e65ea3b3
19 files changed
+3
-1824
No files matched your search
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -1,47 +0,0 @@
|
||||
Copyright 2009-2016 Red Hat, Inc. and/or its affiliates.
|
||||
|
||||
This software is licensed under the GNU General Public License,
|
||||
version 2 (GPLv2) (see COPYING for details), subject to the following
|
||||
clarification.
|
||||
|
||||
With respect to binaries built using the Microsoft(R) Windows Driver
|
||||
Kit (WDK), GPLv2 does not extend to any code contained in or derived
|
||||
from the WDK ("WDK Code"). As to WDK Code, by using or distributing
|
||||
such binaries you agree to be bound by the Microsoft Software License
|
||||
Terms for the WDK. All WDK Code is considered by the GPLv2 licensors
|
||||
to qualify for the special exception stated in section 3 of GPLv2
|
||||
(commonly known as the system library exception).
|
||||
|
||||
There is NO WARRANTY for this software, express or implied,
|
||||
including the implied warranties of NON-INFRINGEMENT, TITLE,
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
This software incorporates material covered by the following terms:
|
||||
|
||||
Copyright 2007 IBM Corporation
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
if "%DDKVER%"=="" set DDKVER=7600.16385.1
|
||||
set BUILDROOT=C:\WINDDK\%DDKVER%
|
||||
|
||||
set DDKBUILDENV=
|
||||
pushd %BUILDROOT%
|
||||
call %BUILDROOT%\bin\setenv.bat %BUILDROOT% %2 fre %1 no_oacr
|
||||
popd
|
||||
build -cZg
|
||||
|
||||
set DDKVER=
|
||||
set BUILDROOT=
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
@echo off
|
||||
|
||||
rmdir /S /Q objfre_wxp_x86
|
||||
rmdir /S /Q objfre_wnet_x86
|
||||
rmdir /S /Q objfre_wnet_amd64
|
||||
rmdir /S /Q objfre_wlh_x86
|
||||
rmdir /S /Q objfre_wlh_amd64
|
||||
rmdir /S /Q objfre_win7_x86
|
||||
rmdir /S /Q objfre_win7_amd64
|
||||
|
||||
del /F *.log *.wrn *.err
|
||||
|
||||
|
||||
@@ -1,263 +0,0 @@
|
||||
#include "device.h"
|
||||
#include "public.h"
|
||||
#include "utils.h"
|
||||
#include "memstat.h"
|
||||
|
||||
#include <dbt.h>
|
||||
#include <setupapi.h>
|
||||
#include <tchar.h>
|
||||
|
||||
CDevice::CDevice()
|
||||
{
|
||||
m_pMemStat = NULL;
|
||||
m_hService = NULL;
|
||||
m_hThread = NULL;
|
||||
m_evtTerminate = NULL;
|
||||
m_evtWrite = NULL;
|
||||
}
|
||||
|
||||
CDevice::~CDevice()
|
||||
{
|
||||
Fini();
|
||||
}
|
||||
|
||||
BOOL CDevice::Init(SERVICE_STATUS_HANDLE hService)
|
||||
{
|
||||
m_pMemStat = new CMemStat();
|
||||
if (!m_pMemStat || !m_pMemStat->Init()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_evtTerminate = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!m_evtTerminate) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_evtWrite = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!m_evtWrite) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_hService = hService;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID CDevice::Fini()
|
||||
{
|
||||
Stop();
|
||||
|
||||
if (m_evtWrite) {
|
||||
CloseHandle(m_evtWrite);
|
||||
m_evtWrite = NULL;
|
||||
}
|
||||
|
||||
if (m_evtTerminate) {
|
||||
CloseHandle(m_evtTerminate);
|
||||
m_evtTerminate = NULL;
|
||||
}
|
||||
|
||||
m_hService = NULL;
|
||||
|
||||
delete m_pMemStat;
|
||||
m_pMemStat = NULL;
|
||||
}
|
||||
|
||||
DWORD CDevice::Run()
|
||||
{
|
||||
PWCHAR DevicePath = GetDevicePath((LPGUID)&GUID_DEVINTERFACE_BALLOON);
|
||||
if (DevicePath == NULL) {
|
||||
PrintMessage("File not found.");
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
HANDLE hDevice = CreateFile(DevicePath, GENERIC_WRITE, 0, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
|
||||
|
||||
free(DevicePath);
|
||||
|
||||
if (hDevice == INVALID_HANDLE_VALUE) {
|
||||
PrintMessage("Failed to create file.");
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
DEV_BROADCAST_HANDLE filter;
|
||||
HDEVNOTIFY devnotify;
|
||||
|
||||
ZeroMemory(&filter, sizeof(filter));
|
||||
filter.dbch_size = sizeof(filter);
|
||||
filter.dbch_devicetype = DBT_DEVTYP_HANDLE;
|
||||
filter.dbch_handle = hDevice;
|
||||
|
||||
devnotify = RegisterDeviceNotification(m_hService, &filter,
|
||||
DEVICE_NOTIFY_SERVICE_HANDLE);
|
||||
|
||||
if (!devnotify) {
|
||||
DWORD err = GetLastError();
|
||||
PrintMessage("Failed to register handle notification.");
|
||||
CloseHandle(hDevice);
|
||||
return err;
|
||||
}
|
||||
|
||||
WriteLoop(hDevice);
|
||||
|
||||
UnregisterDeviceNotification(devnotify);
|
||||
CloseHandle(hDevice);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
VOID CDevice::WriteLoop(HANDLE hDevice)
|
||||
{
|
||||
HANDLE waitfor[] = { m_evtTerminate, m_evtWrite };
|
||||
OVERLAPPED ovlp;
|
||||
DWORD timeout;
|
||||
DWORD written;
|
||||
DWORD waitrc;
|
||||
BOOL writerc;
|
||||
|
||||
ZeroMemory(&ovlp, sizeof(ovlp));
|
||||
ovlp.hEvent = m_evtWrite;
|
||||
|
||||
while (1) {
|
||||
// The old version of the balloon driver didn't block write requests
|
||||
// until stats were requested. So in order not to consume too much CPU
|
||||
// we keep the old 1s delay behavior and switch to infinite wait only
|
||||
// if write result is pending.
|
||||
timeout = 1000;
|
||||
|
||||
if (m_pMemStat->Update()) {
|
||||
writerc = WriteFile(hDevice, m_pMemStat->GetBuffer(),
|
||||
m_pMemStat->GetSize(), NULL, &ovlp);
|
||||
if (!writerc && (GetLastError() == ERROR_IO_PENDING)) {
|
||||
timeout = INFINITE;
|
||||
}
|
||||
}
|
||||
|
||||
waitrc = WaitForMultipleObjects(sizeof(waitfor) / sizeof(waitfor[0]),
|
||||
waitfor, FALSE, timeout);
|
||||
|
||||
if (waitrc == WAIT_OBJECT_0) {
|
||||
break;
|
||||
}
|
||||
else if (waitrc == WAIT_OBJECT_0 + 1) {
|
||||
if (!GetOverlappedResult(hDevice, &ovlp, &written, FALSE) ||
|
||||
(written != m_pMemStat->GetSize()))
|
||||
{
|
||||
PrintMessage("Failed to write stats.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CDevice::Start()
|
||||
{
|
||||
DWORD tid;
|
||||
|
||||
if (!m_hThread) {
|
||||
m_hThread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE)DeviceThread, (LPVOID)this, 0, &tid);
|
||||
}
|
||||
|
||||
return (m_hThread != NULL);
|
||||
}
|
||||
|
||||
VOID CDevice::Stop()
|
||||
{
|
||||
if (m_hThread) {
|
||||
SetEvent(m_evtTerminate);
|
||||
if (WaitForSingleObject(m_hThread, 1000) == WAIT_TIMEOUT) {
|
||||
TerminateThread(m_hThread, 0);
|
||||
}
|
||||
CloseHandle(m_hThread);
|
||||
m_hThread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD WINAPI CDevice::DeviceThread(LPDWORD lParam)
|
||||
{
|
||||
CDevice* pDev = reinterpret_cast<CDevice*>(lParam);
|
||||
return pDev->Run();
|
||||
}
|
||||
|
||||
PTCHAR CDevice::GetDevicePath( IN LPGUID InterfaceGuid )
|
||||
{
|
||||
HDEVINFO HardwareDeviceInfo;
|
||||
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData = NULL;
|
||||
ULONG Length, RequiredLength = 0;
|
||||
BOOL bResult;
|
||||
PTCHAR DevicePath;
|
||||
|
||||
HardwareDeviceInfo = SetupDiGetClassDevs(
|
||||
InterfaceGuid,
|
||||
NULL,
|
||||
NULL,
|
||||
(DIGCF_PRESENT | DIGCF_DEVICEINTERFACE)
|
||||
);
|
||||
|
||||
if (HardwareDeviceInfo == INVALID_HANDLE_VALUE) {
|
||||
PrintMessage("Cannot get class devices");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
|
||||
bResult = SetupDiEnumDeviceInterfaces(
|
||||
HardwareDeviceInfo,
|
||||
0,
|
||||
InterfaceGuid,
|
||||
0,
|
||||
&DeviceInterfaceData
|
||||
);
|
||||
|
||||
if (bResult == FALSE) {
|
||||
PrintMessage("Cannot get enumerate device interfaces");
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetupDiGetDeviceInterfaceDetail(
|
||||
HardwareDeviceInfo,
|
||||
&DeviceInterfaceData,
|
||||
NULL,
|
||||
0,
|
||||
&RequiredLength,
|
||||
NULL
|
||||
);
|
||||
|
||||
DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) LocalAlloc(LMEM_FIXED, RequiredLength);
|
||||
|
||||
if (DeviceInterfaceDetailData == NULL) {
|
||||
PrintMessage("Cannot allocate memory");
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
||||
|
||||
Length = RequiredLength;
|
||||
|
||||
bResult = SetupDiGetDeviceInterfaceDetail(
|
||||
HardwareDeviceInfo,
|
||||
&DeviceInterfaceData,
|
||||
DeviceInterfaceDetailData,
|
||||
Length,
|
||||
&RequiredLength,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (bResult == FALSE) {
|
||||
PrintMessage("Cannot get device interface details");
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
LocalFree(DeviceInterfaceDetailData);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DevicePath = _tcsdup(DeviceInterfaceDetailData->DevicePath);
|
||||
|
||||
SetupDiDestroyDeviceInfoList(HardwareDeviceInfo);
|
||||
LocalFree(DeviceInterfaceDetailData);
|
||||
|
||||
return DevicePath;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef DEVICE_H
|
||||
#define DEVICE_H
|
||||
|
||||
#include <wtypes.h>
|
||||
|
||||
class CMemStat;
|
||||
|
||||
class CDevice {
|
||||
public:
|
||||
CDevice();
|
||||
~CDevice();
|
||||
BOOL Init(SERVICE_STATUS_HANDLE hService);
|
||||
VOID Fini();
|
||||
BOOL Start();
|
||||
VOID Stop();
|
||||
|
||||
protected:
|
||||
PTCHAR GetDevicePath(IN LPGUID InterfaceGuid);
|
||||
DWORD Run();
|
||||
private:
|
||||
static DWORD WINAPI DeviceThread(LPDWORD lParam);
|
||||
VOID WriteLoop(HANDLE hDevice);
|
||||
CMemStat* m_pMemStat;
|
||||
SERVICE_STATUS_HANDLE m_hService;
|
||||
HANDLE m_hThread;
|
||||
HANDLE m_evtTerminate;
|
||||
HANDLE m_evtWrite;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,78 +0,0 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "service.h"
|
||||
|
||||
LPWSTR ServiceName = L"BalloonService";
|
||||
LPWSTR DisplayName = L"Balloon Service";
|
||||
|
||||
CService srvc;
|
||||
|
||||
DWORD WINAPI HandlerEx(DWORD ctlcode, DWORD evtype, PVOID evdata, PVOID context)
|
||||
{
|
||||
CService *service = static_cast<CService*>(context);
|
||||
|
||||
return CService::HandlerExThunk(service, ctlcode, evtype, evdata);
|
||||
}
|
||||
|
||||
void __stdcall ServiceMainEx(DWORD argc, TCHAR* argv[])
|
||||
{
|
||||
srvc.m_StatusHandle = RegisterServiceCtrlHandlerEx(ServiceName, HandlerEx,
|
||||
&srvc);
|
||||
CService::ServiceMainThunk(&srvc, argc, argv);
|
||||
}
|
||||
|
||||
SERVICE_TABLE_ENTRY serviceTableEx[] =
|
||||
{
|
||||
{ ServiceName, (LPSERVICE_MAIN_FUNCTION) ServiceMainEx},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
||||
ULONG
|
||||
_cdecl
|
||||
wmain(
|
||||
__in ULONG argc,
|
||||
__in_ecount(Argc) PWCHAR argv[]
|
||||
)
|
||||
{
|
||||
if(argc == 2)
|
||||
{
|
||||
if (_tcsicmp(L"-i", argv[1]) == 0) {
|
||||
InstallService();
|
||||
} else if (_tcsicmp(L"-u", argv[1]) == 0) {
|
||||
UninstallService();
|
||||
} else if (_tcsicmp(L"-r", argv[1]) == 0) {
|
||||
ServiceRun();
|
||||
} else if (_tcsicmp(L"-s", argv[1]) == 0) {
|
||||
ServiceControl(SERVICE_CONTROL_STOP);
|
||||
} else if (_tcsicmp(L"status", argv[1]) == 0) {
|
||||
SC_HANDLE scm, service;
|
||||
scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (!scm) {
|
||||
ErrorHandler("OpenSCManager", GetLastError());
|
||||
}
|
||||
service = OpenService(scm, ServiceName, SERVICE_ALL_ACCESS);
|
||||
if (!service) {
|
||||
ErrorHandler("OpenService", GetLastError());
|
||||
}
|
||||
printf("STATUS: ");
|
||||
srvc.GetStatus(service);
|
||||
} else if (_tcsicmp(L"config", argv[1]) == 0) {
|
||||
GetConfiguration();
|
||||
} else if (_tcsicmp(L"help", argv[1]) == 0) {
|
||||
ShowUsage();
|
||||
} else {
|
||||
ShowUsage();
|
||||
}
|
||||
} else {
|
||||
BOOL success;
|
||||
success = StartServiceCtrlDispatcher(serviceTableEx);
|
||||
if (!success) {
|
||||
ErrorHandler("StartServiceCtrlDispatcher",GetLastError());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#
|
||||
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
|
||||
# file to this component. This file merely indirects to the real make file
|
||||
# that is shared by all the components of Windows NT
|
||||
#
|
||||
!INCLUDE $(NTMAKEENV)\makefile.def
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
#include "memstat.h"
|
||||
#include "utils.h"
|
||||
|
||||
CMemStat::CMemStat()
|
||||
{
|
||||
initialized = FALSE;
|
||||
locator = NULL;
|
||||
service = NULL;
|
||||
memset(m_Stats, -1, sizeof(m_Stats));
|
||||
}
|
||||
|
||||
CMemStat::~CMemStat()
|
||||
{
|
||||
service = NULL;
|
||||
locator = NULL;
|
||||
|
||||
if (initialized == TRUE) {
|
||||
CoUninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CMemStat::Init()
|
||||
{
|
||||
HRESULT status = S_OK;
|
||||
status = CoInitializeEx(NULL,
|
||||
COINIT_MULTITHREADED);
|
||||
if (FAILED(status)) {
|
||||
PrintMessage("Cannot initialize COM");
|
||||
return status;
|
||||
}
|
||||
initialized = TRUE;
|
||||
|
||||
status = CoInitializeSecurity(
|
||||
NULL,
|
||||
-1,
|
||||
NULL,
|
||||
NULL,
|
||||
RPC_C_AUTHN_LEVEL_PKT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE,
|
||||
NULL,
|
||||
EOAC_NONE,
|
||||
0
|
||||
);
|
||||
|
||||
if (FAILED(status)) {
|
||||
PrintMessage("Cannot initialize security");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = CoCreateInstance(
|
||||
CLSID_WbemLocator,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IWbemLocator,
|
||||
reinterpret_cast< void** >( &locator )
|
||||
);
|
||||
|
||||
if (FAILED(status)) {
|
||||
PrintMessage("Cannot create instance");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = locator->ConnectServer(
|
||||
L"root\\cimv2",
|
||||
NULL,
|
||||
NULL,
|
||||
0L,
|
||||
0L,
|
||||
NULL,
|
||||
NULL,
|
||||
&service
|
||||
);
|
||||
if (FAILED(status)) {
|
||||
PrintMessage("Cannot connect to wmi server");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = CoSetProxyBlanket(service,
|
||||
RPC_C_AUTHN_WINNT,
|
||||
RPC_C_AUTHZ_NONE,
|
||||
NULL,
|
||||
RPC_C_AUTHN_LEVEL_CALL,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE,
|
||||
NULL,
|
||||
EOAC_NONE
|
||||
);
|
||||
if (FAILED(status)) {
|
||||
PrintMessage("Cannot set proxy blanket");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CMemStat::Update()
|
||||
{
|
||||
SYSTEM_INFO sysinfo;
|
||||
MEMORYSTATUSEX statex = {sizeof(statex)};
|
||||
CComPtr< IEnumWbemClassObject > enumerator;
|
||||
CComPtr< IWbemClassObject > memory;
|
||||
ULONG retcnt;
|
||||
_variant_t var_val;
|
||||
HRESULT status = S_OK;
|
||||
UINT idx = 0;
|
||||
|
||||
GetSystemInfo(&sysinfo);
|
||||
|
||||
status = service->ExecQuery(
|
||||
L"WQL",
|
||||
L"SELECT * FROM Win32_PerfRawData_PerfOS_Memory",
|
||||
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
|
||||
NULL,
|
||||
&enumerator
|
||||
);
|
||||
|
||||
if (FAILED(status)) {
|
||||
PrintMessage("Cannot execute query");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while(enumerator)
|
||||
{
|
||||
status = enumerator->Next(
|
||||
WBEM_INFINITE,
|
||||
1L,
|
||||
&memory,
|
||||
&retcnt
|
||||
);
|
||||
if (retcnt == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
status = memory->Get(
|
||||
L"PagesInputPerSec",
|
||||
0,
|
||||
&var_val,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (FAILED(status) || (var_val.vt == VT_NULL)) {
|
||||
PrintMessage("Cannot get PagesInputPerSec");
|
||||
var_val.vt = -1;
|
||||
}
|
||||
m_Stats[idx].tag = VIRTIO_BALLOON_S_SWAP_IN;
|
||||
m_Stats[idx].val = (__int64)var_val * sysinfo.dwPageSize;
|
||||
idx++;
|
||||
|
||||
status = memory->Get(
|
||||
L"PagesOutputPerSec",
|
||||
0,
|
||||
&var_val,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (FAILED(status) || (var_val.vt == VT_NULL)) {
|
||||
PrintMessage("Cannot get PagesOutputPerSec");
|
||||
var_val.vt = -1;
|
||||
}
|
||||
m_Stats[idx].tag = VIRTIO_BALLOON_S_SWAP_OUT;
|
||||
m_Stats[idx].val = (__int64)var_val * sysinfo.dwPageSize;
|
||||
idx++;
|
||||
|
||||
status = memory->Get(
|
||||
L"PageReadsPerSec",
|
||||
0,
|
||||
&var_val,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (FAILED(status) || (var_val.vt == VT_NULL)) {
|
||||
PrintMessage("Cannot get PageReadsPerSec");
|
||||
var_val.vt = -1;
|
||||
}
|
||||
m_Stats[idx].tag = VIRTIO_BALLOON_S_MAJFLT;
|
||||
m_Stats[idx].val = (long)var_val;
|
||||
idx++;
|
||||
|
||||
status = memory->Get(
|
||||
L"PageFaultsPerSec",
|
||||
0,
|
||||
&var_val,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (FAILED(status) || (var_val.vt == VT_NULL)) {
|
||||
PrintMessage("Cannot get PageFaultsPerSec");
|
||||
var_val.vt = -1;
|
||||
}
|
||||
m_Stats[idx].tag = VIRTIO_BALLOON_S_MINFLT;
|
||||
m_Stats[idx].val = (long)var_val;
|
||||
idx++;
|
||||
|
||||
GlobalMemoryStatusEx(&statex);
|
||||
|
||||
m_Stats[idx].tag = VIRTIO_BALLOON_S_MEMFREE;
|
||||
m_Stats[idx].val = statex.ullAvailPhys;
|
||||
idx++;
|
||||
|
||||
m_Stats[idx].tag = VIRTIO_BALLOON_S_MEMTOT;
|
||||
m_Stats[idx].val = statex.ullTotalPhys;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef MEMSTAT_H
|
||||
#define MEMSTAT_H
|
||||
|
||||
#include "Wbemidl.h"
|
||||
#include "coguid.h"
|
||||
#include "atlbase.h"
|
||||
#include "comdef.h"
|
||||
#include "comutil.h"
|
||||
#include "public.h"
|
||||
|
||||
class CMemStat {
|
||||
public:
|
||||
CMemStat();
|
||||
~CMemStat();
|
||||
BOOL Init();
|
||||
BOOL Update();
|
||||
|
||||
PVOID GetBuffer() {
|
||||
return m_Stats;
|
||||
}
|
||||
|
||||
size_t GetSize() {
|
||||
return sizeof(m_Stats);
|
||||
}
|
||||
|
||||
private:
|
||||
BOOL initialized;
|
||||
CComPtr< IWbemLocator > locator;
|
||||
CComPtr< IWbemServices > service;
|
||||
BALLOON_STAT m_Stats[VIRTIO_BALLOON_S_NR];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
@echo off
|
||||
: Param1 - Win7 | Wlh | Wnet | XP
|
||||
: Param2 - x86|x64
|
||||
: Param3 - file name
|
||||
|
||||
if "%2"=="x64" set %%2=amd64
|
||||
|
||||
if /i "%1"=="Win7" goto :checkarch
|
||||
if /i "%1"=="Wlh" goto :checkarch
|
||||
if /i "%1"=="Wnet" goto :checkarch
|
||||
if /i "%1"=="WXp" goto :checkarch
|
||||
goto :printerr
|
||||
:checkarch
|
||||
if /i "%2"=="x86" goto :makeinstall
|
||||
if /i "%2"=="x64" goto :makeinstall
|
||||
:printerr
|
||||
echo wrong parameters (1)%1 (2)%2 (3)%3
|
||||
pause
|
||||
goto :eof
|
||||
|
||||
:makeinstall
|
||||
set INST_OS=%1
|
||||
set INST_ARC=%2
|
||||
set FILE_NAME=%3
|
||||
rem set INST_EXT=INST_ARC
|
||||
|
||||
if /i "%INST_ARC%"=="x64" goto :set_x64
|
||||
|
||||
set INST_EXT=i386
|
||||
goto :startcopy
|
||||
|
||||
:set_x64
|
||||
set INST_ARC=amd64
|
||||
set INST_EXT=amd64
|
||||
|
||||
:startcopy
|
||||
set EXE_PATH_AND_NAME=objfre_%INST_OS%_%INST_ARC%\%INST_EXT%\%FILE_NAME%.exe
|
||||
set PDB_PATH_AND_NAME=objfre_%INST_OS%_%INST_ARC%\%INST_EXT%\%FILE_NAME%.pdb
|
||||
|
||||
echo makeinstall %1 %2 %3
|
||||
mkdir ..\Install\%INST_OS%\%INST_ARC%
|
||||
del /Q ..\Install\%INST_OS%\%INST_ARC%\%FILE_NAME%.*
|
||||
copy /Y %EXE_PATH_AND_NAME% ..\Install\%INST_OS%\%INST_ARC%
|
||||
copy /Y %PDB_PATH_AND_NAME% ..\Install\%INST_OS%\%INST_ARC%
|
||||
|
||||
set INST_OS=
|
||||
set INST_ARC=
|
||||
set FILE_NAME=
|
||||
set EXE_PATH_AND_NAME=
|
||||
set PDB_PATH_AND_NAME=
|
||||
|
||||
|
||||
@@ -1,263 +0,0 @@
|
||||
#define INITGUID
|
||||
|
||||
#include "service.h"
|
||||
#include "utils.h"
|
||||
#include "device.h"
|
||||
#include "public.h"
|
||||
|
||||
CService::CService()
|
||||
{
|
||||
m_hDevNotify = NULL;
|
||||
m_evTerminate = NULL;
|
||||
m_bRunningService = FALSE;
|
||||
m_StatusHandle = NULL;
|
||||
m_pDev = NULL;
|
||||
m_Status = SERVICE_STOPPED;
|
||||
}
|
||||
|
||||
CService::~CService()
|
||||
{
|
||||
m_evTerminate = NULL;
|
||||
m_bRunningService = FALSE;
|
||||
m_StatusHandle = NULL;
|
||||
m_pDev = NULL;
|
||||
m_Status = SERVICE_STOPPED;
|
||||
}
|
||||
|
||||
DWORD __stdcall CService::HandlerExThunk(CService* service, DWORD ctlcode, DWORD evtype, PVOID evdata)
|
||||
{
|
||||
switch (ctlcode) {
|
||||
|
||||
case SERVICE_CONTROL_DEVICEEVENT:
|
||||
case SERVICE_CONTROL_HARDWAREPROFILECHANGE:
|
||||
return service->ServiceHandleDeviceChange(evtype, (_DEV_BROADCAST_HEADER*) evdata);
|
||||
|
||||
case SERVICE_CONTROL_POWEREVENT:
|
||||
return service->ServiceHandlePowerEvent(evtype, (DWORD) evdata);
|
||||
|
||||
default:
|
||||
service->ServiceCtrlHandler(ctlcode);
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
void __stdcall CService::ServiceMainThunk(CService* service, DWORD argc, TCHAR* argv[])
|
||||
{
|
||||
service->ServiceMain(argc, argv);
|
||||
}
|
||||
|
||||
BOOL CService::InitService()
|
||||
{
|
||||
m_bRunningService = TRUE;
|
||||
m_Status = SERVICE_RUNNING;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CService::SendStatusToSCM(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint)
|
||||
{
|
||||
BOOL res;
|
||||
SERVICE_STATUS serviceStatus;
|
||||
|
||||
serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS;
|
||||
serviceStatus.dwCurrentState = dwCurrentState;
|
||||
|
||||
if (dwCurrentState == SERVICE_START_PENDING) {
|
||||
serviceStatus.dwControlsAccepted = 0;
|
||||
} else {
|
||||
serviceStatus.dwControlsAccepted =
|
||||
SERVICE_ACCEPT_STOP |
|
||||
SERVICE_ACCEPT_SHUTDOWN;
|
||||
}
|
||||
|
||||
if (dwServiceSpecificExitCode == 0) {
|
||||
serviceStatus.dwWin32ExitCode = dwWin32ExitCode;
|
||||
} else {
|
||||
serviceStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
|
||||
}
|
||||
|
||||
serviceStatus.dwServiceSpecificExitCode = dwServiceSpecificExitCode;
|
||||
serviceStatus.dwCheckPoint = dwCheckPoint;
|
||||
serviceStatus.dwWaitHint = dwWaitHint;
|
||||
|
||||
res = SetServiceStatus (m_StatusHandle, &serviceStatus);
|
||||
if (!res) {
|
||||
StopService();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void CService::StopService()
|
||||
{
|
||||
if (m_bRunningService && m_pDev) {
|
||||
m_pDev->Stop();
|
||||
m_bRunningService = FALSE;
|
||||
m_Status = SERVICE_STOPPED;
|
||||
}
|
||||
SetEvent(m_evTerminate);
|
||||
}
|
||||
|
||||
void CService::terminate(DWORD error)
|
||||
{
|
||||
if (m_hDevNotify) {
|
||||
UnregisterDeviceNotification(m_hDevNotify);
|
||||
m_hDevNotify = NULL;
|
||||
}
|
||||
|
||||
if (m_evTerminate) {
|
||||
CloseHandle(m_evTerminate);
|
||||
m_evTerminate = NULL;
|
||||
}
|
||||
|
||||
if (m_StatusHandle) {
|
||||
SendStatusToSCM(SERVICE_STOPPED, error, 0, 0, 0);
|
||||
}
|
||||
|
||||
delete m_pDev;
|
||||
}
|
||||
|
||||
void CService::ServiceCtrlHandler(DWORD controlCode)
|
||||
{
|
||||
switch(controlCode)
|
||||
{
|
||||
case SERVICE_CONTROL_STOP:
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
m_Status = SERVICE_STOP_PENDING;
|
||||
SendStatusToSCM(
|
||||
m_Status,
|
||||
NO_ERROR,
|
||||
0,
|
||||
1,
|
||||
5000
|
||||
);
|
||||
StopService();
|
||||
return;
|
||||
|
||||
case SERVICE_CONTROL_INTERROGATE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SendStatusToSCM(m_Status, NO_ERROR, 0, 0, 0);
|
||||
}
|
||||
|
||||
DWORD CService::ServiceHandleDeviceChange(DWORD evtype, _DEV_BROADCAST_HEADER* dbhdr)
|
||||
{
|
||||
switch (evtype)
|
||||
{
|
||||
case DBT_DEVICEARRIVAL:
|
||||
case DBT_DEVICEQUERYREMOVEFAILED:
|
||||
m_pDev->Start();
|
||||
break;
|
||||
|
||||
case DBT_DEVICEQUERYREMOVE:
|
||||
case DBT_DEVICEREMOVECOMPLETE:
|
||||
m_pDev->Stop();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
DWORD CService::ServiceHandlePowerEvent(DWORD evtype, DWORD flags)
|
||||
{
|
||||
PrintMessage("ServiceHandlePowerEvent");
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void CService::ServiceMain(DWORD argc, LPTSTR *argv)
|
||||
{
|
||||
BOOL res;
|
||||
|
||||
if (!m_StatusHandle) {
|
||||
terminate(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
res = SendStatusToSCM(SERVICE_START_PENDING, NO_ERROR, 0 , 1, 5000);
|
||||
if (!res) {
|
||||
terminate(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
m_pDev = new CDevice();
|
||||
if (!m_pDev || !m_pDev->Init(m_StatusHandle) || !m_pDev->Start()) {
|
||||
terminate(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
DEV_BROADCAST_DEVICEINTERFACE filter;
|
||||
|
||||
ZeroMemory(&filter, sizeof(filter));
|
||||
filter.dbcc_size = sizeof(filter);
|
||||
filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
||||
filter.dbcc_classguid = GUID_DEVINTERFACE_BALLOON;
|
||||
|
||||
m_hDevNotify = RegisterDeviceNotification(m_StatusHandle, &filter,
|
||||
DEVICE_NOTIFY_SERVICE_HANDLE);
|
||||
|
||||
if (!m_hDevNotify) {
|
||||
terminate(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
m_evTerminate = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (!m_evTerminate) {
|
||||
terminate(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
res = InitService();
|
||||
if (!res) {
|
||||
terminate(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
res = SendStatusToSCM(SERVICE_RUNNING, NO_ERROR, 0 , 0, 0);
|
||||
if (!res) {
|
||||
terminate(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
WaitForSingleObject(m_evTerminate, INFINITE);
|
||||
terminate(0);
|
||||
}
|
||||
|
||||
|
||||
void CService::GetStatus(SC_HANDLE service)
|
||||
{
|
||||
SERVICE_STATUS status;
|
||||
DWORD CurrentState;
|
||||
|
||||
QueryServiceStatus(service, &status);
|
||||
|
||||
switch(status.dwCurrentState) {
|
||||
case SERVICE_RUNNING:
|
||||
CurrentState = SERVICE_RUNNING;
|
||||
printf("Service RUNNING.\n");
|
||||
break;
|
||||
case SERVICE_STOPPED:
|
||||
CurrentState = SERVICE_STOPPED;
|
||||
printf("Service STOPPED.\n");
|
||||
break;
|
||||
case SERVICE_CONTINUE_PENDING:
|
||||
CurrentState = SERVICE_CONTINUE_PENDING;
|
||||
printf("Service is resuming...\n");
|
||||
break;
|
||||
case SERVICE_START_PENDING:
|
||||
CurrentState = SERVICE_START_PENDING;
|
||||
printf("Service is starting...\n");
|
||||
break;
|
||||
case SERVICE_STOP_PENDING:
|
||||
CurrentState = SERVICE_STOP_PENDING;
|
||||
printf("Service is stopping...\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SendStatusToSCM(CurrentState, NO_ERROR, 0, 0, 0);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#ifndef SERVICE_H
|
||||
#define SERVICE_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbt.h>
|
||||
|
||||
class CDevice;
|
||||
|
||||
class CService
|
||||
{
|
||||
public:
|
||||
CService();
|
||||
~CService();
|
||||
BOOL InitService();
|
||||
void GetStatus(SC_HANDLE service);
|
||||
static DWORD __stdcall HandlerExThunk(CService* service, DWORD ctlcode, DWORD evtype, PVOID evdata);
|
||||
static void __stdcall ServiceMainThunk(CService* service, DWORD argc, TCHAR* argv[]);
|
||||
SERVICE_STATUS_HANDLE m_StatusHandle;
|
||||
|
||||
private:
|
||||
BOOL SendStatusToSCM(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint);
|
||||
void StopService();
|
||||
void terminate(DWORD error);
|
||||
void ServiceCtrlHandler(DWORD controlCode);
|
||||
void ServiceMain(DWORD argc, LPTSTR *argv);
|
||||
DWORD ServiceHandleDeviceChange(DWORD evtype, _DEV_BROADCAST_HEADER* dbhdr);
|
||||
DWORD ServiceHandlePowerEvent(DWORD evtype, DWORD flags);
|
||||
|
||||
HDEVNOTIFY m_hDevNotify;
|
||||
HANDLE m_evTerminate;
|
||||
BOOL m_bRunningService;
|
||||
DWORD m_Status;
|
||||
CDevice* m_pDev;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
TARGETNAME=blnsvr
|
||||
TARGETTYPE=PROGRAM
|
||||
|
||||
_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)
|
||||
|
||||
USE_MSVCRT=1
|
||||
|
||||
UMTYPE=console
|
||||
UMENTRY=wmain
|
||||
|
||||
SOURCES=main.cpp \
|
||||
memstat.cpp \
|
||||
device.cpp \
|
||||
service.cpp \
|
||||
utils.cpp
|
||||
|
||||
TARGETLIBS=$(SDK_LIB_PATH)\ole32.lib \
|
||||
$(SDK_LIB_PATH)\oleaut32.lib \
|
||||
$(SDK_LIB_PATH)\uuid.lib \
|
||||
$(SDK_LIB_PATH)\wbemuuid.lib \
|
||||
$(SDK_LIB_PATH)\setupapi.lib \
|
||||
$(SDK_LIB_PATH)\user32.lib \
|
||||
$(SDK_LIB_PATH)\strsafe.lib
|
||||
|
||||
C_DEFINES=$(C_DEFINES) /D_UNICODE /DUNICODE /D_WIN32_DCOM
|
||||
|
||||
USE_MSVCRT=1
|
||||
USE_VCCOM=1
|
||||
USE_ATL=1
|
||||
ATL_VER=71
|
||||
|
||||
INCLUDES = $(INCLUDES);..\sys
|
||||
|
||||
|
||||
@@ -1,362 +0,0 @@
|
||||
#include "utils.h"
|
||||
#include "service.h"
|
||||
#include "strsafe.h"
|
||||
|
||||
extern LPWSTR ServiceName;
|
||||
extern LPWSTR DisplayName;
|
||||
|
||||
extern CService srvc;
|
||||
|
||||
static struct ErrEntry {
|
||||
int code;
|
||||
const char* msg;
|
||||
} ErrList[] = {
|
||||
{ 0, "No error" },
|
||||
{ 1055, "The service database is locked." },
|
||||
{ 1056, "An instance of the service is already running." },
|
||||
{ 1060, "The service does not exist as an installed service." },
|
||||
{ 1061, "The service cannot accept control messages at this time." },
|
||||
{ 1062, "The service has not been started." },
|
||||
{ 1063, "The service process could not connect to the service controller." },
|
||||
{ 1064, "An exception occurred in the service when handling the control request." },
|
||||
{ 1065, "The database specified does not exist." },
|
||||
{ 1066, "The service has returned a service-specific error code." },
|
||||
{ 1067, "The process terminated unexpectedly." },
|
||||
{ 1068, "The dependency service or group failed to start." },
|
||||
{ 1069, "The service did not start due to a logon failure." },
|
||||
{ 1070, "After starting, the service hung in a start-pending state." },
|
||||
{ 1071, "The specified service database lock is invalid." },
|
||||
{ 1072, "The service marked for deletion." },
|
||||
{ 1073, "The service already exists." },
|
||||
{ 1078, "The name is already in use as either a service name or a service display name." },
|
||||
};
|
||||
|
||||
const int nErrList = sizeof(ErrList) / sizeof(ErrEntry);
|
||||
|
||||
void ErrorHandler(char *s, int err)
|
||||
{
|
||||
printf("Failed. Error %d ", err );
|
||||
int i;
|
||||
for (i = 0; i < nErrList; ++i) {
|
||||
if (ErrList[i].code == err) {
|
||||
printf("%s\n", ErrList[i].msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == nErrList) {
|
||||
printf("unknown error\n");
|
||||
}
|
||||
|
||||
FILE* pLog = fopen("balloon.log","a");
|
||||
fprintf(pLog, "%s failed, error code = %d\n",s , err);
|
||||
fclose(pLog);
|
||||
|
||||
ExitProcess(err);
|
||||
}
|
||||
|
||||
void PrintMessage(char *s)
|
||||
{
|
||||
#ifdef DBG
|
||||
FILE* pLog = fopen("balloon.log", "a");
|
||||
fprintf(pLog, "%s\n", s);
|
||||
fclose(pLog);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShowUsage()
|
||||
{
|
||||
printf("\n");
|
||||
printf("USAGE:\n");
|
||||
printf("blnsvr -i\tInstall service\n");
|
||||
printf("blnsvr -u\tUninstall service\n");
|
||||
printf("blnsvr -r\tRun service\n");
|
||||
printf("blnsvr -s\tStop service\n");
|
||||
printf("blnsvr status\tCurrent status\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
BOOL InstallService()
|
||||
{
|
||||
SC_HANDLE newService;
|
||||
SC_HANDLE scm;
|
||||
TCHAR szBuffer[255];
|
||||
TCHAR szPath[MAX_PATH];
|
||||
|
||||
GetModuleFileName( GetModuleHandle(NULL), szPath, MAX_PATH );
|
||||
if (FAILED( StringCchCopy(szBuffer, 255, TEXT("\"")))) {
|
||||
return FALSE;
|
||||
}
|
||||
if (FAILED( StringCchCat(szBuffer, 255, szPath))) {
|
||||
return FALSE;
|
||||
}
|
||||
if (FAILED( StringCchCat(szBuffer, 255, TEXT("\"")))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
|
||||
if (scm == NULL) {
|
||||
ErrorHandler("OpenSCManager", GetLastError());
|
||||
}
|
||||
newService = CreateService(
|
||||
scm,
|
||||
ServiceName,
|
||||
DisplayName,
|
||||
SERVICE_ALL_ACCESS,
|
||||
SERVICE_WIN32_OWN_PROCESS,
|
||||
SERVICE_AUTO_START,
|
||||
SERVICE_ERROR_NORMAL,
|
||||
szBuffer,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
if (!newService) {
|
||||
ErrorHandler("CreateService", GetLastError());
|
||||
return FALSE;
|
||||
} else {
|
||||
printf("Service Installed\n");
|
||||
ServiceRun();
|
||||
}
|
||||
|
||||
CloseServiceHandle(newService);
|
||||
CloseServiceHandle(scm);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL UninstallService()
|
||||
{
|
||||
SC_HANDLE service;
|
||||
SC_HANDLE scm;
|
||||
BOOL res;
|
||||
SERVICE_STATUS status;
|
||||
|
||||
scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (!scm) {
|
||||
ErrorHandler("OpenSCManager", GetLastError());
|
||||
}
|
||||
|
||||
service = OpenService(scm, ServiceName, SERVICE_ALL_ACCESS | DELETE);
|
||||
if (!service) {
|
||||
ErrorHandler("OpenService", GetLastError());
|
||||
}
|
||||
|
||||
res = QueryServiceStatus(service, &status);
|
||||
if (!res) {
|
||||
ErrorHandler("QueryServiceStatus", GetLastError());
|
||||
}
|
||||
|
||||
if (status.dwCurrentState != SERVICE_STOPPED) {
|
||||
printf("Stopping service...\n");
|
||||
res = ControlService(service, SERVICE_CONTROL_STOP, &status);
|
||||
if (!res) {
|
||||
ErrorHandler("ControlService", GetLastError());
|
||||
}
|
||||
Sleep(5000);
|
||||
}
|
||||
|
||||
res = DeleteService(service);
|
||||
if (res) {
|
||||
printf("Service Uninstalled\n");
|
||||
} else {
|
||||
ErrorHandler("DeleteService", GetLastError());
|
||||
}
|
||||
|
||||
CloseServiceHandle(service);
|
||||
CloseServiceHandle(scm);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ServiceRun()
|
||||
{
|
||||
SC_HANDLE scm, Service;
|
||||
SERVICE_STATUS ssStatus;
|
||||
DWORD dwOldCheckPoint;
|
||||
DWORD dwStartTickCount;
|
||||
DWORD dwWaitTime;
|
||||
DWORD dwStatus;
|
||||
|
||||
scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (!scm) {
|
||||
ErrorHandler("OpenSCManager", GetLastError());
|
||||
}
|
||||
|
||||
Service = OpenService(scm, ServiceName, SERVICE_ALL_ACCESS);
|
||||
if (!Service) {
|
||||
ErrorHandler("OpenService", GetLastError());
|
||||
return FALSE;
|
||||
} else {
|
||||
StartService(Service, 0, NULL);
|
||||
srvc.GetStatus(Service);
|
||||
|
||||
if (!QueryServiceStatus( Service, &ssStatus) ) {
|
||||
ErrorHandler("QueryServiceStatus", GetLastError());
|
||||
}
|
||||
dwStartTickCount = GetTickCount();
|
||||
dwOldCheckPoint = ssStatus.dwCheckPoint;
|
||||
|
||||
while (ssStatus.dwCurrentState == SERVICE_START_PENDING) {
|
||||
dwWaitTime = ssStatus.dwWaitHint / 10;
|
||||
|
||||
if( dwWaitTime < 1000 ) {
|
||||
dwWaitTime = 1000;
|
||||
} else if ( dwWaitTime > 10000 ) {
|
||||
dwWaitTime = 10000;
|
||||
}
|
||||
|
||||
Sleep( dwWaitTime );
|
||||
|
||||
if (!QueryServiceStatus(Service, &ssStatus) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ssStatus.dwCheckPoint > dwOldCheckPoint ) {
|
||||
dwStartTickCount = GetTickCount();
|
||||
dwOldCheckPoint = ssStatus.dwCheckPoint;
|
||||
} else {
|
||||
if(GetTickCount()-dwStartTickCount > ssStatus.dwWaitHint) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ssStatus.dwCurrentState == SERVICE_RUNNING) {
|
||||
srvc.GetStatus(Service);
|
||||
dwStatus = NO_ERROR;
|
||||
} else {
|
||||
|
||||
printf("\nService not started.\n");
|
||||
printf(" Current State: %d\n", ssStatus.dwCurrentState);
|
||||
printf(" Exit Code: %d\n", ssStatus.dwWin32ExitCode);
|
||||
printf(" Service Specific Exit Code: %d\n", ssStatus.dwServiceSpecificExitCode);
|
||||
printf(" Check Point: %d\n", ssStatus.dwCheckPoint);
|
||||
printf(" Wait Hint: %d\n", ssStatus.dwWaitHint);
|
||||
dwStatus = GetLastError();
|
||||
}
|
||||
}
|
||||
|
||||
CloseServiceHandle(scm);
|
||||
CloseServiceHandle(Service);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ServiceControl(int ctrl)
|
||||
{
|
||||
SC_HANDLE service;
|
||||
SC_HANDLE scm;
|
||||
BOOL res;
|
||||
SERVICE_STATUS status;
|
||||
|
||||
scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (!scm) {
|
||||
ErrorHandler("OpenSCManager", GetLastError());
|
||||
}
|
||||
|
||||
service = OpenService(scm, ServiceName, SERVICE_ALL_ACCESS);
|
||||
if (!service) {
|
||||
ErrorHandler("OpenService", GetLastError());
|
||||
}
|
||||
|
||||
if (ctrl == SERVICE_CONTROL_STOP) {
|
||||
printf("Service is stopping...\n");
|
||||
res = ControlService(service, SERVICE_CONTROL_STOP, &status);
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
ErrorHandler("ControlService", GetLastError());
|
||||
} else {
|
||||
srvc.GetStatus(service);
|
||||
}
|
||||
|
||||
CloseServiceHandle(service);
|
||||
CloseServiceHandle(scm);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL GetConfiguration()
|
||||
{
|
||||
SC_HANDLE service;
|
||||
SC_HANDLE scm;
|
||||
BOOL res;
|
||||
LPQUERY_SERVICE_CONFIG buffer;
|
||||
DWORD sizeNeeded;
|
||||
|
||||
scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (!scm) {
|
||||
ErrorHandler("OpenSCManager", GetLastError());
|
||||
}
|
||||
|
||||
service = OpenService(scm, ServiceName, SERVICE_QUERY_CONFIG);
|
||||
if (!service) {
|
||||
ErrorHandler("OpenService", GetLastError());
|
||||
}
|
||||
|
||||
buffer = (LPQUERY_SERVICE_CONFIG)LocalAlloc(LPTR, 4096);
|
||||
res = QueryServiceConfig(service, buffer, 4096, &sizeNeeded);
|
||||
if (!res) {
|
||||
ErrorHandler("QueryServiceConfig", GetLastError());
|
||||
}
|
||||
|
||||
printf("Service name:\t%s\n", buffer->lpDisplayName);
|
||||
printf("Service type:\t%d\n", buffer->dwServiceType);
|
||||
printf("Start type:\t%d\n",buffer->dwStartType);
|
||||
printf("Start name:\t%s\n",buffer->lpServiceStartName);
|
||||
printf("Path:\t\t%s\n",buffer->lpBinaryPathName);
|
||||
|
||||
LocalFree(buffer);
|
||||
|
||||
CloseServiceHandle(service);
|
||||
CloseServiceHandle(scm);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL ChangeConfig()
|
||||
{
|
||||
SC_HANDLE service;
|
||||
SC_HANDLE scm;
|
||||
BOOL res;
|
||||
SC_LOCK lock;
|
||||
|
||||
scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS | GENERIC_WRITE);
|
||||
if (!scm) {
|
||||
ErrorHandler("OpenSCManager", GetLastError());
|
||||
}
|
||||
lock = LockServiceDatabase(scm);
|
||||
if (lock == 0) {
|
||||
ErrorHandler("LockServiceDatabase", GetLastError());
|
||||
}
|
||||
service = OpenService(scm, ServiceName, SERVICE_ALL_ACCESS);
|
||||
if (!service) {
|
||||
ErrorHandler("OpenService", GetLastError());
|
||||
}
|
||||
res = ChangeServiceConfig(
|
||||
service,
|
||||
SERVICE_NO_CHANGE,
|
||||
SERVICE_NO_CHANGE,
|
||||
SERVICE_NO_CHANGE,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
if (!res) {
|
||||
UnlockServiceDatabase(lock);
|
||||
ErrorHandler("ChangeServiceConfig", GetLastError());
|
||||
}
|
||||
|
||||
res = UnlockServiceDatabase(lock);
|
||||
if (!res) {
|
||||
ErrorHandler("UnlockServiceDatabase", GetLastError());
|
||||
}
|
||||
CloseServiceHandle(service);
|
||||
CloseServiceHandle(scm);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
BOOL InstallService();
|
||||
BOOL UninstallService();
|
||||
BOOL GetConfiguration();
|
||||
BOOL ChangeConfig();
|
||||
BOOL ServiceRun();
|
||||
BOOL ServiceControl(int ctrl);
|
||||
|
||||
void ShowUsage();
|
||||
void ErrorHandler(char *s, int err);
|
||||
void PrintMessage(char *s);
|
||||
|
||||
#endif
|
||||
+2
-22
@@ -1,11 +1,9 @@
|
||||
@echo off
|
||||
|
||||
set SYS_FILE_NAME=balloon
|
||||
set APP_FILE_NAME=blnsvr
|
||||
|
||||
for %%A in (Win7 Wnet Wlh WXp Win8) do for %%B in (32 64) do call :%%A_%%B
|
||||
set SYS_FILE_NAME=
|
||||
set APP_FILE_NAME=
|
||||
goto :eof
|
||||
|
||||
:buildsys
|
||||
@@ -14,29 +12,15 @@ call buildOne.bat %1 %2
|
||||
cd ..
|
||||
goto :eof
|
||||
|
||||
:buildapp
|
||||
cd app
|
||||
call buildOne.bat %1 %2
|
||||
cd ..
|
||||
goto :eof
|
||||
|
||||
:packsys
|
||||
cd sys
|
||||
call packOne.bat %1 %2 %SYS_FILE_NAME%
|
||||
cd ..
|
||||
goto :eof
|
||||
|
||||
:packapp
|
||||
cd app
|
||||
call packOne.bat %1 %2 %APP_FILE_NAME%
|
||||
cd ..
|
||||
goto :eof
|
||||
|
||||
:buildpack
|
||||
call :buildsys %1 %2
|
||||
call :buildapp %1 %2
|
||||
call :packsys %1 %2
|
||||
call :packapp %1 %2
|
||||
set BUILD_OS=
|
||||
set BUILD_ARC=
|
||||
goto :eof
|
||||
@@ -104,9 +88,7 @@ goto :eof
|
||||
setlocal
|
||||
set BUILD_OS=Win8
|
||||
set BUILD_ARC=x86
|
||||
call :buildsys %BUILD_OS% %BUILD_ARC%
|
||||
call :packsys %BUILD_OS% %BUILD_ARC%
|
||||
copy /y Install\Win7\x86\%APP_FILE_NAME%.* Install\Win8\x86
|
||||
call :buildpack %BUILD_OS% %BUILD_ARC%
|
||||
endlocal
|
||||
rem pause
|
||||
goto :eof
|
||||
@@ -115,9 +97,7 @@ goto :eof
|
||||
setlocal
|
||||
set BUILD_OS=Win8
|
||||
set BUILD_ARC=x64
|
||||
call :buildsys %BUILD_OS% %BUILD_ARC%
|
||||
call :packsys %BUILD_OS% %BUILD_ARC%
|
||||
copy /y Install\Win7\amd64\%APP_FILE_NAME%.* Install\Win8\amd64
|
||||
call :buildpack %BUILD_OS% %BUILD_ARC%
|
||||
endlocal
|
||||
rem pause
|
||||
goto :eof
|
||||
@@ -4,10 +4,6 @@ rmdir /S /Q Install
|
||||
|
||||
del /F *.log *.wrn *.err
|
||||
|
||||
cd app
|
||||
call cleanAll.bat
|
||||
cd ..
|
||||
|
||||
cd sys
|
||||
call cleanAll.bat
|
||||
cd ..
|
||||
|
||||
+1
-2
@@ -1,3 +1,2 @@
|
||||
DIRS= \
|
||||
sys \
|
||||
app
|
||||
sys
|
||||
Reference in new issue
Block a user