Fix some places using 'int' instead of IntPtr. (#828)

This commit is contained in:
J.D. Purcell 2017-04-08 18:36:29 -04:00
parent b63aede96c
commit a786f73154
6 changed files with 25 additions and 28 deletions

View File

@ -360,15 +360,13 @@ namespace BizHawk.Client.EmuHawk
ret.codec = Win32.decode_mmioFOURCC(opts.fccHandler);
ret.Format = new byte[opts.cbFormat];
ret.Parms = new byte[opts.cbParms];
if(opts.lpFormat != 0) Marshal.Copy(new IntPtr(opts.lpFormat), ret.Format, 0, opts.cbFormat);
if (opts.lpParms != 0) Marshal.Copy(new IntPtr(opts.lpParms), ret.Parms, 0, opts.cbParms);
if (opts.lpFormat != IntPtr.Zero) Marshal.Copy(opts.lpFormat, ret.Format, 0, opts.cbFormat);
if (opts.lpParms != IntPtr.Zero) Marshal.Copy(opts.lpParms, ret.Parms, 0, opts.cbParms);
return ret;
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool HeapFree(IntPtr hHeap, uint dwFlags, int lpMem);
public static extern bool HeapFree(IntPtr hHeap, uint dwFlags, IntPtr lpMem);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetProcessHeap();
[DllImport("kernel32.dll", SetLastError = false)]
@ -377,25 +375,24 @@ namespace BizHawk.Client.EmuHawk
public static void DeallocateAVICOMPRESSOPTIONS(ref Win32.AVICOMPRESSOPTIONS opts)
{
//test: increase stability by never freeing anything, ever
//if (opts.lpParms != 0) CodecToken.HeapFree(CodecToken.GetProcessHeap(), 0, opts.lpParms);
//if (opts.lpFormat != 0) CodecToken.HeapFree(CodecToken.GetProcessHeap(), 0, opts.lpFormat);
opts.lpParms = 0;
opts.lpFormat = 0;
//if (opts.lpParms != IntPtr.Zero) CodecToken.HeapFree(CodecToken.GetProcessHeap(), 0, opts.lpParms);
//if (opts.lpFormat != IntPtr.Zero) CodecToken.HeapFree(CodecToken.GetProcessHeap(), 0, opts.lpFormat);
opts.lpParms = IntPtr.Zero;
opts.lpFormat = IntPtr.Zero;
}
public void AllocateToAVICOMPRESSOPTIONS(ref Win32.AVICOMPRESSOPTIONS opts)
{
opts = comprOptions;
if (opts.cbParms != 0)
{
opts.lpParms = HeapAlloc(GetProcessHeap(), 0, opts.cbParms).ToInt32();
Marshal.Copy(Parms, 0, new IntPtr(opts.lpParms), opts.cbParms);
opts.lpParms = HeapAlloc(GetProcessHeap(), 0, opts.cbParms);
Marshal.Copy(Parms, 0, opts.lpParms, opts.cbParms);
}
if (opts.cbFormat != 0)
{
opts.lpFormat = HeapAlloc(GetProcessHeap(), 0, opts.cbFormat).ToInt32();
Marshal.Copy(Format, 0, new IntPtr(opts.lpFormat), opts.cbFormat);
opts.lpFormat = HeapAlloc(GetProcessHeap(), 0, opts.cbFormat);
Marshal.Copy(Format, 0, opts.lpFormat, opts.cbFormat);
}
}

View File

@ -77,7 +77,7 @@ namespace BizHawk.Client.EmuHawk
case 1:
{
IntPtr str = Marshal.StringToHGlobalUni(SelectedPath);
Win32.SendMessage(hwnd, (0x400 + 103), 1, str.ToInt32());
Win32.SendMessage(hwnd, (0x400 + 103), (IntPtr)1, str);
Marshal.FreeHGlobal(str);
break;
}

View File

@ -499,8 +499,8 @@ namespace BizHawk.Client.EmuHawk
Win32.SendMessage(
this.Handle,
(int)ListViewMessages.LVM_SETITEMSTATE,
index,
ptrItem.ToInt32());
(IntPtr)index,
ptrItem);
}
catch (Exception ex)
{
@ -524,8 +524,8 @@ namespace BizHawk.Client.EmuHawk
Win32.SendMessage(
this.Handle,
(int)ListViewMessages.LVM_SETITEMCOUNT,
this._itemCount,
0);
(IntPtr)this._itemCount,
IntPtr.Zero);
}
protected void OnDispInfoNotice(ref Message m, bool useAnsi)
@ -749,14 +749,14 @@ namespace BizHawk.Client.EmuHawk
lvhti.Point.X = x;
lvhti.Point.Y = y;
Marshal.StructureToPtr(lvhti, ptrlvhti, true);
int z = Win32.SendMessage(this.Handle, (int)ListViewMessages.LVM_HITTEST, 0, ptrlvhti.ToInt32());
int z = (int)Win32.SendMessage(this.Handle, (int)ListViewMessages.LVM_HITTEST, (IntPtr)0, ptrlvhti);
Marshal.PtrToStructure(ptrlvhti, lvhti);
return z;
}
public void ensureVisible(int index)
{
Win32.SendMessage(Handle, (int)ListViewMessages.LVM_ENSUREVISIBLE, index, 1);
Win32.SendMessage(Handle, (int)ListViewMessages.LVM_ENSUREVISIBLE, (IntPtr)index, (IntPtr)1);
}
public void ensureVisible()

View File

@ -311,9 +311,9 @@ namespace BizHawk.Client.EmuHawk
public int dwQuality;
public int dwBytesPerSecond;
public int dwFlags;
public int lpFormat;
public IntPtr lpFormat;
public int cbFormat;
public int lpParms;
public IntPtr lpParms;
public int cbParms;
public int dwInterleaveEvery;
}
@ -472,7 +472,7 @@ namespace BizHawk.Client.EmuHawk
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
[DllImport("Kernel32.dll", EntryPoint = "RtlZeroMemory", SetLastError = false)]
public static extern void ZeroMemory(IntPtr dest, uint size);

View File

@ -159,8 +159,8 @@ namespace BizHawk.Client.EmuHawk
if (Win32.AllocConsole())
{
//set icons for the console so we can tell them apart from the main window
Win32.SendMessage(Win32.GetConsoleWindow(), 0x0080/*WM_SETICON*/, 0/*ICON_SMALL*/, Properties.Resources.console16x16.GetHicon().ToInt32());
Win32.SendMessage(Win32.GetConsoleWindow(), 0x0080/*WM_SETICON*/, 1/*ICON_LARGE*/, Properties.Resources.console32x32.GetHicon().ToInt32());
Win32.SendMessage(Win32.GetConsoleWindow(), 0x0080/*WM_SETICON*/, (IntPtr)0/*ICON_SMALL*/, Properties.Resources.console16x16.GetHicon());
Win32.SendMessage(Win32.GetConsoleWindow(), 0x0080/*WM_SETICON*/, (IntPtr)1/*ICON_LARGE*/, Properties.Resources.console32x32.GetHicon());
hasConsole = true;
}
else

View File

@ -892,7 +892,7 @@ namespace BizHawk.Client.EmuHawk
{
groupFreeze.SuspendLayout();
Win32.SendMessage(groupFreeze.Handle, 11, 0, 0); //WM_SETREDRAW false
Win32.SendMessage(groupFreeze.Handle, 11, (IntPtr)0, IntPtr.Zero); //WM_SETREDRAW false
var tp = tabctrlDetails.SelectedTab;
@ -912,7 +912,7 @@ namespace BizHawk.Client.EmuHawk
groupFreeze.ResumeLayout();
Win32.SendMessage(groupFreeze.Handle, 11, 1, 0); //WM_SETREDRAW true
Win32.SendMessage(groupFreeze.Handle, 11, (IntPtr)1, IntPtr.Zero); //WM_SETREDRAW true
groupFreeze.Refresh();
}