/[gr2lib]/trunk/gr2lib/core/coreclasses/header/granny_reference.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/coreclasses/header/granny_reference.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 94 - (show annotations) (download)
Sat Jul 17 05:09:42 2010 UTC (9 years, 6 months ago) by william
File size: 2423 byte(s)
add support for getting access to the Granny2 Header

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using gr2lib.core.interfaces;
6 using System.Diagnostics;
7 using gr2lib.core.helpers;
8
9 namespace gr2lib.core.coreclasses.header
10 {
11 public class granny_reference : igranny_reference
12 {
13
14 public granny_reference()
15 {
16 this.SectionIndex = 0;
17 this.Offset = 0;
18 }
19 internal static granny_reference ReadFromMemory(IntPtr pointer)
20 {
21 try
22 {
23 if (pointer == IntPtr.Zero) return null;
24 gr2lib.core.coretypes.native.granny_grn_reference native = Helpers.ReadFromMemory<gr2lib.core.coretypes.native.granny_grn_reference>(pointer);
25 granny_reference managed = ReadFromNative(native);
26 managed.NativePointer = pointer;
27 return managed;
28 }
29 catch (Exception ex)
30 {
31 StackTrace st = new StackTrace(true);
32 Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
33 return default(granny_reference);
34 }
35 }
36 internal static granny_reference ReadFromNative(gr2lib.core.coretypes.native.granny_grn_reference native)
37 {
38 try
39 {
40 granny_reference managed = new granny_reference();
41 //process reference
42 managed.SectionIndex = native.SectionIndex;
43 managed.Offset = native.Offset;
44 return managed;
45 }
46 catch (Exception ex)
47 {
48 StackTrace st = new StackTrace(true);
49 Console.WriteLine(st.ToString() + "\n\n" + "Stack Trace: \n" + ex.ToString());
50 return default(granny_reference);
51 }
52 }
53
54 #region INativePointer Members
55 private IntPtr _NativePointer;
56 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
57 #endregion
58
59 #region igranny_reference members
60 private Int32 _SectionIndex;
61 private Int32 _Offset;
62
63 public Int32 SectionIndex { get { return _SectionIndex; } set { _SectionIndex = value; } }
64 public Int32 Offset { get { return _Offset; } set { _Offset = value; } }
65 #endregion
66 }
67 }

  ViewVC Help
Powered by ViewVC 1.1.22