Skip to content

Commit

Permalink
Fix a memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoppai authored Aug 12, 2023
1 parent 8ab64d7 commit abce40a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OPT=-Os -Wall
CFLAGS=-fno-ident -fno-stack-check -fno-stack-protector
LDFLAGS=-L. -nostartfiles -nostdlib -lucrt -luser32 -lkernel32 -Wl,--exclude-all-symbols,--enable-stdcall-fixup,--dynamicbase,--nxcompat,--subsystem,windows:6.0
CFLAGS=-fno-ident
LDFLAGS=-L. -nostartfiles -nostdlib -lkernel32 -lshlwapi -Wl,--exclude-all-symbols,--enable-stdcall-fixup,--dynamicbase,--nxcompat,--subsystem,windows:6.0

PREFIX32=C:/mingw32/bin/
PREFIX64=C:/mingw64/bin/
Expand Down
22 changes: 8 additions & 14 deletions sppc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <windows.h>
#include <shlwapi.h>

typedef GUID SLID;
typedef void *HSLC;
Expand Down Expand Up @@ -49,27 +50,20 @@ BOOL APIENTRY WINAPI dll_main(
}

BOOL check_for_grace(HSLC hSLC, SLID *pProductSkuId) {
PBYTE *pBuffer = malloc(4096);
UINT cbSize = 4096;
PBYTE pBuffer = 0;
UINT cbSize = 0;

if(SLGetProductSkuInformation(
hSLC,
pProductSkuId,
L"Name",
NULL,
&cbSize,
pBuffer
) != S_OK) {
free(pBuffer);
if(SLGetProductSkuInformation(hSLC, pProductSkuId, L"Name", NULL, &cbSize, &pBuffer) != S_OK) {
LocalFree(pBuffer);
return FALSE;
}

if(wcsstr((PWSTR)*pBuffer, L"Grace") != NULL) {
free(pBuffer);
if(StrStrNIW((PWSTR)pBuffer, L"Grace", cbSize) != NULL) {
LocalFree(pBuffer);
return TRUE;
}

free(pBuffer);
LocalFree(pBuffer);
return FALSE;
}

Expand Down
8 changes: 4 additions & 4 deletions sppc.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1 VERSIONINFO
FILEVERSION 0,2,0,0
PRODUCTVERSION 0,2,0,0
FILEVERSION 0,3,0,0
PRODUCTVERSION 0,3,0,0
FILEOS 0x40004L
FILETYPE 0x2L
BEGIN
Expand All @@ -10,12 +10,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Anomalous Software Deterioration Corporation"
VALUE "FileDescription", "ohook SPPC"
VALUE "FileVersion", "0.2.0.0"
VALUE "FileVersion", "0.3.0.0"
VALUE "InternalName", "sppc"
VALUE "LegalCopyright", "© 2023 Anomalous Software Deterioration Corporation"
VALUE "OriginalFilename", "sppc.dll"
VALUE "ProductName", "ohook"
VALUE "ProductVersion", "0.2.0.0"
VALUE "ProductVersion", "0.3.0.0"
END
END

Expand Down
2 changes: 1 addition & 1 deletion sppcs32.def
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LIBRARY sppcs.dll
EXPORTS
SLGetLicensingStatusInformation@24
SLGetProductSkuInformation@24
SLGetProductSkuInformation@24

0 comments on commit abce40a

Please sign in to comment.