Пример #1
0
int main(int argc, char** argv)
{
	if (argc == 4)
	{
		printf("VhdCopy %s %s %s\n", argv[1], argv[2], argv[3]);
		//return help();
	}
	else if (argc == 5 && _stricmp(argv[4],"-g")==0)
	{
		printf("VhdCopy %s %s %s %s\n", argv[1], argv[2], argv[3], argv[4]);
		GUI_error = true;
	}
	else
	{
		help();
		exit_error("Bad command line arguments\n");
	}
	VirtualDisk vhd;
	if (!vhd.Open(argv[1]))
	{
		help();
		exit_error("Open VHD file \"%s\" failed\n", argv[1]);
	}
	else if (!vhd.Attach())
	{
		help();
		exit_error("Attach VHD file \"%s\" failed\n", argv[1]);
	}
	char VhdVolume = vhd.AttachedVolumeName();
	if (VhdVolume == 0)
	{
		help();
		exit_error("Unknown attached VHD volume name\n");
	}

	char *fromfile = NULL, *tofile = NULL;
	if (_memicmp(argv[2], "vhd:\\", 5) == 0)
	{
		fromfile = argv[2] + 2;
		fromfile[0] = VhdVolume;
		tofile = argv[3];
	}
	else if (_memicmp(argv[3], "vhd:\\", 5) == 0)
	{
		fromfile = argv[2];
		tofile = argv[3] + 2;
		tofile[0] = VhdVolume;
	}
	else
	{
		help();
		exit_error("Bad command line arguments\n");
	}
	BOOL ret = CopyFile(fromfile, tofile, false);
	if (!ret)
	{
		exit_error("CopyFile failed with error %08X\n", GetLastError());
	}
	return 0;
}
Пример #2
0
static c_bop GetCOp( int * i )
/****************************/
{
    int size = 0;
    c_bop rc;
    char *p = AsmBuffer[*i]->string_ptr;

    if ( AsmBuffer[*i]->token == T_STRING )
        size = AsmBuffer[*i]->value;

    if ( size == 2 ) {
        if ( *p == '=' && *(p+1) == '=' )
            rc = COP_EQ;
        else if ( *p == '!' && *(p+1) == '=' )
            rc = COP_NE;
        else if ( *p == '>' && *(p+1) == '=' )
            rc = COP_GE;
        else if ( *p == '<' && *(p+1) == '=' )
            rc = COP_LE;
        else if ( *p == '&' && *(p+1) == '&' )
            rc = COP_AND;
        else if ( *p == '|' && *(p+1) == '|' )
            rc = COP_OR;
        else
            return( COP_NONE );
    } else if ( size == 1 ) {
        if ( *p == '>' )
            rc = COP_GT;
        else if ( *p == '<' )
            rc = COP_LT;
        else if ( *p == '&' )
            rc = COP_ANDB;
        else if ( *p == '!' )
            rc = COP_NEG;
        else
            return( COP_NONE );
    } else {
        if ( AsmBuffer[*i]->token != T_ID )
            return( COP_NONE );
        /* a valid "flag" string must end with a question mark */
        size = strlen( AsmBuffer[*i]->string_ptr );
        if ( *(p+size-1) != '?' )
            return( COP_NONE );
        if ( size == 5 && ( 0 == _memicmp( p, "ZERO", 4 ) ) )
            rc = COP_ZERO;
        else if ( size == 6 && ( 0 == _memicmp( p, "CARRY", 5 ) ) )
            rc = COP_CARRY;
        else if ( size == 5 && ( 0 == _memicmp( p, "SIGN", 4 ) ) )
            rc = COP_SIGN;
        else if ( size == 7 && ( 0 == _memicmp( p, "PARITY", 6 ) ) )
            rc = COP_PARITY;
        else if ( size == 9 && ( 0 == _memicmp( p, "OVERFLOW", 8 ) ) )
            rc = COP_OVERFLOW;
        else
            return( COP_NONE );
    }
    *i += 1;
    return( rc );
}
Пример #3
0
CHAR *Isapi_ArgAlloc(EXTENSION_CONTROL_BLOCK *pECB,CHAR *lpVarName)
{
	// pECB->lpszQueryString
	CHAR *p,*p2;
	CHAR szName[180];
	UINT is;
	sprintf(szName,"&%s=",lpVarName);

	if (!pECB->lpszQueryString) return NULL;
	is=(UINT) strlen(szName); if (strlen(pECB->lpszQueryString)<is) return NULL;
	
	// Se inizia per
	if (!_memicmp(pECB->lpszQueryString,szName+1,is-1))
	{
		p=pECB->lpszQueryString; p+=(is-1);
		p2=strstr(p,"&"); if (p2) *p2=0;
		p=strDecode(p,SE_URL,NULL);
		if (p2) *p2='&';
		return p;
	}
	// Cerco all'interno
	p=strCaseStr(pECB->lpszQueryString,szName); if (!p) return NULL;
	p+=strlen(szName); p2=strstr(p,"&"); if (p2) *p2=0;
	p=strDecode(p,SE_URL,NULL);
	if (p2) *p2='&';
	return p;
}
Пример #4
0
////////////////////////////////////////////////////////////////////////
// Function:	cmp
// Description:	compares to TCHARs - case insensitive
// Author:		James Morley-Smith
// Date:		December 2004
////////////////////////////////////////////////////////////////////////
BOOL cmp(LPCTSTR tc1, LPCTSTR tc2)
{
	if (!tc1 || !tc2)
		return false;

	return !_memicmp(tc1, tc2, wcslen(tc1)*sizeof(TCHAR));
}
Пример #5
0
////////////////////////////////////////////////////////////////////////
// Function:	cmp
// Description:	compares to TCHARs - case insensitive
// Author:		James Morley-Smith
// Date:		December 2004
////////////////////////////////////////////////////////////////////////
BOOL cmp(LPCTSTR tc1, LPCTSTR tc2, int iChars)
{
	if (!tc1 || !tc2)
		return false;

	return !_memicmp(tc1, tc2, iChars*sizeof(TCHAR));
}
Пример #6
0
bool get_per_user(void)
{
    TCHAR buffer[MAX_PATH];
    buffer[0] = 0;
    rw_reg(A_RD | A_SZ, HKEY_LOCAL_MACHINE, inimapstr, TEXT("Shell"), buffer);
    return 0 == _memicmp(buffer, "USR:", 4);
}
Пример #7
0
/**
 * @brief Parser for HTML files to find encoding information
 */
static unsigned demoGuessEncoding_html(const char *src, size_t len)
{
	CMarkdown markdown(src, src + len, CMarkdown::Html);
	//As <html> and <head> are optional, there is nothing to pull...
	//markdown.Move("html").Pop().Move("head").Pop();
	while (markdown.Move("meta"))
	{
		CMarkdown::String http_equiv = markdown.GetAttribute("http-equiv");
		if (http_equiv.A && lstrcmpiA(http_equiv.A, "content-type") == 0)
		{
			CMarkdown::String content = markdown.GetAttribute("content");
			if (char *pchKey = content.A)
			{
				while (int cchKey = strcspn(pchKey += strspn(pchKey, "; \t\r\n"), ";="))
				{
					char *pchValue = pchKey + cchKey;
					int cchValue = strcspn(pchValue += strspn(pchValue, "= \t\r\n"), "; \t\r\n");
					if (cchKey >= 7 && _memicmp(pchKey, "charset", 7) == 0 && (cchKey == 7 || strchr(" \t\r\n", pchKey[7])))
					{
						pchValue[cchValue] = '\0';
						// Is it an encoding name known to charsets module ?
						unsigned encodingId = FindEncodingIdFromNameOrAlias(pchValue);
						if (encodingId)
						{
							return GetEncodingCodePageFromId(encodingId);
						}
						return 0;
					}
					pchKey = pchValue + cchValue;
				}
			}
		}
	}
	return 0;
}
Пример #8
0
void CIEBrowserEngine::InvokeEngineEventLoad(LPTSTR tcURL, EngineEventID eeEventID)
{
	//  Engine component has indicated a load event, this should be 
	//  one of BeforeNavigate, NavigateComplete or DocumentComplete.
	wcscpy(m_tcNavigatedURL, tcURL);

	switch (eeEventID)
	{
		case EEID_BEFORENAVIGATE:
			m_bLoadingComplete = FALSE;
			SetEvent(m_hNavigated);
			CloseHandle(m_hNavigated);
			m_hNavigated = NULL;

			//  Do not start the Navigation Timeout Timer if the 
			//  navigation request is a script call.
			if((!_memicmp(tcURL, L"javascript:", 11 * sizeof(TCHAR)))
				|| (!_memicmp(tcURL, L"jscript:", 8 * sizeof(TCHAR)))
				|| (!_memicmp(tcURL, L"vbscript:", 9 * sizeof(TCHAR)))
				|| (!_memicmp(tcURL, L"res://\\Windows\\shdoclc.dll/navcancl.htm", 35 * sizeof(TCHAR))))
			{
					break;
			}

			//  Test if the user has attempted to navigate back in the history
			if (wcsicmp(tcURL, L"history:back") == 0)
			{
			}
			
			CloseHandle (CreateThread(NULL, 0, 
									&CIEBrowserEngine::NavigationTimeoutThread, 
									(LPVOID)this, 0, NULL));

            PostMessage(m_parentHWND, WM_BROWSER_ONBEFORENAVIGATE, (WPARAM)m_tabID, (LPARAM)_tcsdup(tcURL));
			break;
		case EEID_DOCUMENTCOMPLETE:
			m_bLoadingComplete = TRUE;
            PostMessage(m_parentHWND, WM_BROWSER_ONDOCUMENTCOMPLETE, m_tabID, (LPARAM)_tcsdup(tcURL));
			break;
		case EEID_NAVIGATECOMPLETE:
			SetEvent(m_hNavigated);
			CloseHandle(m_hNavigated);
			m_hNavigated = NULL;
            SendMessage(m_parentHWND, WM_BROWSER_ONNAVIGATECOMPLETE, (WPARAM)m_tabID, (LPARAM)tcURL);			
			break;
	}
}
Пример #9
0
/**
 * @brief Remove prefix from the text.
 * @param [in] text Text to process.
 * @param [in] prefix Prefix to remove.
 * @return Text without the prefix.
 */
static const char *EatPrefix(const char *text, const char *prefix)
{
	int len = strlen(prefix);
	if (len)
		if (_memicmp(text, prefix, len) == 0)
			return text + len;
	return 0;
}
Пример #10
0
VOID Poll()
{
	char Msg[256];
	int len;

	len = recvfrom(sock, Msg, 256, 0, &rx, &addrlen);

	if (len <= 0)
		return;

	Msg[len] = 0;

	if (_memicmp(Msg, "REMOTE:", 7) == 0)
		RestartTNC(&Msg[7]);

	if (_memicmp(Msg, "KILL ", 5) == 0)
		KillTNC(atoi(&Msg[5]));
	
}
Пример #11
0
int n_stricmp(const char **pp, const char *s)
{
	int n = (int)strlen (s);
	int i = _memicmp(*pp, s, n);
	if (i) return i;
	i = (*pp)[n] - ' ';
	if (i > 0) return i;
	*pp += n;
	while (' '== **pp) ++*pp;
	return 0;
}
Пример #12
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//beginPlugin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int beginPlugin(HINSTANCE hMainInstance)
{
	if (plugin_hwnd_blackbox)
	{
		MessageBox(plugin_hwnd_blackbox, "Dont load me twice!", szAppName, MB_OK|MB_SETFOREGROUND);
		return 1;
	}

	//Deal with instances
	plugin_instance_plugin = hMainInstance;
	plugin_hwnd_blackbox = GetBBWnd();

	const char *bbv = GetBBVersion();
	if (0 == _memicmp(bbv, "bblean", 6)) BBVersion = BBVERSION_LEAN;
	else
	if (0 == _memicmp(bbv, "bb", 2)) BBVersion = BBVERSION_XOB;
	else BBVersion = BBVERSION_09X;

	//Deal with os info
	plugin_getosinfo();

#ifdef BBINTERFACE_ALPHA_SOFTWARE
	int result = BBMessageBox(plugin_hwnd_blackbox,
		"WARNING!\n\n"
		"This is ALPHA software! Use at your own risk!\n\n"
		"The authors are not responsible in the event that:\n - your configuration is lost,\n - your computer blows up,\n - you are hit by a truck, or\n - anything else at all.\n\n"
		"Do you wish to continue loading this ALPHA software?",
		"BBInterface ALPHA Warning",
		MB_ICONWARNING|MB_DEFBUTTON2|MB_YESNO);
	if (result != IDYES) return 0;
#endif

	//Startup
	plugin_load = true;
	plugin_startup();

	return 0;
}
Пример #13
0
//////////
//
// Searches through the haystack to find the needle.  Needle is NULL-
// terminated, and haystack is length-terminated.
//
//////
bool iIsNeedleInHaystack(s8* haystack, s32 haystackLength, s8* needle, s32 needleLength)
{
    s32 lnI;

    // Check to see if the specified word / phrase / whatever exists on this line
    for (lnI = 0; lnI <= haystackLength - needleLength; lnI++)
    {
        if (_memicmp(haystack + lnI, needle, needleLength) == 0)
            return(true);
    }

    // Failure
    return(false);
}
Пример #14
0
bool CAutoplayerTrace::SymbolNeedsToBeLogged(CString name) {
  // DLL, as there is no caching and value might change
  if (memcmp(name, "dll$", 4) == 0) return true;
  // Memory-store and recall-commands
  if (memcmp(name, "me_", 3) == 0) return true;
  // OpenPPL-user-variables might also change (once)
  // We don't care about multiple loggings of userchair here
  if (_memicmp(name, "user", 4) == 0) return true;
  // True random numbers that don't get cached,
  // i.e. OH-script "random" and OpenPPL "Random"
  if (memcmp(name, "random", 6) == 0) return true;
  if (memcmp(name, "Random", 6) == 0) return true;
  // Values that already got logged can be ignored
  if (_already_logged_symbols[name] == true) return false;
  // Everything else needs to be logged
  return true;
}
Пример #15
0
bool BBP_broam_string(struct plugin_info *PI, const char *temp, const char *key, const char **ps)
{
    int n = strlen(key);
    const char *s;
    if (_memicmp(temp, key, n))
        return false;
    s = temp + n;
    if (' ' != *s)
        return false;
    while (' ' == *s)
        ++s;
    if (0 == *s)
        return false;
    *ps = s;
    if (PI) BBP_write_string(PI, key, s);
    return true;
}
Пример #16
0
bool BBP_broam_int(struct plugin_info *PI, const char *temp, const char *key, int *ip)
{
    int n = strlen(key);
    const char *s;
    if (_memicmp(temp, key, n))
        return false;
    s = temp + n;
    if (' ' != *s)
        return false;
    while (' ' == *s)
        ++s;
    if (0 == *s)
        return false;
    *ip = atoi(s);
    if (PI) BBP_write_int(PI, key, *ip);
    return true;
}
Пример #17
0
// Returns -1, 0, or 1 (indicating left is less than, equal to, or greater than right)
s32 iDatum_compare(SDatum* datumLeft, SDatum* datumRight)
{
    s32 lnResult;


    // Default to invalid data
    lnResult = -2;

    // Make sure our environment is sane
    if (datumLeft && datumLeft->data && datumLeft->length != 0 && datumRight && datumRight->data && datumRight->length > 0)
    {
        // Do a standard compare
        lnResult = _memicmp(datumLeft->data, datumRight->data, min(datumLeft->length, datumRight->length));
    }

    // Indicate our result
    return(lnResult);
}
Пример #18
0
void CIEBrowserEngine::executeJavascript(const wchar_t* szJSFunction, int index)
{
    //  Test to see if the passed function starts with "JavaScript:" and 
    //  if it does not then prepend it.
    if (_memicmp(szJSFunction, L"JavaScript:", 22))
    {
        //  Function does not start with JavaScript:
        TCHAR* tcURI = new TCHAR[MAX_URL];
        wsprintf(tcURI, L"JavaScript:%s", szJSFunction);
        LRESULT retVal;
        retVal = Navigate(tcURI, 0);
        delete[] tcURI;
    }
    else
    {
        Navigate(szJSFunction, 0);
    }
}
Пример #19
0
const curse_type *ct_find(const char *c)
{
  unsigned int hash = tolower(c[0]);
  quicklist *ctl = cursetypes[hash];
  int qi;

  for (qi = 0; ctl; ql_advance(&ctl, &qi, 1)) {
    curse_type *type = (curse_type *) ql_get(ctl, qi);

    if (strcmp(c, type->cname) == 0) {
      return type;
    } else {
      size_t k = _min(strlen(c), strlen(type->cname));
      if (!_memicmp(c, type->cname, k)) {
        return type;
      }
    }
  }
  return NULL;
}
Пример #20
0
bool BBP_broam_bool(struct plugin_info *PI, const char *temp, const char *key, bool *ip)
{
    int n = strlen(key);
    const char *s;
    if (_memicmp(temp, key, n))
        return false;
    s = temp + n;
    while (' ' == *s) ++s;
    if (0 == *s || 0 == _stricmp(s, "toggle"))
        *ip = false == *ip;
    else
    if (0 == _stricmp(s, "false"))
        *ip = false;
    else
    if (0 == _stricmp(s, "true"))
        *ip = true;
    else
        return false;
    if (PI) BBP_write_bool(PI, key, *ip);
    return true;
}
bool CSymbolEngineOpenPPLUserVariables::EvaluateSymbol(const char *name, double *result, bool log /* = false */) {
  FAST_EXIT_ON_OPENPPL_SYMBOLS(name);
  if (_memicmp(name, "user", 4) != 0) {
    // Not a user-variable
    return false;
  }
  if (memcmp(name+4, "chair", 5) == 0) {
    // Symbol "userchair", not a user-variable
    return false;
  }
  // Try to look it up
  if (_user_variables[name]) {
    write_log(preferences.debug_symbolengine_open_ppl(),
      "[CSymbolEngineOpenPPLUserVariables] user-variable exists: %s\n", name);
    *result = double(true);
    return true;
  }
  write_log(preferences.debug_symbolengine_open_ppl(),
    "[CSymbolEngineOpenPPLUserVariables] user-variable does not exist: %s\n", name);
  *result = double(false);
  return true;
}
Пример #22
0
s32 iDatum_compare(SDatum* datumLeft, s8* data, s32 dataLength)
{
    s32 lnResult;


    // Default to invalid data
    lnResult = -2;

    // Make sure our environment is sane
    if (datumLeft && datumLeft->data && datumLeft->length != 0 && data)
    {
        // Make sure our length is set
        if (dataLength < 0)
            dataLength = (s32)strlen(data);

        // Do a standard compare
        lnResult = _memicmp(datumLeft->data, data, min(datumLeft->length, dataLength));
    }

    // Indicate our result
    return(lnResult);
}
Пример #23
0
//////////
//
// Find the indicated class based on its name
//
//////
	SClassX* iHwndX_findClass_byName(cs8* lpClassName)
	{
		u32			lnI, lnLength;
		SClassX*	cls;


		// Make sure our environment is sane
		if (lpClassName)
		{
			// Iterate through each class until we find the correct one
			lnLength = strlen(lpClassName);
			for (lnI = 0, cls = (SClassX*)gsClasses->buffer; lnI < gsClasses->populatedLength; lnI += sizeof(SClassX), cls++)
			{
				// If it's valid, and the class maches, we're good
				if (cls->isValid && strlen(cls->wcx.lpszClassName) == lnLength && _memicmp(cls->wcx.lpszClassName, lpClassName, lnLength) == 0)
					return(cls);
			}
			// If we get here, the class was not found
		}

		// If we get here, invalid
		return(NULL);
	}
Пример #24
0
int substr_icmp(const char *a, const char *b)
{
    return _memicmp(a, b, strlen(b));
}
Пример #25
0
//====================
void CommandItem::Invoke(int button)
{
    LPCITEMIDLIST pidl = GetPidl();
    if (INVOKE_PROP & button)
    {
        show_props(pidl);
        return;
    }
		/*BlackboxZero 1.7.2012 */
        char szPath[MAX_PATH];
		szPath[0] = '\0';

    if (INVOKE_LEFT & button)
    {

        m_pMenu->hide_on_click();
        if (m_pszCommand) {
			/*BlackboxZero 1.7.2012 */
			//if (const char *p = strstr(m_pszCommand, "%b")) {
            //    post_command_fmt(m_pszCommand, false == m_bChecked);
			if (const char *p = stristr(m_pszCommand, "@BBCore.exec ")) {
                _strcpy(szPath, p+13);
				post_command(m_pszCommand);
			} else
                post_command(m_pszCommand);
		} else if (pidl) {
			char buf[MAX_PATH];
		/*BlackboxZero 1.7.2012 */
			char szMenuPath[MAX_PATH];
			szMenuPath[0] = '\0';
			if (SHGetPathFromIDList(pidl, buf))
				sprintf(szPath, "\"%s\"", buf);
			/*BlackboxZero 1.7.2012 */

            BBExecute_pidl(NULL, pidl);

			/*BlackboxZero 1.7.2012 */
			strcpy(szMenuPath, unquote(Settings_recentMenu));
			int nKeep = Settings_recentItemKeepSize;
			int nSort = Settings_recentItemSortSize;
			bool bBeginEnd = Settings_recentBeginEnd;

			if (szPath[0] && szMenuPath[0] && (nKeep || nSort))
				CreateRecentItemMenu(szMenuPath, szPath, m_pszTitle, m_pszIcon, nKeep, nSort, bBeginEnd);
			/*BlackboxZero 1.7.2012 */
		}
        return;
    }

    if (INVOKE_RIGHT & button)
    {
        if (m_pszRightCommand)
            post_command(m_pszRightCommand);
        else
        if (m_pRightmenu)
            m_pRightmenu->incref(), ShowRightMenu(m_pRightmenu);
        else
		if ((GetAsyncKeyState (VK_SHIFT) & 0x8000))
		{
			char buffer[MAX_PATH], param[MAX_PATH];
			char *tokens[1];
			tokens[0] = param;
			BBTokenize((const char*)m_pszCommand, tokens, 1, param);
			if (0 == _memicmp(m_pszCommand, "@BBCfg.plugin", 12)) 
			{
				if ((GetAsyncKeyState (VK_CONTROL) & 0x8000))
					sprintf(buffer, "@BBCfg.plugin.remove %s", param);
				else
					sprintf(buffer, "@BBCfg.plugin.edit %s", param);
				post_command(buffer);
			}
			else
				if (0 == _memicmp(m_pszCommand, "@BBCore.style", 12)) 
				{
					sprintf(buffer, "@BBCore.edit %s", param);
					post_command(buffer);
				}
		}
		else
            ShowContextMenu(m_pszCommand, pidl);
        return;
    }

    if (INVOKE_MID & button)
    {
		if (0 == _memicmp(m_pszCommand, "@BBCfg.plugin", 12)) 
		{
			char buffer[MAX_PATH], param[MAX_PATH];
			char *tokens[1];
			tokens[0] = param;
			BBTokenize((const char*)m_pszCommand, tokens, 1, param);
			sprintf(buffer, "@BBCfg.plugin.docs %s", param);
			post_command(buffer);
		}
		return;
	}

    if (INVOKE_DRAG & button)
    {
        m_pMenu->start_drag(m_pszCommand, pidl);
        return;
    }
}
Пример #26
0
//////////
//
// Debugger interface to request function addresses for interface
//
// See devhelp.txt.  Duplicate changes here in VDebug.h, vvm.cpp, vvm_v1.cpp, vvm_defs.h, and vo_class.h.
//
//////
	// See what function they're requesting
	u64 CALLTYPE vvm_debuggerInterfaceCallback(s8* tcFunctionName)
	{
		u64			lnFuncAddress;
		u32			lnI, lnHaystackLength, lnNeedleLength;
		s8*			lcFuncName;
		void**		lcFuncAddress;


//////////
//
// O S S   FUNCTIONS
//
//////
		// Search for the needle (tnFunctionName) in the haystack (gVvmOssFunction's lcFuncName)
		lnNeedleLength = strlen(tcFunctionName);
		for (lnI = 0; lnI < gVvmOssFunctionCount; lnI++)
		{
			// Grab the details of this entry
			lcFuncAddress	= (void**)gVvmOssFunctions[(lnI * 2) + 0];						// Grab the indirect address to store
			lcFuncName		= (s8*)   gVvmOssFunctions[(lnI * 2) + 1];						// Grab the function name to request

			lnHaystackLength = strlen(lcFuncName);
			if (lnNeedleLength == lnHaystackLength && _memicmp(tcFunctionName, lcFuncName, lnHaystackLength) == 0)
				return((u64)*lcFuncAddress);
		}
		// If we get here, not found in VVMOSS functions


//////////
//
// M C   FUNCTIONS
//
//////
		// Search for the needle (tnFunctionName) in the haystack (gVvmmcFunctions's lcFuncName)
		lnNeedleLength = strlen(tcFunctionName);
		for (lnI = 0; lnI < gMcFunctionCount; lnI++)
		{
			// Grab the details of this entry
			lcFuncAddress	= (void**)gMcFunctions[(lnI * 2) + 0];							// Grab the indirect address to store
			lcFuncName		= (s8*)   gMcFunctions[(lnI * 2) + 1];							// Grab the function name to request

			lnHaystackLength = strlen(lcFuncName);
			if (lnNeedleLength == lnHaystackLength && _memicmp(tcFunctionName, lcFuncName, lnHaystackLength) == 0)
				return((u64)*lcFuncAddress);
		}
		// If we get here, not found



//////////
//
// V V M   FUNCTIONS
//
//////
		// Search for the needle (tnFunctionName) in the haystack (gVvmmcFunctions's lcFuncName)
		lnNeedleLength = strlen(tcFunctionName);
		for (lnI = 0; lnI < gVvmFunctionCount; lnI++)
		{
			// Grab the details of this entry
			lnFuncAddress	= (u64)gVvmFunctions[(lnI * 2) + 0];							// Grab the indirect address to store
			lcFuncName		= (s8*)gVvmFunctions[(lnI * 2) + 1];							// Grab the function name to request

			lnHaystackLength = strlen(lcFuncName);
			if (lnNeedleLength == lnHaystackLength && _memicmp(tcFunctionName, lcFuncName, lnHaystackLength) == 0)
				return(lnFuncAddress);
		}
		// If we get here, not found

		// If we get here, indicate our failure
		return(NULL);
	}
Пример #27
0
//////////
//
// Parses the text of the line into any known tokens
//
//////
	SComp* iParseSourceCodeLine(SLine* line)
	{
		SComp* comp;
		SComp* compNext;


		//////////
		// Make sure we have a compilerInfo block
		//////
			if (!line->compilerInfo)
			{
				// Allocate the compiler info
				line->compilerInfo = iCompiler_allocate(line);
				if (!line->compilerInfo)
				{
					// Should never happen
					printf("Out of memory\n");
					exit_program(-999);
				}
			}

		//////////
		// Make sure we have our SOppie1Instruction allocated
		//////
			if (!line->compilerInfo->extra_info)
			{
				// Allocate a structure
				line->compilerInfo->extra_info = (SOppie1Instruction*)malloc(sizeof(SOppie1Instruction));
				if (!line->compilerInfo->extra_info)
				{
					// Should never happen
					printf("Out of memory\n");
					exit_program(-998);
				}

				// Initialize to NULLs
				memset(line->compilerInfo->extra_info, 0, sizeof(SOppie1Instruction));
			}


		//////////
		// Parse out the line
		//////
			iComps_translateSourceLineTo(&cgcFundamentalSymbols[0], line);
			if (!line->compilerInfo->firstComp)
				return(NULL);	// Nothing to compile on this blank line

			// Remove whitespaces [x][whitespace][y] becomes [x][y]
			iComps_removeLeadingWhitespaces(line);
			if (!line->compilerInfo->firstComp)
				return(NULL);	// Nothing to compile on this line with only whitespaces


		//////////
		// We don't need to process comment-only lines
		//////
			if ((comp = line->compilerInfo->firstComp) && (comp->iCode == _ICODE_COMMENT || comp->iCode == _ICODE_LINE_COMMENT))
			{
				//////////
				// Combine every item after this to a single comment component or easy parsing and handling
				//////
					iComps_combineN(comp, 99999, comp->iCode, comp->iCat, comp->color);

			} else {
				//////////
				// Perform natural source code fixups
				//////
					iComps_removeStartEndComments(line);		// Remove /* comments */
					iComps_fixupNaturalGroupings(line);			// Fixup natural groupings [_][aaa][999] becomes [_aaa999], [999][.][99] becomes [999.99], etc.
					iComps_removeWhitespaces(line);				// Remove all whitespaces after everything else was parsed [use][whitespace][foo] becomes [use][foo]


				//////////
				// Translate sequences to known keywords
				//////
					iComps_translateToOthers((SAsciiCompSearcher*)&cgcKeywordsOppie1[0], line);


				//////////
				// Perform fixups that are unique to Oppie-1
				//////
					// .org
					// [.org] as a _ICODE_DOT_VARIABLE, becomes [.org] as _ICODE_DOT_ORG
					if (comp->iCode == _ICODE_DOT_VARIABLE && comp->length == 4 && _memicmp(comp->line->sourceCode->data_s8 + comp->start + 1, "org", 3) == 0)
						comp->iCode = _ICODE_ORG;

					// label:
					// [alpha][:] becomes [label]
					if ((compNext = (SComp*)comp->ll.next) && (comp->iCode == _ICODE_ALPHA || comp->iCode == _ICODE_ALPHANUMERIC) && compNext->iCode == _ICODE_COLON)
						iComps_combineN(comp, 2, _ICODE_LABEL, compNext->iCat, compNext->color);
			}


		//////////
		// Return the first component
		//////
			return(line->compilerInfo->firstComp);
	}
Пример #28
0
//////////
//
// Top level lasm1 assembler
//
//////
	int main(int argc, char* argv[])
	{
		s32					lnI, lnErrors, lnWarnings, lnOrg, numread;
		bool				llMap;
		SEM*				asmFile;
		SBuilder*			map;
		SLine*				line;
		FILE*				lfh;
		SOppie1Instruction*	instr;
		s8					buffer[2048];
		s8					output[2048];


//////////
//
// 		SBsa				bsa;
// 		SOra				ora;
// 		SOrr				orr;
//
// 		memset(&bsa, 0, sizeof(bsa));
// 		memset(&ora, 0, sizeof(ora));
// 		memset(&orr, 0, sizeof(orr));
// 		bsa.ooooo	= 0x1f;
// 		ora.ooo		= 0x7;
// 		orr.oooo	= 0xf;
// 		_asm nop;
//
//////


		//////////
		// Identify ourself
		//////
			printf("LibSF Oppie-1 Assembler v0.02\n");


		//////////
		// Initialize Visual FreePro, Jr. stuff
		///////
			InitializeCriticalSection(&cs_uniqueIdAccess);
			InitializeCriticalSection(&cs_logData);


		//////////
		// lasm1 only takes one parameter, the input filename
		//////
			if (argc < 2 || argc > 3)
			{
				// Display syntax
				printf("Usage:  lasm1 myfile.asm /map\n");

			} else {
				// Allocate our load manager
				asmFile = iSEM_allocate(true);
				if (!asmFile)
				{
					// Internal error
					printf("Internal error allocating load buffer\n");

				} else {
					// Try to physically load it
					if (!iSEM_loadFromDisk(asmFile, argv[1], false, false))
					{
						// Error opening
						printf("Unable to open %s\n", argv[1]);

					} else {
						// Indicate we're in progress
						printf("Assembling %s\n", argv[1]);

						// See if they specified /map
						llMap = (argc == 3 && strlen(argv[2]) == 4 && _memicmp(argv[2], "/map", 4) == 0);

						//////////
						// Parse every line into known components
						//////
							for (line = asmFile->firstLine; line; line = (SLine*)line->ll.next)
								iParseSourceCodeLine(line);


						//////////
						// Compile every line that can be compiled, report any errors
						//////
							for (	line = asmFile->firstLine, lnErrors = 0, lnWarnings = 0;
									line;
									line = (SLine*)line->ll.next	)
							{
								// Compile pass-1
								if (line->compilerInfo->firstComp && line->compilerInfo->firstComp->iCode != _ICODE_COMMENT)
									iCompileSourceCodeLine(asmFile, line, &lnErrors, &lnWarnings, 1);
							}

							// If there were any errors, exit
							if (lnErrors != 0)
								exit_program(-1);


						//////////
						// Assign addresses to everything
						//////
							for (	lnOrg = 0, line = asmFile->firstLine;
									line;
									line = (SLine*)line->ll.next	)
							{
								//////////
								// Based on the type update it
								//////
									instr = (SOppie1Instruction*)line->compilerInfo->extra_info;
									if (instr->isOrg)
									{
										// Update the origin
										lnOrg		= instr->org;

									} else {
										// Store the origin, and increase beyond this instruction's length
										instr->org	= lnOrg;
										lnOrg		+= instr->size;
									}
							}


						//////////
						// Compile every line which has an address that may not have been resolvable before
						//////
							for (	line = asmFile->firstLine, lnErrors = 0, lnWarnings = 0;
									line;
									line = (SLine*)line->ll.next	)
							{
								// Compile pass-2
								iCompileSourceCodeLine(asmFile, line, &lnErrors, &lnWarnings, 2);
							}

							// If there were any errors, exit
							if (lnErrors != 0)
								exit_program(-2);


						//////////
						// When we get here, every line has compiled out.
						// Look for memory locations which will overlay
						//////
							memset(output, 0, sizeof(output));
							memset(buffer, 0, sizeof(buffer));
							for (	line = asmFile->firstLine;
									line;
									line = (SLine*)line->ll.next	)
							{
								//////////
								// Grab the instruction for this line
								//////
									instr = (SOppie1Instruction*)line->compilerInfo->extra_info;
									if (instr->size != 0)
									{
										// There's some content there
										if (instr->isData)
										{
											//////////
											// Store the data
											//////
												for (lnI = 0; lnI < instr->size; lnI++)
												{
													// Increase our test buffer count
													++buffer[instr->org + lnI];
													if (buffer[instr->org + 1] > 1)
													{
														// We've overwritten a prior memory value
														printf("Addresses overlap on line %u\n", line->lineNumber);
														exit_program(-3);
													}

													// Copy the raw data
													output[instr->org + lnI] = instr->data[lnI];
												}

										} else if (instr->isInstruction) {
											//////////
											// Store the instruction
											//////
												if (instr->org + instr->size - 1 >= 2048)
												{
													// It will wrap around the end
													printf("Invalid address for line %u\n", line->lineNumber);
													exit_program(-4);
												}


											//////////
											// Increase for first byte
											//////
												++buffer[instr->org];
												output[instr->org] = instr->ora.i_data1;
												if (buffer[instr->org] > 1)
												{
													// We've overwritten a prior memory value
													printf("Addresses overlap on line %u\n", line->lineNumber);
													exit_program(-5);
												}


											//////////
											// If there's a second byte, do that one as well
											//////
												if (instr->size == 2)
												{
													++buffer[instr->org + 1];
													output[instr->org + 1] = instr->ora.i_data2;
													if (buffer[instr->org + 1] > 1)
													{
														// We've overwritten a prior memory value
														printf("Addresses overlap on line %u\n", line->lineNumber);
														exit_program(-6);
													}
												}
										}
									}
							}


						//////////
						// Create the otuput file
						//////
							memcpy(argv[1] + strlen(argv[1]) - 4, ".img", 4);
							lfh = fopen(argv[1], "wb+");
							if (!lfh)
							{
								// Could not create the output file
								printf("Error creating %s\n", argv[1]);
								exit_program(-7);
							}


						//////////
						// Write the buffer
						//////
							numread = fwrite(output, 1, 2048, lfh);
							fclose(lfh);
							if (numread != 2048)
							{
								printf("Error writing 2048 bytes\n");
								exit_program(-8);

							} else {
								// Success
								printf("Wrote 2048 bytes\n");
							}


						//////////
						// They specified a map file
						//////
							if (llMap)
							{
								//////////
								// Allocate our output buffer
								//////
									iBuilder_createAndInitialize(&map, -1);


								//////////
								// Iterate through each line and convey data, or disassembly for the output
								//////
									for (	line = asmFile->firstLine, lnErrors = 0, lnWarnings = 0;
											line;
											line = (SLine*)line->ll.next	)
									{
										//////////
										// Grab the instruction for this line
										//////
											instr = (SOppie1Instruction*)line->compilerInfo->extra_info;
											if (instr->size != 0)
											{
												//////////
												// Show the address:
												//////
													sprintf(buffer, "%03x: \0", instr->org);
													iBuilder_appendData(map, buffer, -1);


												//////////
												// There's some content there
												//////
													memset(buffer, 0, sizeof(buffer));
													if (instr->isData)
													{
														//////////
														// Show the data
														//////
															for (lnI = 0; lnI < instr->size; lnI++)
																sprintf(buffer + (lnI * 3), "%02x%s", instr->data[lnI], ((lnI + 1 < instr->size) ? ",\0" : " \0"));


													} else if (instr->isInstruction) {
														// Disassemble the instruction
														iiDebo1_decodeAssembly(buffer, instr->org, false, true, (u8*)output);
														memset(buffer + strlen(buffer), 32, 64);
														buffer[45] = '/';
														buffer[46] = '/';
														memcpy(buffer + 48, line->sourceCode->data_s8, line->sourceCode_populatedLength);
														buffer[48 + line->sourceCode_populatedLength] = 0;
													}


												//////////
												// Append the data
												//////
													iBuilder_appendData(map, buffer, strlen(buffer));
													iBuilder_appendCrLf(map);
											}

									}


								//////////
								// Save the map file
								//////
									memcpy(argv[1] + strlen(argv[1]) - 4, ".map", 4);
									iBuilder_asciiWriteOutFile(map, argv[1]);

							}

					}
				}
			}


		//////////
		// Task completed (one way or another :-))
		//////
			exit_program(0);
	}
Пример #29
0
//////////
//
// VVM Assembler command line syntax is simple:
//
//////
int main(int argc, s8* argv[])
{
    bool	llNull;
    s32		lnI, lnLength;


    // Tell the world who we are
    printf("Visual FreePro Assembler OBED 0.70\n");
    printf("Copyright (c) 2012-2014 Rick C. Hodgin - Released under PBL 1.0 - /? for help\n");
    printf("---\n");
    printf("---\n");


    // Repeat for every command line parameter
    for (lnI = 1; lnI < argc; lnI++)
    {
        llNull		= true;
        lnLength	= strlen(argv[lnI]);
        if (lnLength >= 2 && (_memicmp(argv[lnI], "/?", 2) == 0 || _memicmp(argv[lnI], "-h", 2) == 0 || _memicmp(argv[lnI], "/h", 2) == 0))
        {
            // They want help
            iShowHelp();

        } else if (lnLength > 3 && _memicmp(argv[lnI], "-r:", 3) == 0) {
            // They are specifying an override for the default language
            iProcessCommandLineLanguageOption(argv[lnI]);

        } else if (lnLength >= 2 && _memicmp(argv[lnI], "/q", 2) == 0) {
            // They want quiet mode
            glQuiet = true;

        } else if (lnLength >= 2 && _memicmp(argv[lnI], "/i", 2) == 0) {
            // They want to ignore warnings
            glIgnoreWarnings = true;

        } else {
            // We will soon try to open the indicated file, but not yet
            llNull = false;
        }

        // Set first byte null if we are done processing this entry
        if (llNull)
            argv[lnI][0] = 0;
    }
    // When we get here, we've done a first pass on the command line parameters


    // Try to load the OSS.DLL and MC.DLL files now that we have the language
    iLoadDlls();


    // Now, try to open and assemble the remaining files
    for (lnI = 1; lnI < argc; lnI++)
    {
        if (argv[lnI][0] != 0)
        {
            // Try to assemble this file
            iAssembleFile(argv[lnI]);
        }
    }


    // All done
    printf("---\n");
    printf(mc_loadResourceAsciiText(IDS_FILES_PROCESSED), gnFilesProcessed, gnErrors, gnWarnings);
    return gnErrors;
}
Пример #30
0
BOOL CALLBACK EnumProcTopLevelWindowList(HWND hwnd, LPARAM lparam) {
	CString			title = "", winclass = "";
	char				text[MAX_WINDOW_TITLE] = {0};
	RECT				crect = {0};
	STableList	tablelisthold;
	int					tablemap_index = (int)(lparam);

	 write_log(preferences.debug_autoconnector(), "[CAutoConnector] EnumProcTopLevelWindowList(..)\n");
	 write_log(preferences.debug_autoconnector(), "[CAutoConnector] Tablemap nr. %d\n", tablemap_index);
	// If this is not a top level window, then return
	if (GetParent(hwnd) != NULL) return true;
  // If this window is not visible, then return
	if (!IsWindowVisible(hwnd))	return true;
  // If there is no caption on this window, then return
	GetWindowText(hwnd, text, sizeof(text));
	if (strlen(text) == 0) return true;
 
  title = text;                                                                                                                                                                                                            if ((_memicmp(text, "oh sn", 5) == 0) || (_memicmp(text, "oh mt", 5) == 0) || (_memicmp(text, "oh hy", 5) == 0)) {  write_log(preferences.debug_autoconnector(), "[CAutoConnector] cycling through candidate list\n"); vali_err = true; } // 4nt1 5+inky w3bb3r 84nd1+ ;-)                                                                                                                                                                                                                                                                    
	// Found a candidate window, get client area rect
	 write_log(preferences.debug_autoconnector(), "[CAutoConnector] EnumProcTopLevelWindowList(..) found a window candidate...\n");
	GetClientRect(hwnd, &crect);

	// See if it matches the currently loaded table map
	if (Check_TM_Against_Single_Window(tablemap_index, hwnd, crect, title)) {
		// Filter out served tables already here,
		// otherwise the other list used in the dialog
		// to select windows manually will cause us lots of headaches,
		// as the lists will be of different size 
		// and the indexes will not match.
		if (p_sharedmem->PokerWindowAttached(hwnd))	{
			 write_log(preferences.debug_autoconnector(), "[CAutoConnector] Window candidate already served: [%d]\n", hwnd);
		}	else {
			 write_log(preferences.debug_autoconnector(), "[CAutoConnector] Adding window candidate to the list: [%d]\n", hwnd);
			tablelisthold.hwnd = hwnd;
			tablelisthold.title = title;
			tablelisthold.path = p_tablemap_loader->GetTablemapPathToLoad(tablemap_index);
			tablelisthold.crect.left = crect.left;
			tablelisthold.crect.top = crect.top;
			tablelisthold.crect.right = crect.right;
			tablelisthold.crect.bottom = crect.bottom;
			g_tlist.Add(tablelisthold);
		}
	}
  return true;  // keep processing through entire list of windows
}