![]() SaFilenames.i = CkStringArray:: ckCreate()ĬkStringArray:: ckAppend(saDomains, "CkStringArray:: ckAppend(saDomains, "CkStringArray:: ckAppend(saDomains, "CkStringArray:: ckAppend(saDomains, "CkStringArray:: ckAppend(saDomains, "CkStringArray:: ckAppend(saUrls, "")ĬkStringArray:: ckAppend(saFilenames, "chilkatsoft.out")ĬkStringArray:: ckAppend(saFilenames, "cknotes.out")ĬkStringArray:: ckAppend(saFilenames, "google.out")ĬkStringArray:: ckAppend(saFilenames, "example-code.out")ĬkStringArray:: ckAppend(saFilenames, "yahoo.out") Before we begin, create a few StringArray objects holding domain names, URLs, and output filenames to be used in this example. This will be the socket object that will contain other connected sockets. See Global Unlock Sample for sample code. This example requires the Chilkat API to have been previously unlocked. The SelectForReading method waits until one or more sockets in the set have incoming data ready and available to read. Demonstrates how the Chilkat socket object can become a "socket set" that contains other connected socket objects, and this can be used to "select" on multiple sockets for reading. Tidy up process handles identified in the PROCESS_INFORMATION structure. If Not ContinueDebugEvent_ ( myDebug\dwProcessId, myDebug\dwThreadId, #DBG_CONTINUE) MessageBox_ ( WindowID ( 1 ), "Debugging error!", "Error", #MB_ICONERROR | #MB_TOPMOST | #MB_SETFOREGROUND) EndIf Until EXIT_PROCESS_DEBUG_EVENT DEBUG_EVENT, - 1 ) If PeekB ( \dwDebugEventCode ) = #EXIT_PROCESS_DEBUG_EVENTĮXIT_PROCESS_DEBUG_EVENT = #True EndIf EndIf Continue debugging the process. STARTUPINFO ) If CreateProcess_ (# Null, GetCommandLine_ (), #Null, #Null, #False, #DEBUG_PROCESS, #Null, #Null, Infinitely wait for the debugging event EXIT_PROCESS_DEBUG_EVENT in our new process. CloseHandle_ ( ghMutex ) MessageBox_ ( WindowID ( 1 ), "Self-debugging already in progress.", "Error", #MB_ICONERROR | #MB_TOPMOST | #MB_SETFOREGROUND) ProcedureReturn EndIf Find out who we are and create a duplicate process of ourselves. GhMutex = CreateMutex_ (# Null, #True, "Blocker_Mutex") If ghMutex = #Null Or GetLastError_() = #ERROR_ALREADY_EXISTS If return handle is the existing object GetLastError returns ERROR_ALREADY_EXISTS. Create a mutex object, we can use it as an identity to limit the number of spawned processes to be self - debugged. Procedure DebugBlocker () Protected ghMutex, EXIT_PROCESS_DEBUG_EVENT Declare DebugBlocker () If OpenWindow ( 1, #Null, #Null, 300, 60, "Self-debugging Example", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) ButtonGadget ( 1, 5, 5, 290, 50, "CLICK ME!", #PB_Button_MultiLine) Repeat MyEvent = WaitWindowEvent () Select MyEvent Case #PB_Event_Gadget Select EventGadget () Case 1 DebugBlocker () EndSelect EndSelect Until MyEvent = #PB_Event_CloseWindow EndIf A very simple example of self - debugging ( Debug - Blocker ). Remarks : Debugging events and actions are handled within the function. Return Values : This function does not return a value. Ring - 3 debugger can be attached to a process in Windows OS. to protect the parent ( now child ) process from being debugged. commonly referred to as "self-debugging" or "Debug Blocker" and is used process as a child and attaches to it for self - debugging. PureBasic DebugBlocker () function, creates a copy of the currently running Any queries about the code please comment below. Compile (or run one of the attached executables in the archive) and click on the "CLICK ME!" button to create a duplicate process being self-debugged. Here is a simple example in PureBasic code for using a self-debugger, commonly referred to as Debug Blocker. This is a repost from the "PureBasic Adventures" blog.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |