a lot of code that is not safe or cannot be compiled under 64

delphi package - easy access to kernel objects etc.
Post Reply
advwang
Posts: 11
Joined: Fri Mar 15, 2019 4:48 am

a lot of code that is not safe or cannot be compiled under 64

Post by advwang »

In madkernel, there is a lot of code that is not safe or cannot be compiled under 64

1.
T9xHandleTable = packed record
itemCount : integer;
items : array [0..maxInt shr 3 - 1] of T9xHandleItem;
end;

Compile under 64-bit, it will generate the error of data size over 2G

2.
function GetHandleTableNt : TNtHandleTable;
var c1 : cardinal;
p1 : pointer;
begin
result.ItemCount := 0;
result.Items := nil;
if @NtQuerySystemInformation = nil then
NtQuerySystemInformation := GetProcAddress(GetModuleHandle(ntdll), 'NtQuerySystemInformation');
dword(p1) := LocalAlloc(LPTR, 20);
try

Pointer size is 8byte under 64-bit, Cardinal() will cause the high 4byte of the pointer value to be lost

3.
windows.ZeroMemory(@tic, sizeOf(TTrayIconCommand2000Ex));
tic.main.size := sizeOf(TTrayIconCommand2000);
tic.main.flags := $80000037;
integer(tic.main.tip) := integer(ptic) + sizeOf(TTrayIconCommand2000);

Similarly, Integer() causes the high 4byte of the pointer value to be lost
madshi
Site Admin
Posts: 10414
Joined: Sun Mar 21, 2004 5:25 pm

Re: a lot of code that is not safe or cannot be compiled under 64

Post by madshi »

Yeah, there will be many more such code sections in madKernel. It was written at a time when there was no x64 Delphi yet (probably not even x64 Windows OSs, but I can't remember). It really needs a full x64 rework. Sadly, I'm notoriously busy these days, so it doesn't seem likely that this will happen any time soon... :(
Post Reply