Skip to content

Commit bc297e6

Browse files
committed
Fixed a possible issue where we could possibly detect an invalid memory region.
1 parent 62f0f6a commit bc297e6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

source/modules/memory/windows.lua

+9-4
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ end
286286

287287
local regionptr = new("unsigned char*[1]", nil)
288288

289+
local NULL = cast("uint32_t", 0x00000000)
290+
289291
function MEMORY:findGamecubeRAMOffset()
290292
local info = MEMORY_BASIC_INFORMATION_PTR()[0]
291293

@@ -301,10 +303,13 @@ function MEMORY:findGamecubeRAMOffset()
301303
if psapi.QueryWorkingSetEx(self.process_handle, wsinfo, sizeof(wsinfo)) == 1 then
302304
local flags = tonumber(wsinfo.VirtualAttributes.Flags)
303305

304-
if band(flags, lshift(1, 0)) == 1 then -- Check if the Valid flag is set
305-
--log.debug("%08X %x", tonumber(cast("ULONG_PTR", info.BaseAddress)), tonumber(cast("ULONG_PTR", info.RegionSize)))
306-
self.dolphin_base_addr = cast("ULONG_PTR", info.BaseAddress)
307-
self.dolphin_addr_size = cast("ULONG_PTR", info.RegionSize)
306+
local base = cast("ULONG_PTR", info.BaseAddress)
307+
local region = cast("ULONG_PTR", info.RegionSize)
308+
309+
if band(flags, lshift(1, 0)) == 1 and cast("uint32_t", info.BaseAddress) ~= NULL then -- Check if the Valid flag is set
310+
--log.debug("%08X %x", tonumber(base), tonumber(region))
311+
self.dolphin_base_addr = base
312+
self.dolphin_addr_size = region
308313
return true
309314
end
310315
end

source/overlay/skins/default.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ function SKIN:Paint(controller)
221221
local angle = math.atan2(x, y)
222222
local mag = math.sqrt(x*x + y*y)
223223

224-
local far = mag * 12
225-
local near = mag * 20
224+
local far = mag * 12 -- Higher value = headed towards infinity
225+
local near = mag * 20 -- Higher value = more rotation into the horizon
226226

227227
-- Make the rectangle look like its fading into the horizon
228228

@@ -236,7 +236,7 @@ function SKIN:Paint(controller)
236236
-- Bottom right
237237
vertices[2][2] = near
238238

239-
local rotated = transformVertices(vertices, 64 + 22 + (40 * vx), 64 + 12 + (40 * vy), angle, 64, 64)
239+
local rotated = transformVertices(vertices, 64 + 22 + (44 * vx), 64 + 8 + (44 * vy), angle, 64, 64)
240240

241241
graphics.setColor(255, 255, 255, 255)
242242

0 commit comments

Comments
 (0)