AllocateMemory() 공개 메소드

Allocates memory of specified type on the xbox.
public AllocateMemory ( AllocationType type, uint size ) : uint
type AllocationType
size uint
리턴 uint
예제 #1
0
        public static bool RunModule(Xbox xbox, string module_path, ref uint base_address,
                                     out uint entry_point, out uint exit_address, out string error_details)
        {
            entry_point   = exit_address = uint.MaxValue;
            error_details = null;
            LowLevel.HResult result;

            if (!File.Exists(module_path))
            {
                error_details = "File does not exist!";
                return(false);
            }

            byte[] rebased_module;
            result = RebasedModuleBufferAllocate(module_path, out rebased_module, out error_details);

            if (result == LowLevel.HResult.Success)
            {
                try { base_address = xbox.AllocateMemory((uint)rebased_module.Length); }
                catch (Exception ex)
                {
                    result        = LowLevel.HResult.Unexpected;
                    error_details = ex.ToString();
                }

                entry_point = base_address;
                try { result = RebaseModule(xbox, module_path, rebased_module, ref entry_point); }
                catch (Exception ex)
                {
                    result        = LowLevel.HResult.Unexpected;
                    error_details = ex.ToString();
                }
                entry_point += base_address;

                if (result == LowLevel.HResult.Success)
                {
                    xbox.Pause();
                    xbox.SetMemory(base_address, rebased_module);
                    exit_address = xbox.CallAddress(entry_point, true);
                    xbox.Continue();
                }
            }

            if (error_details == null)
            {
                error_details = GetResultString(result);
            }

            return(result == LowLevel.HResult.Success);
        }
예제 #2
0
		public static bool RunModule(Xbox xbox, string module_path, ref uint base_address, 
			out uint entry_point, out uint exit_address, out string error_details)
		{
			entry_point = exit_address = uint.MaxValue;
			error_details = null;
			LowLevel.HResult result;

			if (!File.Exists(module_path))
			{
				error_details = "File does not exist!";
				return false;
			}

			byte[] rebased_module;
			result = RebasedModuleBufferAllocate(module_path, out rebased_module, out error_details);

			if (result == LowLevel.HResult.Success)
			{
				try { base_address = xbox.AllocateMemory((uint)rebased_module.Length); }
				catch (Exception ex)
				{
					result = LowLevel.HResult.Unexpected;
					error_details = ex.ToString();
				}

				entry_point = base_address;
				try { result = RebaseModule(xbox, module_path, rebased_module, ref entry_point); }
				catch (Exception ex)
				{
					result = LowLevel.HResult.Unexpected;
					error_details = ex.ToString();
				}
				entry_point += base_address;

				if (result == LowLevel.HResult.Success)
				{
					xbox.Pause();
					xbox.SetMemory(base_address, rebased_module);
					exit_address = xbox.CallAddress(entry_point, true);
					xbox.Continue();
				}
			}

			if(error_details == null)
				error_details = GetResultString(result);

			return result == LowLevel.HResult.Success;
		}