Author Topic: A pair of bugs in Kernel32.lib and kernlp.lib (solved)  (Read 8287 times)

rsala

  • Member
  • ***
  • Posts: 322
    • Easy Code
A pair of bugs in Kernel32.lib and kernlp.lib (solved)
« on: July 28, 2012, 03:54:50 AM »
Hi All,

As you probably know, the latest release of MASM32 has a pair of bugs in the kernel32 library referred to Module32First / Module32Next and Process32First / Process32Next API functions. According to Microsoft MSDN, the ANSI versions are not Module32FirstA / Module32NextA nor Process32FirstA / Process32NextA, but Module32First / Module32Next and Process32First / Process32Next. So when you call Module32First, even if the __UNICODE__ constant is set, you are calling the ANSI version, which is Module32First, and the same happens for Module32Next, Process32First and Process32Next (no problem with Unicode versions as they are Module32FirstW, Module32NextW, etc.). These bugs cause serious problems when you are using the ANSI versions of any of those functions.

I have fixed the problem modifying the kernel32.inc file (lines 1582 to 1586 and 1712 to 1716) and rebuilding the kernel32.lib. Now everything works fine, so I attach both files for those who want to fix them. Just replace kernel32.inc (in MASM32 include folder) and kernel32.lib (in MAMS32 lib folder) with the ones attached to this post.

Regards,

Ramon
« Last Edit: July 29, 2012, 05:19:43 AM by rsala »
EC coder

Vortex

  • Member
  • *****
  • Posts: 2383
Re: A pair of bugs in Kernel32.lib (solved)
« Reply #1 on: July 28, 2012, 06:33:24 PM »
Hi rsala,

You are right, thanks. Here is how it looks :

Code: [Select]
dumpbin /EXPORTS C:\WINDOWS\system32\kernel32.dll >exports.txt
Code: [Select]
        605  25C 000653A0 Module32First
        606  25D 000652E7 Module32FirstW
        607  25E 00065525 Module32Next
        608  25F 00065484 Module32NextW

Tested on a XP SP3 system.

rsala

  • Member
  • ***
  • Posts: 322
    • Easy Code
Re: A pair of bugs in Kernel32.lib (solved)
« Reply #2 on: July 28, 2012, 10:34:05 PM »
Hi Vortex,

Thank you very much for testing it.

Regards,

Ramon
EC coder

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: A pair of bugs in Kernel32.lib (solved)
« Reply #3 on: July 29, 2012, 04:49:46 AM »
as i recall, there were a few other kernel32 functions that had the same issue
also - the same issues occur in kernl32p.inc/lib

rsala

  • Member
  • ***
  • Posts: 322
    • Easy Code
Re: A pair of bugs in Kernel32.lib (solved)
« Reply #4 on: July 29, 2012, 05:19:05 AM »
Hi,

Sorry, but I was not aware of the same problem in kernl32p.inc/lib files. Anyway, I've just fixed the bug and the new (and fixed) files are attached.

Ramon
EC coder

jj2007

  • Member
  • *****
  • Posts: 10675
  • Assembler is fun ;-)
    • MasmBasic
Re: A pair of bugs in Kernel32.lib and kernlp.lib (solved)
« Reply #5 on: October 13, 2012, 10:40:43 AM »
Here is one more bugfix related to GetEnvironmentStrings (see old forum thread):

Usage:
include \masm32\include\masm32rt.inc
uselib kernel32Fix

PsYcHoCoDe

  • Guest
Re: A pair of bugs in Kernel32.lib and kernlp.lib (solved)
« Reply #6 on: December 26, 2012, 08:16:30 PM »
these are nasty... i'ld recommend including that in the official download package  :eusa_naughty: XP SP2 is the same...  8)

morgot

  • Member
  • **
  • Posts: 78
Re: A pair of bugs in Kernel32.lib and kernlp.lib (solved)
« Reply #7 on: March 19, 2020, 08:13:57 AM »
What is kernl32p ? Such DLL dont exists in windows, if I try to compile - windows loaders say error..
Why is it?
Sorry for the bad English