+MmSafeCopyFromUser()
authorshort <>
Sun, 2 Feb 2003 19:07:28 +0000 (19:07 +0000)
committershort <>
Sun, 2 Feb 2003 19:07:28 +0000 (19:07 +0000)
src/libcaptive/mm/memsafe.c

index a2513d9..445679b 100644 (file)
 
 
 /**
+ * MmSafeCopyFromUser:
+ * @Dest: Destination memory area address.
+ * %NULL value is forbidden.
+ * @Src: Source memory area address.
+ * %NULL value is forbidden.
+ * @NumberOfBytes: Length of memory area.
+ *
+ * This function moves the data between two memory areas.
+ * Given memory areas must not overlap.
+ * libcaptive does not differentiate between user and kernel memory - this functions
+ * implements the simple memcpy() function.
+ * 
+ * Returns: %STATUS_SUCCESS if the memory was copied successfuly.
+ */
+NTSTATUS MmSafeCopyFromUser(PVOID Dest,PVOID Src,ULONG NumberOfBytes)
+{
+       g_return_val_if_fail(Dest!=NULL,STATUS_INVALID_PARAMETER);
+       g_return_val_if_fail(Dest+NumberOfBytes>=Dest,STATUS_INVALID_PARAMETER);
+       g_return_val_if_fail(Src!=NULL,STATUS_INVALID_PARAMETER);
+       g_return_val_if_fail(Src+NumberOfBytes>=Src,STATUS_INVALID_PARAMETER);
+       /* do not overlap: */
+       g_return_val_if_fail((Dest+NumberOfBytes<=Src || Dest>=Src+NumberOfBytes),STATUS_INVALID_PARAMETER);
+
+       memcpy(Dest,Src,NumberOfBytes);
+
+       return STATUS_SUCCESS;
+}
+
+
+/**
  * MmSafeCopyToUser:
  * @Dest: Destination memory area address.
  * %NULL value is forbidden.