32-bit

Check if unmanaged DLL is 32-bit or 64-bit?

允我心安 提交于 2019-11-26 15:18:32
问题 How can I programmatically tell in C# if an unmanaged DLL file is x86 or x64? 回答1: Refer to the specifications. Here's a basic implementation: public static MachineType GetDllMachineType(string dllPath) { // See http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx // Offset to PE header is always at 0x3C. // The PE header starts with "PE\0\0" = 0x50 0x45 0x00 0x00, // followed by a 2-byte machine type field (see the document above for the enum). // FileStream fs = new FileStream

Converting a pointer into an integer

夙愿已清 提交于 2019-11-26 14:23:25
I am trying to adapt an existing code to a 64 bit machine. The main problem is that in one function, the previous coder uses a void* argument that is converted into suitable type in the function itself. A short example: void function(MESSAGE_ID id, void* param) { if(id == FOO) { int real_param = (int)param; // ... } } Of course, on a 64 bit machine, I get the error: error: cast from 'void*' to 'int' loses precision I would like to correct this so that it still works on a 32 bit machine and as cleanly as possible. Any idea ? Milan Babuškov Use intptr_t and uintptr_t . To ensure it is defined in

SetWindowsHookEx failing in .NET 4.0 on 32-bit machine with “module not found”?

↘锁芯ラ 提交于 2019-11-26 12:44:55
问题 I have found similar questions on this page, but I can\'t seem to figure out how to interpret the answers or figure out if they are truly duplicates. Here are the possible duplicates I\'ve found, with comments: SetWindowsHookEx returns 0 when compiling for the .NET 4.0 framework in 32bit machines It doesn\'t seem to return 0 on mine, but I noticed that the handle reported when it crashes (.NET 4.0 on 32-bit) is way different from the handle reported when it runs (.NET 3.5 on 32-bit), like

Linking 32-bit library to 64-bit program

纵饮孤独 提交于 2019-11-26 11:25:47
问题 I have a 32-bit .so binary-only library and I have to generate 64-bit program that uses it. Is there a way to wrap or convert it, so it can be used with 64-bit program? 回答1: No. You can't directly link to 32bit code inside of a 64bit program. The best option is to compile a 32bit (standalone) program that can run on your 64bit platform (using ia32), and then use a form of inter-process communication to communicate to it from your 64bit program. 回答2: For an example of using IPC to run 32-bit

Find most significant bit (left-most) that is set in a bit array

坚强是说给别人听的谎言 提交于 2019-11-26 11:19:25
I have a bit array implementation where the 0th index is the MSB of the first byte in an array, the 8th index is the MSB of the second byte, etc... What's a fast way to find the first bit that is set in this bit array? All the related solutions I have looked up find the first least significant bit, but I need the first most significant one. So, given 0x00A1, I want 8 (since it's the 9th bit from the left). GCC has __builtin_clz that translates to BSR on x86/x64, CLZ on ARM, etc. and emulates the instruction if the hardware does not implement it. Visual C++ 2005 and up has _BitScanReverse . tl

What are the pros and cons of running IIS as 32bit vs 64bit on a 64bit OS?

烂漫一生 提交于 2019-11-26 10:56:22
问题 Possibly better suited for \"Rack Overflow\", but from a developer\'s point of view, what are the advantages and disadvantages of running IIS (serving both legacy classic ASP and .NET) as a 32bit process instead of a 64bit process on a 64bit windows host? The main advantage of 32/64 (iis/server) over 32/32 seems to be the ability to go up to 4gb in memory per IIS process. The advantages I expect of 32/64 over 64/64 appear to be that it\'s easier to access legacy 32-bit in-process DLLs (of

Determine if current PowerShell Process is 32-bit or 64-bit?

微笑、不失礼 提交于 2019-11-26 10:21:39
问题 When running a PowerShell script on a x64-bit OS platform, how can you determine in the script what version of PowerShell (32-bit or 64-bit) the script is running on? Background Both 32-bit and 64-bit versions of PowerShell are installed by default on a 64-bit platform such as Windows Server 2008. This can lead to difficulties when a PowerShell script is ran that must target a specific architecture (i.e. using 64-bit for a script for SharePoint 2010, in order to consume the 64-bit libraries).

Is an int a 64-bit integer in 64-bit C#?

十年热恋 提交于 2019-11-26 09:54:30
问题 In my C# source code I may have declared integers as: int i = 5; or Int32 i = 5; In the currently prevalent 32-bit world they are equivalent. However, as we move into a 64-bit world, am I correct in saying that the following will become the same? int i = 5; Int64 i = 5; 回答1: No. The C# specification rigidly defines that int is an alias for System.Int32 with exactly 32 bits. Changing this would be a major breaking change. 回答2: The int keyword in C# is defined as an alias for the System.Int32

On 32-bit CPUs, is an 'integer' type more efficient than a 'short' type?

╄→гoц情女王★ 提交于 2019-11-26 09:52:58
问题 On a 32-bit CPU, an integer is 4 bytes and a short integer is 2 bytes. If I am writing a C/C++ application that uses many numeric values that will always fit within the provided range of a short integer, is it more efficient to use 4 byte integers or 2 byte integers? I have heard it suggested that 4 byte integers are more efficient as this fits the bandwidth of the bus from memory to the CPU. However, if I am adding together two short integers, would the CPU package both values in a single

How do I tell if my application is running as a 32-bit or 64-bit application?

无人久伴 提交于 2019-11-26 09:29:57
问题 How do I tell if my application (compiled in Visual Studio 2008 as Any CPU ) is running as a 32-bit or 64-bit application? 回答1: if (IntPtr.Size == 8) { // 64 bit machine } else if (IntPtr.Size == 4) { // 32 bit machine } 回答2: If you're using .NET 4.0, it's a one-liner for the current process: Environment.Is64BitProcess Reference: Environment.Is64BitProcess Property (MSDN) 回答3: I found this code from Martijn Boven that does the trick: public static bool Is64BitMode() { return System.Runtime