Skip to content

Commit

Permalink
Merge pull request #18 from icnocop/master
Browse files Browse the repository at this point in the history
Fixed issue #10 - System.OverflowException: Arithmetic operation resulte...
  • Loading branch information
dblock committed May 12, 2014
2 parents 4e035f3 + 5ca037d commit f015f9c
Show file tree
Hide file tree
Showing 43 changed files with 94 additions and 94 deletions.
Binary file modified .nuget/nuget.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
### Next Release

* [#9](https://github.com/dblock/resourcelib/pull/9): Added a strong signature to the .NET assembly - [@dwmkerr](https://github.com/dwmkerr).
* [#10](https://github.com/dblock/resourcelib/issues/10): Fixed System.OverflowException: Arithmetic operation resulted in an overflow (64-bit systems) by replacing most calls to ToInt32 with ToInt64 - [@icnocop](https://github.com/icnocop).
* [#16](https://github.com/dblock/resourcelib/issues/16): Fixed NuGet error "Package restore is disabled by default." when building by updating to NuGet 2.8.1 - [@icnocop](https://github.com/icnocop).
* Including Vestris.ResourceLib.pdb and Vestris.ResourceLib.xml in release zip for documentation and easier debugging support - [@icnocop](https://github.com/icnocop).

### 1.4 (3/3/2013)

Expand Down
2 changes: 1 addition & 1 deletion ResourceLib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<Copy SourceFiles="CHANGELOG.md" DestinationFolder="$(ReleaseDir)" Condition="'$(Configuration)'=='Release'" />
<Copy SourceFiles="README.md" DestinationFolder="$(ReleaseDir)" Condition="'$(Configuration)'=='Release'" />
<Copy SourceFiles="LICENSE" DestinationFolder="$(ReleaseDir)" Condition="'$(Configuration)'=='Release'" />
<CreateItem Include="Source\**\$(Configuration)/Vestris.*.dll" Exclude="Source\**\$(Configuration)/Vestris.*UnitTests.dll">
<CreateItem Include="Source\**\$(Configuration)/Vestris.*.*" Exclude="Source\**\$(Configuration)/Vestris.*UnitTests.*">
<Output TaskParameter="Include" ItemName="BinaryFiles" />
</CreateItem>
<Copy SourceFiles="@(BinaryFiles)" DestinationFolder="$(ReleaseDir)\Bin" />
Expand Down
31 changes: 14 additions & 17 deletions ResourceLib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{D703E923
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{AD64D826-875E-44FB-8DC4-95E2D37CC0BE}"
ProjectSection(SolutionItems) = preProject
Documentation\ResourceLib.content = Documentation\ResourceLib.content
Documentation\ResourceLib.shfbproj = Documentation\ResourceLib.shfbproj
Documentation\WhatsNew.html = Documentation\WhatsNew.html
CHANGELOG.md = CHANGELOG.md
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Content", "Content", "{642C46FF-FC48-496B-9C03-E48B91A8EBAB}"
ProjectSection(SolutionItems) = preProject
Documentation\Content\AcceleratorResources.aml = Documentation\Content\AcceleratorResources.aml
Documentation\Content\BitmapResources.aml = Documentation\Content\BitmapResources.aml
Documentation\Content\CursorResources.aml = Documentation\Content\CursorResources.aml
Documentation\Content\DevContribute.aml = Documentation\Content\DevContribute.aml
Documentation\Content\DialogResources.aml = Documentation\Content\DialogResources.aml
Documentation\Content\FontResources.aml = Documentation\Content\FontResources.aml
Documentation\Content\GettingStarted.aml = Documentation\Content\GettingStarted.aml
Documentation\Content\IconResources.aml = Documentation\Content\IconResources.aml
Documentation\Content\License.aml = Documentation\Content\License.aml
Documentation\Content\Main.aml = Documentation\Content\Main.aml
Documentation\Content\ManifestResources.aml = Documentation\Content\ManifestResources.aml
Documentation\Content\MenuResources.aml = Documentation\Content\MenuResources.aml
Documentation\Content\StringResources.aml = Documentation\Content\StringResources.aml
Documentation\Content\VersionResources.aml = Documentation\Content\VersionResources.aml
Docs\Accelerator.md = Docs\Accelerator.md
Docs\Bitmap.md = Docs\Bitmap.md
Docs\Contributing.md = Docs\Contributing.md
Docs\Cursor.md = Docs\Cursor.md
Docs\Dialog.md = Docs\Dialog.md
Docs\Font.md = Docs\Font.md
Docs\Icon.md = Docs\Icon.md
Docs\Manifest.md = Docs\Manifest.md
Docs\Menu.md = Docs\Menu.md
Docs\String.md = Docs\String.md
Docs\Version.md = Docs\Version.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceLib", "Source\ResourceLib\ResourceLib.csproj", "{AC9AF16F-7BF8-4400-95DE-6BC6CA53181E}"
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/Accelerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal IntPtr Read(IntPtr lpRes)
_accel = (User32.ACCEL) Marshal.PtrToStructure(
lpRes, typeof(User32.ACCEL));

return new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_accel));
return new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_accel));
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/AcceleratorResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public AcceleratorResource(IntPtr hModule, IntPtr hResource, ResourceId type, Re
/// <returns>Address of the end of the accelerator table.</returns>
internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
{
int count = _size / Marshal.SizeOf(typeof(User32.ACCEL));
for (int i = 0; i < count; i++)
long count = _size / Marshal.SizeOf(typeof(User32.ACCEL));
for (long i = 0; i < count; i++)
{
Accelerator accelerator = new Accelerator();
lpRes = accelerator.Read(lpRes);
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/BitmapResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
byte[] data = new byte[_size];
Marshal.Copy(lpRes, data, 0, data.Length);
_bitmap = new DeviceIndependentBitmap(data);
return new IntPtr(lpRes.ToInt32() + _size);
return new IntPtr(lpRes.ToInt64() + _size);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/CursorResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public override void SaveIconTo(string filename)
internal override void ReadImage(IntPtr dibBits, UInt32 size)
{
_hotspotx = (UInt16) Marshal.ReadInt16(dibBits);
dibBits = new IntPtr(dibBits.ToInt32() + sizeof(UInt16));
dibBits = new IntPtr(dibBits.ToInt64() + sizeof(UInt16));
_hotspoty = (UInt16) Marshal.ReadInt16(dibBits);
dibBits = new IntPtr(dibBits.ToInt32() + sizeof(UInt16));
dibBits = new IntPtr(dibBits.ToInt64() + sizeof(UInt16));

base.ReadImage(dibBits, size - 2 * sizeof(UInt16));
}
Expand Down
10 changes: 5 additions & 5 deletions Source/ResourceLib/DialogExTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,23 @@ internal override IntPtr Read(IntPtr lpRes)
_header = (User32.DIALOGEXTEMPLATE)Marshal.PtrToStructure(
lpRes, typeof(User32.DIALOGEXTEMPLATE));

lpRes = base.Read(new IntPtr(lpRes.ToInt32() + 26)); // Marshal.SizeOf(_header)
lpRes = base.Read(new IntPtr(lpRes.ToInt64() + 26)); // Marshal.SizeOf(_header)

if ((Style & (uint)User32.DialogStyles.DS_SETFONT) > 0
|| (Style & (uint)User32.DialogStyles.DS_SHELLFONT) > 0)
{
// weight
Weight = (UInt16)Marshal.ReadInt16(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);
// italic
Italic = (Marshal.ReadByte(lpRes) > 0);
lpRes = new IntPtr(lpRes.ToInt32() + 1);
lpRes = new IntPtr(lpRes.ToInt64() + 1);
// character set
CharacterSet = Marshal.ReadByte(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + 1);
lpRes = new IntPtr(lpRes.ToInt64() + 1);
// typeface
TypeFace = Marshal.PtrToStringUni(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + (TypeFace.Length + 1) * Marshal.SystemDefaultCharSize);
lpRes = new IntPtr(lpRes.ToInt64() + (TypeFace.Length + 1) * Marshal.SystemDefaultCharSize);
}

return ReadControls(lpRes);
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/DialogExTemplateControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ internal override IntPtr Read(IntPtr lpRes)
_header = (User32.DIALOGEXITEMTEMPLATE)Marshal.PtrToStructure(
lpRes, typeof(User32.DIALOGEXITEMTEMPLATE));

lpRes = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header));
lpRes = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));
return base.Read(lpRes);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/DialogTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ internal override IntPtr Read(IntPtr lpRes)
_header = (User32.DIALOGTEMPLATE) Marshal.PtrToStructure(
lpRes, typeof(User32.DIALOGTEMPLATE));

lpRes = new IntPtr(lpRes.ToInt32() + 18); // Marshal.SizeOf(_header)
lpRes = new IntPtr(lpRes.ToInt64() + 18); // Marshal.SizeOf(_header)
lpRes = base.Read(lpRes);

if ((Style & (uint)User32.DialogStyles.DS_SETFONT) > 0
|| (Style & (uint)User32.DialogStyles.DS_SHELLFONT) > 0)
{
// typeface
TypeFace = Marshal.PtrToStringUni(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + (TypeFace.Length + 1) * Marshal.SystemDefaultCharSize);
lpRes = new IntPtr(lpRes.ToInt64() + (TypeFace.Length + 1) * Marshal.SystemDefaultCharSize);
}

return ReadControls(lpRes);
Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/DialogTemplateBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ internal virtual IntPtr Read(IntPtr lpRes)
lpRes = DialogTemplateUtil.ReadResourceId(lpRes, out _windowClassId);
// caption
Caption = Marshal.PtrToStringUni(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + (Caption.Length + 1) * Marshal.SystemDefaultCharSize);
lpRes = new IntPtr(lpRes.ToInt64() + (Caption.Length + 1) * Marshal.SystemDefaultCharSize);

if ((Style & (uint)User32.DialogStyles.DS_SETFONT) > 0
|| (Style & (uint)User32.DialogStyles.DS_SHELLFONT) > 0)
{
// point size
PointSize = (UInt16)Marshal.ReadInt16(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);
}

return lpRes;
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/DialogTemplateControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal override IntPtr Read(IntPtr lpRes)
_header = (User32.DIALOGITEMTEMPLATE)Marshal.PtrToStructure(
lpRes, typeof(User32.DIALOGITEMTEMPLATE));

lpRes = new IntPtr(lpRes.ToInt32() + 18); // Marshal.SizeOf(_header)
lpRes = new IntPtr(lpRes.ToInt64() + 18); // Marshal.SizeOf(_header)
lpRes = base.Read(lpRes);

return lpRes;
Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/DialogTemplateControlBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ internal virtual IntPtr Read(IntPtr lpRes)
switch ((UInt16)Marshal.ReadInt16(lpRes))
{
case 0x0000: // no data
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);
break;
default:
UInt16 size = (UInt16)Marshal.ReadInt16(lpRes);
_creationData = new byte[size];
Marshal.Copy(lpRes, _creationData, 0, _creationData.Length);
lpRes = new IntPtr(lpRes.ToInt32() + size);
lpRes = new IntPtr(lpRes.ToInt64() + size);
break;
}

Expand Down
8 changes: 4 additions & 4 deletions Source/ResourceLib/DialogTemplateUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ internal static IntPtr ReadResourceId(IntPtr lpRes, out ResourceId rc)
switch ((UInt16) Marshal.ReadInt16(lpRes))
{
case 0x0000: // no predefined resource
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);
break;
case 0xFFFF: // one additional element that specifies the ordinal value of the resource
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);
rc = new ResourceId((UInt16)Marshal.ReadInt16(lpRes));
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);
break;
default: // null-terminated Unicode string that specifies the name of the resource
rc = new ResourceId(Marshal.PtrToStringUni(lpRes));
lpRes = new IntPtr(lpRes.ToInt32() + (rc.Name.Length + 1) * Marshal.SystemDefaultCharSize);
lpRes = new IntPtr(lpRes.ToInt64() + (rc.Name.Length + 1) * Marshal.SystemDefaultCharSize);
break;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/DirectoryResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
_header = (Kernel32.GRPICONDIR)Marshal.PtrToStructure(
lpRes, typeof(Kernel32.GRPICONDIR));

IntPtr pEntry = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header));
IntPtr pEntry = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));

for (UInt16 i = 0; i < _header.wImageCount; i++)
{
Expand Down
8 changes: 4 additions & 4 deletions Source/ResourceLib/FontDirectoryEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ internal IntPtr Read(IntPtr lpRes)
IntPtr lpHead = lpRes;

_fontOrdinal = (UInt16) Marshal.ReadInt16(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);

_font = (User32.FONTDIRENTRY)Marshal.PtrToStructure(
lpRes, typeof(User32.FONTDIRENTRY));

lpRes = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_font));
lpRes = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_font));

_deviceName = Marshal.PtrToStringAnsi(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + _deviceName.Length + 1);
lpRes = new IntPtr(lpRes.ToInt64() + _deviceName.Length + 1);

_faceName = Marshal.PtrToStringAnsi(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + _faceName.Length + 1);
lpRes = new IntPtr(lpRes.ToInt64() + _faceName.Length + 1);

return lpRes;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/FontDirectoryResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
IntPtr lpHead = lpRes;

UInt16 count = (UInt16)Marshal.ReadInt16(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);

for (int i = 0; i < count; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/GenericResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
Marshal.Copy(lpRes, _data, 0, _data.Length);
}

return new IntPtr(lpRes.ToInt32() + _size);
return new IntPtr(lpRes.ToInt64() + _size);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/IconFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal IntPtr Read(IntPtr lpData)
_header = (Kernel32.FILEGRPICONDIR)Marshal.PtrToStructure(
lpData, typeof(Kernel32.FILEGRPICONDIR));

IntPtr lpEntry = new IntPtr(lpData.ToInt32() + Marshal.SizeOf(_header));
IntPtr lpEntry = new IntPtr(lpData.ToInt64() + Marshal.SizeOf(_header));

for (int i = 0; i < _header.wCount; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/IconFileIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ internal IntPtr Read(IntPtr lpData, IntPtr lpAllData)
_header = (Kernel32.FILEGRPICONDIRENTRY)Marshal.PtrToStructure(
lpData, typeof(Kernel32.FILEGRPICONDIRENTRY));

IntPtr lpImage = new IntPtr(lpAllData.ToInt32() + _header.dwFileOffset);
IntPtr lpImage = new IntPtr(lpAllData.ToInt64() + _header.dwFileOffset);
_image.Read(lpImage, _header.dwImageSize);

return new IntPtr(lpData.ToInt32() + Marshal.SizeOf(_header));
return new IntPtr(lpData.ToInt64() + Marshal.SizeOf(_header));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/IconImageResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)

ReadImage(dibBits, (UInt32) Kernel32.SizeofResource(hModule, hIconInfo));

return new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header));
return new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/ManifestResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
Marshal.Copy(lpRes, _data, 0, _data.Length);
}

return new IntPtr(lpRes.ToInt32() + _size);
return new IntPtr(lpRes.ToInt64() + _size);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/MenuExTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal override IntPtr Read(IntPtr lpRes)
_header = (User32.MENUEXTEMPLATE) Marshal.PtrToStructure(
lpRes, typeof(User32.MENUEXTEMPLATE));

IntPtr lpMenuItem = ResourceUtil.Align(lpRes.ToInt32()
IntPtr lpMenuItem = ResourceUtil.Align(lpRes.ToInt64()
+ Marshal.SizeOf(_header)
+ _header.wOffset);

Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/MenuExTemplateItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal virtual IntPtr Read(IntPtr lpRes)
_header = (User32.MENUEXITEMTEMPLATE) Marshal.PtrToStructure(
lpRes, typeof(User32.MENUEXITEMTEMPLATE));

lpRes = new IntPtr(lpRes.ToInt32()
lpRes = new IntPtr(lpRes.ToInt64()
+ Marshal.SizeOf(_header));

switch ((UInt32) Marshal.ReadInt32(lpRes))
Expand All @@ -54,7 +54,7 @@ internal virtual IntPtr Read(IntPtr lpRes)
break;
default:
_menuString = Marshal.PtrToStringUni(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() +
lpRes = new IntPtr(lpRes.ToInt64() +
(_menuString.Length + 1) * Marshal.SystemDefaultCharSize);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/MenuExTemplateItemCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal IntPtr Read(IntPtr lpRes)
{
while(true)
{
lpRes = ResourceUtil.Align(lpRes.ToInt32());
lpRes = ResourceUtil.Align(lpRes.ToInt64());

User32.MENUEXITEMTEMPLATE childItem = (User32.MENUEXITEMTEMPLATE)Marshal.PtrToStructure(
lpRes, typeof(User32.MENUEXITEMTEMPLATE));
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/MenuExTemplateItemPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal override IntPtr Read(IntPtr lpRes)

lpRes = ResourceUtil.Align(lpRes);
_dwHelpId = (UInt32) Marshal.ReadInt32(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + 4);
lpRes = new IntPtr(lpRes.ToInt64() + 4);

return _subMenuItems.Read(lpRes);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ResourceLib/MenuTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal override IntPtr Read(IntPtr lpRes)
_header = (User32.MENUTEMPLATE) Marshal.PtrToStructure(
lpRes, typeof(User32.MENUTEMPLATE));

IntPtr lpMenuItem = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header) + _header.wOffset);
IntPtr lpMenuItem = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header) + _header.wOffset);
return _menuItems.Read(lpMenuItem);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/MenuTemplateItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ internal virtual IntPtr Read(IntPtr lpRes)
switch ((UInt16) Marshal.ReadInt16(lpRes))
{
case 0:
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);
break;
default:
_menuString = Marshal.PtrToStringUni(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() +
lpRes = new IntPtr(lpRes.ToInt64() +
(_menuString.Length + 1) * Marshal.SystemDefaultCharSize);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/ResourceLib/MenuTemplateItemCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ internal override IntPtr Read(IntPtr lpRes)
_header = (User32.MENUITEMTEMPLATE)Marshal.PtrToStructure(
lpRes, typeof(User32.MENUITEMTEMPLATE));

lpRes = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header));
lpRes = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));

_menuId = (UInt16) Marshal.ReadInt16(lpRes);
lpRes = new IntPtr(lpRes.ToInt32() + 2);
lpRes = new IntPtr(lpRes.ToInt64() + 2);

lpRes = base.Read(lpRes);

Expand Down
Loading

0 comments on commit f015f9c

Please sign in to comment.