Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

fix for issue X64 pointer arithmetic issue #18 #19

Merged
merged 1 commit into from
Nov 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ public void Add(FuncItem funcItem)
RtlMoveMemory(newPointer, _nativePointer, oldSize);
Marshal.FreeHGlobal(_nativePointer);
}
IntPtr ptrPosNewItem = (IntPtr)((int)newPointer + oldSize);
IntPtr ptrPosNewItem = (IntPtr)(newPointer.ToInt64() + oldSize);
byte[] aB = Encoding.Unicode.GetBytes(funcItem._itemName + "\0");
Marshal.Copy(aB, 0, ptrPosNewItem, aB.Length);
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 128);
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 128);
IntPtr p = (funcItem._pFunc != null) ? Marshal.GetFunctionPointerForDelegate(funcItem._pFunc) : IntPtr.Zero;
Marshal.WriteIntPtr(ptrPosNewItem, p);
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + IntPtr.Size);
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + IntPtr.Size);
Marshal.WriteInt32(ptrPosNewItem, funcItem._cmdID);
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 4);
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 4);
Marshal.WriteInt32(ptrPosNewItem, Convert.ToInt32(funcItem._init2Check));
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 4);
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 4);
if (funcItem._pShKey._key != 0)
{
IntPtr newShortCutKey = Marshal.AllocHGlobal(4);
Expand All @@ -103,15 +103,15 @@ public void RefreshItems()
{
FuncItem updatedItem = new FuncItem();
updatedItem._itemName = _funcItems[i]._itemName;
ptrPosItem = (IntPtr)((int)ptrPosItem + 128);
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 128);
updatedItem._pFunc = _funcItems[i]._pFunc;
ptrPosItem = (IntPtr)((int)ptrPosItem + IntPtr.Size);
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + IntPtr.Size);
updatedItem._cmdID = Marshal.ReadInt32(ptrPosItem);
ptrPosItem = (IntPtr)((int)ptrPosItem + 4);
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 4);
updatedItem._init2Check = _funcItems[i]._init2Check;
ptrPosItem = (IntPtr)((int)ptrPosItem + 4);
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 4);
updatedItem._pShKey = _funcItems[i]._pShKey;
ptrPosItem = (IntPtr)((int)ptrPosItem + IntPtr.Size);
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + IntPtr.Size);

_funcItems[i] = updatedItem;
}
Expand Down