Changeset 801 in dev
- Timestamp:
- Feb 6, 2011, 9:47:29 PM (14 years ago)
- Location:
- branches/egtra/ab5.0/abdev
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/egtra/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.cpp
r798 r801 590 590 591 591 // グローバルローケルを日本語にする 592 std::locale::global(std::locale("japanese"));593 _setmode(_fileno(stdout), _O_BINARY);592 //std::locale::global(std::locale("japanese")); 593 //_setmode(_fileno(stdout), _O_BINARY); 594 594 595 595 //_Test(); -
branches/egtra/ab5.0/abdev/OldWindowsHelper.asm
r800 r801 20 20 ImportTrap InterlockedPopEntrySList, 4 21 21 ImportTrap InterlockedCompareExchange, 12 22 ImportTrap GetModuleHandleW, 4 23 ImportTrap GetStartupInfoW, 4 24 ImportTrap GetEnvironmentStringsW, 0 25 ImportTrap FreeEnvironmentStringsW, 4 22 26 TrapTableLast LABEL DWORD 23 27 -
branches/egtra/ab5.0/abdev/OldWindowsHelperImpl.cpp
r800 r801 1 1 #include "stdafx.h" 2 2 #include <cstdint> 3 #include <cstring> 3 4 #include <process.h> 4 5 #include "OSVersion.h" … … 16 17 extern FARPROC alias__imp__InterlockedPushEntrySList; 17 18 extern FARPROC alias__imp__InterlockedPopEntrySList; 19 extern FARPROC alias__imp__GetModuleHandleW; 20 extern FARPROC alias__imp__GetStartupInfoW; 21 extern FARPROC alias__imp__GetEnvironmentStringsW; 22 extern FARPROC alias__imp__FreeEnvironmentStringsW; 18 23 extern void* TrapTableLast; 19 24 } // extern "C" … … 26 31 if (hmodKernel == nullptr) 27 32 { 28 hmodKernel = GetModuleHandle (TEXT("kernel32"));33 hmodKernel = GetModuleHandleA("kernel32"); 29 34 } 30 35 return hmodKernel; … … 65 70 #pragma warning(pop) 66 71 67 __declspec(naked) long __stdcallAlternative_InterlockedCompareExchange(long volatile*, long, long)72 __declspec(naked) long WINAPI Alternative_InterlockedCompareExchange(long volatile*, long, long) 68 73 { 69 74 __asm … … 83 88 } 84 89 90 HMODULE WINAPI Alternative_GetModuleHandleW(LPCWSTR moduleName) 91 { 92 HMODULE ret = nullptr; 93 auto size = std::wcslen(moduleName) + 1; 94 auto mbsSize = size * 2; 95 if (auto buffer = static_cast<LPSTR>(::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, mbsSize))) 96 { 97 if (::WideCharToMultiByte(CP_ACP, 0, moduleName, static_cast<int>(size), buffer, static_cast<int>(mbsSize), nullptr, nullptr) > 0) 98 { 99 ret = ::GetModuleHandleA(buffer); 100 } 101 ::HeapFree(::GetProcessHeap(), 0, buffer); 102 } 103 return ret; 104 } 105 106 // CRT用に最小限の実装 107 void WINAPI Alternative_GetStartupInfoW(LPSTARTUPINFOW psi) 108 { 109 STARTUPINFOA sia; 110 ::GetStartupInfoA(&sia); 111 112 *psi = STARTUPINFOW(); 113 psi->cb = sizeof *psi; 114 if (sia.dwFlags & STARTF_USESHOWWINDOW) 115 { 116 psi->dwFlags = STARTF_USESHOWWINDOW; 117 psi->wShowWindow = sia.wShowWindow; 118 } 119 } 120 121 LPWCH WINAPI Alternative_GetEnvironmentStringsW() 122 { 123 static WCHAR c[2]; 124 return c; 125 } 126 127 BOOL WINAPI Alternative_FreeEnvironmentStringsW(LPWCH) 128 { 129 return TRUE; 130 } 131 85 132 #define FUNCTION_INIT(name) \ 86 133 if (auto f = ::GetProcAddress(GetKernelModule(), #name)) { \ … … 88 135 } else { \ 89 136 alias__imp__ ## name = reinterpret_cast<FARPROC>(Alternative_ ## name); \ 137 } 138 139 #define FUNCTION_INIT_9X(name) \ 140 if (ActiveBasic::Common::Is9x()) { \ 141 alias__imp__ ## name = reinterpret_cast<FARPROC>(Alternative_ ## name); \ 142 } else { \ 143 alias__imp__ ## name = ::GetProcAddress(GetKernelModule(), #name); \ 90 144 } 91 145 … … 100 154 FUNCTION_INIT(DecodePointer); 101 155 FUNCTION_INIT(HeapSetInformation); 102 alias__imp__InitializeCriticalSectionAndSpinCount = 103 ActiveBasic::Common::Is9x() 104 ? reinterpret_cast<FARPROC>(Alternative_InitializeCriticalSectionAndSpinCount) 105 : ::GetProcAddress(GetKernelModule(), "InitializeCriticalSectionAndSpinCount"); 156 FUNCTION_INIT_9X(InitializeCriticalSectionAndSpinCount); 106 157 FUNCTION_INIT(InterlockedCompareExchange); 107 158 FUNCTION_INIT(IsProcessorFeaturePresent); 108 159 alias__imp__InterlockedPushEntrySList = ::GetProcAddress(GetKernelModule(), "InterlockedPushEntrySList"); 109 160 alias__imp__InterlockedPopEntrySList = ::GetProcAddress(GetKernelModule(), "InterlockedPopEntrySList"); 161 FUNCTION_INIT_9X(GetModuleHandleW); 162 FUNCTION_INIT_9X(GetStartupInfoW); 163 FUNCTION_INIT_9X(GetEnvironmentStringsW); 164 FUNCTION_INIT_9X(FreeEnvironmentStringsW); 110 165 111 166 ::VirtualProtect(&TrapTableFirst, … … 118 173 extern "C" 119 174 { 120 #ifdef _UNICODE 121 int wWinMainCRTStartup(); 122 #define tWinMainCRTStartup wWinMainCRTStartup 175 #ifdef _CONSOLE 176 # ifdef _UNICODE 177 int wmainCRTStartup(); 178 # define CRTStartup wmainCRTStartup 179 # else 180 int mainCRTStartup(); 181 # define CRTStartup mainCRTStartup 182 # endif 123 183 #else 124 int WinMainCRTStartup(); 125 #define tWinMainCRTStartup WinMainCRTStartup 184 # ifdef _UNICODE 185 int wWinMainCRTStartup(); 186 # define CRTStartup wWinMainCRTStartup 187 # else 188 int WinMainCRTStartup(); 189 # define CRTStartup WinMainCRTStartup 190 # endif 126 191 #endif 127 192 128 void WinMainStartup_OldWindowsHelper()193 void Startup_OldWindowsHelper() 129 194 { 130 195 __security_init_cookie(); 131 196 // MessageBox(0, "Startup", "", 0); 132 197 InitializeOldWindowsHelper(); 133 198 134 199 __asm 135 200 { 136 jmp tWinMainCRTStartup;201 jmp CRTStartup; 137 202 } 138 203 } -
branches/egtra/ab5.0/abdev/abdev/abdev.vcxproj
r800 r801 115 115 <SubSystem>Windows</SubSystem> 116 116 <TargetMachine>MachineX86</TargetMachine> 117 <EntryPointSymbol> WinMainStartup_OldWindowsHelper</EntryPointSymbol>117 <EntryPointSymbol>Startup_OldWindowsHelper</EntryPointSymbol> 118 118 </Link> 119 119 <Manifest> … … 153 153 <SubSystem>Windows</SubSystem> 154 154 <TargetMachine>MachineX64</TargetMachine> 155 <EntryPointSymbol>WinMainStartup_OldWindowsHelper</EntryPointSymbol> 155 <EntryPointSymbol> 156 </EntryPointSymbol> 156 157 </Link> 157 158 <Manifest> … … 194 195 <EnableCOMDATFolding>true</EnableCOMDATFolding> 195 196 <TargetMachine>MachineX86</TargetMachine> 196 <EntryPointSymbol> WinMainStartup_OldWindowsHelper</EntryPointSymbol>197 <EntryPointSymbol>Startup_OldWindowsHelper</EntryPointSymbol> 197 198 </Link> 198 199 <Manifest> … … 235 236 <EnableCOMDATFolding>true</EnableCOMDATFolding> 236 237 <TargetMachine>MachineX64</TargetMachine> 237 <EntryPointSymbol>WinMainStartup_OldWindowsHelper</EntryPointSymbol> 238 <EntryPointSymbol> 239 </EntryPointSymbol> 238 240 </Link> 239 241 <Manifest> -
branches/egtra/ab5.0/abdev/compiler.vcxproj
r798 r801 46 46 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> 47 47 <ImportGroup Label="ExtensionSettings"> 48 <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" /> 48 49 </ImportGroup> 49 50 <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> … … 98 99 <Optimization>Disabled</Optimization> 99 100 <AdditionalIncludeDirectories>..\;BasicCompiler_Common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> 100 <PreprocessorDefinitions>_DEBUG;_ WINDOWS;JPN;%(PreprocessorDefinitions)</PreprocessorDefinitions>101 <PreprocessorDefinitions>_DEBUG;_CONSOLE;JPN;%(PreprocessorDefinitions)</PreprocessorDefinitions> 101 102 <MinimalRebuild>false</MinimalRebuild> 102 103 <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> … … 116 117 <SubSystem>Console</SubSystem> 117 118 <StackReserveSize>4194304</StackReserveSize> 119 <EntryPointSymbol>mainStartup_OldWindowsHelper</EntryPointSymbol> 120 <DelayLoadDLLs>PSAPI.DLL</DelayLoadDLLs> 118 121 </Link> 119 122 <Manifest> … … 138 141 <Optimization>Disabled</Optimization> 139 142 <AdditionalIncludeDirectories>..\;BasicCompiler_Common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> 140 <PreprocessorDefinitions>_DEBUG;_ WINDOWS;JPN;_AMD64_;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>143 <PreprocessorDefinitions>_DEBUG;_CONSOLE;JPN;_AMD64_;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> 141 144 <MinimalRebuild>false</MinimalRebuild> 142 145 <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> … … 179 182 <Optimization>MaxSpeed</Optimization> 180 183 <AdditionalIncludeDirectories>..\;BasicCompiler_Common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> 181 <PreprocessorDefinitions>NDEBUG;_ WINDOWS;JPN;%(PreprocessorDefinitions)</PreprocessorDefinitions>184 <PreprocessorDefinitions>NDEBUG;_CONSOLE;JPN;%(PreprocessorDefinitions)</PreprocessorDefinitions> 182 185 <RuntimeLibrary>MultiThreaded</RuntimeLibrary> 183 186 <PrecompiledHeader>Use</PrecompiledHeader> … … 197 200 <EnableCOMDATFolding>true</EnableCOMDATFolding> 198 201 <ImageHasSafeExceptionHandlers>true</ImageHasSafeExceptionHandlers> 202 <EntryPointSymbol>Startup_OldWindowsHelper</EntryPointSymbol> 203 <DelayLoadDLLs>PSAPI.DLL</DelayLoadDLLs> 199 204 </Link> 200 205 <Manifest> … … 219 224 <Optimization>MaxSpeed</Optimization> 220 225 <AdditionalIncludeDirectories>..\;BasicCompiler_Common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> 221 <PreprocessorDefinitions>NDEBUG;_ WINDOWS;JPN;_AMD64_;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>226 <PreprocessorDefinitions>NDEBUG;_CONSOLE;JPN;_AMD64_;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> 222 227 <RuntimeLibrary>MultiThreaded</RuntimeLibrary> 223 228 <PrecompiledHeader>Use</PrecompiledHeader> … … 839 844 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> 840 845 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> 846 </ClCompile> 847 <ClCompile Include="OldWindowsHelperImpl.cpp"> 848 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> 849 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> 841 850 </ClCompile> 842 851 </ItemGroup> … … 918 927 </ProjectReference> 919 928 </ItemGroup> 929 <ItemGroup> 930 <MASM Include="OldWindowsHelper.asm"> 931 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> 932 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> 933 </MASM> 934 </ItemGroup> 920 935 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> 921 936 <ImportGroup Label="ExtensionTargets"> 937 <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" /> 922 938 </ImportGroup> 923 939 </Project> -
branches/egtra/ab5.0/abdev/compiler.vcxproj.filters
r777 r801 391 391 <Filter>Source Files\x64Compiler\Procedure\Opcode</Filter> 392 392 </ClCompile> 393 <ClCompile Include="OldWindowsHelperImpl.cpp"> 394 <Filter>Source Files</Filter> 395 </ClCompile> 393 396 </ItemGroup> 394 397 <ItemGroup> … … 563 566 </None> 564 567 </ItemGroup> 568 <ItemGroup> 569 <MASM Include="OldWindowsHelper.asm"> 570 <Filter>Source Files</Filter> 571 </MASM> 572 </ItemGroup> 565 573 </Project>
Note:
See TracChangeset
for help on using the changeset viewer.