Page 1 of 14
Windows Services & Other Stuff
Posted: Sun Nov 02, 2014 6:21 pm
by JHPJHP
Re: Services, Stuff, and Shellhook
Posted: Sun Nov 02, 2014 11:37 pm
by Mythros
Sweet, is there a way this can be used for example to check whether 2 same processes are open at once?
Re: Services, Stuff, and Shellhook
Posted: Mon Nov 03, 2014 2:03 am
by JHPJHP
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
Code: Select all
Procedure FindWindow(WindowName.s)
Protected hWnd
hWnd = GetWindow_(GetDesktopWindow_(), #GW_CHILD)
Repeat
winCaption.s = Space(#MAX_PATH)
GetWindowText_(hWnd, winCaption, #MAX_PATH)
If Len(Trim(winCaption)) > 0
If FindString(winCaption, WindowName) > 0 : Break : EndIf
EndIf
hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
Until hWnd = 0
ProcedureReturn hWnd
EndProcedure
hWnd = FindWindow("Window Watcher")
If hWnd
MessageBox_(hWnd, "The application is already running.", "Window Watcher", #MB_ICONWARNING)
EndIf
Another option may be to use either the CreateMutex or FindWindow function.
- CreateMutex:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
-- test for: GetLastError = ERROR_ALREADY_EXISTS
- FindWindow:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
-- test for: return value NOT NULL
Re: Services, Stuff, and Shellhook
Posted: Tue Nov 18, 2014 7:49 am
by JHPJHP
Updated the Services scripts to be more intuitive and easier to use.
See the first post for a more in-depth description.
Cheers!
Re: Services, Stuff, and Shellhook
Posted: Tue Nov 18, 2014 9:10 am
by Rings
thx a lot
Re: Services, Stuff, and Shellhook
Posted: Sun Nov 23, 2014 5:52 am
by JHPJHP
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/tutoria ... a-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
Re: Services, Stuff, and Shellhook
Posted: Thu Dec 18, 2014 11:44 am
by JHPJHP
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
-- #SC_MANAGER_ALL_ACCESS was changed to #SC_MANAGER_ENUMERATE_SERVICE
Re: Services, Stuff, and Shellhook
Posted: Sat Dec 20, 2014 9:26 pm
by JHPJHP
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.
Information:
-
http://mfctips.com/2013/01/04/createpro ... -manifest/
-
http://msdn.microsoft.com/en-us/library ... 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/1581 ... -or-64-bit
NB*: Numerous other improvements have been made to various examples.
Re: Services, Stuff, and Shellhook
Posted: Tue Dec 23, 2014 11:41 am
by JHPJHP
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.
Re: Services, Stuff, and Shellhook
Posted: Mon Dec 29, 2014 6:49 pm
by JHPJHP
Updated:
- GetExternalIP.pb: get the external IP Address using DNS
- WebGadget_NoScroll.pb: remove scrolling / scrollbars from the webgadget
Re: Services, Stuff, and Shellhook
Posted: Thu Jan 08, 2015 1:15 am
by JHPJHP
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/viewtop ... 78#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
Re: Services, Stuff, and Shellhook
Posted: Thu Jan 15, 2015 1:09 am
by JHPJHP
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/viewtop ... 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
AWS.pb
- the following information will need to be filled in for the example to work
Code: Select all
SecretAccessKey.s = ""
AWSAccessKeyId.s = ""
AssociateTag.s = ""
CreateMountableImage.pb
- a mountable image file cannot be created from a drive-root, or a circular reference
Power2Bitwise.pb
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.
Re: Services, Stuff, and Shellhook
Posted: Fri Feb 13, 2015 2:29 am
by JHPJHP
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/viewtop ... =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
Re: Services, Stuff, and Shellhook
Posted: Sun Feb 15, 2015 8:13 pm
by JHPJHP
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
SendToNotepad
- 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)
ShareMemory
- 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
Re: Services, Stuff, and Shellhook
Posted: Sun Feb 15, 2015 8:41 pm
by marroh
Thx for update and share