Page 3 of 14

Re: Services, Stuff, and Shellhook

Posted: Wed Oct 05, 2016 6:22 pm
by JHPJHP
Updated:
- renamed 1 example
-- Stuff\AESEncryption\EncryptDecrypt.pb to Stuff\AESEncryption\AES_EncoderDecoder.pb
- added 2 examples
-- Stuff\AESEncryption\AES_CipherBuffer.pb
-- Stuff\OtherStuff\PlotCurve.pb: based on an equation found here

Plot Curve Function:
- used in PureBasic Interface to OpenCV to enhance the morphing examples

Re: Services, Stuff, and Shellhook

Posted: Tue Oct 18, 2016 11:27 pm
by JHPJHP
Updated:
- added 3 examples
-- Stuff\MemoryFolder\MemoryFolder.pb
-- Stuff\OtherStuff\CompressUncompress.pb
-- Stuff\OtherStuff\GetFolderSize.pb

Currently LSB (Least Significant Bit) File Embedding doesn't support embedding folders. While it does allow for embedding zipped folders, I wanted a way to compress a folder in memory without first writing to disk or requiring user-interaction.

MemoryFolder.pb:
- write a folder, subfolders, and files to memory
- compress the memory
- uncompress the memory
- recreate the folder, subfolders, and files to a specified location

The following options can be configured to suit requirements.
- Iterate Subfolders: empty folders are ignored
- Max Folder Size: 150MB or less
- Root Folder: folder path, new folder name, folder path \ new folder name

Code: Select all

IterateSubfolders   = #True
MaxFolderSize.q     = 104857600
RootFolder.s        = "MemoryFolder"

Re: Services, Stuff, and Shellhook

Posted: Fri Oct 21, 2016 3:58 am
by JHPJHP
Updated:
- added 2 examples
-- Stuff\iPhoneIV\iPhoneIV.pb
-- Stuff\WebSnapshot\WebSnapshot.pb

iPhoneIV.pb (iPhone Image Viewer)
- press the iPhone Home button to slide between images
- press the Esc key to close the window

WebSnapshot.pb
- save a snapshot of a webpage regardless of scroll area

Based on script found here by Kiffi.
- fixed a bug in the original code not correctly calculating height with some webpages (e.g. https://en.wikipedia.org/wiki/PureBasic)

Re: Services, Stuff, and Shellhook

Posted: Fri Oct 21, 2016 7:55 pm
by JHPJHP
Updated Stuff\iPhoneIV\iPhoneIV.pb (iPhone Image Viewer)
- renamed the example Stuff\PNGWindow\PNGWindow.pb to Stuff\PhoneIV\PhoneIV.pb
- fixed a bug with the iPhone Home button

Re: Services, Stuff, and Shellhook

Posted: Mon Oct 24, 2016 8:30 am
by JHPJHP
Updated:
- added 1 example
-- Stuff\InflateDeflate\InflateDefalte.pb

This example creates a gzip (*.gz) compressed file to the current folder, and an uncompressed version of the original file.
- the windowBits parameter determines the format: see zlib Manual
-- 8..15 = zlib format
-- 24..31 = gzip format
-- -8..-15 = raw zlib format with no header
NB*: Originally used in PureBasic Interface to WinDivert to compress and decompress webpages; updated to work with any file.

------------------------------------------------------------------------------

Updated:
- OSX compatible
- added additional OS Constants: GZIP file format specification version 4.3
- added header Procedures
- fixed a bug that caused the header filename to display incorrectly

NB*: Enable Debug to view header data.

Re: Services, Stuff, and Shellhook

Posted: Tue Oct 25, 2016 1:16 pm
by JHPJHP
Updated Stuff\iPhoneIV\iPhoneIV.pb (iPhone Image Viewer)
- added the option to toggle between Portrait and Landscape
-- press the Spacebar to switch orientation
- added image scaling on resize
- added a couple sound effects

Image

Re: Services, Stuff, and Shellhook

Posted: Tue Jan 10, 2017 8:06 pm
by JHPJHP
Updated the first post:
- added individual download links to all parts of the package

NB*: Some of the download links contain executables (source code included), and may be flagged by your AV software.

Re: Services, Stuff, and Shellhook

Posted: Tue Jan 10, 2017 10:34 pm
by boyoss
Thank you very much it's wonderfull!!

i'm using a batch script for starting and stopping services:

Code: Select all

stop
sc config dhcp start= disabled
net stop dhcp /y
start
sc config dhcp start= auto
net start dhcp /y
it seems your code is only doing the first line, sc, how can i do also the second line, net?

Re: Services, Stuff, and Shellhook

Posted: Wed Jan 11, 2017 1:38 am
by JHPJHP
Hi boyos,

The following is from the first post... or is there something else you need help with?

Services:
- WindowsServices.pbi (ServiceStatusEnum, ServiceCreate, ServiceDelete, ServiceStatus, ServiceStartup, ServiceStart, ServiceStop)
- TestService.pb: example to create a service
- binaries\
-- TestJHP_EXE.pb : TestJHP.exe
--- example program run as a service
-- TestJHPService_EXE.pb : TestJHPService.exe
--- example service used to execute: TestJHP.exe
This window / executable is being run from a service.

If the window is closed, it will reopen within 10 seconds.

The service is being executed using the current user's credentials.

Run the file: TestService.pb a second time to delete the service.

The following is a list of services created using the ServiceStatusEnum Procedure.

Re: Services, Stuff, and Shellhook

Posted: Wed Jan 11, 2017 1:42 am
by boyoss
Yes, i need help to run the net command ftom purebasic.
Thank you very much

Re: Services, Stuff, and Shellhook

Posted: Wed Jan 11, 2017 4:47 am
by JHPJHP
Hi boyos,

I'm assuming you mean the START and STOP parameters of the NET command used for a service :?:
- if so the equivalent Procedures are located in the file WindowsServices.pbi (recently updated)
The syntax of this command is:
NET
[ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
STATISTICS | STOP | TIME | USE | USER | VIEW ]
I've also updated the SERVICES section of the package to include an additional example.
- StartStopService.pb: example to stop then start a service

NB*: Some filenames have been changed.

Re: Services, Stuff, and Shellhook

Posted: Wed Jan 11, 2017 2:18 pm
by boyoss
i'm sorry i didn't understand
you mean you have a function NetStop(service.s)?
i don't see it??

Re: Services, Stuff, and Shellhook

Posted: Wed Jan 11, 2017 3:31 pm
by JHPJHP
Hi boyos,

If you haven't already done so, download the updated SERVICES section of the package.

The two files you will need to review:
- StartStopService.pb: example script-file testing three of the Procedures from WindowsServices.pbi
-- ServiceStatus, ServiceStop, ServiceStart
- WindowsServices.pbi: include-file hosting Structures, and Procedures interfacing Windows (service) API's

Run the file StartStopService.pb for a working example on starting and stopping a service, but notice the main body of work is from the Include file WindowsServices.pbi.

NB*: In order to interface Windows API's, a licenced version of PureBasic is required, the demo version excludes this feature.

Re: Services, Stuff, and Shellhook

Posted: Wed Jan 11, 2017 10:27 pm
by boyoss
i'm sorry, but i think i need also the "net" command, because when i stop the services, they restart automaticly.

Code: Select all

IncludeFile "plus\WindowsServices.pbi"
services.s = "dhcp dnscache netman netprofm nsi webclient wlansvc rasauto rasman IKEEXT sstpsvc wcmsvc"

Procedure yhe_service(services.s, mode.l)
	Define.l i, result
	Define.s service, success, not_success
	
	
	
	For i = 1 To CountString(services, " ") + 1
		service = StringField(services, i, " ")
		Select mode
			Case 0
				If ServiceStop(service) : success + service + " " : Else : not_success + service + " " : EndIf
			Case 1
				If ServiceStart(service) : success + service + " " : Else : not_success + service + " " : EndIf
			Case 2
				Select ServiceStatus(service)
					Case "The service is running." : success + service + " "
					Case "The service is stopped." : not_success + service + " "
				EndSelect
		EndSelect
	Next
	
	Debug "OK: " + success
	Debug "ERROR: " + not_success
EndProcedure

yhe_service(services, 0); stop
;yhe_service(services, 1); start
yhe_service(services, 2); check

thanks

Re: Services, Stuff, and Shellhook

Posted: Wed Jan 11, 2017 11:14 pm
by JHPJHP
Hi boyoss,

Try the following:
- make sure to set Request Administrator mode for Windows Vista and above from Compiler Options

NOTE: Services such as DHCP have dependencies services, and may need a greater timeout then the current 60 seconds to report the status accurately
- you can try running the script a second time to see if the service is "stop pending"
- some services may have a timed-restart or cannot be stopped

Code: Select all

IncludeFile "WindowsServices.pbi"

Procedure set_service(services.s, mode)
  Define.s service, status

  Debug "STARTED" + #LF$

  For i = 1 To CountString(services, " ") + 1
    service = StringField(services, i, " ")
    status = ServiceStatus(service)
    nTimeOut = ElapsedMilliseconds()

    Select mode
      Case 0
        If status = "The service is running."
          Debug service + " [ STOP ] working..."
          ServiceStop(service)

          Repeat
            Delay(100) : status = ServiceStatus(service)
          Until status <> "The service is running." Or ElapsedMilliseconds() - nTimeOut > 60000
          Debug service + ": " + ServiceStatus(service) + #LF$
        Else
          Debug service + ": The service is not running (" + status + ")" + #LF$
        EndIf
      Case 1
        If status = "The service is stopped."
          Debug service + " [ START ] working..."
          ServiceStart(service)

          Repeat
            Delay(100) : status = ServiceStatus(service)
          Until status = "The service is running." Or ElapsedMilliseconds() - nTimeOut > 60000
          Debug service + ": " + ServiceStatus(service) + #LF$
        Else
          Debug service + ": The service is not stopped (" + status + ")" + #LF$
        EndIf
    EndSelect
  Next
  Debug "COMPLETED"
EndProcedure

services.s = "dhcp dnscache netman netprofm nsi webclient wlansvc rasauto rasman IKEEXT sstpsvc wcmsvc"
set_service(services, 0)