GW2RegisterOutputMemory
ฟังก์ชัน GW2RegisterOutputMemory ลงทะเบียนตำแหน่งหน่วยความจำสำหรับวางไฟล์ที่ถูกจัดการซึ่งสร้างโดย Glasswall ให้กับ session การใช้ฟังก์ชันนี้จะเปิดใช้งาน Manage & Protect Process Mode สำหรับ session.
- C++
- C#
- Java
- Python
- JavaScript
สรุป
สำหรับ session session ฟังก์ชัน GW2RegisterOutputMemory จะลงทะเบียนตำแหน่งที่จะวางเนื้อหาที่ถูกจัดการ และตำแหน่งที่จะวางขนาดเป็นไบต์ของเนื้อหาที่ถูกจัดการ พอยน์เตอร์ไปยังเนื้อหาไฟล์ที่ถูกจัดการจะถูกวางไว้ในอ็อบเจ็กต์ที่ outputBuffer ชี้ไป และขนาดเป็นไบต์ของข้อมูลที่ถูกจัดการจะถูกวางไว้ในอ็อบเจ็กต์ size_t ที่ outputLength ชี้ไป เนื้อหาไฟล์ที่ถูกจัดการจะถูกลบเมื่อปิด session โดยใช้ GW2CloseSession การใช้ฟังก์ชันนี้จะเปิดใช้งาน Manage and Protect Process Mode สำหรับ session.
#include "glasswall.core2.api.h"
int GW2RegisterOutputMemory(Session session, char **outputBuffer, size_t *outputLength);
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
ตัวอย่าง
#include "glasswall.core2.api.h"
HANDLE session = GW2OpenSession();
char *managed_content = NULL;
size_t size = 0;
if (!session)
/* deal with error */
else
{
if (GW2RegisterOutputMemory(session, &managed_content, &size) < 0)
/* deal with error */
else
/* continue processing */
...
}
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
else
/* managed file content has been deleted */
สรุป
public int RegisterOutputMemory(
int session,
out IntPtr outputBufferPtr,
ref UIntPtr outputBufferLengthPtr)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
import com.glasswall.core2javabridge.*;
public int GW2RegisterOutputMemory(int session) throws GlasswallException
คำอธิบาย
ฟังก์ชัน GW2RegisterOutputMemory ลงทะเบียนบัฟเฟอร์หน่วยความจำเพื่อใช้เป็นเอาต์พุตสำหรับไฟล์เอาต์พุตของ session ที่ระบุโดย session.
คุณจะต้องเรียก GetOutputBuffer หลังจากเรียก GW2RunSession แล้ว เพื่อดึงไฟล์เอาต์พุตกลับมา.
ส่งกลับ
ฟังก์ชัน GW2RegisterOutputMemory ส่งคืนค่า enumeration GW2_RetStatus ที่แปลงเป็น int ค่าเป็นลบหากเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types.
ระบบจะโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง
เรื่องย่อ - ดึงข้อมูล
import com.glasswall.core2javabridge.*;
public byte[] GetOutputBuffer(int session) throws GlasswallException
คำอธิบาย
ฟังก์ชัน GetOutputBuffer ดึงข้อมูลบัฟเฟอร์เอาต์พุตที่เชื่อมโยงกับเซสชันที่ระบุโดย session.
ส่งกลับ
ฟังก์ชัน GetOutputBuffer จะส่งกลับ byte[] ที่มีไฟล์เอาต์พุตอยู่ภายใน ค่านี้จะเป็น null หากยังไม่ได้เรียก GW2RegisterOutputMemory และ GW2RunSession หรือหากไฟล์ไม่เป็นไปตามข้อกำหนด.
ระบบจะโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง
สรุป
ลงทะเบียนไฟล์เอาต์พุตสำหรับเซสชันที่กำหนด หาก output_file เป็น None ไฟล์จะถูกส่งกลับเป็นแอตทริบิวต์ 'buffer' และ 'buffer_length'
def register_output(self, session, output_file: Optional[str] = None):
""" Register an output file for the given session. If output_file is None the file will be returned as 'buffer' and 'buffer_length' attributes.
Args:
session (int): The session integer.
output_file (Optional[str]): If specified, during run session the file will be written to output_file, otherwise the file will be written to the glasswall.GwReturnObj 'buffer' and 'buffer_length' attributes.
Returns:
gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attribute 'status' indicating the result of the function call. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size.
"""
ส่งกลับ
gw_return_object (glasswall.GwReturnObj): อินสแตนซ์ GwReturnObj ที่มีแอตทริบิวต์ 'status' ระบุผลลัพธ์ของการเรียกใช้ฟังก์ชัน หาก output_file เป็น None (โหมดหน่วยความจำ) จะมี 'buffer' และ 'buffer_length' รวมอยู่ด้วย ซึ่งประกอบด้วยเนื้อหาไฟล์และขนาดไฟล์
แอตทริบิวต์ status เป็นค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงความล้มเหลว
สรุป
ฟังก์ชันนี้ใช้ลงทะเบียนตำแหน่งที่จะวางเนื้อหาที่จัดการแล้ว และตำแหน่งที่จะวางตัวแปรขนาดของเนื้อหานั้น.
/**
* @param {number} session The ID of the session.
* @param {string} outputBuffer The specified output path. Must be different to the specified input file path.
* @param {string} outputLength The size of the file buffer
*/
GW2RegisterOutputMemory(
session,
outputBuffer,
outputLength)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว