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

Commit efb371b

Browse files
authored
Merge pull request #19 from chcg/x64_fix
fix for issue X64 pointer arithmetic issue #18
2 parents b813020 + 69f2d6c commit efb371b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Visual Studio Project Template C#/PluginInfrastructure/NppPluginNETHelper.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ public void Add(FuncItem funcItem)
7474
RtlMoveMemory(newPointer, _nativePointer, oldSize);
7575
Marshal.FreeHGlobal(_nativePointer);
7676
}
77-
IntPtr ptrPosNewItem = (IntPtr)((int)newPointer + oldSize);
77+
IntPtr ptrPosNewItem = (IntPtr)(newPointer.ToInt64() + oldSize);
7878
byte[] aB = Encoding.Unicode.GetBytes(funcItem._itemName + "\0");
7979
Marshal.Copy(aB, 0, ptrPosNewItem, aB.Length);
80-
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 128);
80+
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 128);
8181
IntPtr p = (funcItem._pFunc != null) ? Marshal.GetFunctionPointerForDelegate(funcItem._pFunc) : IntPtr.Zero;
8282
Marshal.WriteIntPtr(ptrPosNewItem, p);
83-
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + IntPtr.Size);
83+
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + IntPtr.Size);
8484
Marshal.WriteInt32(ptrPosNewItem, funcItem._cmdID);
85-
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 4);
85+
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 4);
8686
Marshal.WriteInt32(ptrPosNewItem, Convert.ToInt32(funcItem._init2Check));
87-
ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 4);
87+
ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 4);
8888
if (funcItem._pShKey._key != 0)
8989
{
9090
IntPtr newShortCutKey = Marshal.AllocHGlobal(4);
@@ -103,15 +103,15 @@ public void RefreshItems()
103103
{
104104
FuncItem updatedItem = new FuncItem();
105105
updatedItem._itemName = _funcItems[i]._itemName;
106-
ptrPosItem = (IntPtr)((int)ptrPosItem + 128);
106+
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 128);
107107
updatedItem._pFunc = _funcItems[i]._pFunc;
108-
ptrPosItem = (IntPtr)((int)ptrPosItem + IntPtr.Size);
108+
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + IntPtr.Size);
109109
updatedItem._cmdID = Marshal.ReadInt32(ptrPosItem);
110-
ptrPosItem = (IntPtr)((int)ptrPosItem + 4);
110+
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 4);
111111
updatedItem._init2Check = _funcItems[i]._init2Check;
112-
ptrPosItem = (IntPtr)((int)ptrPosItem + 4);
112+
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 4);
113113
updatedItem._pShKey = _funcItems[i]._pShKey;
114-
ptrPosItem = (IntPtr)((int)ptrPosItem + IntPtr.Size);
114+
ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + IntPtr.Size);
115115

116116
_funcItems[i] = updatedItem;
117117
}

0 commit comments

Comments
 (0)