diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
commit | db20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch) | |
tree | e5435159cd1bf0519276363a6fe1663d1721bed3 /src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.c | |
parent | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff) | |
download | coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2 coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip |
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.c')
-rw-r--r-- | src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.c | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.c b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.c deleted file mode 100644 index 4c1c3b00ab..0000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.c +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: getmodulefilenamew.c -** -** Purpose: Test the GetModuleFileNameW to retrieve the specified module -** full path and file name in UNICODE. -** -** -**============================================================*/ -#define UNICODE -#include <palsuite.h> - -#define MODULENAMEBUFFERSIZE 1024 - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define ModuleName "librotor_pal"SHLEXT -#define Delimiter "/" -#else -#define ModuleName "rotor_pal.dll" -#define Delimiter "\\" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - WCHAR *lpModuleName; - DWORD ModuleNameLength; - WCHAR *ModuleFileNameBuf; - char* TempBuf = NULL; - char* LastBuf = NULL; - char NewModuleFileNameBuf[MODULENAMEBUFFERSIZE+200] = ""; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - ModuleFileNameBuf = malloc(MODULENAMEBUFFERSIZE*sizeof(WCHAR)); - - //convert a normal string to a wide one - lpModuleName = convert(ModuleName); - - //load a module - ModuleHandle = LoadLibrary(lpModuleName); - - //free the memory - free(lpModuleName); - - if(!ModuleHandle) - { - Fail("Failed to call LoadLibrary API!\n"); - } - - - //retrieve the specified module full path and file name - ModuleNameLength = GetModuleFileName( - ModuleHandle,//specified module handle - ModuleFileNameBuf,//buffer for module file name - MODULENAMEBUFFERSIZE); - - - - //convert a wide full path name to a normal one - strcpy(NewModuleFileNameBuf,convertC(ModuleFileNameBuf)); - - //strip out all full path - TempBuf = strtok(NewModuleFileNameBuf,Delimiter); - LastBuf = TempBuf; - while(NULL != TempBuf) - { - LastBuf = TempBuf; - TempBuf = strtok(NULL,Delimiter); - } - - - //free the memory - free(ModuleFileNameBuf); - - if(0 == ModuleNameLength || strcmp(ModuleName,LastBuf)) - { - Trace("\nFailed to all GetModuleFileName API!\n"); - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - Fail(""); - } - - - - //decrement the reference count of the loaded dll - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - - PAL_Terminate(); - return PASS; -} - |