diff --git a/config/SYS.CFG b/config/SYS.CFG index 2f755d1..556e818 100644 --- a/config/SYS.CFG +++ b/config/SYS.CFG @@ -1 +1 @@ -version = "6.5.18" \ No newline at end of file +version = "6.5.19" \ No newline at end of file diff --git a/config/lang/lib.txt b/config/lang/lib.txt index 93ab42e..743f92c 100644 --- a/config/lang/lib.txt +++ b/config/lang/lib.txt @@ -75,4 +75,5 @@ unqlite = unqlite chm = chm ������ icmp = icmp ����Э�� newLisp = newLisp ���� -wps = wps �칫���� \ No newline at end of file +wps = wps �칫���� +service = service ������� \ No newline at end of file diff --git a/example/HTMLayout/tint.aau b/example/HTMLayout/tint.aau index 1dda643..ff20108 100644 --- a/example/HTMLayout/tint.aau +++ b/example/HTMLayout/tint.aau @@ -1,11 +1,12 @@ //tint ����ת������ import win.ui; /*DSG{{*/ -var winform = ..win.form(text="HTMLayout tint����ת������";right=599;bottom=399;parent=...) +var winform = ..win.form(text="HTMLayout tint����ת������";right=599;bottom=399;border="dialog frame";max=false;parent=...) winform.add( -btnTint={cls="button";text="����";left=309;top=43;right=376;bottom=70;z=2}; +btnTint={cls="button";text="����";left=309;top=43;right=389;bottom=70;z=2}; edit={cls="edit";text="tint(#FF0000,-0.5, 0.9)";left=30;top=43;right=306;bottom=67;edge=1;multiline=1;z=1}; -editResult={cls="edit";left=30;top=78;right=306;bottom=101;edge=1;multiline=1;z=3} +editResult={cls="edit";left=30;top=78;right=306;bottom=101;edge=1;multiline=1;z=3}; +static={cls="edit";text="tint( ��ɫ,����,���Ͷ�) ���Ȼ򱥺Ͷȵ�ȡֵ��ΧΪ-1.0��+1.0 ֮���ʾ�ٷֱȵ�С��";left=31;top=15;right=540;bottom=37;bgcolor=16777215;readonly=1;z=4} ) /*}}*/ diff --git a/lib/preload/_.aau b/lib/preload/_.aau index 5f2a3c7..98ba04d 100644 --- a/lib/preload/_.aau +++ b/lib/preload/_.aau @@ -107,9 +107,13 @@ namespace string { concatUnicode = function(a,b,...){ a = toUnicode(a); b = toUnicode(b); - if( #a > 2 ) c = left(a,-3) ++ b; - else c = b; - if(!...) return c; + + var c = a; + if( #a > 2 && #b > 2 ) c = left(a,-3) ++ b; + elseif( #b > 2 ) c = b; + + a,b = ... + if( (a === null) && (b === null) ) return c; return concatUnicode(c,...); } } diff --git a/lib/process/admin.aau b/lib/process/admin.aau index 73c760d..6683359 100644 --- a/lib/process/admin.aau +++ b/lib/process/admin.aau @@ -7,6 +7,11 @@ namespace process.admin; OpenProcessToken = ::Advapi32.api( "OpenProcessToken", "pointer(POINTER ProcessHandle,INT DesiredAccess,pointer &TokenHandle)"); GetTokenInformation = ::Advapi32.api( "GetTokenInformation", "int(POINTER TokenHandle,int infoClass,struct &TokenInfo,INT len,INT &retLen)"); +isLeastPrivileges = function(hProcess){ + var admin,xpVersion = isRunAs(hProcess); + return !(xpVersion || admin) +} + isRunAs = function(hProcess) { if(!hProcess){ hProcess = ..process.getHandle(); @@ -89,6 +94,7 @@ runas_leastPrivileges = function(path,arguments,workdir,taskName){ } /**intellisense(process.admin) +isLeastPrivileges() = �����Ƿ�������VISTA�Ժ��ϵͳ�����޹���Ȩ��\n��ѡ�ڲ�����ָ�����̾��,��ָ����Ĭ��ȡ��ǰ����Ȩ�� isRunAs(.(���̾��) = �жϽ����Ƿ��Թ���Ȩ������,\n�ɹ�����true,XP����flase,�Լ�majorVersion�汾��,\n������ѡ,Ĭ��Ϊ��ǰ��� runas(.(ִ�г���·��,��������,������ʾ��ʽ,����Ŀ¼,���ھ��,�ȴ�ѡ��) = ����Ӧ�ó���,\n�����vista�Ժ�ϵͳ�������Ȩ��,\nʡ�Բ���@1��Ĭ��ָ��Ϊ��ǰEXE·��,����������ѡ runas_wait(.(ִ�г���·��,��������,������ʾ��ʽ,����Ŀ¼,���ھ��) = ����Ӧ�ó���,���ȴ����̽���,\n�����vista�Ժ�ϵͳ�������Ȩ��,,\nʡ�Բ���@1��Ĭ��ָ��Ϊ��ǰEXE·��,����������ѡ diff --git a/lib/service/_.aau b/lib/service/_.aau new file mode 100644 index 0000000..14acb66 --- /dev/null +++ b/lib/service/_.aau @@ -0,0 +1,562 @@ +namespace service; + +::Advapi32 := ..raw.loadDll("Advapi32.dll"); + +class manager{ + ctor(desiredAccess,machineName,databaseName){ + this.handle = ::Advapi32.OpenSCManager(machineName,databaseName,desiredAccess:1/*_SC_MANAGER_CONNECT*/); + ..table.add_gc(this, "close"); + }; + create = function(binaryPathName,serviceName,displayName,desiredAccess,serviceType,startType,errorControl,loadOrderGroup,tagId,dependencies,serviceStartName,password){ + if(!this.handle) return ; + if( type(binaryPathName) != type.string || !#serviceName ) error("��ָ��������������,����@1����",2); + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������,����@2����",2); + if( desiredAccess === null ) desiredAccess = 0x10/*_SERVICE_START*/; + if( serviceType === null ) serviceType = 0x10/*_SERVICE_WIN32_OWN_PROCESS*/; + if( startType === null ) startType = 0x2/*_SERVICE_AUTO_START*/; + if( errorControl === null ) errorControl = 0x0/*_SERVICE_ERROR_IGNORE*/; + if( displayName === null ) displayName = serviceName; + + + var hService = ::Advapi32.CreateService(this.handle,serviceName,displayName,desiredAccess,serviceType,startType,errorControl,binaryPathName,loadOrderGroup,tagId,dependencies,serviceStartName,password); + if( hService ){ + var ret = ::Advapi32.StartService(hService,0,null); + ::Advapi32.CloseServiceHandle(hService); + return !!ret; + } + }; + open = function(serviceName,desiredAccess){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + if( desiredAccess === null ) desiredAccess = 0x4/*_SERVICE_QUERY_STATUS*/ + return ::Advapi32.OpenService(this.handle, serviceName, desiredAccess ); + }; + start =function(serviceName,...){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var hService = this.open(serviceName, 0x10/*_SERVICE_START*/) + if (hService) { + var args; + var len = 0; + if(...){ + args = { string v[] = {serviceName;...} }; + len = #args.v; + } + var ret = ::Advapi32.StartService(hService,len,args); + ::Advapi32.CloseServiceHandle(hService); + return !!ret; + } + }; + control = function(serviceName,desiredAccess,control,reason,comment){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var hService = this.open(serviceName, desiredAccess) + if (hService) { + /** + var statusReason = { + INT reason = 0x20000000; + string comment ; + struct serviceStatus = SERVICE_STATUS_PROCESS(); + } + var ret = ::Advapi32.ControlServiceEx(hService,1,1/*SERVICE_CONTROL_STATUS_REASON_INFO*/,statusReason); + **/ + var status = SERVICE_STATUS(); + var ret = ::Advapi32.ControlService(hService,control,status) + + + ::Advapi32.CloseServiceHandle(hService); + return !!ret,status; + } + }; + stop = function(serviceName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + return this.control(serviceName, 0x20/*_SERVICE_STOP*/,0x1/*_SERVICE_CONTROL_STOP*/); + }; + pause = function(serviceName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + return this.control(serviceName, 0x40/*_SERVICE_PAUSE_CONTINUE*/,0x2/*_SERVICE_CONTROL_PAUSE*/); + }; + resume = function(serviceName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + return this.control(serviceName, 0x40/*_SERVICE_PAUSE_CONTINUE*/,0x3/*_SERVICE_CONTROL_CONTINUE*/); + }; + delete = function(serviceName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + this.stop(serviceName); + + var hService = this.open(serviceName, 0x10000/*_DELETE*/ ) + if (hService) { + var ret = ::Advapi32.DeleteService(hService); + ::Advapi32.CloseServiceHandle(hService); + return ret; + } + }; + isExist = function(serviceName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var hService = this.open(serviceName, 0x4/*_SERVICE_QUERY_STATUS*/) + if (hService) { + ::Advapi32.CloseServiceHandle(hService); + return true; + } + }; + queryStatus = function(serviceName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var hService = this.open(serviceName, 0x4/*_SERVICE_QUERY_STATUS*/) + if (hService) { + var status = SERVICE_STATUS_PROCESS(); + var cbBytesNeeded = {INT value}; + if( ! ::Advapi32.QueryServiceStatusEx(hService, 0/*_SC_STATUS_PROCESS_INFO*/, status,..raw.sizeof(status),cbBytesNeeded) ){ + status = null; + } + else { + status.state = STATE_TEXT[status.currentState]; + } + + ::Advapi32.CloseServiceHandle(hService); + return status; + } + }; + changeDescription = function(serviceName,desc){ + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + return this.changeConfig2(serviceName,0x1/*_SERVICE_CONFIG_DESCRIPTION*/,{string value=desc}); + }; + queryDescription = function(serviceName){ + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var out = {string value=desc}; + if( this.queryConfig2(serviceName,0x1/*_SERVICE_CONFIG_DESCRIPTION*/,out) ) + return out.value; + }; + queryBinaryPathName = function(serviceName){ + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var cfg = this.queryConfig(serviceName) + if( cfg ) return cfg.binaryPathName; + }; + changeConfig = function(serviceName,serviceType,startType,errorControl,binaryPathName,loadOrderGroup,tagId,dependencies,serviceStartName,password,displayName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + if( startType === null ) startType = 0x2/*_SERVICE_AUTO_START*/ + if( serviceType === null ) serviceType = 0xFFFFFFFF/*_SERVICE_NO_CHANGE_INT*/ + if( errorControl === null ) errorControl = 0xFFFFFFFF/*_SERVICE_NO_CHANGE_INT*/ + + var hService = this.open(serviceName,0x2/*_SERVICE_CHANGE_CONFIG*/ ) + if (hService) { + tagId = { INT value = tagId }; + var ret = ::Advapi32.ChangeServiceConfig(serviceName,serviceType,startType,errorControl,binaryPathName,loadOrderGroup,tagId,dependencies,serviceStartName,password,displayName); + ::Advapi32.CloseServiceHandle(hService); + return ret; + } + }; + changeConfig2 = function(serviceName,infoLevel,struct){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + if( !struct[["_struct"]] ) error("����@3�����ǽṹ��",2) + var hService = this.open(serviceName, 0x1/*_SERVICE_QUERY_CONFIG*/) + if (hService) { + var ret = ::Advapi32.ChangeServiceConfig2(hService,infoLevel,struc); + ::Advapi32.CloseServiceHandle(hService); + return ret; + } + } + queryConfig2 = function(serviceName,infoLevel,struct){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + if( !struct[["_struct"]] ) error("����@3�����ǽṹ��",2) + var hService = this.open(serviceName, 0x1/*_SERVICE_QUERY_CONFIG*/) + if (hService) { + var needSize = {INT size}; + ::Advapi32.QueryServiceConfig2(hService,infoLevel,null,0,needSize); + var buffer = ..raw.malloc(needSize.size); + var ret = ::Advapi32.QueryServiceConfig2(hService,infoLevel,buffer,#buffer,needSize);; + ::Advapi32.CloseServiceHandle(hService); + if( ret ){ + ..raw.convert(buffer,struct) + } + return ret; + } + } + queryConfig = function(serviceName){ + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var hService = this.open(serviceName, 0x1/*_SERVICE_QUERY_CONFIG*/) + if (hService) { + var cfg; + var cbBytesNeeded = {INT value}; + ::Advapi32.QueryServiceConfig(hService,null,0,cbBytesNeeded) + if( ::GetLastError() != 0x7A/*_ERROR_INSUFFICIENT_BUFFER*/) return; + + var buf = ..raw.malloc(cbBytesNeeded.value); + if( ::Advapi32.QueryServiceConfig(hService,buf,cbBytesNeeded.value,cbBytesNeeded) ){ + cfg = ..raw.convert(buf,QUERY_SERVICE_CONFIG());; + } + + ::Advapi32.CloseServiceHandle(hService); + return cfg; + } + }; + each = function(serviceType,serviceState,groupName){ + if( serviceType === null ) serviceType = 0x30/*_SERVICE_WIN32*/; + if( serviceState === null )serviceState = 0x3/*_SERVICE_STATE_ALL*/; + + if(!this.handle) return ; + + var cbBytesNeeded = {INT size}; + var servicesReturned = {INT size}; + var resumeHandle = {INT handle}; + + var ok = ::Advapi32.EnumServicesStatusEx(this.handle,0/*_SC_ENUM_PROCESS_INFO*/,serviceType,serviceState,null,0,cbBytesNeeded,servicesReturned,resumeHandle,groupName); + if( ok || ( ::GetLastError() != 0xEA/*_ERROR_MORE_DATA*/) ){ return function(){} }; + + var buffer = ..raw.malloc(cbBytesNeeded.size); + var ok = ::Advapi32.EnumServicesStatusEx(this.handle,0/*_SC_ENUM_PROCESS_INFO*/,serviceType,serviceState,buffer,cbBytesNeeded.size,cbBytesNeeded,servicesReturned,resumeHandle,groupName); + if( !ok ){ + return function(){ + + } + } + + var offset = 0; + var count = servicesReturned.size; + var info = { + string serviceName; + string displayName; + struct svrStatusProcess = SERVICE_STATUS_PROCESS(); + } + var infoSize = ..raw.sizeof(info); + + return function(){ + if( !count ) return; + ..raw.convert(buffer,info,offset); + offset = offset + infoSize; + count--; + + info.svrStatusProcess.state = STATE_TEXT[info.svrStatusProcess.currentState]; + return info.serviceName,info.displayName,info.svrStatusProcess; + } + }; + eachDependent = function(serviceName,serviceState){ + if( serviceState === null )serviceState = 0x3/*_SERVICE_STATE_ALL*/; + + if(!this.handle) return ; + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������",2); + var hService = this.open(serviceName, 0x8/*_SERVICE_ENUMERATE_DEPENDENTS*/) + if (!hService) return; + + var cbBytesNeeded = {INT size}; + var servicesReturned = {INT size}; + var ok = ::Advapi32.EnumDependentServices(hService,serviceState,null,0,cbBytesNeeded,servicesReturned); + if( ok || ( ::GetLastError() != 0xEA/*_ERROR_MORE_DATA*/) ){ ::Advapi32.CloseServiceHandle(hService);return function(){} }; + + var buffer = ..raw.malloc(cbBytesNeeded.size); + var ok = ::Advapi32.EnumDependentServices(hService,serviceState,buffer,cbBytesNeeded.size,cbBytesNeeded,servicesReturned); + if( !ok ){ ::Advapi32.CloseServiceHandle(hService); return function(){} }; + + var offset = 0; + var count = servicesReturned.size; + var info = { + string serviceName; + string displayName; + struct serviceStatus = SERVICE_STATUS(); + } + var infoSize = ..raw.sizeof(info); + + return function(){ + if( !count ) return; + ..raw.convert(buffer,info,offset); + offset = offset + infoSize; + count--; + + info.serviceStatus.state = STATE_TEXT[info.serviceStatus.currentState]; + return info.serviceName,info.displayName,info.serviceStatus; + },function(){ + ::Advapi32.CloseServiceHandle(hService); + } + + }; + close = function(){ + if( this.handle ){ + ::Advapi32.CloseServiceHandle(this.handle); + this.handle = null; + } + } +} + +namespace manager { + + class QUERY_SERVICE_CONFIG { + INT serviceType; + INT startType; + INT errorControl; + string binaryPathName; + string loadOrderGroup; + INT tagId; + string dependencies; + string serviceStartName; + string displayName; + } + + class SERVICE_STATUS_PROCESS { + INT serviceType; + INT currentState; + INT controlsAccepted; + INT win32ExitCode; + INT serviceSpecificExitCode; + INT checkPoint; + INT waitHint; + INT processId; + INT serviceFlags; + } + + class SERVICE_STATUS { + INT serviceType; + INT currentState; + INT controlsAccepted; + INT win32ExitCode; + INT serviceSpecificExitCode; + INT checkPoint; + INT waitHint; + } + + + STATE_TEXT = { + [5] = "CONTINUE_PENDING"; + [6] = "PAUSE_PENDING"; + [7] = "PAUSED"; + [4] = "RUNNING"; + [2] = "START_PENDING"; + [3] = "STOP_PENDING"; + [1] = "STOPPED"; + } +} + +isExist = function(serviceName){ + var srvMgr = manager(); + var ret = srvMgr.isExist( serviceName ); + srvMgr.close(); + return ret; +} + +start = function(serviceName){ + var srvMgr = manager(); + var ret = srvMgr.start( serviceName ); + srvMgr.close(); + return ret; +} + +pause = function(serviceName){ + var srvMgr = manager(); + var ret = srvMgr.pause( serviceName ); + srvMgr.close(); + return ret; +} + +resume = function(serviceName){ + var srvMgr = manager(); + var ret = srvMgr.resume( serviceName ); + srvMgr.close(); + return ret; +} + +stop = function(serviceName){ + var srvMgr = manager(); + var ret = srvMgr.stop( serviceName ); + srvMgr.close(); + return ret; +} + +delete = function(serviceName){ + var srvMgr = manager(); + var ret = srvMgr.delete( serviceName ); + srvMgr.close(); + return ret; +} + +create = function(binaryPathName,serviceName,displayName,description,...){ + if( binaryPathName === null ) binaryPathName = ..io._exepath; + if( type(binaryPathName) != type.string || !#binaryPathName ) error("��ָ��������������,����@1����",2); + if( type(serviceName) != type.string || !#serviceName ) error("��ָ��������,����@2����",2); + + var srvMgr = manager(0x2/*_SC_MANAGER_CREATE_SERVICE*/); + var ret = srvMgr.create( binaryPathName,serviceName,displayName,...); + if( ret ){ + srvMgr.changeDescription(serviceName,description) + } + srvMgr.close(); + return ret; +} + +each = function(serviceType,serviceState,groupName){ + var serviceMgr = manager(0x4/*_SC_MANAGER_ENUMERATE_SERVICE*/); + return serviceMgr.each(serviceType,serviceState,groupName),function(){ + serviceMgr.close(); + } +} + +_serveiceTableEntry = {}; +//����û�н���ǰ�˺������᷵��,ע�����ں������������Ժ�Ӧ�����ȵ���registerServiceCtrlHandler +startDispatchThread = function( disp ){ + for(serviceName,serviceProc in disp){ + ..table.push( _serveiceTableEntry,{string serviceName = serviceName; pointer lpServiceProc = ..thread.tostdcall( + function(argc,argv){ + import service; + service.CURRENT_SERVICE_NAME = serviceName; + + if( argc ){ + argv = ..raw.convertArray(argv,argc,"string") + } + + serviceProc = loadcode(owner.serviceProc) + return serviceProc(owner.serviceName,argv); + },"void(int,pointer)",{serviceProc = dumpcode(serviceProc);serviceName=serviceName}) } ); + } + ..table.push( _serveiceTableEntry ,{string serviceName;pointer lpServiceProc} ); + ::Advapi32.StartServiceCtrlDispatcher( { struct entry[] = _serveiceTableEntry } ); +} + +_serveiceCtrlHandler = {}; +registerCtrlThread = function( serviceName,handler ){ + if( type(serviceName) != type.string || !#serviceName) error("��ָ��������,����@1����",2); + _serveiceCtrlHandler[serviceName] = ..thread.tostdcall(handler,"int(int,int,ptr,ptr)",{serviceName=serviceName}); + + var hServiceStatus = ::Advapi32.RegisterServiceCtrlHandlerEx( serviceName,_serveiceCtrlHandler[serviceName],null); + if(hServiceStatus){ + var status = manager.SERVICE_STATUS(); + status.serviceType = 0x30/*_SERVICE_WIN32*/ + status.currentState = 0x2/*_SERVICE_START_PENDING*/ + status.controlsAccepted = 0x1/*_SERVICE_ACCEPT_STOP*/ + status.hServiceStatus = hServiceStatus; + status.threadId = ..thread.getId(); + ..thread.set("NT_SERVICE_STATUS(" + serviceName + ")", ) + + return status; + } +} + +updateStatus = function(status,serviceName){ + if( type(serviceName) != type.string || !#serviceName) error("��ָ��������,����@1����",2); + if( status.threadId == ..thread.getId() && status._struct ){ + ..thread.set("NT_SERVICE_STATUS(" + serviceName + ")", status ) + } + else { + status = ..table.mixin( ..thread.get("NT_SERVICE_STATUS(" + serviceName + ")"),status); + } + + return ::Advapi32.SetServiceStatus( status.hServiceStatus,status); +} + + +/**intellisense() +service = NT�������\n���ݲ�����Ҫ����Ȩ�� +service.isExist(.("������") = �Ƿ����ָ���ķ��� +service.start(.("������") = ��������,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +service.stop(.("������") = ֹͣ����,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +service.pause(.("������") = ��ͣ����,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +service.resume(.("������") = ��ͣ״̬�ָ�����,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +service.create(.(����·��,������,��ʾȫ��,��������) = ��������,\n����@1��Ϊ��,Ĭ��ʹ�õ�ǰӦ�ó���·��,\n������ѡ����δ�г���鿴����Դ�� +service.delete(.("������") = ɾ������ +service.manager(.(desiredAccess,machineName,databaseName) = ���������� +service.manager() = !ntsrvmgr. +!ntsrvmgr.create(.(����·��,������,��ʾȫ��) = ��������,������ѡ����δ�г���鿴����Դ�� +!ntsrvmgr.open(serviceName,desiredAccess) = �򿪷����� +!ntsrvmgr.close() = �ر� +!ntsrvmgr.isExist(.("������") = �Ƿ����ָ���ķ��� +!ntsrvmgr.start(.("������") = ��������,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +!ntsrvmgr.stop(.("������") = ֹͣ����,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +!ntsrvmgr.pause(.("������") = ��ͣ����,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +!ntsrvmgr.resume(.("������") = ��ͣ״̬�ָ�����,\n�ɹ�����true,\nʧ����ʹ��lasterr������ȡ������Ϣ +!ntsrvmgr.delete(.("������") = ɾ������ +!ntsrvmgr.control(.(serviceName,desiredAccess,control) = ���Ʒ��� +!ntsrvmgr.queryStatus(.("������") = ����״̬ +!ntsrvmgr.queryConfig(.("������") = �������� +!ntsrvmgr.changeDescription(.("������","˵��") = �޸ķ���˵�� +!ntsrvmgr.queryDescription(.("������") = ���ط���˵�� +!ntsrvmgr.queryBinaryPathName(.("������") = ��������·���Լ����� +!ntsrvmgr.changeConfig(.(serviceName,serviceType,startType) = �޸�����,������ѡ����δ�г���鿴����Դ�� +!ntsrvmgr.queryConfig2(.("������",������,����ֵ) = ��ȡ����\n����ֵ�����ǽṹ�� +!ntsrvmgr.changeConfig2(.("������",������,����ֵ) = �޸�����\n����ֵ�����ǽṹ�� +!ntsrvmgr.eachDependent() = !ntsrvsta2. +!ntsrvmgr.eachDependent("������") = @for(serviceName,displayName,serviceStatus in ??.eachDependent("__/*ָ���������г������˷���ķ���*/") ){ + +} +service.each(serviceType,serviceState,groupName) = @for( serviceName,displayName,svrStatusProcess in service.each()){ + io.print(serviceName, displayName,svrStatusProcess.state) +} +service.updateStatus(.(����״̬��,������) = ����@1Ӧ��registerCtrlHandler�����ķ���ֵ,\n��CtrlHandler������ָ��������Ҫ���µ�ֵ���� +service.startDispatchThread(����ص�������) = @.service.startDispatchThread( \n ������ = function(serviceName,argv){\n import service; \n var srvStatus = service.registerCtrlThread(serviceName,function(control,eventType,pEventData){ \n import service; \n if( control == 0x1/*_SERVICE_CONTROL_STOP*/ ){ \n service.updateStatus({currentState = 0x1/*_SERVICE_STOPPED*/},owner.serviceName); \n } \n } )\n \n srvStatus.controlsAccepted = 0x1/*_SERVICE_ACCEPT_STOP*/\n srvStatus.currentState = 0x4/*_SERVICE_RUNNING*/;\n service.updateStatus(srvStatus,serviceName)\n \n __/*�������д���*/\n \n srvStatus.controlsAccepted = 0;\n srvStatus.currentState = 0x1/*_SERVICE_STOPPED*/\n service.updateStatus(srvStatus,serviceName)\n }\n) +service.registerCtrlThread(serviceName,handle) = @.registerCtrlThread( serviceName,function(control,eventType,pEventData){\n \n }\n) +service.registerCtrlThread() = !ntsrvsta2. +service.each() = !ntsrvsta2. +!ntsrvmgr.queryStatus() = !ntsrvsta2. +!ntsrvsta2.serviceType = serviceType +!ntsrvsta2.currentState = currentState +!ntsrvsta2.state = state +!ntsrvsta2.controlsAccepted = controlsAccepted +!ntsrvsta2.win32ExitCode = win32ExitCode +!ntsrvsta2.serviceSpecificExitCode = serviceSpecificExitCode +!ntsrvsta2.checkPoint = checkPoint +!ntsrvsta2.waitHint = waitHint +!ntsrvsta2.processId = processId +!ntsrvsta2.serviceFlags = processId +!ntsrvmgr.queryConfig() = !ntsrvconfig. +!ntsrvconfig.serviceType = serviceType +!ntsrvconfig.startType = startType +!ntsrvconfig.errorControl = errorControl +!ntsrvconfig.binaryPathName = binaryPathName +!ntsrvconfig.loadOrderGroup = loadOrderGroup +!ntsrvconfig.tagId = tagId +!ntsrvconfig.dependencies = dependencies +!ntsrvconfig.serviceStartName = serviceStartName +!ntsrvconfig.displayName = displayName +end intellisense**/ + +/**intellisense() +_SERVICE_FILE_SYSTEM_DRIVER=@0x2/*_SERVICE_FILE_SYSTEM_DRIVER*/ +_SERVICE_KERNEL_DRIVER=@0x1/*_SERVICE_KERNEL_DRIVER*/ +_SERVICE_WIN32_OWN_PROCESS=@0x10/*_SERVICE_WIN32_OWN_PROCESS*/ +_SERVICE_WIN32_SHARE_PROCESS=@0x20/*_SERVICE_WIN32_SHARE_PROCESS*/ +_SERVICE_CONTINUE_PENDING=@0x5/*_SERVICE_CONTINUE_PENDING*/ +_SERVICE_PAUSE_PENDING=@0x6/*_SERVICE_PAUSE_PENDING*/ +_SERVICE_PAUSED=@0x7/*_SERVICE_PAUSED*/ +_SERVICE_RUNNING=@0x4/*_SERVICE_RUNNING*/ +_SERVICE_START_PENDING=@0x2/*_SERVICE_START_PENDING*/ +_SERVICE_STOP_PENDING=@0x3/*_SERVICE_STOP_PENDING*/ +_SERVICE_STOPPED=@0x1/*_SERVICE_STOPPED*/ +_SERVICE_ACCEPT_NETBINDCHANGE=@0x10/*_SERVICE_ACCEPT_NETBINDCHANGE*/ +_SERVICE_CONTROL_NETBINDADD=@0x7/*_SERVICE_CONTROL_NETBINDADD*/ +_SERVICE_CONTROL_NETBINDREMOVE=@0x8/*_SERVICE_CONTROL_NETBINDREMOVE*/ +_SERVICE_CONTROL_NETBINDENABLE=@0x9/*_SERVICE_CONTROL_NETBINDENABLE*/ +_SERVICE_CONTROL_NETBINDDISABLE=@0xA/*_SERVICE_CONTROL_NETBINDDISABLE*/ +_SERVICE_ACCEPT_PARAMCHANGE=@0x8/*_SERVICE_ACCEPT_PARAMCHANGE*/ +_SERVICE_CONTROL_PARAMCHANGE=@0x6/*_SERVICE_CONTROL_PARAMCHANGE*/ +_SERVICE_ACCEPT_PAUSE_CONTINUE=@0x2/*_SERVICE_ACCEPT_PAUSE_CONTINUE*/ +_SERVICE_CONTROL_PAUSE=@0x2/*_SERVICE_CONTROL_PAUSE*/ +_SERVICE_CONTROL_CONTINUE=@0x3/*_SERVICE_CONTROL_CONTINUE*/ +_SERVICE_ACCEPT_SHUTDOWN=@0x4/*_SERVICE_ACCEPT_SHUTDOWN*/ +_SERVICE_CONTROL_SHUTDOWN=@0x5/*_SERVICE_CONTROL_SHUTDOWN*/ +_SERVICE_ACCEPT_STOP=@0x1/*_SERVICE_ACCEPT_STOP*/ +_SERVICE_CONTROL_STOP=@0x1/*_SERVICE_CONTROL_STOP*/ +_SERVICE_ACCEPT_HARDWAREPROFILECHANGE=@0x20/*_SERVICE_ACCEPT_HARDWAREPROFILECHANGE*/ +_SERVICE_CONTROL_HARDWAREPROFILECHANGE=@0xC/*_SERVICE_CONTROL_HARDWAREPROFILECHANGE*/ +_SERVICE_ACCEPT_POWEREVENT=@0x40/*_SERVICE_ACCEPT_POWEREVENT*/ +_SERVICE_CONTROL_POWEREVENT=@0xD/*_SERVICE_CONTROL_POWEREVENT*/ +_SERVICE_ACCEPT_SESSIONCHANGE=@0x80/*_SERVICE_ACCEPT_SESSIONCHANGE*/ +_SERVICE_CONTROL_SESSIONCHANGE=@0xE/*_SERVICE_CONTROL_SESSIONCHANGE*/ +_SERVICE_RUNS_IN_SYSTEM_PROCESS=@0x1/*_SERVICE_RUNS_IN_SYSTEM_PROCESS*/ +_SERVICE_AUTO_START=@0x2/*_SERVICE_AUTO_START*/ +_SERVICE_BOOT_START=@0x0/*_SERVICE_BOOT_START*/ +_SERVICE_DEMAND_START=@0x3/*_SERVICE_DEMAND_START*/ +_SERVICE_DISABLED=@0x4/*_SERVICE_DISABLED*/ +_SERVICE_SYSTEM_START=@0x1/*SERVICE_SYSTEM_START*/ +_SERVICE_ADAPTER=@0x4/*_SERVICE_ADAPTER*/ +_SERVICE_FILE_SYSTEM_DRIVER=@0x2/*_SERVICE_FILE_SYSTEM_DRIVER*/ +_SERVICE_KERNEL_DRIVER=@0x1/*_SERVICE_KERNEL_DRIVER*/ +_SERVICE_RECOGNIZER_DRIVER=@0x8/*_SERVICE_RECOGNIZER_DRIVER*/ +_SERVICE_WIN32_OWN_PROCESS=@0x10/*_SERVICE_WIN32_OWN_PROCESS*/ +_SERVICE_WIN32_SHARE_PROCESS=@0x20/*_SERVICE_WIN32_SHARE_PROCESS*/ +_SERVICE_WIN32 =@0x30/*_SERVICE_WIN32*/ +end intellisense**/ \ No newline at end of file diff --git a/lib/thread/works.aau b/lib/thread/works.aau index 62c1396..9517199 100644 --- a/lib/thread/works.aau +++ b/lib/thread/works.aau @@ -9,14 +9,14 @@ class works{ var guid = tostring(..win.guid.create()) this._gArg = guid; this._gRet = guid + "_R"; - this._gWorked = guid + "_W" - this._gSign = guid + "_S" + this._gWorked = guid + "_W"; + this._gSign = guid + "_S"; - this._tArgs = ..thread.table( this._gArg ) - this._tRet = ..thread.table( this._gRet ) - this._tWorked = ..thread.table( this._gWorked ) + this._tArgs = ..thread.table( this._gArg ); + this._tRet = ..thread.table( this._gRet ); + this._tWorked = ..thread.table( this._gWorked ); - ..thread.set(this._gSign ,true ) + ..thread.set(this._gSign ,true ); var threads = {} for(i=1;limit;1){ var thrd = {} @@ -34,7 +34,8 @@ class works{ arg = tArgs.remove() if(arg){ tWorked.push(1) - tRet.insert( func(arg) ); + var ret = func(arg); + if(ret!==null) tRet.insert( ret ); tWorked.pop(1) continue ; } @@ -133,12 +134,12 @@ class works{ } if( f ){ r = this.pop(1); - if(r)f(r); + if(r!==null)f(r); } } if(f){ r = this.pop(1); - while( r && delay(10) ){ + while( (r!==null) && delay(10) ){ f(r); r = this.pop(1); } @@ -171,5 +172,4 @@ thread.works() = !thread_wk. !thread_wk.each = @for( idx,args in ??.each() ){ __/*�������д�ִ������,\n�ú�������ͣ��������*/ } -end intellisense**/ - \ No newline at end of file +end intellisense**/ \ No newline at end of file