本文整理汇总了Python中winappdbg.System.get_service_display_name方法的典型用法代码示例。如果您正苦于以下问题:Python System.get_service_display_name方法的具体用法?Python System.get_service_display_name怎么用?Python System.get_service_display_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类winappdbg.System
的用法示例。
在下文中一共展示了System.get_service_display_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copypasta
# 需要导入模块: from winappdbg import System [as 别名]
# 或者: from winappdbg.System import get_service_display_name [as 别名]
def copypasta(action, params, wait_state, doing_verb, done_verb):
'common code in a lot of methods here :)'
try:
target = params[0]
# Do the requested action.
status = System.get_service(target)
try:
name = System.get_service_display_name(target)
except WindowsError:
name = target
print "%s service \"%s\"..." % (doing_verb, name)
action(*params)
# Wait for it to finish.
timeout = 20
status = System.get_service(target)
while status.CurrentState == wait_state:
timeout -= 1
if timeout <= 0:
print "Error: timed out."
return
time.sleep(0.5)
status = System.get_service(target)
# Done.
print "Service %s successfully." % done_verb
# On error show a message and quit.
except WindowsError, e:
print str(e)
return
示例2: restart_service
# 需要导入模块: from winappdbg import System [as 别名]
# 或者: from winappdbg.System import get_service_display_name [as 别名]
def restart_service( service ):
try:
# Get the display name.
try:
display_name = System.get_service_display_name( service )
except WindowsError:
display_name = service
# Get the service descriptor.
descriptor = System.get_service( service )
# Is the service running?
if descriptor.CurrentState != win32.SERVICE_STOPPED:
# Tell the service to stop.
print "Stopping service \"%s\"..." % display_name
System.stop_service( service )
# Wait for the service to stop.
wait_for_service( service, win32.SERVICE_STOP_PENDING )
print "Service stopped successfully."
# Tell the service to start.
print "Starting service \"%s\"..." % display_name
System.start_service( service )
# Wait for the service to start.
wait_for_service( service, win32.SERVICE_START_PENDING )
print "Service started successfully."
# Show the new process ID.
# This feature requires Windows XP and above.
descriptor = System.get_service( service )
try:
print "New process ID is: %d" % descriptor.ProcessId
except AttributeError:
pass
# On error, show an error message.
except WindowsError, e:
if e.winerror == win32.ERROR_ACCESS_DENIED:
print "Access denied! Is this an UAC elevated prompt?"
else:
print str(e)