本文整理汇总了C++中LE32函数的典型用法代码示例。如果您正苦于以下问题:C++ LE32函数的具体用法?C++ LE32怎么用?C++ LE32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LE32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckRpcHeaders
// Check Header of RPC Response
static int CheckRpcHeaders(const RPC_HEADER *const ResponseHeader, const RPC_HEADER *const RequestHeader, const BYTE desiredPacketType, const PRINTFUNC p)
{
int status = CheckRpcHeader(ResponseHeader, desiredPacketType, p);
if (desiredPacketType == RPC_PT_BIND_ACK)
{
if ((ResponseHeader->PacketFlags & RPC_PF_MULTIPLEX) != (RequestHeader->PacketFlags & RPC_PF_MULTIPLEX))
{
p("Warning: RPC_PF_MULTIPLEX of RPC request and response should match\n");
}
}
else
{
if (ResponseHeader->PacketFlags & RPC_PF_MULTIPLEX)
{
p("Warning: %s should not be set\n", "RPC_PF_MULTIPLEX");
}
}
if (ResponseHeader->CallId != RequestHeader->CallId)
{
p("Fatal: Sent Call Id %u but received answer for Call Id %u\n",
(uint32_t)LE32(RequestHeader->CallId),
(uint32_t)LE32(ResponseHeader->CallId)
);
status = !0;
}
return status;
}
示例2: do_check32
static inline bool
do_check32 (size_t i, const Elf32_auxv_t (*a32)[], uint_fast8_t *elfdata)
{
/* The AUXV pointer might not even be naturally aligned for 32-bit
data, because note payloads in a core file are not aligned. */
uint32_t type = read_4ubyte_unaligned_noncvt (&(*a32)[i].a_type);
uint32_t val = read_4ubyte_unaligned_noncvt (&(*a32)[i].a_un.a_val);
if (type == BE32 (PROBE_TYPE)
&& val == BE32 (PROBE_VAL32))
{
*elfdata = ELFDATA2MSB;
return true;
}
if (type == LE32 (PROBE_TYPE)
&& val == LE32 (PROBE_VAL32))
{
*elfdata = ELFDATA2LSB;
return true;
}
return false;
}
示例3: RpcRequest
static int RpcRequest(const RPC_REQUEST *const Request, RPC_RESPONSE *const Response, const DWORD RpcAssocGroup, const SOCKET sock, const unsigned int len)
{
uint_fast16_t _v;
_v = LE16(((WORD*)Request->Data)[1]) - 4;
int ResponseSize = _Versions[_v].CreateResponse(Request->Data, Response->Data);
if ( ResponseSize )
{
Response->Ndr.DataSizeIs1 = LE32(0x00020000);
Response->Ndr.DataLength =
Response->Ndr.DataSizeIs2 = LE32(ResponseSize);
int len = ResponseSize + sizeof(Response->Ndr);
BYTE* pRpcReturnCode = ((BYTE*)&Response->Ndr) + len;
UA32(pRpcReturnCode) = 0; //LE16 not needed for 0
len += sizeof(DWORD);
// Pad zeros to 32-bit align (seems not neccassary but Windows RPC does it this way)
int pad = ((~len & 3) + 1) & 3;
memset(pRpcReturnCode + sizeof(DWORD), 0, pad);
len += pad;
Response->AllocHint = LE32(len);
Response->AllocHint +=
Response->ContextId = Request->ContextId;
*((WORD*)&Response->CancelCount) = 0; // CancelCount + Pad1
}
return ResponseSize;
}
示例4: logResponseVerbose
void logResponseVerbose(const char *const ePID, const BYTE *const hwid, const RESPONSE *const response, const PRINTFUNC p)
{
char guidBuffer[GUID_STRING_LENGTH + 1];
//SYSTEMTIME st;
p("Protocol version : %u.%u\n", (uint32_t)LE16(response->MajorVer), (uint32_t)LE16(response->MinorVer));
p("KMS host extended PID : %s\n", ePID);
if (LE16(response->MajorVer) > 5)
# ifndef _WIN32
p("KMS host Hardware ID : %016llX\n", (unsigned long long)BE64(*(uint64_t*)hwid));
# else // _WIN32
p("KMS host Hardware ID : %016I64X\n", (unsigned long long)BE64(*(uint64_t*)hwid));
# endif // WIN32
uuid2StringLE(&response->CMID, guidBuffer);
p("Client machine ID : %s\n", guidBuffer);
char mbstr[64];
time_t st;
st = fileTimeToUnixTime(&response->ClientTime);
strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %X", gmtime(&st));
p("Client request timestamp (UTC) : %s\n", mbstr);
p("KMS host current active clients : %u\n", (uint32_t)LE32(response->Count));
p("Renewal interval policy : %u\n", (uint32_t)LE32(response->VLRenewalInterval));
p("Activation interval policy : %u\n", (uint32_t)LE32(response->VLActivationInterval));
}
示例5: client_give_level
/* Give a Blue Burst client some free level ups. */
int client_give_level(ship_client_t *c, uint32_t level_req) {
uint32_t exp_total;
bb_level_entry_t *ent;
int cl;
uint32_t exp_gained;
if(c->version != CLIENT_VERSION_BB || !c->bb_pl || level_req > 199)
return -1;
/* No need if they've already at that level. */
if(c->bb_pl->character.level >= level_req)
return 0;
/* Grab the entry for that level... */
cl = c->bb_pl->character.ch_class;
ent = &char_stats.levels[cl][level_req];
/* Add in the experience to their total so far. */
exp_total = LE32(c->bb_pl->character.exp);
exp_gained = ent->exp - exp_total;
c->bb_pl->character.exp = LE32(ent->exp);
/* Send the packet telling them they've gotten experience. */
if(subcmd_send_bb_exp(c, exp_gained))
return -1;
/* Send the level-up packet. */
c->bb_pl->character.level = LE32(level_req);
if(subcmd_send_bb_level(c))
return -1;
return 0;
}
示例6: handle_ship_select
/* Handle a client's ship select packet. */
static int handle_ship_select(login_client_t *c, bb_select_pkt *pkt) {
uint32_t menu_id = LE32(pkt->menu_id);
uint32_t item_id = LE32(pkt->item_id);
switch(menu_id & 0xFF) {
/* Initial menu */
case 0x00:
if(item_id == ITEM_ID_INIT_SHIP) {
/* Ship Select */
return send_ship_list(c, 0);
}
return -1;
/* Ship */
case 0x01:
if(item_id == 0) {
/* A "Ship List" menu item */
return send_ship_list(c, (uint16_t)(menu_id >> 8));
}
else {
/* An actual ship */
return ship_transfer(c, item_id);
}
default:
return -1;
}
示例7: BlowfishEncryptLE
void BlowfishEncryptLE (unsigned char *inBlock, unsigned char *outBlock, BF_KEY *key, int encrypt)
{
word32 left = LE32 (((word32 *) inBlock)[0]);
word32 right = LE32 (((word32 *) inBlock)[1]);
const word32 *const s = key->sbox;
const word32 * p = encrypt ? key->pbox : key->pbox_dec;
unsigned i;
left ^= p[0];
for (i=0; i<ROUNDS/2; i++)
{
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
^ p[2*i+2];
}
right ^= p[ROUNDS+1];
((word32 *) outBlock)[0] = LE32 (right);
((word32 *) outBlock)[1] = LE32 (left);
}
示例8: CRYPT_PC_CryptData
void CRYPT_PC_CryptData(CRYPT_SETUP* pc,void* data,unsigned long size)
{
uint32_t x, tmp;
for (x = 0; x < size; x += 4) {
tmp = *((uint32_t *)(data + x));
tmp = LE32(tmp) ^ CRYPT_PC_GetNextKey(pc);
*((uint32_t *)(data + x)) = LE32(tmp);
}
}
示例9: ext2_dir_lookup
/* read in the dir, look for the entry */
static int ext2_dir_lookup(ext2_t *ext2, struct ext2_inode *dir_inode, const char *name, inodenum_t *inum)
{
uint file_blocknum;
int err;
uint8_t *buf;
size_t namelen = strlen(name);
if (!S_ISDIR(dir_inode->i_mode))
return ERR_NOT_DIR;
buf = malloc(EXT2_BLOCK_SIZE(ext2->sb));
file_blocknum = 0;
for (;;) {
/* read in the offset */
err = ext2_read_inode(ext2, dir_inode, buf, file_blocknum * EXT2_BLOCK_SIZE(ext2->sb), EXT2_BLOCK_SIZE(ext2->sb));
if (err <= 0) {
free(buf);
return -1;
}
/* walk through the directory entries, looking for the one that matches */
struct ext2_dir_entry_2 *ent;
uint pos = 0;
while (pos < EXT2_BLOCK_SIZE(ext2->sb)) {
ent = (struct ext2_dir_entry_2 *)&buf[pos];
LTRACEF("ent %d:%d: inode 0x%x, reclen %d, namelen %d\n",
file_blocknum, pos, LE32(ent->inode), LE16(ent->rec_len), ent->name_len/* , ent->name*/);
/* sanity check the record length */
if (LE16(ent->rec_len) == 0)
break;
if (ent->name_len == namelen && memcmp(name, ent->name, ent->name_len) == 0) {
// match
*inum = LE32(ent->inode);
LTRACEF("match: inode %d\n", *inum);
free(buf);
return 1;
}
pos += ROUNDUP(LE16(ent->rec_len), 4);
}
file_blocknum++;
/* sanity check the directory. 4MB should be enough */
if (file_blocknum > 1024) {
free(buf);
return -1;
}
}
}
示例10: RpcBind
static int RpcBind(const RPC_BIND_REQUEST *const Request, RPC_BIND_RESPONSE *const Response, const DWORD RpcAssocGroup, const SOCKET sock, const unsigned int len)
{
unsigned int i, _st = 0;
for (i = 0; i < LE32(Request->NumCtxItems); i++)
{
if ( IsEqualGUID((GUID*)TransferSyntaxNDR32, &Request->CtxItems[i].TransferSyntax) )
{
Response->Results[i].SyntaxVersion = LE32(2);
Response->Results[i].AckResult =
Response->Results[i].AckReason = 0;
memcpy(&Response->Results[i].TransferSyntax, TransferSyntaxNDR32, sizeof(GUID));
_st = !0;
}
else
{
Response->Results[i].SyntaxVersion = 0;
Response->Results[i].AckResult =
Response->Results[i].AckReason = LE16(2); // Unsupported
memset(&Response->Results[i].TransferSyntax, 0, sizeof(GUID));
}
}
if ( _st )
{
Response->MaxXmitFrag = Request->MaxXmitFrag;
Response->MaxRecvFrag = Request->MaxRecvFrag;
Response->AssocGroup = LE32(RpcAssocGroup);
socklen_t len;
struct sockaddr_storage addr;
// M$ RPC does not do this. Excess bytes contain apparently random data
memset(Response->SecondaryAddress, 0, sizeof(Response->SecondaryAddress));
len = sizeof addr;
if (getsockname(sock, (struct sockaddr*)&addr, &len) ||
getnameinfo((struct sockaddr*)&addr, len, NULL, 0, (char*)Response->SecondaryAddress, sizeof(Response->SecondaryAddress), NI_NUMERICSERV))
{
// In case of failure (should never happen) use default port (doesn't seem to break activation)
strcpy((char*)Response->SecondaryAddress, "1688");
}
uint_fast8_t temp = strlen((char*)Response->SecondaryAddress) + 1;
////FIXME: Temporary workaround for TCP ports < 10. sizeof(Response->SecondaryAddress) must be padded to 2, 6, 10, ...
if (temp < 3) temp = 3;
Response->SecondaryAddressLength = LE16(temp);
Response->NumResults = Request->NumCtxItems;
}
return _st;
}
示例11: handle_guild_chunk
static int handle_guild_chunk(login_client_t *c, bb_guildcard_req_pkt *pkt) {
uint32_t chunk, cont;
chunk = LE32(pkt->chunk);
cont = LE32(pkt->cont);
/* Send data as long as the client is still looking for it. */
if(cont) {
/* Send the chunk */
return send_bb_guild_chunk(c, chunk);
}
return 0;
}
示例12: InitSectorIVAndWhitening
// Initializes IV and whitening values for sector encryption/decryption in CBC mode.
// IMPORTANT: This function has been deprecated (legacy).
static void
InitSectorIVAndWhitening (unsigned __int64 unitNo,
int blockSize,
unsigned __int32 *iv,
unsigned __int64 *ivSeed,
unsigned __int32 *whitening)
{
/* IMPORTANT: This function has been deprecated (legacy) */
unsigned __int64 iv64[4];
unsigned __int32 *iv32 = (unsigned __int32 *) iv64;
iv64[0] = ivSeed[0] ^ LE64(unitNo);
iv64[1] = ivSeed[1] ^ LE64(unitNo);
iv64[2] = ivSeed[2] ^ LE64(unitNo);
if (blockSize == 16)
{
iv64[3] = ivSeed[3] ^ LE64(unitNo);
}
iv[0] = iv32[0];
iv[1] = iv32[1];
switch (blockSize)
{
case 16:
// 128-bit block
iv[2] = iv32[2];
iv[3] = iv32[3];
whitening[0] = LE32( crc32int ( &iv32[4] ) ^ crc32int ( &iv32[7] ) );
whitening[1] = LE32( crc32int ( &iv32[5] ) ^ crc32int ( &iv32[6] ) );
break;
case 8:
// 64-bit block
whitening[0] = LE32( crc32int ( &iv32[2] ) ^ crc32int ( &iv32[5] ) );
whitening[1] = LE32( crc32int ( &iv32[3] ) ^ crc32int ( &iv32[4] ) );
break;
default:
GST_THROW_FATAL_EXCEPTION;
}
}
示例13: logRequestVerbose
void logRequestVerbose(const REQUEST *const Request, const PRINTFUNC p)
{
char guidBuffer[GUID_STRING_LENGTH + 1];
char WorkstationBuffer[3 * WORKSTATION_NAME_BUFFER];
const char *productName;
ProdListIndex_t index;
p("Protocol version : %u.%u\n", LE16(Request->MajorVer), LE16(Request->MinorVer));
p("Client is a virtual machine : %s\n", LE32(Request->VMInfo) ? "Yes" : "No");
p("Licensing status : %u (%s)\n", (uint32_t)LE32(Request->LicenseStatus), LE32(Request->LicenseStatus) < _countof(LicenseStatusText) ? LicenseStatusText[LE32(Request->LicenseStatus)] : "Unknown");
p("Remaining time (0 = forever) : %i minutes\n", (uint32_t)LE32(Request->BindingExpiration));
uuid2StringLE(&Request->AppID, guidBuffer);
productName = getProductNameLE(&Request->AppID, AppList, getAppListSize(), &index);
p("Application ID : %s (%s)\n", guidBuffer, productName);
uuid2StringLE(&Request->ActID, guidBuffer);
# ifndef NO_EXTENDED_PRODUCT_LIST
productName = getProductNameLE(&Request->ActID, ExtendedProductList, getExtendedProductListSize(), &index);
# else
productName = "Unknown";
# endif
p("SKU ID (aka Activation ID) : %s (%s)\n", guidBuffer, productName);
uuid2StringLE(&Request->KMSID, guidBuffer);
productName = getProductNameLE(&Request->KMSID, ProductList, getProductListSize(), &index);
p("KMS ID (aka KMS counted ID) : %s (%s)\n", guidBuffer, productName);
uuid2StringLE(&Request->CMID, guidBuffer);
p("Client machine ID : %s\n", guidBuffer);
uuid2StringLE(&Request->CMID_prev, guidBuffer);
p("Previous client machine ID : %s\n", guidBuffer);
char mbstr[64];
time_t st;
st = fileTimeToUnixTime(&Request->ClientTime);
strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %X", gmtime(&st));
p("Client request timestamp (UTC) : %s\n", mbstr);
ucs2_to_utf8(Request->WorkstationName, WorkstationBuffer, WORKSTATION_NAME_BUFFER, sizeof(WorkstationBuffer));
p("Workstation name : %s\n", WorkstationBuffer);
p("N count policy (minimum clients): %u\n", (uint32_t)LE32(Request->N_Policy));
}
示例14: checkRpcRequestSize
/*
* check RPC request for (somewhat) correct size
* allow any size that does not cause CreateResponse to fail badly
*/
static unsigned int checkRpcRequestSize(const RPC_REQUEST64 *const Request, const unsigned int requestSize, WORD* NdrCtx, WORD* Ndr64Ctx)
{
WORD Ctx = LE16(Request->ContextId);
# if defined(_PEDANTIC) && !defined(NO_LOG)
CheckRpcRequest(Request, requestSize, NdrCtx, Ndr64Ctx, Ctx);
# endif // defined(_PEDANTIC) && !defined(NO_LOG)
// Anything that is smaller than a v4 request is illegal
if (requestSize < sizeof(REQUEST_V4) + (Ctx != *Ndr64Ctx ? sizeof(RPC_REQUEST) : sizeof(RPC_REQUEST64))) return 0;
// Get KMS major version
uint16_t majorIndex, minor;
DWORD version;
# ifndef SIMPLE_RPC
if (Ctx != *Ndr64Ctx)
{
version = LE32(*(DWORD*)Request->Ndr.Data);
}
else
{
version = LE32(*(DWORD*)Request->Ndr64.Data);
}
# else // SIMPLE_RPC
version = LE32(*(DWORD*)Request->Ndr.Data);
# endif // SIMPLE_RPC
majorIndex = (uint16_t)(version >> 16) - 4;
minor = (uint16_t)(version & 0xffff);
// Only KMS v4, v5 and v6 are supported
if (majorIndex >= vlmcsd_countof(_Versions) || minor)
{
# ifndef NO_LOG
logger("Fatal: KMSv%hu.%hu unsupported\n", (unsigned short)majorIndex + 4, (unsigned short)minor);
# endif // NO_LOG
return 0;
}
// Could check for equality but allow bigger requests to support buggy RPC clients (e.g. wine)
// Buffer overrun is check by caller.
return (requestSize >= _Versions[majorIndex].RequestSize);
}
示例15: main
int main(int argc, char *argv[]) {
uint8_t *dat = NULL;
uint32_t sz, ocnt, area;
int alt, idx = 0, i, type = 0;
const quest_dat_hdr_t *ptrs[2][18] = { { 0 } };
const quest_dat_hdr_t *hdr;
/* Parse the command line... */
parse_command_line(argc, argv);
/* See if we got a .qst file a .dat file. */
type = is_qst(filename, version);
if(type == 1) {
dat = read_qst(filename, &sz, version);
}
else if(!type) {
dat = read_dat(filename, &sz, compressed);
}
if(!dat) {
printf("Confused by earlier errors, bailing out.\n");
return -1;
}
parse_quest_objects(dat, sz, &ocnt, ptrs);
printf("Found %d objects\n", (int)ocnt);
for(i = 0; i < 18; ++i) {
if((hdr = ptrs[1][i])) {
/* XXXX: Ugly! */
sz = LE32(hdr->size);
area = LE32(hdr->area);
alt = 0;
if((episode == 3 && area > 5) || (episode == 2 && area > 15))
alt = 1;
if(parse_map((map_enemy_t *)(hdr->data), sz / sizeof(map_enemy_t),
episode, alt, &idx, (int)area)) {
printf("Cannot parse map!\n");
return -4;
}
}
}
return 0;
}