Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed OverflowException when a dialog template contains a SysListView32 control #41

Merged
merged 1 commit into from Jul 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@

* [#40](https://github.com/dblock/resourcelib/pull/40): Added `Resource.Save(string filename, IEnumerable<Resource> resources)` for saving multiple resources in one batch - [@thoemmi](https://github.com/thoemmi).

**Bugs**

* [#41](https://github.com/dblock/resourcelib/pull/41): Fixed `OverflowException` when a dialog template contains a `SysListView32` control - [@thoemmi](https://github.com/thoemmi).

### 1.5 (3/28/2016)

**Misc**
Expand Down
20 changes: 12 additions & 8 deletions Source/ResourceLib/DialogExTemplateControl.cs
Expand Up @@ -165,17 +165,21 @@ public override string ToString()
StringBuilder sb = new StringBuilder();

sb.AppendFormat("{0} \"{1}\" {2}, {3}, {4}, {5}, {6}, {7}, {8}",
ControlClass, CaptionId, Id, ControlClass, x, y, cx, cy,
ControlClassId, CaptionId, Id, ControlClassId, x, y, cx, cy,
DialogTemplateUtil.StyleToString<User32.WindowStyles, User32.StaticControlStyles>(Style, ExtendedStyle));

switch (ControlClass)
if (ControlClassId.IsIntResource())
{
case User32.DialogItemClass.Button:
sb.AppendFormat("| {0}", (User32.ButtonControlStyles)(Style & 0xFFFF));
break;
case User32.DialogItemClass.Edit:
sb.AppendFormat("| {0}", DialogTemplateUtil.StyleToString<User32.EditControlStyles>(Style & 0xFFFF));
break;
switch (ControlClass)
{
case User32.DialogItemClass.Button:
sb.AppendFormat("| {0}", (User32.ButtonControlStyles) (Style & 0xFFFF));
break;
case User32.DialogItemClass.Edit:
sb.AppendFormat("| {0}",
DialogTemplateUtil.StyleToString<User32.EditControlStyles>(Style & 0xFFFF));
break;
}
}

return sb.ToString();
Expand Down
Binary file modified Source/ResourceLibUnitTests/Binaries/custom.exe
Binary file not shown.
43 changes: 23 additions & 20 deletions Source/ResourceLibUnitTests/ResourceInfoTests.cs
Expand Up @@ -12,30 +12,33 @@ namespace Vestris.ResourceLibUnitTests
[TestFixture]
public class ResourceInfoTests
{
[Test]
public void TestLoad()
private static IEnumerable<string> TestFiles
{
Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));

string[] files =
get
{
// Path.Combine(Environment.SystemDirectory, "regedt32.exe"),
// Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "explorer.exe"),
Path.Combine(uriPath, "Binaries\\gutils.dll"),
Path.Combine(uriPath, "Binaries\\6to4svc.dll"),
Path.Combine(uriPath, "Binaries\\custom.exe"),
};
Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath));
string[] files =
{
// Path.Combine(Environment.SystemDirectory, "regedt32.exe"),
// Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "explorer.exe"),
Path.Combine(uriPath, "Binaries\\gutils.dll"),
Path.Combine(uriPath, "Binaries\\6to4svc.dll"),
Path.Combine(uriPath, "Binaries\\custom.exe"),
};
return files;
}
}

foreach (string filename in files)
[TestCaseSource("TestFiles")]
public void TestLoad(string filename)
{
Console.WriteLine(filename);
Assert.IsTrue(File.Exists(filename));
using (ResourceInfo vi = new ResourceInfo())
{
Console.WriteLine(filename);
Assert.IsTrue(File.Exists(filename));
using (ResourceInfo vi = new ResourceInfo())
{
vi.Load(filename);
DumpResource.Dump(vi);
}
vi.Load(filename);
DumpResource.Dump(vi);
}
}

Expand Down