ObjLoad causes problem

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
rodemp
Posts: 44
Joined: 15 Nov 2016, 00:28

ObjLoad causes problem

14 Feb 2019, 23:48

ObjLoad.JPG
ObjLoad.JPG (12.53 KiB) Viewed 665 times
I had trouble using the built-in ObjLoad and used the new ObjLoad library so it worked properly

But the compressed save file could not be loaded

+Fixed to load file compressed with UnZipRawMemory

https://www.autohotkey.com/boards/viewtopic.php?f=6&t=3573

Code: Select all

;ahk_h v2
ObjLoad(addr,objects:=0)
{
	if Type(addr)="string" ; FileRead Mode
	{
		if !FileExist(addr)
			return
		else
			v:=FileRead(addr,"RAW")
		if ErrorLevel||!sz:=FileGetSize(addr)
			return
		if UnZipRawMemory(&v, sz, unzip)
			addr:=&unzip
		else
			addr:=&v
	}
	obj:=[],end:=addr+8+(sz:=NumGet(addr,"Int64")),addr+=8,(!objects)?objects:={0:obj}:objects.Push(obj)
	While addr<end ; 9 = Int64 for size and Char for type
	{
		if NumGet(addr,"Char")=-12
			k:=objects[NumGet(addr+1,"Int64")],addr+=9
		else if NumGet(addr,"Char")=-11
			k:=ObjLoad(addr+1,objects),addr+=9+NumGet(addr+1,"Int64")
		else if NumGet(addr,"Char")=-10
			sz:=NumGet(addr+1,"Int64"),k:=StrGet(addr+9),addr+=sz+9
		else
			k:=NumGet(addr+1,SubStr("Char  UChar Short UShortInt   UInt  Int64 UInt64Double",(sz:=-NumGet(addr,"Char"))*6-5,6)),addr+=SubStr("112244888",sz,1)+1
		if NumGet(addr,"Char")=12
			obj[k]:=objects[NumGet(addr+1,"Int64")],addr+=9
		else if NumGet(addr,"Char")=11
			obj[k]:=ObjLoad(addr+1,objects),addr+=9+NumGet(addr+1,"Int64")
		else if NumGet(addr,"Char")=10
			obj[k]:=StrGet(addr+9),obj.SetCapacity(k,sz:=NumGet(addr+1,"Int64")),DllCall("RtlMoveMemory","PTR",obj.GetAddress(k),"PTR",addr+9,"PTR",sz),addr+=sz+9
		else
			obj[k]:=NumGet(addr+1,SubStr("Char  UChar Short UShortInt   UInt  Int64 UInt64Double",(sz:=NumGet(addr,"Char"))*6-5,6)),addr+=SubStr("112244888",sz,1)+1
	}
	return obj
}
HotKeyIt
Posts: 1870
Joined: 29 Sep 2013, 18:35
Contact:

Re: ObjLoad causes problem

15 Feb 2019, 02:48

Can you show the code/object that causes the Problem?
rodemp
Posts: 44
Joined: 15 Nov 2016, 00:28

Re: ObjLoad causes problem

15 Feb 2019, 03:10

HotKeyIt wrote:
15 Feb 2019, 02:48
Can you show the code/object that causes the Problem?
The code is too long, upload the file with the problem.
qqq.zip
(9.29 KiB) Downloaded 30 times

Code: Select all

time1:=A_TickCount
loadtemp:=ObjLoad("Scripts\qqq.bin")

MsgBox "time - " (A_TickCount-time1) " `n" loadtemp.maxindex() "/" loadtemp.1.slot.1.maxindex()
HotKeyIt
Posts: 1870
Joined: 29 Sep 2013, 18:35
Contact:

Re: ObjLoad causes problem

15 Feb 2019, 06:31

I will need ObjDump example too, can you try to reproduce it with a script?
As far as I can see the problem is a not valid object, probably an object without reference or a special type of an object, hope this helps you to narrow it down.

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 3 guests