Exemplo n.º 1
0
/**
 * Dumps an Objects rotation into the xml node.
 * @param obj_node The XML node.
 * @param object The Object.
 */
void FileProcessor::saveArea_Rotation(mxml_node_t* obj_node, Object* object) {
	mxml_node_t *rot_node = mxmlNewElement(obj_node, "rotation");
	mxmlElementSetAttrf(rot_node, "rx", "%f", object->getRotX());
	mxmlElementSetAttrf(rot_node, "ry", "%f", object->getRotY());
	mxmlElementSetAttrf(rot_node, "rz", "%f", object->getRotZ());
	mxmlElementSetAttrf(rot_node, "angle", "%f", object->getRotAngle());
}
Exemplo n.º 2
0
/**
 * Dumps all tile in an area into the xml node.
 * @param area The refrence to the area.
 * @param area_node The pointer to the xml node.
 */
void FileProcessor::saveArea_Tiles(mxml_node_t* area_node, Area& area) {
	mxml_node_t *tiles_node = mxmlNewElement(area_node, "tiles");
	for(int y = 0; y < area.getHeight(); y++) {
		for(int x = 0; x < area.getWidth(); x++) {

			Tile* tile = area.getTile(x, y);
			if(!tile) {
				continue;
			}

			mxml_node_t *tile_node = mxmlNewElement(tiles_node, "tile");
			mxmlElementSetAttrf(tile_node, "x", "%d", x);
			mxmlElementSetAttrf(tile_node, "y", "%d", y);

			const char* solid = "false";
			if(area.getSolid(x, y)) {
				solid = "true";
			}
			mxmlElementSetAttr(tile_node, "solid", solid);

			const char* filename = tile->getFilename().c_str();
			mxmlElementSetAttr(tile_node, "filename", filename);

			mxmlElementSetAttrf(tile_node, "rotation", "%f", tile->getRotation());
		}
	}
}
Exemplo n.º 3
0
void HwmonDriver::writeEvents(mxml_node_t *root) const {
	root = mxmlNewElement(root, "category");
	mxmlElementSetAttr(root, "name", "hwmon");

	char buf[1024];
	for (HwmonCounter *counter = static_cast<HwmonCounter *>(getCounters()); counter != NULL; counter = static_cast<HwmonCounter *>(counter->getNext())) {
		mxml_node_t *node = mxmlNewElement(root, "event");
		mxmlElementSetAttr(node, "counter", counter->getName());
		mxmlElementSetAttr(node, "title", counter->getTitle());
		if (counter->isDuplicate()) {
			mxmlElementSetAttrf(node, "name", "%s (0x%x)", counter->getLabel(), counter->getKey());
		} else {
			mxmlElementSetAttr(node, "name", counter->getLabel());
		}
		mxmlElementSetAttr(node, "display", counter->getDisplay());
		mxmlElementSetAttr(node, "class", counter->getCounterClass());
		mxmlElementSetAttr(node, "units", counter->getUnit());
		if (counter->getModifier() != 1) {
			mxmlElementSetAttrf(node, "modifier", "%d", counter->getModifier());
		}
		if (strcmp(counter->getDisplay(), "average") == 0 || strcmp(counter->getDisplay(), "maximum") == 0) {
			mxmlElementSetAttr(node, "average_selection", "yes");
		}
		snprintf(buf, sizeof(buf), "libsensors %s sensor %s (%s)", counter->getTitle(), counter->getLabel(), counter->getName());
		mxmlElementSetAttr(node, "description", buf);
	}
}
Exemplo n.º 4
0
void GasBurner_runXML(GasBurner* me)
{
mxml_node_t* childnode; // used as a temp node
childnode = mxmlNewElement(me->_simevents,"Event");
mxmlElementSetAttr(childnode, "Name", "TurnOn");
mxmlElementSetAttr(childnode, "Scope", "Input");
mxmlElementSetAttr(childnode, "Type", "EVENT");
if(  me->_input.event.TurnOn )
    mxmlElementSetAttr(childnode, "Value", "Present");
else
    mxmlElementSetAttr(childnode, "Value", "Absent");
childnode = mxmlNewElement(me->_simevents,"Event");
mxmlElementSetAttr(childnode, "Name", "TurnOff");
mxmlElementSetAttr(childnode, "Scope", "Input");
mxmlElementSetAttr(childnode, "Type", "EVENT");
if(  me->_input.event.TurnOff )
    mxmlElementSetAttr(childnode, "Value", "Present");
else
    mxmlElementSetAttr(childnode, "Value", "Absent");
childnode = mxmlNewElement(me->_simevents,"Event");
mxmlElementSetAttr(childnode, "Name", "On");
mxmlElementSetAttr(childnode, "Scope", "Output");
mxmlElementSetAttr(childnode, "Type", "EVENT");
if(  me->_output.event.On )
    mxmlElementSetAttr(childnode, "Value", "Present");
else
    mxmlElementSetAttr(childnode, "Value", "Absent");
childnode = mxmlNewElement(me->_simevents,"Event");
mxmlElementSetAttr(childnode, "Name", "Off");
mxmlElementSetAttr(childnode, "Scope", "Output");
mxmlElementSetAttr(childnode, "Type", "EVENT");
if(  me->_output.event.Off )
    mxmlElementSetAttr(childnode, "Value", "Present");
else
    mxmlElementSetAttr(childnode, "Value", "Absent");
childnode = mxmlNewElement(me->_simevents,"Event");
mxmlElementSetAttr(childnode, "Name", "Update");
mxmlElementSetAttr(childnode, "Scope", "Output");
mxmlElementSetAttr(childnode, "Type", "EVENT");
if(  me->_output.event.Update )
    mxmlElementSetAttr(childnode, "Value", "Present");
else
    mxmlElementSetAttr(childnode, "Value", "Absent");
childnode = mxmlNewElement(me->_simvars,"Var");
mxmlElementSetAttr(childnode, "Name", "y");
mxmlElementSetAttr(childnode, "Scope", "Output");
mxmlElementSetAttr(childnode, "Type", "REAL");
mxmlElementSetAttrf(childnode, "Value", "%f", me->_y);
childnode = mxmlNewElement(me->_simvars,"Var");
mxmlElementSetAttr(childnode, "Name", "d");
mxmlElementSetAttr(childnode, "Scope", "Internal");
mxmlElementSetAttr(childnode, "Type", "REAL");
mxmlElementSetAttrf(childnode, "Value", "%f", me->d);
//mxmlElementSetAttrf(me->_simstate, "Name", "%s", me->_statename); // set in run function
}
mxml_node_t* CapturedXML::getTree(bool includeTime) {
	mxml_node_t *xml;
	mxml_node_t *captured;
	mxml_node_t *target;
	int x;

	xml = mxmlNewXML("1.0");

	captured = mxmlNewElement(xml, "captured");
	mxmlElementSetAttr(captured, "version", "1");
	if (gSessionData->perf.isSetup()) {
		mxmlElementSetAttr(captured, "type", "Perf");
	}
	mxmlElementSetAttrf(captured, "protocol", "%d", PROTOCOL_VERSION);
	if (includeTime) { // Send the following only after the capture is complete
		if (time(NULL) > 1267000000) { // If the time is reasonable (after Feb 23, 2010)
			mxmlElementSetAttrf(captured, "created", "%lu", time(NULL)); // Valid until the year 2038
		}
	}

	target = mxmlNewElement(captured, "target");
	mxmlElementSetAttr(target, "name", gSessionData->mCoreName);
	mxmlElementSetAttrf(target, "sample_rate", "%d", gSessionData->mSampleRate);
	mxmlElementSetAttrf(target, "cores", "%d", gSessionData->mCores);
	mxmlElementSetAttrf(target, "cpuid", "0x%x", gSessionData->mMaxCpuId);

	if (!gSessionData->mOneShot && (gSessionData->mSampleRate > 0)) {
		mxmlElementSetAttr(target, "supports_live", "yes");
	}

	if (gSessionData->mLocalCapture) {
		mxmlElementSetAttr(target, "local_capture", "yes");
	}

	mxml_node_t *counters = NULL;
	for (x = 0; x < MAX_PERFORMANCE_COUNTERS; x++) {
		const Counter & counter = gSessionData->mCounters[x];
		if (counter.isEnabled()) {
			if (counters == NULL) {
				counters = mxmlNewElement(captured, "counters");
			}
			mxml_node_t *const node = mxmlNewElement(counters, "counter");
			mxmlElementSetAttrf(node, "key", "0x%x", counter.getKey());
			mxmlElementSetAttr(node, "type", counter.getType());
			if (counter.getEvent() != -1) {
				mxmlElementSetAttrf(node, "event", "0x%x", counter.getEvent());
			}
			if (counter.getCount() > 0) {
				mxmlElementSetAttrf(node, "count", "%d", counter.getCount());
			}
			if (counter.getCores() > 0) {
				mxmlElementSetAttrf(node, "cores", "%d", counter.getCores());
			}
		}
	}

	return xml;
}
Exemplo n.º 6
0
int
WSAAPI
Hookedrecv(
	SOCKET s,
	char *buf,
	int len,
	int flags
	)
{

	if ( DbgGetShellcodeFlag() == PWNYPOT_STATUS_SHELLCODE_FLAG_SET && len > 1)
	{
		CHAR szPort[20];
        CHAR szUID[UID_SIZE];
		sockaddr_in sdata;
		int sock_len = sizeof(sockaddr);
		PXMLNODE XmlIDLogNode;
			
		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		// type
		mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_RECV);
		getpeername( s, (sockaddr *)&sdata, &sock_len);
		mxmlElementSetAttrf(XmlIDLogNode, "socket", "%d", s);
		mxmlElementSetAttr(XmlIDLogNode, "recv_ip", inet_ntoa(sdata.sin_addr));
		mxmlElementSetAttr(XmlIDLogNode, "recv_port", _itoa(htons(sdata.sin_port), szPort, 10));
		mxmlElementSetAttr(XmlIDLogNode, "recv_datalen", _itoa(len, szPort, 10));
		mxmlElementSetAttr(XmlIDLogNode, "data_uid", GenRandomStr(szUID, UID_SIZE-1));
        HexDumpToFile((PBYTE)buf, len ,szUID);
		// save
		SaveXml( XmlLog );
	}

	return (recv_( s, buf, len, flags));
}
Exemplo n.º 7
0
BOOL
WINAPI
HookedSetProcessDEPPolicy(
	DWORD dwFlags
	)
{
	PXMLNODE XmlIDLogNode;
	XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
	mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_API);
	mxmlElementSetAttr(XmlIDLogNode, "api", "SetProcessDEPPolicy");
	mxmlElementSetAttrf(XmlIDLogNode, "value", "%d", dwFlags);
	if (PWNYPOT_REGCONFIG.GENERAL.ALLOW_MALWARE_EXEC) 
	{
		SaveXml( XmlLog );
		return SetProcessDEPPolicy_(dwFlags);
	}
	else 
	{	
		if (dwFlags == 0)
		{
			DEBUG_PRINTF(LSHL, NULL, "Stopping Process because it was trying to disable DEP.\n");
			SaveXml( XmlLog );
			TerminateProcess(GetCurrentProcess(), STATUS_ACCESS_VIOLATION);
		}
	}
	return 0;
}
Exemplo n.º 8
0
NTSTATUS
WINAPI
HookedNtSetInformationProcess(
	HANDLE ProcessHandle,
    ULONG ProcessInformationClass,
    PVOID ProcessInformation,
    ULONG ProcessInformationLength 
    )
{
	if (ProcessInformationClass == ProcessExecuteFlags){
		PXMLNODE XmlIDLogNode;
		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_API);
		mxmlElementSetAttr(XmlIDLogNode, "api", "NtSetInformationProcess");
		mxmlElementSetAttrf(XmlIDLogNode, "value", "0x%p", (*(ULONG_PTR *)ProcessInformation));
		SaveXml( XmlLog );
		if (PWNYPOT_REGCONFIG.GENERAL.ALLOW_MALWARE_EXEC) 
		{
			DEBUG_PRINTF(LSHL, NULL, "HookedNtSetInformationProcess is called with ProcessExecuteFlags value: %p.\n", (*(ULONG_PTR *)ProcessInformation) );
			return NtSetInformationProcess_(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength);
		}
		else 
		{				 
			if (((*(ULONG_PTR *)ProcessInformation) & MEM_EXECUTE_OPTION_ENABLE) == 0x2 )
			{
				DEBUG_PRINTF(LSHL, NULL, "Stopping Process because it was trying to disable DEP.\n");
				TerminateProcess(GetCurrentProcess(), STATUS_ACCESS_VIOLATION);
			}
		}
	}
	return 0;
}
Exemplo n.º 9
0
VOID 
NTAPI
HookedLdrHotPatchRoutine(
	HotPatchBuffer * s_HotPatchBuffer
	)
{
	DEBUG_PRINTF(LSHL, NULL, "HookedLdrHotPatchRoutine called.\n");
	PXMLNODE XmlIDLogNode;
	XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
	mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_API);
	mxmlElementSetAttr(XmlIDLogNode, "api", "LdrHotPatchRoutine");
	mxmlElementSetAttrf(XmlIDLogNode, "value", "%ls,%ls", s_HotPatchBuffer->PatcherName,  s_HotPatchBuffer->PatcheeName);
	if (PWNYPOT_REGCONFIG.SHELLCODE.ALLOW_MALWARE_DOWNLOAD)
	{
		//mxmlElementSetAttr(XmlIDLogNode, "downloaded_dll", "1");
		SaveXml( XmlLog );
		LdrHotPatchRoutine_(s_HotPatchBuffer);
	}
	else {
		//mxmlElementSetAttr(XmlIDLogNode, "downloaded_dll", "0");
		SaveXml( XmlLog );
		DEBUG_PRINTF(LSHL, NULL, "Denied downloading of library because of ALLOW_MALWARE_DOWNLOAD=0");
	}
	
}
Exemplo n.º 10
0
int
PLCvalidation_precompileST(mxml_node_t *pou, mxml_node_t *ST) {
    ST	= mxmlWalkNext (ST, NULL, MXML_DESCEND);

    if	(ST->type != MXML_ELEMENT) {
        RTL_TRDBG (TRACE_ST, "precompile ST code : not an MXML_ELEMENT (%d)\n", ST->type);
        return 0;
    }

    char *STcode = ST->value.element.name;
    if	(!memcmp(STcode, "![CDATA[", 8))
        STcode += 8;
    while	(STcode[strlen(STcode)-1] == ']')
        STcode[strlen(STcode)-1] = 0;

    RTL_TRDBG (TRACE_ST, "precompile ST code : (%s)\n", STcode);

    if	(compileST (STcode) != 0) {
        char *name = (char *)mxmlElementGetAttr(pou, "name");
        sprintf (_lastError, "pou '%s' compilation failed '%20.20s'", name, STcode);
        return -1;
    }
    mxmlElementSetAttrf (ST, "tree", "%ld", programBlock);
    RTL_TRDBG (TRACE_ST, "ST code precompiled at %p\n", programBlock);
    return	0;
}
Exemplo n.º 11
0
int
WSAAPI
Hookedbind(
  SOCKET s,
  const struct sockaddr *name,
  int namelen
  )
{
	if ( DbgGetShellcodeFlag() == PWNYPOT_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlIDLogNode;
		CHAR szPort[20];
		sockaddr_in *sdata;
		sdata = (sockaddr_in *)name;

		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		// type
		mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_BIND);
		mxmlElementSetAttrf(XmlIDLogNode, "socket", "%d", s);
		mxmlElementSetAttr(XmlIDLogNode, "bind_ip", inet_ntoa(sdata->sin_addr));
		mxmlElementSetAttr(XmlIDLogNode, "bind_port", _itoa(htons(sdata->sin_port),szPort, 10));
		// save
		SaveXml( XmlLog );
	}

	return (bind_(s, name, namelen));
}
Exemplo n.º 12
0
int
WSAAPI
Hookedlisten(
	SOCKET s,
	int backlog
	)
{
	if ( DbgGetShellcodeFlag() == PWNYPOT_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlIDLogNode;
		PXMLNODE XmlLogNode;

		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		// type
		mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_LISTEN);
		// listen
		mxmlElementSetAttrf(XmlIDLogNode, "socket", "%d", s);
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "listen_desc");
		mxmlNewText( XmlLogNode, 0, "Shellcode attemp to listen on a port (possibly on previously bind address).");
		// save
		SaveXml( XmlLog );
	}

	return (listen_( s,backlog ));
}
Exemplo n.º 13
0
/**
 * Saves an area to an XML file.
 * @param area The area to save.
 * @param filename The name of the file to write to.
 */
void FileProcessor::saveArea(Area& area, string filename) {
	LOG("Saving area['%s'] to '%s'.", area.getTag().c_str(), filename.c_str());

	//mxml_node_t *xml = mxmlNewXML("1.0");
	mxml_node_t *xml = mxmlNewElement(NULL, "?xml version=\"1.0\" encoding=\"UTF-8\"?");

	mxml_node_t *area_node = mxmlNewElement(xml, "area");
	saveArea_Tag(area_node, &area);
	mxmlElementSetAttrf(area_node,"width", "%d", area.getWidth());
	mxmlElementSetAttrf(area_node,"height", "%d", area.getHeight());
	saveArea_Objects(area_node, area);
	saveArea_Tiles(area_node, area);

	FILE *fp = fopen(filename.c_str(), "w");
	mxmlSaveFile(xml, fp, whitespace_cb);
	fclose(fp);	
}
Exemplo n.º 14
0
void StreamlineSetup::sendCounters() {
	mxml_node_t *xml;
	mxml_node_t *counters;

	xml = mxmlNewXML("1.0");
	counters = mxmlNewElement(xml, "counters");
	int count = 0;
	for (Driver *driver = Driver::getHead(); driver != NULL; driver = driver->getNext()) {
		count += driver->writeCounters(counters);
	}

	if (count == 0) {
		logg.logError("No counters found, this could be because /dev/gator/events can not be read or because perf is not working correctly");
		handleException();
	}

	mxml_node_t *setup = mxmlNewElement(counters, "setup_warnings");
	mxmlNewText(setup, 0, logg.getSetup());

	if (gSessionData.mSharedData->mClustersAccurate) {
		for (int cluster = 0; cluster < gSessionData.mSharedData->mClusterCount; ++cluster) {
			mxml_node_t *node = mxmlNewElement(counters, "cluster");
			mxmlElementSetAttrf(node, "id", "%i", cluster);
			mxmlElementSetAttr(node, "name", gSessionData.mSharedData->mClusters[cluster]->getPmncName());
		}
		for (int cpu = 0; cpu < gSessionData.mCores; ++cpu) {
			if (gSessionData.mSharedData->mClusterIds[cpu] >= 0) {
				mxml_node_t *node = mxmlNewElement(counters, "cpu");
				mxmlElementSetAttrf(node, "id", "%i", cpu);
				mxmlElementSetAttrf(node, "cluster", "%i", gSessionData.mSharedData->mClusterIds[cpu]);
			}
		}
	}

	char* string = mxmlSaveAllocString(xml, mxmlWhitespaceCB);
	mxmlDelete(xml);

	sendString(string, RESPONSE_XML);
	free(string);
}
Exemplo n.º 15
0
void WaterTank_initXML(mxml_node_t* node, WaterTank* me, char* instancename)
{
    // Add to tree
    mxmlAdd(node, MXML_ADD_AFTER, NULL, me->_simdata);
    // Add constanty things
    mxmlElementSetAttrf(me->_simdata, "Name", "%s", instancename);
    mxmlElementSetAttr(me->_simdata, "Type", "WaterTank");
    me->_simevents = mxmlNewElement(me->_simdata,"Events");
    me->_simvars = mxmlNewElement(me->_simdata,"Vars");
    me->_simstates = mxmlNewElement(me->_simdata,"ECStates");
    me->_simstate = mxmlNewElement(me->_simstates,"ECState");
    me->_simtransitions = mxmlNewElement(me->_simdata,"ECTransitions");
}
Exemplo n.º 16
0
int BCF_Write(bcf_t* bcf, const char* filename)
{
  FILE *fp;
  int i;
  mxml_node_t *baroboData, *addresses, *dongles, *iter;
  if(filename == NULL) {
    filename = bcf->filename;
  }
  fp = fopen(filename, "w");
  if(fp == NULL) {
    fprintf(stderr, "Error opening file %s for writing.\n", filename);
    return -1;
  }
  /* Write everything */
  bcf->root = mxmlNewXML("1.0");
  baroboData = mxmlNewElement(bcf->root, "BaroboData");
  addresses = mxmlNewElement(baroboData, "addresses");
  mxmlElementSetAttrf(
      addresses,
      "num",
      "%d", bcf->num);
  dongles = mxmlNewElement(baroboData, "dongles");
  mxmlElementSetAttrf(
      dongles,
      "num", "%d", bcf->numDongles);
  
  for(i = 0; i < bcf->num; i++) {
    iter = mxmlNewElement(addresses, "child");
    mxmlNewText(iter, 0, bcf->entries[i]);
  }
  for(i = 0; i < bcf->numDongles; i++) {
    iter = mxmlNewElement(dongles, "dongle");
    mxmlNewText(iter, 0, bcf->dongles[i]);
  }
  mxmlSaveFile(bcf->root, fp, MXML_NO_CALLBACK);
  fclose(fp);
  return 0;
}
Exemplo n.º 17
0
/**
 * Dumps an Object Visual information into the xml node.
 * @param obj_node The XML node.
 * @param object The Object.
 */
void FileProcessor::saveArea_Visual(mxml_node_t* obj_node, Object* object) {
	Visual* visual = &object->getVisual();
	if(!visual) {
		return;
	}

	VModel* vmodel = dynamic_cast<VModel*>(visual);

	if(!vmodel) {
		return;
	}

	const char* filename = vmodel->getFilename().c_str();
	mxml_node_t *mod_node = mxmlNewElement(obj_node, "model");
	mxmlElementSetAttrf(mod_node, "filename", "%s", filename);

	string visiblity = "true";
	if(!vmodel->isVisible()) {
		visiblity = "false";
	}

	mxmlElementSetAttrf(mod_node, "visible", "%s", visiblity.c_str());
}
Exemplo n.º 18
0
SOCKET
WSAAPI
Hookedaccept(
	SOCKET s,
	struct sockaddr *addr,
	int *addrlen
	)
{

	if ( DbgGetShellcodeFlag() == PWNYPOT_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlIDLogNode;
		CHAR szPort[20];
		sockaddr_in *sdata;
		sdata = (sockaddr_in *)addr;
		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_ACCEPT);

		if ( addr != NULL && addrlen != NULL )
		{
			mxmlElementSetAttrf(XmlIDLogNode, "socket", "%d", s);
			mxmlElementSetAttr(XmlIDLogNode, "accept_ip", inet_ntoa(sdata->sin_addr));
			mxmlElementSetAttr(XmlIDLogNode, "accept_port", _itoa(htons(sdata->sin_port),szPort, 10));
		}
		else
		{
			mxmlElementSetAttr(XmlIDLogNode, "accept_ip", "NULL");
			mxmlElementSetAttr(XmlIDLogNode, "accept_port", "NULL");
		}
		// save
		SaveXml( XmlLog );
	}


	return (accept_( s, addr, addrlen ));
}
Exemplo n.º 19
0
void BRLAN_CreateXMLTag(tag_header tagHeader, void* data, u32 offset, mxml_node_t *pane)
{
    BRLAN_fileoffset = offset;
    BRLAN_ReadDataFromMemory(&tagHeader, data, sizeof(tag_header));

    mxml_node_t *tag;
    tag = mxmlNewElement(pane, "tag"); mxmlElementSetAttrf(tag, "type", "%c%c%c%c", tagHeader.magic[0], tagHeader.magic[1], tagHeader.magic[2], tagHeader.magic[3]);

    tag_entryinfo tagEntryInfo;
    u32 tagentrylocations[tagHeader.entry_count];
    BRLAN_ReadDataFromMemory(&tagentrylocations, data, tagHeader.entry_count * sizeof(u32));
    u32 i, j;
    for ( i = 0; i < tagHeader.entry_count; i++)
    {
        mxml_node_t *entry;
        BRLAN_fileoffset = offset + be32(tagentrylocations[i]);
        BRLAN_ReadDataFromMemory(&tagEntryInfo, data, sizeof(tag_entryinfo));
        if(short_swap_bytes(tagEntryInfo.type) < 16)
	{
            char type_rlmc[4] = {'R', 'L', 'M', 'C'};
            char type_rlvc[4] = {'R', 'L', 'V', 'C'};
            if(memcmp(tagHeader.magic, type_rlmc, 4) == 0)
            {
                entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%s", tag_types_rlmc_list[short_swap_bytes(tagEntryInfo.type)]);
            } else if (memcmp(tagHeader.magic, type_rlvc, 4) == 0) {
                entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%s", tag_types_rlvc_list[short_swap_bytes(tagEntryInfo.type)]);
            } else {
                entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%s", tag_types_list[short_swap_bytes(tagEntryInfo.type)]);
            }
        } else {
            entry = mxmlNewElement(tag, "entry"); mxmlElementSetAttrf(entry, "type", "%u", short_swap_bytes(tagEntryInfo.type));
        }

        for( j = 0; j < short_swap_bytes(tagEntryInfo.coord_count); j++)
        {
            if ( tagEntryInfo.unk1 == 0x2 )
            {
                mxml_node_t *triplet;
                mxml_node_t *frame;
                mxml_node_t *value;
                mxml_node_t *blend;
                tag_data tagData;
                BRLAN_ReadDataFromMemory(&tagData, data, sizeof(tag_data));

                u32 p1 = be32(tagData.part1);
                u32 p2 = be32(tagData.part2);
                u32 p3 = be32(tagData.part3);
                triplet = mxmlNewElement(entry, "triplet");
                frame = mxmlNewElement(triplet, "frame"); mxmlNewTextf(frame, 0, "%.15f", *(f32*)(&p1));
                value = mxmlNewElement(triplet, "value"); mxmlNewTextf(value, 0, "%.15f", *(f32*)(&p2));
                blend = mxmlNewElement(triplet, "blend"); mxmlNewTextf(blend, 0, "%.15f", *(f32*)(&p3));
            } else {
                tag_data2 tagData2;
                BRLAN_ReadDataFromMemory(&tagData2, data, sizeof(tag_data2));

                mxml_node_t *pair;
                mxml_node_t *data1;
                mxml_node_t *data2;
                mxml_node_t *padding;
                u32 p1 = be32(tagData2.part1);
                u16 p2 = short_swap_bytes(tagData2.part2);
                u16 p3 = short_swap_bytes(tagData2.padding);
                pair = mxmlNewElement(entry, "pair");
                data1 = mxmlNewElement(pair, "data1"); mxmlNewTextf(data1, 0, "%.15f", *(f32*)(&p1));
                data2 = mxmlNewElement(pair, "data2"); mxmlNewTextf(data2, 0, "%04x", p2);
                padding = mxmlNewElement(pair, "padding"); mxmlNewTextf(padding, 0, "%04x", p3);
            }
        }
    }
}
Exemplo n.º 20
0
/**
 * Sets the objects tag in the XML node.
 * @param node The XML node.
 * @param tagged The tagged object.
 */
void FileProcessor::saveArea_Tag(mxml_node_t* node, Tagged* tagged) {
	mxmlElementSetAttrf(node, "tag", "%s", tagged->getTag().c_str());
}
Exemplo n.º 21
0
/**
 * Dumps an Objects position into the xml node.
 * @param object The object.
 * @param obj_node The XML node.
 */
void FileProcessor::saveArea_Position(mxml_node_t* obj_node, Object* object) {
	mxml_node_t *pos_node = mxmlNewElement(obj_node, "position");
	mxmlElementSetAttrf(pos_node, "x", "%f", object->getX());
	mxmlElementSetAttrf(pos_node, "y", "%f", object->getY());
	mxmlElementSetAttrf(pos_node, "z", "%f", object->getZ());
}
Exemplo n.º 22
0
mxml_node_t* CapturedXML::getTree() {
	bool perfCounters = false;
	mxml_node_t *xml;
    mxml_node_t *captured;
    mxml_node_t *target;
    mxml_node_t *counters;
	mxml_node_t *counter;
	int x;

	for (x=0; x<MAX_PERFORMANCE_COUNTERS; x++) {
		if (gSessionData->mPerfCounterEnabled[x]) {
			perfCounters = true;
			break;
		}
	}

	xml = mxmlNewXML("1.0");

	captured = mxmlNewElement(xml, "captured");
	mxmlElementSetAttr(captured, "version", "1");
	mxmlElementSetAttrf(captured, "protocol", "%d", PROTOCOL_VERSION);
	if (gSessionData->mBytes > 0) { // Send the following only after the capture is complete
		if (time(NULL) > 1267000000) { // If the time is reasonable (after Feb 23, 2010)
			mxmlElementSetAttrf(captured, "created", "%lu", time(NULL)); // Valid until the year 2038
		}
		mxmlElementSetAttrf(captured, "bytes", "%d", gSessionData->mBytes);
	}

	target = mxmlNewElement(captured, "target");
	mxmlElementSetAttr(target, "name", gSessionData->mCoreName);
	mxmlElementSetAttrf(target, "sample_rate", "%d", gSessionData->mSampleRate);
	mxmlElementSetAttrf(target, "cores", "%d", gSessionData->mCores);

	if (perfCounters) {
		counters = mxmlNewElement(captured, "counters");
		for (x = 0; x < MAX_PERFORMANCE_COUNTERS; x++) {
			if (gSessionData->mPerfCounterEnabled[x]) {
				counter = mxmlNewElement(counters, "counter");
				mxmlElementSetAttr(counter, "title", gSessionData->mPerfCounterTitle[x]);
				mxmlElementSetAttr(counter, "name", gSessionData->mPerfCounterName[x]);
				mxmlElementSetAttrf(counter, "color", "0x%08x", gSessionData->mPerfCounterColor[x]);
				mxmlElementSetAttrf(counter, "key", "0x%08x", gSessionData->mPerfCounterKey[x]);
				mxmlElementSetAttr(counter, "type", gSessionData->mPerfCounterType[x]);
				mxmlElementSetAttrf(counter, "event", "0x%08x", gSessionData->mPerfCounterEvent[x]);
				if (gSessionData->mPerfCounterPerCPU[x]) {
					mxmlElementSetAttr(counter, "per_cpu", "yes");
				}
				if (strlen(gSessionData->mPerfCounterOperation[x]) > 0) {
					mxmlElementSetAttr(counter, "operation", gSessionData->mPerfCounterOperation[x]);
				}
				if (gSessionData->mPerfCounterCount[x] > 0) {
					mxmlElementSetAttrf(counter, "count", "%d", gSessionData->mPerfCounterCount[x]);
				}
				if (gSessionData->mPerfCounterLevel[x]) {
					mxmlElementSetAttr(counter, "level", "yes");
				}
				if (strlen(gSessionData->mPerfCounterAlias[x]) > 0) {
					mxmlElementSetAttr(counter, "alias", gSessionData->mPerfCounterAlias[x]);
				}
				if (strlen(gSessionData->mPerfCounterDisplay[x]) > 0) {
					mxmlElementSetAttr(counter, "display", gSessionData->mPerfCounterDisplay[x]);
				}
				if (strlen(gSessionData->mPerfCounterUnits[x]) > 0) {
					mxmlElementSetAttr(counter, "units", gSessionData->mPerfCounterUnits[x]);
				}
				if (gSessionData->mPerfCounterAverageSelection[x]) {
					mxmlElementSetAttr(counter, "average_selection", "yes");
				}
				mxmlElementSetAttr(counter, "description", gSessionData->mPerfCounterDescription[x]);
			}
		}
	}

	return xml;
}
Exemplo n.º 23
0
void CCNDriver::writeEvents(mxml_node_t *const root) const {
	mxml_node_t *const counter_set = mxmlNewElement(root, TAG_COUNTER_SET);
	mxmlElementSetAttr(counter_set, ATTR_NAME, ARM_CCN_5XX_CNT);
	mxmlElementSetAttr(counter_set, ATTR_COUNT, STRIFY(CCN_COUNT));

	mxml_node_t *const category = mxmlNewElement(root, TAG_CATEGORY);
	mxmlElementSetAttr(category, ATTR_NAME, CCN_5XX);
	mxmlElementSetAttr(category, TAG_COUNTER_SET, ARM_CCN_5XX_CNT);

	mxml_node_t *const clock_event = mxmlNewElement(category, TAG_EVENT);
	mxmlElementSetAttr(clock_event, ATTR_COUNTER, ARM_CCN_5XX "ccnt");
	mxmlElementSetAttr(clock_event, ATTR_EVENT, "0xff00");
	mxmlElementSetAttr(clock_event, ATTR_TITLE, "CCN-5xx Clock");
	mxmlElementSetAttr(clock_event, ATTR_NAME, "Cycles");
	mxmlElementSetAttr(clock_event, ATTR_DISPLAY, "hertz");
	mxmlElementSetAttr(clock_event, ATTR_UNITS, "Hz");
	mxmlElementSetAttr(clock_event, ATTR_AVERAGE_SELECTION, "yes");
	mxmlElementSetAttr(clock_event, ATTR_DESCRIPTION, "The number of core clock cycles");

	mxml_node_t *const xp_option_set = mxmlNewElement(category, TAG_OPTION_SET);
	mxmlElementSetAttr(xp_option_set, ATTR_NAME, XP_REGION);

	for (int i = 0; i < mXpCount; ++i) {
		mxml_node_t *const option = mxmlNewElement(xp_option_set, TAG_OPTION);
		mxmlElementSetAttrf(option, ATTR_EVENT_DELTA, "0x%x", getConfig(i, 0, 0, 0, 0));
		mxmlElementSetAttrf(option, ATTR_NAME, "XP %i", i);
		mxmlElementSetAttrf(option, ATTR_DESCRIPTION, "Crosspoint %i", i);
	}

	for (int vc = 0; vc < ARRAY_LENGTH(VC_TYPES); ++vc) {
		if (VC_TYPES[vc] == NULL) {
			continue;
		}
		for (int bus = 0; bus < 2; ++bus) {
			for (int eventId = 0; eventId < ARRAY_LENGTH(XP_EVENT_NAMES); ++eventId) {
				if (XP_EVENT_NAMES[eventId] == NULL) {
					continue;
				}
				mxml_node_t *const event = mxmlNewElement(category, TAG_EVENT);
				mxmlElementSetAttrf(event, ATTR_EVENT, "0x%x", getConfig(0, 0x08, eventId, bus, vc));
				mxmlElementSetAttr(event, ATTR_OPTION_SET, XP_REGION);
				mxmlElementSetAttr(event, ATTR_TITLE, CCN_5XX);
				mxmlElementSetAttrf(event, ATTR_NAME, "Bus %i: %s: %s", bus, VC_TYPES[vc], XP_EVENT_NAMES[eventId]);
				mxmlElementSetAttrf(event, ATTR_DESCRIPTION, "Bus %i: %s: %s", bus, VC_TYPES[vc], XP_EVENT_DESCRIPTIONS[eventId]);
			}
		}
	}

	mxml_node_t *const hnf_option_set = mxmlNewElement(category, TAG_OPTION_SET);
	mxmlElementSetAttr(hnf_option_set, ATTR_NAME, HNF_REGION);

	for (int eventId = 0; eventId < ARRAY_LENGTH(HNF_EVENT_NAMES); ++eventId) {
		if (HNF_EVENT_NAMES[eventId] == NULL) {
			continue;
		}
		mxml_node_t *const event = mxmlNewElement(category, TAG_EVENT);
		mxmlElementSetAttrf(event, ATTR_EVENT, "0x%x", getConfig(0, 0x04, eventId, 0, 0));
		mxmlElementSetAttr(event, ATTR_OPTION_SET, HNF_REGION);
		mxmlElementSetAttr(event, ATTR_TITLE, CCN_5XX);
		mxmlElementSetAttr(event, ATTR_NAME, HNF_EVENT_NAMES[eventId]);
		mxmlElementSetAttr(event, ATTR_DESCRIPTION, HNF_EVENT_DESCRIPTIONS[eventId]);
	}

	mxml_node_t *const rni_option_set = mxmlNewElement(category, TAG_OPTION_SET);
	mxmlElementSetAttr(rni_option_set, ATTR_NAME, RNI_REGION);

	for (int eventId = 0; eventId < ARRAY_LENGTH(RNI_EVENT_NAMES); ++eventId) {
		if (RNI_EVENT_NAMES[eventId] == NULL) {
			continue;
		}
		mxml_node_t *const event = mxmlNewElement(category, TAG_EVENT);
		mxmlElementSetAttrf(event, ATTR_EVENT, "0x%x", getConfig(0, 0x16, eventId, 0, 0));
		mxmlElementSetAttr(event, ATTR_OPTION_SET, RNI_REGION);
		mxmlElementSetAttr(event, ATTR_TITLE, CCN_5XX);
		mxmlElementSetAttr(event, ATTR_NAME, RNI_EVENT_NAMES[eventId]);
		mxmlElementSetAttr(event, ATTR_DESCRIPTION, RNI_EVENT_DESCRIPTIONS[eventId]);
	}

	mxml_node_t *const sbas_option_set = mxmlNewElement(category, TAG_OPTION_SET);
	mxmlElementSetAttr(sbas_option_set, ATTR_NAME, SBAS_REGION);

	for (int eventId = 0; eventId < ARRAY_LENGTH(SBAS_EVENT_NAMES); ++eventId) {
		if (SBAS_EVENT_NAMES[eventId] == NULL) {
			continue;
		}
		mxml_node_t *const event = mxmlNewElement(category, TAG_EVENT);
		mxmlElementSetAttrf(event, ATTR_EVENT, "0x%x", getConfig(0, 0x10, eventId, 0, 0));
		mxmlElementSetAttr(event, ATTR_OPTION_SET, SBAS_REGION);
		mxmlElementSetAttr(event, ATTR_TITLE, CCN_5XX);
		mxmlElementSetAttr(event, ATTR_NAME, SBAS_EVENT_NAMES[eventId]);
		mxmlElementSetAttr(event, ATTR_DESCRIPTION, SBAS_EVENT_DESCRIPTIONS[eventId]);
	}

	for (int i = 0; i < 2*mXpCount; ++i) {
		switch (mNodeTypes[i]) {
		case NT_HNF: {
			mxml_node_t *const option = mxmlNewElement(hnf_option_set, TAG_OPTION);
			mxmlElementSetAttrf(option, ATTR_EVENT_DELTA, "0x%x", getConfig(i, 0, 0, 0, 0));
			mxmlElementSetAttrf(option, ATTR_NAME, "HN-F %i", i);
			mxmlElementSetAttrf(option, ATTR_DESCRIPTION, "Fully-coherent Home Node %i", i);
			break;
		}
		case NT_RNI: {
			mxml_node_t *const option = mxmlNewElement(rni_option_set, TAG_OPTION);
			mxmlElementSetAttrf(option, ATTR_EVENT_DELTA, "0x%x", getConfig(i, 0, 0, 0, 0));
			mxmlElementSetAttrf(option, ATTR_NAME, "RN-I %i", i);
			mxmlElementSetAttrf(option, ATTR_DESCRIPTION, "I/O-coherent Requesting Node %i", i);
			break;
		}
		case NT_SBAS: {
			mxml_node_t *const option = mxmlNewElement(sbas_option_set, TAG_OPTION);
			mxmlElementSetAttrf(option, ATTR_EVENT_DELTA, "0x%x", getConfig(i, 0, 0, 0, 0));
			mxmlElementSetAttrf(option, ATTR_NAME, "SBAS %i", i);
			mxmlElementSetAttrf(option, ATTR_DESCRIPTION, "ACE master to CHI protocol bridge %i", i);
			break;
		}
		default:
			continue;
		}
	}
}
Exemplo n.º 24
0
void parse_brlan(char* filename, char *filenameout)
{
    FILE* fp = fopen(filename, "rb");
    if(fp == NULL) {
        printf("Error! Couldn't open %s!\n", filename);
        exit(1);
    }
    fseek(fp, 0, SEEK_END);
    u32 lengthOfFile = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    u8 data[lengthOfFile];
    fread(data, lengthOfFile, 1, fp);

    int i, j;
    for(i = 0; i < 16; i++)
    {
        memset(tag_types_list[i], 0, 24);
        memset(tag_types_rlmc_list[i], 0, 24);
	memset(tag_types_rlvc_list[i], 0, 24);
    }
    strcpy(tag_types_list[0], "X Translation");
    strcpy(tag_types_list[1], "Y Translation");
    strcpy(tag_types_list[2], "Z Translation");
    strcpy(tag_types_list[3], "X Flip");
    strcpy(tag_types_list[4], "Y Flip");
    strcpy(tag_types_list[5], "Angle");
    strcpy(tag_types_list[6], "X Zoom");
    strcpy(tag_types_list[7], "Y Zoom");
    strcpy(tag_types_list[8], "Width");
    strcpy(tag_types_list[9], "Height");
    strcpy(tag_types_list[10], "0x0A");
    strcpy(tag_types_list[11], "0x0B");
    strcpy(tag_types_list[12], "0x0C");
    strcpy(tag_types_list[13], "0x0D");
    strcpy(tag_types_list[14], "0x0E");
    strcpy(tag_types_list[15], "0x0F");

    strcpy(tag_types_rlmc_list[0], "0x00");
    strcpy(tag_types_rlmc_list[1], "0x01");
    strcpy(tag_types_rlmc_list[2], "0x02");
    strcpy(tag_types_rlmc_list[3], "0x03");
    strcpy(tag_types_rlmc_list[4], "Blackcolor R");
    strcpy(tag_types_rlmc_list[5], "Blackcolor G");
    strcpy(tag_types_rlmc_list[6], "Blackcolor B");
    strcpy(tag_types_rlmc_list[7], "Blackcolor A");
    strcpy(tag_types_rlmc_list[8], "Whitecolor R");
    strcpy(tag_types_rlmc_list[9], "Whitecolor G");
    strcpy(tag_types_rlmc_list[10], "Whitecolor B");
    strcpy(tag_types_rlmc_list[11], "Whitecolor A");
    strcpy(tag_types_rlmc_list[12], "0x0C");
    strcpy(tag_types_rlmc_list[13], "0x0D");
    strcpy(tag_types_rlmc_list[14], "0x0E");
    strcpy(tag_types_rlmc_list[15], "0x0F");

    strcpy(tag_types_rlvc_list[0], "Top Left R");
    strcpy(tag_types_rlvc_list[1], "Top Left G");
    strcpy(tag_types_rlvc_list[2], "Top Left B");
    strcpy(tag_types_rlvc_list[3], "Top Left A");
    strcpy(tag_types_rlvc_list[4], "Top Right R");
    strcpy(tag_types_rlvc_list[5], "Top Right G");
    strcpy(tag_types_rlvc_list[6], "Top Right B");
    strcpy(tag_types_rlvc_list[7], "Top Right A");
    strcpy(tag_types_rlvc_list[8], "Bottom Left R");
    strcpy(tag_types_rlvc_list[9], "Bottom Left G");
    strcpy(tag_types_rlvc_list[10], "Bottom Left B");
    strcpy(tag_types_rlvc_list[11], "Bottom Left A");
    strcpy(tag_types_rlvc_list[12], "Bottom Right R");
    strcpy(tag_types_rlvc_list[13], "Bottom Right G");
    strcpy(tag_types_rlvc_list[14], "Bottom Right B");
    strcpy(tag_types_rlvc_list[15], "Bottom Right A");

    BRLAN_fileoffset = 0;
    brlan_header header;
    BRLAN_ReadDataFromMemoryX(&header, data, sizeof(brlan_header));
    BRLAN_fileoffset = short_swap_bytes(header.pai1_offset);
    brlan_pai1_universal universal;
    BRLAN_ReadDataFromMemoryX(&universal, data, sizeof(brlan_pai1_universal));
    
    int pai1_header_type;
    brlan_pai1_header_type1 pai1_header1;
    brlan_pai1_header_type2 pai1_header2;
    brlan_pai1_header_type2 pai1_header;

    if((be32(universal.flags) & (1 << 25)) >= 1) {
        pai1_header_type = 2;
        BRLAN_ReadDataFromMemory(&pai1_header2, data, sizeof(brlan_pai1_header_type2));
    } else {
        pai1_header_type = 1;
        BRLAN_ReadDataFromMemory(&pai1_header1, data, sizeof(brlan_pai1_header_type1));
    }

    CreateGlobal_pai1(&pai1_header, pai1_header1, pai1_header2, pai1_header_type);


    FILE *xmlFile;
    xmlFile = fopen(filenameout, "w");
    mxml_node_t *xml;
    mxml_node_t *xmlan;
    xml = mxmlNewXML("1.0");
    xmlan = mxmlNewElement(xml, "xmlan");
    mxmlElementSetAttrf(xmlan, "version", "%d.%d.%d%s", BENZIN_VERSION_MAJOR, BENZIN_VERSION_MINOR, BENZIN_VERSION_BUILD, BENZIN_VERSION_OTHER);
    mxmlElementSetAttrf(xmlan, "framesize", "%lu", (long unsigned int)short_swap_bytes(pai1_header.framesize));
    mxmlElementSetAttrf(xmlan, "flags", "%02x", pai1_header.flags);

    int timgs = short_swap_bytes(pai1_header.num_timgs);

    BRLAN_fileoffset = short_swap_bytes(header.pai1_offset) + sizeof(brlan_pai1_header_type1);
    if ( pai1_header_type == 2 ) BRLAN_fileoffset += 4;
    int tableoff = BRLAN_fileoffset;
    int currtableoff = BRLAN_fileoffset;

    mxml_node_t *timg;
    for( i = 0; i < timgs; i++) {
        u32 curr_timg_off = 0;
        BRLAN_ReadDataFromMemory(&curr_timg_off, data, 4);
        char timgname[256];
        memset(timgname, 0, 256);
        int z = tableoff + be32(curr_timg_off);
        for( j = 0; data[z] != 0; timgname[j++] = data[z], z++);
        {
            timg = mxmlNewElement(xmlan, "timg");
            mxmlElementSetAttrf(timg, "name", "%s", timgname);
        }
        currtableoff += 4;
    }

    int tagcount = short_swap_bytes(pai1_header.num_entries);
    u32 taglocations[tagcount];
    BRLAN_fileoffset = be32(pai1_header.entry_offset) + short_swap_bytes(header.pai1_offset);
    BRLAN_ReadDataFromMemory(taglocations, data, tagcount * sizeof(u32));

    for( i = 0; i < tagcount; i++) {
        brlan_entry brlanEntry;
        tag_header tagHeader;
        BRLAN_fileoffset = be32(taglocations[i]) + short_swap_bytes(header.pai1_offset);
        u32 brlanEntryOffset = BRLAN_fileoffset;
        BRLAN_ReadDataFromMemory(&brlanEntry, data, sizeof(brlan_entry));

        mxml_node_t *pane;
        pane = mxmlNewElement(xmlan, "pane"); mxmlElementSetAttrf(pane, "name", "%s", brlanEntry.name); mxmlElementSetAttrf(pane, "type", "%u", brlanEntry.is_material);

        u32 entrylocations[brlanEntry.num_tags];
        BRLAN_ReadDataFromMemory(entrylocations, data, brlanEntry.num_tags * sizeof(u32));
        for ( j = 0; j < brlanEntry.num_tags; j++)
        {
            BRLAN_CreateXMLTag(tagHeader, data, brlanEntryOffset + be32(entrylocations[j]), pane);
        }
     }
    mxmlSaveFile(xml, xmlFile, whitespace_cb);
    mxmlDelete(xml);
    fclose(xmlFile);
    fclose(fp);
}
Exemplo n.º 25
0
SOCKET
WSAAPI
Hookedsocket(
	int af,
	int type,
	int protocol
	)
{
	int ret_val;

	ret_val = (socket_( af, type, protocol));
	if ( DbgGetShellcodeFlag() == PWNYPOT_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlIDLogNode;

		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		// type
		mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_SOCKET);
		mxmlElementSetAttrf(XmlIDLogNode, "socket", "%d", ret_val);
		// socket
		switch (af) 
		{
		case AF_UNSPEC:
			mxmlElementSetAttr( XmlIDLogNode, "AF", "Unspecified");
				break;
		case AF_INET:
			mxmlElementSetAttr( XmlIDLogNode, "AF", "AF_INET (IPv4)");
			break;
		case AF_INET6:
			mxmlElementSetAttr( XmlIDLogNode, "AF", "AF_INET6 (IPv6)");
			break;
		case AF_NETBIOS:
			mxmlElementSetAttr( XmlIDLogNode, "AF", "AF_NETBIOS (NetBIOS)");
			break;
		case AF_BTH:
			mxmlElementSetAttr( XmlIDLogNode, "AF", "AF_BTH (Bluetooth)");
			break;
		default:
			mxmlElementSetAttr( XmlIDLogNode, "AF", "Other");
			break;
		}

		switch (type) 
		{
		case 0:
			mxmlElementSetAttr( XmlIDLogNode, "socket_type", "Unspecified");
			break;
		case SOCK_STREAM:
			mxmlElementSetAttr( XmlIDLogNode, "socket_type", "SOCK_STREAM (stream)");
			break;
		case SOCK_DGRAM:
			mxmlElementSetAttr( XmlIDLogNode, "socket_type", "SOCK_DGRAM (datagram)");
			break;
		case SOCK_RAW:
			mxmlElementSetAttr( XmlIDLogNode, "socket_type", "SOCK_RAW (raw)");
			break;
		case SOCK_RDM:
			mxmlElementSetAttr( XmlIDLogNode, "socket_type", "SOCK_RDM (reliable message datagram)");
			break;
		case SOCK_SEQPACKET:
			mxmlElementSetAttr( XmlIDLogNode, "socket_type", "SOCK_SEQPACKET (pseudo-stream packet)");
			break;
		default:
			mxmlElementSetAttr( XmlIDLogNode, "socket_type", "Other");
			break;
		}

		switch (protocol)
		{
		case 0:
			mxmlElementSetAttr( XmlIDLogNode, "socket_protocol", "Unspecified");
			break;
		case IPPROTO_ICMP:
			mxmlElementSetAttr( XmlIDLogNode, "socket_protocol", "IPPROTO_ICMP (ICMP)");
			break;
		case IPPROTO_IGMP:
			mxmlElementSetAttr( XmlIDLogNode, "socket_protocol", "IPPROTO_IGMP (IGMP)");
			break;
		case IPPROTO_TCP:
			mxmlElementSetAttr( XmlIDLogNode, "socket_protocol", "IPPROTO_TCP (TCP)");
			break;
		case IPPROTO_UDP:
			mxmlElementSetAttr( XmlIDLogNode, "socket_protocol", "IPPROTO_UDP (UDP)");
			break;
		case IPPROTO_ICMPV6:
			mxmlElementSetAttr( XmlIDLogNode, "socket_protocol", "IPPROTO_ICMPV6 (ICMP Version 6)");
			break;
		default:
			mxmlElementSetAttr( XmlIDLogNode, "socket_protocol", "Other");
			break;
		}
		// save
		SaveXml( XmlLog );
	}
	return ret_val;
}