Anonymous avatar Anonymous committed 6c5d845

Fake the system plugin for the LoadImage API function on 64-bit Windows.

Comments (0)

Files changed (2)

Contrib/System/Source/System.c

     0, // PAT_VOID (Size will be equal to 1)
     1, // PAT_INT
     2, // PAT_LONG
+#ifdef SYSTEM_X64
+    2, // PAT_STRING
+    2, // PAT_WSTRING
+#else
     1, // PAT_STRING
     1, // PAT_WSTRING
+#endif
     1, // PAT_GUID
     0}; // PAT_CALLBACK (Size will be equal to 1)
 
     if ((proc->Options & POPT_PERMANENT) == 0)
         GlobalFree((HANDLE) proc); // No, free it
 #else
-    ParamsOut(proc);
-    system_pushintptr(0);
+    // Fake the behavior of the System plugin for the LoadImage API function.
+    // Otherwise, it is not yet implemented on 64-bit Windows.
+    if (lstrcmp(proc->ProcName, "LoadImageA") == 0)
+    {
+      HANDLE res = LoadImage((HINSTANCE)proc->Params[1].Value,
+        (LPCSTR)proc->Params[2].Value,
+        (UINT)proc->Params[3].Value,
+        (int)proc->Params[4].Value,
+        (int)proc->Params[5].Value,
+        (UINT)proc->Params[6].Value);
+      ParamsOut(proc);
+      system_pushintptr((INT_PTR)res);
+    }
+    else
+    {
+      ParamsOut(proc);
+      system_pushintptr(0);
+    }
 #endif
 } PLUGINFUNCTIONEND
 
     for (i = 0; i <= proc->ParamCount; i++)
         if (((HANDLE) proc->Params[i].Value == NULL) && (proc->Params[i].Option == -1))
         {
-            proc->Params[i].Value = BUGBUG64(int) GlobalAlloc(GPTR, 4*ParamSizeByType[proc->Params[i].Type]);
+            proc->Params[i].Value = (INT_PTR) GlobalAlloc(GPTR, 4*ParamSizeByType[proc->Params[i].Type]);
         }
 }
 

Contrib/System/Source/System.h

 {
     int Type;
     int Option; // -1 -> Pointer, 1-... -> Special+1
-    int Value;  // it can hold any 4 byte value BUGBUG: What about pointers on Win64?
+    INT_PTR Value;  // it can hold any value up to 4 bytes on Win32 or 8 bytes on Win64
     int _value; // value buffer for structures > 4 bytes (I hope 8 bytes will be enough)
     int Size; // Value real size (should be either 1 or 2 (the number of pushes))
     int Input; //BUGBUG: What about pointers on Win64?
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.