PureBasic Forum

Windows Services & Other Stuff
Page 1 of 7

Author:  JHPJHP [ Sun Nov 02, 2014 6:21 pm ]
Post subject:  Windows Services & Other Stuff


Download Windows Services & Other Stuff from My PureBasic Stuff


Tricks 'n' Tips
PureBasic Interface to OpenCV
PureBasic Interface to WinDivert
PureBasic Interface to WinRAR
PureBasic Interface to 7-Zip
PureBasic Interface to ImDisk
Windows Services & Other Stuff
Invading Space Aliens
Death Star vs Asteroids
GIF Toolkit
LSB File Embedding
Spider Web Drawing
Deform Image: MLS
Video Snipping Tool
Image Waves: LUT
HTML5 YouTube Player
HTML5 MP4 Player
Barcode Generator
Embed JS into PureBasic
Geolocation: Google Maps
Book & Viewer & Magnify
Video for Windows: VfW
Alternate Console
Network Share Management


- includes\WindowsServices.pbi (ServiceStatusEnum, ServiceCreate, ServiceDelete, ServiceStatus, ServiceStartup, ServiceStart, ServiceStop)
- binaries\TestWindow_EXE.pb, TestWindow.exe: example program run as a service
- binaries\TestService_EXE.pb, TestService.exe: example service used to execute TestWindow.exe
- CreateService.pb: example to create a service
- StartStopService.pb: example to stop then start a service


- AESEncryption: AES_CipherBuffer.pb, AES_EncoderDecoder.pb
- AlternateDataStream: ADS.pb
- AmazonWebServices: AWS.pb
- AnimatedGIF: MovableSpriteObject.pb, UseGIFImageDecoder.pb, WebGadgetGIF.pb
- BrowserCache: CacheChrome.pb, CacheExplorer.pb

- CopyShare
-- CopyData\Text_Receive.pb, Text_Send.pb
-- ShareMemory\Image\1. Send.pb, 2. Receive.pb
-- ShareMemory\Text\1. Send.pb, 2. Receive.pb

- CriticalFlag: CriticalFlag.pb
- DigitalClock: DigitalClock.pb
- FileDates: FileDates.pb
- GadgetBar: GadgetBar.pb

- GadgetStuff: Explorer_Thumbnail.pb, Reset_Window.pb, TreeGadget_Sync.pb
-- CanvasGadget\CanvasImageButton_1.pb, CanvasImageButton_2.pb
-- ListIconGadget\MoveMultiple.pb, MultiLineImage.pb
-- WebGadget\ImageSize.pb, NoScroll.pb, VideoInfo.pb

- GetUsage: GetUsage.pb

- HideVideo
-- AlternateDataStream\CreateADS.pb, ExtractADS.pb
-- DataSection\DataSection.pbi, PlayVideo.pb

- ImageWindow: ImageWindow.pb
- InflateDeflate: InflateDeflate.pb

- ISAPI: ISAPI_Test.pb
-- binaries\ ISAPI_Test_32.dll, ISAPI_Test_64.dll
-- includes\ ISAPI.pbi
-- references\ HttpExt.h

- ManifestResource: SetManifest.pb
- MemoryFolder: MemoryFolder.pb
- MonitorStuff: ChangeDisplayOrientation.pb, GetAutoRotationState.pb, GetMonitorInfo.pb, ScaleFactor.pb, SetDpiAwareness.pb, WindowsDpiStuff.pb
- MountImage: MountImage.pb
- Odometer: Odometer.pb

- OpenGLStuff
-- RotateDice\RotateDice.pb

- OtherStuff
-- GetProgramData\GetProgramData.pb
-- SetWindowsHookEx\SetWindowsHookEx.pb, SetWindowsHookEx_DLL.pb
-- Base64ImagePB.pb, BringWindowToTop.pb, CompressUncompress.pb, ConnectUNC.pb, CryptQueryObject.pb, DisableClose.pb, EnumerateWindows.pb, FileSecurity.pb, FormatDevice.pb,
-- GetExternalIP.pb, GetFileVersion.pb, GetFolderSize.pb, GetProductKey.pb, GlobalKeyboardHook.pb, GlobalMouseHook.pb, Grayscale.pb, IsOS64Bit.pb, MapDrive.pb,
-- PlotCurve.pb, Power2Bitwise.pb, RecordMic.pb, RegisterShellHookWindow.pb, RunScriptCMD.pb, SetProgressState.pb, TimedMessageBox.pb

- PowerShell: SendHtmlEmail.pb
-- RestorePoints\RestorePoints.pbi, CreateShowDelete.pb

- PrinterStuff
-- PrinterStuff.pbi, AddMonitor.pb, DeleteMonitor.pb, AddPort.pb, DeletePort.pb, GetDriver.pb, AddDriver.pb, DeleteDriver.pb,
-- UploadDriverPackage.pb, InstallDriverPackage.pb, DeleteDriverPackage.pb, AddPrinter.pb, DeletePrinter.pb, SetSecurity.pb,
-- EnumerateMonitors.pb, EnumeratePorts.pb, EnumeratePrinters.pb, EnumerateDrivers.pb
-- MS_PS_CD_V3\... (required by AddDriver.pb)
-- MS_PS_CD_V4\... (required by UploadDriver.pb)

- ProcessStuff: GetProcessCL.pb, GetProcessList.pb, GetProcessPath.pb
-- CallingProcess\process.dll, process.exe, process_dll.pb, process_exe.pb
-- ParentProcess\ParentProcess.exe, GetParentProcess.exe, ParentProcess.pb, GetParentProcess.pb
-- RunProcess\Elevated.pb, RPAS.pb (Run Process As SYSTEM)
-- RunProcess\binaries\RPAU-EXE.pb (Run Process As User)

- ProtocolStuff: FTP.pb, HTTP.pb, Telnet.pb
- RotateImage: RotateImage.pb
- ScreenCapture: CaptureDesktopAll.pb, ScreenCapturePlus.pb
- SelectedItems: SelectedItems.pb
- SendToNotepad: SendToNotepad.pb
- SQLiteDatabase: ATTACH.pb, RTF2BLOB.pb, SELECT.pb, UPDATE.pb
- WebSnapshot: WebSnapshot.pb
- WolframAlpha: WolframAlpha_1.pb, WolframAlpha_2.pb
- XMLStuff: GetXMLNodes.pb

Author:  Mythros [ Sun Nov 02, 2014 11:37 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Sweet, is there a way this can be used for example to check whether 2 same processes are open at once?

Author:  JHPJHP [ Mon Nov 03, 2014 2:03 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Hi Mythros,

Stuff Folder:
- GetProcessPath.pb can be used to check for a running PATH\executable
- ProcessList.pb can be used to check for a running executable

Shellhook Folder
- shellhook.pb includes the following FindWindow Procedure
Procedure FindWindow(WindowName.s)
  Protected hWnd

  hWnd = GetWindow_(GetDesktopWindow_(), #GW_CHILD)

    winCaption.s = Space(#MAX_PATH)
    GetWindowText_(hWnd, winCaption, #MAX_PATH)

    If Len(Trim(winCaption)) > 0
      If FindString(winCaption, WindowName) > 0 : Break : EndIf
    hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
  Until hWnd = 0
  ProcedureReturn hWnd

hWnd = FindWindow("Window Watcher")

If hWnd
  MessageBox_(hWnd, "The application is already running.", "Window Watcher", #MB_ICONWARNING)

Another option may be to use either the CreateMutex or FindWindow function.
- CreateMutex: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682411(v=vs.85).aspx
-- test for: GetLastError = ERROR_ALREADY_EXISTS
- FindWindow: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx
-- test for: return value NOT NULL

Author:  JHPJHP [ Tue Nov 18, 2014 7:49 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Updated the Services scripts to be more intuitive and easier to use.

See the first post for a more in-depth description.


Author:  Rings [ Tue Nov 18, 2014 9:10 am ]
Post subject:  Re: Services, Stuff, and Shellhook

thx a lot

Author:  JHPJHP [ Sun Nov 23, 2014 5:52 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Hi Rings,

You're welcome, and thank you for your many positive comments across my "Tricks 'n' Tips" posts.


The following are some simple examples that may help a beginner with learning PureBasic:
- updated the Stuff folder

Added 3 additional script files and 1 image file.
- GlobalKeyboardHook.pb: global keyboard hook capturing keystrokes
-- currently set to capture: A - Z, ESC to quit
- RotateImage.pb: 90, 180, 270, and flip
-- logo.jpg: image used by: RotateImage.pb
- TreeGadget_Sync.pb: 2 TreeGadget's synced


Here is another example added to the Stuff folder.
- ADS.pb: (Windows) Alternate Data Streams
-- http://www.bleepingcomputer.com/tutorials/windows-alternate-data-streams/

The example demonstrates one approach to hide / link an executable to a text file, but the process is not limited to text / executable files.
- read the documentation to better understand the application and dangers with using this method

Author:  JHPJHP [ Thu Dec 18, 2014 11:44 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Added another three examples to the folder: Stuff
- CacheChrome.pb
- CacheExplorer.pb
- AlwaysOnTop.pb

Both cache examples list browser cache with the option to delete.
- unlike other browsers Google Chrome uses SQLite to store cache

AlwaysOnTop.pb: Tries to set the window using the current thread as the active window.


Updated all the examples to work with Windows 8.
- an additional update was made to the service example

Author:  JHPJHP [ Sat Dec 20, 2014 9:26 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Added another three examples to the folder: Stuff
- RunElevated.pb: run an executable in an elevated process using the Function: ShellExecuteEx
- SetManifest.pb: set a manifest file to an executable
- IsOS64Bit.pb: returns true if the OS is 64 bit otherwise false

I used the RunElevated & SetManifest scripts in the latest update to PureBasic Interface to WinDivert.

- http://mfctips.com/2013/01/04/createprocess-fails-to-launch-exe-with-elevated-manifest/
- http://msdn.microsoft.com/en-us/library/aa374191%28v=vs.85%29.aspx
-- tool to view manifest in binary: http://www.angusj.com/resourcehacker/

Running the example: SetManifest.pb on the current folder will set: rpau.manifest to the executable: rpau.exe.

I used the IsOS64Bit script in updating the example: GetProcessCL.pb.
- http://stackoverflow.com/questions/15811006/checking-processor-is-32-bit-or-64-bit

NB*: Numerous other improvements have been made to various examples.

Author:  JHPJHP [ Tue Dec 23, 2014 11:41 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Added another example to the Stuff folder:
- ListIconGadget_Move.pb: allows the moving of multiple selected items [ CTRL / SHIFT ]

NB*: Update also includes numerous improvements and bug fixes to various examples.

Author:  JHPJHP [ Mon Dec 29, 2014 6:49 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

- GetExternalIP.pb: get the external IP Address using DNS
- WebGadget_NoScroll.pb: remove scrolling / scrollbars from the webgadget

Author:  JHPJHP [ Thu Jan 08, 2015 1:15 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Added another couple examples to the Stuff folder:
- MovieData
-- Alternate Data Stream (folder: ADS)
--- folder: videos
---- walking.avi
--- MovieData.pb
---- MovieData.exe
--- ADS.pb
-- DataSection (folder: DS)
--- MovieData.pb
---- MovieData.exe
--- DataSection.pbi

The example: MovieData.pb was from a question asked here: http://www.purebasic.fr/english/viewtopic.php?f=13&t=61382&p=459078#p459078

The ADS folder example uses an Alternate Data Stream to conceal the video file.
- the current executable: MovieData.exe will not work because zip files do not include ADS
-- if I chose to compress using WinRAR the option to include ADS is available
- recompile the file: MovieData.pb (MovieData.exe) then add the ADS by running the file: ADS.pb

The DS folder example uses a DataSection to conceal the video file.
- the example highlights PureDataConverter by ts-soft

NB*: In both examples the temp file is created in the current directory, but this should be changed for better concealment.
- Function: GetTemporaryDirectory

Author:  JHPJHP [ Thu Jan 15, 2015 1:09 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Added another three examples to the Stuff folder.
- folder: MoreStuff
-- AWS.pb: (Amazon Web Services) used to retrieve a variety of information
--- utilizes the script (HMAC_SHA1 Procedure) by hss: http://www.purebasic.fr/english/viewtopic.php?f=12&t=46460
-- CreateMountableImage.pb: creates a mountable image file from a folder location
--- bingo did it first: http://www.purebasic.fr/english/viewtopic.php?t=29757
-- Power2Bitwise.pb: extracted from: PureBasic Interface to ImDisk

- the following information will need to be filled in for the example to work
SecretAccessKey.s = ""
AWSAccessKeyId.s = ""
AssociateTag.s = ""

- a mountable image file cannot be created from a drive-root, or a circular reference


I asked myself this question: If given a number that is the total sum of a group of numbers, how can I extract the individual numbers?

General information:
- counting by powers of two: 1, 2, 4, 8, 16, 32, 64, 128, 256, ...
-- every leading number is greater (by 1) then the sum of all the previous numbers combined

Power of Two / Bitwise:
- Value = Pow(2, nCount) (starting from 0)
-- nCount: the position in the series you want returned: Pow(2, 6) = 64
- (Value & Sum) = Value (Bitwise comparison)
-- Value: the number you want to test is included in the Sum
-- Sum: the sum of various numbers from the series

NB*: I've use the "Power of Two / Bitwise" technique in conjunction with a database to control access privileges, track various auditing information, etc.

Author:  JHPJHP [ Fri Feb 13, 2015 2:29 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Added another two examples to the Stuff folder:
- WindowStuff/TimerStuff
-- messagebox.pb
-- splash.pb
--- processing.gif

splash.pb: from a question asked here: http://www.purebasic.fr/english/viewtopic.php?f=7&t=61565
- a timed splash window created in a separate thread

messagebox.pb: something I was going to use in: PureBasic Interface to UnRAR (WinRAR)
- a timed message box created in a separate thread

Author:  JHPJHP [ Sun Feb 15, 2015 8:13 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Added another four examples to the Stuff folder:
- SendToNotepad
-- SendToNotepad.pb
--- gpl.txt (test file)
- WindowStuff/CopyData
-- Text_Send.pb, Text_Receive.pb
- WindowStuff/ShareMemory
-- Image_Send.pb, Image_Receive.pb, baboon.jpg
-- Text_Send.pb, Text_Receive.pb

- Open / change the Title of Notepad / Work with an opened instance of Notepad
-- RunNotepad: two optional parameters (Title.s, nDelay)
- Append (newline)
-- WriteToNotepad: nStart < 0 (default) / nLength < 0 (default)
- Prepend (newline)
-- WriteToNotepad: nStart = 0 / nLength < 0 (default)
- Replace
-- WriteToNotepad: nStart >= 0 / nLength > 0
- ReplaceAll
-- WriteToNotepad: nStart = 0 / nLength = 0
- Insert
-- WriteToNotepad: nStart > 0 / nLength <= 0 (default)

- CopyData examples pass text from one PureBasic window to another.
- ShareMemory examples pass text / images from one PureBasic window to another


Updated the Share Memory examples.
- Image_Send.pb: includes the option to change images
- Image_Receive.pb: includes a separate thread to monitor changes

Author:  marroh [ Sun Feb 15, 2015 8:41 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Thx for update and share :mrgreen:

Page 1 of 7 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group