Skip to content

Commit

Permalink
fix: Add file description and details to help prevent false positives.
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwmtr committed Oct 14, 2024
1 parent a39aac5 commit 0fd35ad
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 13 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,18 @@ if (GITHUB_ACTION_BUILD)
message("${GITHUB_ACTION_BUILD}")
endif()

# find_program(WINDRES windres)
# if (WINDRES)
# add_custom_command(
# OUTPUT ${CMAKE_BINARY_DIR}/version.o
# COMMAND ${WINDRES} -i ${CMAKE_SOURCE_DIR}/scripts/version.rc -o ${CMAKE_BINARY_DIR}/version.o
# DEPENDS ${CMAKE_SOURCE_DIR}/scripts/version.rc
# )

# add_custom_target(resource DEPENDS ${CMAKE_BINARY_DIR}/version.o)
# add_dependencies(Millennium resource)
# target_link_libraries(Millennium ${CMAKE_BINARY_DIR}/version.o)
# endif()
find_program(WINDRES windres)
if (WINDRES)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/version.o
COMMAND ${WINDRES} -i ${CMAKE_SOURCE_DIR}/scripts/version.rc -o ${CMAKE_BINARY_DIR}/version.o
DEPENDS ${CMAKE_SOURCE_DIR}/scripts/version.rc
)

add_custom_target(resource DEPENDS ${CMAKE_BINARY_DIR}/version.o)
add_dependencies(Millennium resource)
target_link_libraries(Millennium ${CMAKE_BINARY_DIR}/version.o)
endif()

target_link_libraries(Millennium CURL::libcurl unofficial::minizip::minizip)

Expand Down
56 changes: 56 additions & 0 deletions scripts/crash_browser.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Define the URL to fetch the JSON data
$versionUrl = "http://localhost:8080/json/version"

# Fetch the JSON data from the version URL
try {
$jsonResponse = Invoke-RestMethod -Uri $versionUrl -Method Get
} catch {
Write-Host "Failed to fetch JSON from $versionUrl" -ForegroundColor Red
exit 1
}

# Extract the webSocketDebuggerUrl from the JSON
$webSocketDebuggerUrl = $jsonResponse.webSocketDebuggerUrl

if (-not $webSocketDebuggerUrl) {
Write-Host "webSocketDebuggerUrl not found" -ForegroundColor Red
exit 1
}

Write-Host "WebSocket Debugger URL: $webSocketDebuggerUrl"

# Open a WebSocket connection
$socket = New-Object System.Net.WebSockets.ClientWebSocket
$uri = New-Object Uri($webSocketDebuggerUrl)

try {
$socket.ConnectAsync($uri, [System.Threading.CancellationToken]::None).Wait()
Write-Host "Connected to WebSocket"
} catch {
Write-Host "Failed to connect to WebSocket" -ForegroundColor Red
exit 1
}

# Prepare the message to crash the browser
$crashMessage = @{
id = 443300
method = "Browser.crash"
}

# Convert the crash message to JSON
$jsonCrashMessage = $crashMessage | ConvertTo-Json

# Send the crash message via the WebSocket
$buffer = [System.Text.Encoding]::UTF8.GetBytes($jsonCrashMessage)
$bufferSegment = New-Object 'ArraySegment[Byte]' $buffer, 0, $buffer.Length

try {
$socket.SendAsync($bufferSegment, [System.Net.WebSockets.WebSocketMessageType]::Text, $true, [System.Threading.CancellationToken]::None).Wait()
Write-Host "Crash message sent"
} catch {
Write-Host "Failed to send message over WebSocket" -ForegroundColor Red
}

# Close the WebSocket connection
$socket.CloseAsync([System.Net.WebSockets.WebSocketCloseStatus]::NormalClosure, "Closing", [System.Threading.CancellationToken]::None).Wait()
Write-Host "WebSocket connection closed"
2 changes: 1 addition & 1 deletion src/core/co_initialize/co_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void OnBackendLoad(uint16_t ftpPort, uint16_t ipcPort)
JavaScript::SharedJSMessageEmitter::InstanceRef().OnMessage("msg",
// capture the shared pointers by copy, as to gain ownership && prevent premature deallocation
[hasUnpausedDebuggerPtr = hasUnpausedDebugger, hasScriptIdentifierPtr = hasScriptIdentifier]
(const nlohmann::json& eventMessage, int listenerId)
(const nlohmann::json eventMessage, int listenerId)
{
try
{
Expand Down
6 changes: 6 additions & 0 deletions src/core/co_initialize/events.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ void CoInitializer::BackendCallbacks::RegisterForLoad(EventCallback callback)
Logger.Log("Registering for load event @ {}", (void*)&callback);
listeners[ON_BACKEND_READY_EVENT].push_back(callback);

if (this->EvaluateBackendStatus())
{
callback();
return;
}

if (isReadyForCallback)
{
Logger.Log("Force firing [{}] callback as the target event was already called.", __FUNCTION__);
Expand Down

0 comments on commit 0fd35ad

Please sign in to comment.