本文整理汇总了C++中FreeBuf函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeBuf函数的具体用法?C++ FreeBuf怎么用?C++ FreeBuf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FreeBuf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CfgTest
void CfgTest()
{
#if 0
FOLDER *root;
BUF *b;
Debug("\nCFG Test Begin\n");
root = CfgCreateFolder(NULL, TAG_ROOT);
CfgTest2(root, 5);
b = CfgFolderToBufText(root);
//Print("%s\n", b->Buf);
SeekBuf(b, 0, 0);
CfgDeleteFolder(root);
DumpBuf(b, "test1.config");
root = CfgBufTextToFolder(b);
FreeBuf(b);
b = CfgFolderToBufText(root);
// Print("%s\n", b->Buf);
DumpBuf(b, "test2.config");
FreeBuf(b);
CfgSave(root, "test.txt");
CfgDeleteFolder(root);
Debug("\nCFG Test End\n");
#endif
}
示例2: StrToMac
// Convert the string to a MAC address
bool StrToMac(UCHAR *mac_address, char *str)
{
BUF *b;
// Validate arguments
if (mac_address == NULL || str == NULL)
{
return false;
}
b = StrToBin(str);
if (b == NULL)
{
return false;
}
if (b->Size != 6)
{
FreeBuf(b);
return false;
}
Copy(mac_address, b->Buf, 6);
FreeBuf(b);
return true;
}
示例3: ViExtractCabinetFile
// Extract the Cabinet file from the EXE file
bool ViExtractCabinetFile(char *exe, char *cab)
{
BUF *b;
// Validate arguments
if (exe == NULL || cab == NULL)
{
return false;
}
b = ViExtractResource(exe, RT_RCDATA, "CABINET");
if (b == NULL)
{
return false;
}
if (DumpBuf(b, cab) == false)
{
FreeBuf(b);
return false;
}
FreeBuf(b);
return true;
}
示例4: PackError
PACK *WpcCallEx(char *url, INTERNET_SETTING *setting, UINT timeout_connect, UINT timeout_comm,
char *function_name, PACK *pack, X *cert, K *key, void *sha1_cert_hash, bool *cancel, UINT max_recv_size,
char *additional_header_name, char *additional_header_value)
{
URL_DATA data;
BUF *b, *recv;
UINT error;
WPC_PACKET packet;
// Validate arguments
if (function_name == NULL || pack == NULL)
{
return PackError(ERR_INTERNAL_ERROR);
}
if (ParseUrl(&data, url, true, NULL) == false)
{
return PackError(ERR_INTERNAL_ERROR);
}
PackAddStr(pack, "function", function_name);
b = WpcGeneratePacket(pack, cert, key);
if (b == NULL)
{
return PackError(ERR_INTERNAL_ERROR);
}
SeekBuf(b, b->Size, 0);
WriteBufInt(b, 0);
SeekBuf(b, 0, 0);
if (IsEmptyStr(additional_header_name) == false && IsEmptyStr(additional_header_value) == false)
{
StrCpy(data.AdditionalHeaderName, sizeof(data.AdditionalHeaderName), additional_header_name);
StrCpy(data.AdditionalHeaderValue, sizeof(data.AdditionalHeaderValue), additional_header_value);
}
recv = HttpRequestEx(&data, setting, timeout_connect, timeout_comm, &error,
false, b->Buf, NULL, NULL, sha1_cert_hash, cancel, max_recv_size);
FreeBuf(b);
if (recv == NULL)
{
return PackError(error);
}
if (WpcParsePacket(&packet, recv) == false)
{
FreeBuf(recv);
return PackError(ERR_PROTOCOL_ERROR);
}
FreeBuf(recv);
FreeX(packet.Cert);
return packet.Pack;
}
示例5: SaveUnicodeCache
// Save the Unicode cache
void SaveUnicodeCache(wchar_t *strfilename, UINT strfilesize, UCHAR *hash)
{
UNICODE_CACHE c;
BUF *b;
UINT i;
IO *io;
wchar_t name[MAX_PATH];
UCHAR binhash[MD5_SIZE];
// Validate arguments
if (strfilename == NULL || hash == NULL)
{
return;
}
Zero(&c, sizeof(c));
UniToStr(c.StrFileName, sizeof(c.StrFileName), strfilename);
c.StrFileSize = strfilesize;
GetMachineName(c.MachineName, sizeof(c.MachineName));
c.OsType = GetOsInfo()->OsType;
Copy(c.hash, hash, MD5_SIZE);
#ifdef OS_UNIX
GetCurrentCharSet(c.CharSet, sizeof(c.CharSet));
#else // OS_UNIX
{
UINT id = MsGetThreadLocale();
Copy(c.CharSet, &id, sizeof(id));
}
#endif // OS_UNIX
b = NewBuf();
WriteBuf(b, &c, sizeof(c));
WriteBufInt(b, LIST_NUM(TableList));
for (i = 0;i < LIST_NUM(TableList);i++)
{
TABLE *t = LIST_DATA(TableList, i);
WriteBufInt(b, StrLen(t->name));
WriteBuf(b, t->name, StrLen(t->name));
WriteBufInt(b, StrLen(t->str));
WriteBuf(b, t->str, StrLen(t->str));
WriteBufInt(b, UniStrLen(t->unistr));
WriteBuf(b, t->unistr, UniStrLen(t->unistr) * sizeof(wchar_t));
}
Hash(binhash, b->Buf, b->Size, false);
WriteBuf(b, binhash, MD5_SIZE);
GenerateUnicodeCacheFileName(name, sizeof(name), strfilename, strfilesize, hash);
io = FileCreateW(name);
if (io != NULL)
{
SeekBuf(b, 0, 0);
BufToFile(io, b);
FileClose(io);
}
FreeBuf(b);
}
示例6: BM_Free
void BM_Free(void *hBuf, u32 ui32Flags)
{
struct BM_BUF *pBuf = (struct BM_BUF *)hBuf;
struct SYS_DATA *psSysData;
struct IMG_SYS_PHYADDR sHashAddr;
PVR_DPF(PVR_DBG_MESSAGE, "BM_Free (h=%08X)", hBuf);
PVR_ASSERT(pBuf != NULL);
if (pBuf == NULL) {
PVR_DPF(PVR_DBG_ERROR, "BM_Free: invalid parameter");
return;
}
if (SysAcquireData(&psSysData) != PVRSRV_OK)
return;
pBuf->ui32RefCount--;
if (pBuf->ui32RefCount == 0) {
struct BM_MAPPING *map = pBuf->pMapping;
struct BM_CONTEXT *ctx = map->pBMHeap->pBMContext;
if (map->eCpuMemoryOrigin == hm_wrapped ||
map->eCpuMemoryOrigin == hm_wrapped_virtaddr) {
sHashAddr = SysCpuPAddrToSysPAddr(pBuf->CpuPAddr);
HASH_Remove(ctx->pBufferHash, (u32)sHashAddr.uiAddr);
}
FreeBuf(pBuf, ui32Flags);
pvr_put_ctx(ctx);
}
}
示例7: LoadTableW
bool LoadTableW(wchar_t *filename)
{
bool ret;
BUF *b;
wchar_t replace_name[MAX_PATH];
Zero(replace_name, sizeof(replace_name));
TrackingDisable();
b = ReadDump("@table_name.txt");
if (b != NULL)
{
char *s = CfgReadNextLine(b);
if (s != NULL)
{
if (IsEmptyStr(s) == false)
{
StrToUni(replace_name, sizeof(replace_name), s);
filename = replace_name;
}
Free(s);
}
FreeBuf(b);
}
ret = LoadTableMain(filename);
TrackingEnable();
return ret;
}
示例8: NsGenMacAddressSignatureForMachine
// Determine the last two bytes of the MAC address
void NsGenMacAddressSignatureForMachine(UCHAR *dst_last_2, UCHAR *src_mac_addr_4)
{
char machine_name[MAX_SIZE];
BUF *b;
UCHAR hash[SHA1_SIZE];
// Validate arguments
if (dst_last_2 == NULL || src_mac_addr_4 == NULL)
{
return;
}
GetMachineHostName(machine_name, sizeof(machine_name));
Trim(machine_name);
StrUpper(machine_name);
b = NewBuf();
WriteBuf(b, src_mac_addr_4, 4);
WriteBufStr(b, machine_name);
HashSha1(hash, b->Buf, b->Size);
FreeBuf(b);
Copy(dst_last_2, hash, 2);
}
示例9: WriteTinyLog
// Write to tiny log
void WriteTinyLog(TINY_LOG *t, char *str)
{
BUF *b;
char dt[MAX_PATH];
// Validate arguments
if (t == NULL)
{
return;
}
GetDateTimeStrMilli64(dt, sizeof(dt), LocalTime64());
StrCat(dt, sizeof(dt), ": ");
b = NewBuf();
WriteBuf(b, dt, StrLen(dt));
WriteBuf(b, str, StrLen(str));
WriteBuf(b, "\r\n", 2);
Lock(t->Lock);
{
FileWrite(t->io, b->Buf, b->Size);
//FileFlush(t->io);
}
Unlock(t->Lock);
FreeBuf(b);
}
示例10: NewBuf
// Build the Attribute list
BUF *SstpBuildAttributeList(LIST *o, USHORT message_type)
{
UINT i;
BUF *b;
USHORT us;
// Validate arguments
if (o == NULL)
{
return NULL;
}
b = NewBuf();
us = Endian16(message_type);
WriteBuf(b, &us, sizeof(USHORT));
us = Endian16((USHORT)LIST_NUM(o));
WriteBuf(b, &us, sizeof(USHORT));
for (i = 0;i < LIST_NUM(o);i++)
{
SSTP_ATTRIBUTE *a = LIST_DATA(o, i);
BUF *ab = SstpBuildAttribute(a);
if (ab != NULL)
{
WriteBufBuf(b, ab);
FreeBuf(ab);
}
}
return b;
}
示例11: ViExtractResource
// Extract the license agreement from the EXE file
wchar_t *ViExtractEula(char *exe)
{
BUF *b;
UINT tmp_size;
char *tmp;
wchar_t *ret;
// Validate arguments
if (exe == NULL)
{
return false;
}
b = ViExtractResource(exe, RT_RCDATA, "LICENSE");
if (b == NULL)
{
return NULL;
}
tmp_size = b->Size + 1;
tmp = ZeroMalloc(tmp_size);
Copy(tmp, b->Buf, b->Size);
FreeBuf(b);
ret = CopyStrToUni(tmp);
Free(tmp);
return ret;
}
示例12: NullGenerateMacAddress
// Generate MAC address
void NullGenerateMacAddress(UCHAR *mac, UINT id, UINT seq)
{
UCHAR hash[SHA1_SIZE];
char name[MAX_SIZE];
BUF *b;
// Validate arguments
if (mac == NULL)
{
return;
}
b = NewBuf();
WriteBufInt(b, id);
WriteBufInt(b, seq);
GetMachineHostName(name, sizeof(name));
#ifdef OS_WIN32
WriteBufInt(b, MsGetCurrentProcessId());
#endif // OS_WIN32
WriteBufStr(b, name);
HashSha1(hash, b->Buf, b->Size);
FreeBuf(b);
Copy(mac, hash, 6);
mac[0] = 0x7E;
}
示例13: PackToBuf
// Generate the packet
BUF *WpcGeneratePacket(PACK *pack, X *cert, K *key)
{
UCHAR hash[SHA1_SIZE];
BUF *pack_data;
BUF *cert_data = NULL;
BUF *sign_data = NULL;
BUF *b;
// Validate arguments
if (pack == NULL)
{
return NULL;
}
pack_data = PackToBuf(pack);
HashSha1(hash, pack_data->Buf, pack_data->Size);
if (cert != NULL && key != NULL)
{
UCHAR sign[128];
cert_data = XToBuf(cert, false);
RsaSign(sign, hash, sizeof(hash), key);
sign_data = NewBuf();
WriteBuf(sign_data, sign, sizeof(sign));
SeekBuf(sign_data, 0, 0);
}
b = NewBuf();
WpcAddDataEntryBin(b, "PACK", pack_data->Buf, pack_data->Size);
WpcAddDataEntryBin(b, "HASH", hash, sizeof(hash));
if (cert_data != NULL)
{
WpcAddDataEntryBin(b, "CERT", cert_data->Buf, cert_data->Size);
WpcAddDataEntryBin(b, "SIGN", sign_data->Buf, sign_data->Size);
}
FreeBuf(pack_data);
FreeBuf(cert_data);
FreeBuf(sign_data);
SeekBuf(b, 0, 0);
return b;
}
示例14: NullToken
// Cut out the token from the string (not ignore the blanks between delimiters)
TOKEN_LIST *ParseTokenWithNullStr(char *str, char *split_chars)
{
LIST *o;
UINT i, len;
BUF *b;
char zero = 0;
TOKEN_LIST *t;
// Validate arguments
if (str == NULL)
{
return NullToken();
}
if (split_chars == NULL)
{
split_chars = DefaultTokenSplitChars();
}
b = NewBuf();
o = NewListFast(NULL);
len = StrLen(str);
for (i = 0;i < (len + 1);i++)
{
char c = str[i];
bool flag = IsCharInStr(split_chars, c);
if (c == '\0')
{
flag = true;
}
if (flag == false)
{
WriteBuf(b, &c, sizeof(char));
}
else
{
WriteBuf(b, &zero, sizeof(char));
Insert(o, CopyStr((char *)b->Buf));
ClearBuf(b);
}
}
t = ZeroMalloc(sizeof(TOKEN_LIST));
t->NumTokens = LIST_NUM(o);
t->Token = ZeroMalloc(sizeof(char *) * t->NumTokens);
for (i = 0;i < t->NumTokens;i++)
{
t->Token[i] = LIST_DATA(o, i);
}
ReleaseList(o);
FreeBuf(b);
return t;
}
示例15: NsIpTablesThread
// iptables thread
void NsIpTablesThread(THREAD *thread, void *param)
{
IPTABLES_STATE *state;
NATIVE_STACK *s;
UINT counter = 0;
BUF *seed_buf;
char exe_name[MAX_PATH];
if (thread == NULL || param == NULL)
{
return;
}
s = (NATIVE_STACK *)param;
seed_buf = NewBuf();
WriteBuf(seed_buf, s->MacAddress, 6);
GetExeName(exe_name, sizeof(exe_name));
WriteBufStr(seed_buf, exe_name);
state = StartAddIpTablesEntryForNativeStack(seed_buf->Buf, seed_buf->Size);
FreeBuf(seed_buf);
if (state == NULL)
{
NoticeThreadInit(thread);
return;
}
s->IpTablesInitOk = true;
NoticeThreadInit(thread);
while (true)
{
UINT wait_interval;
if (s->IpTablesHalt)
{
break;
}
if (MaintainAddIpTablesEntryForNativeStack(state))
{
counter = 0;
}
counter++;
wait_interval = NS_CHECK_IPTABLES_INTERVAL_INIT * counter;
wait_interval = MIN(wait_interval, NS_CHECK_IPTABLES_INTERVAL_MAX);
//Debug("NsIpTablesThread: wait for %u\n", wait_interval);
Wait(s->IpTablesHaltEvent, wait_interval);
}
EndAddIpTablesEntryForNativeStack(state);
}