Fix invalid memory access in capture.dll

This commit is contained in:
David Vogel 2024-02-08 16:12:55 +01:00
parent dddaad938f
commit 9cfb01187c
2 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,8 @@
; This software is released under the MIT License. ; This software is released under the MIT License.
; https://opensource.org/licenses/MIT ; https://opensource.org/licenses/MIT
EnableExplicit
UsePNGImageEncoder() UsePNGImageEncoder()
Declare Worker(*Dummy) Declare Worker(*Dummy)
@ -26,6 +28,8 @@ Structure WorkerInfo
workerNumber.i workerNumber.i
EndStructure EndStructure
#Workers = 8
; Returns the size of the main OpenGL rendering output. ; Returns the size of the main OpenGL rendering output.
ProcedureDLL GetGLViewportSize(*dims.GLViewportDims) ProcedureDLL GetGLViewportSize(*dims.GLViewportDims)
If Not *dims If Not *dims
@ -61,16 +65,16 @@ ProcedureDLL AttachProcess(Instance)
CreateDirectory("mods/noita-mapcap/output/") CreateDirectory("mods/noita-mapcap/output/")
Static Workers = 8 Static Dim WorkerInfos.WorkerInfo(#Workers-1)
Dim WorkerInfos.WorkerInfo(Workers-1) Protected i
For i = 0 To Workers-1 For i = 0 To #Workers-1
WorkerInfos(i)\workerNumber = i WorkerInfos(i)\workerNumber = i
CreateThread(@Worker(), @WorkerInfos(i)) CreateThread(@Worker(), @WorkerInfos(i))
Next Next
EndProcedure EndProcedure
Procedure Worker(*workerInfo.WorkerInfo) Procedure Worker(*workerInfo.WorkerInfo)
Protected img, x, y Protected img, x, y, sx, sy
Repeat Repeat
WaitSemaphore(Semaphore) WaitSemaphore(Semaphore)
@ -110,6 +114,8 @@ ProcedureDLL Capture(*capRect.RECT, x.l, y.l, sx.l, sy.l)
ProcedureReturn #False ProcedureReturn #False
EndIf EndIf
Protected imageID, hDC, *pixelBuffer
; Limit the desired capture area to the actual client area of the viewport. ; Limit the desired capture area to the actual client area of the viewport.
If *capRect\left < 0 : *capRect\left = 0 : EndIf If *capRect\left < 0 : *capRect\left = 0 : EndIf
If *capRect\top < 0 : *capRect\top = 0 : EndIf If *capRect\top < 0 : *capRect\top = 0 : EndIf
@ -182,8 +188,8 @@ EndProcedure
; IDE Options = PureBasic 6.04 LTS (Windows - x64) ; IDE Options = PureBasic 6.04 LTS (Windows - x64)
; ExecutableFormat = Shared dll ; ExecutableFormat = Shared dll
; CursorPosition = 94 ; CursorPosition = 116
; FirstLine = 51 ; FirstLine = 99
; Folding = - ; Folding = -
; Optimizer ; Optimizer
; EnableThread ; EnableThread

Binary file not shown.